| | |
| | | import com.gps31.push.netty.PushMsg; |
| | | import com.gps31.push.netty.client.TcpClient; |
| | | import com.gps31.push.util.MapUtil; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sy.service.impl.ArdSyCarServiceImpl; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | |
| | | |
| | | }else if("8003".equals(pushMsg.getCmd())){//订阅动态消息应答 |
| | | String rspResult = MapUtil.getStrVal(pushMsg.getJsonMap(),"rspResult","1"); |
| | | log.error(String.format(" 订阅应答:%s", "0".equals(rspResult)?"成功":"失败")); |
| | | //log.error(String.format(" 订阅应答:%s", "0".equals(rspResult)?"成功":"失败")); |
| | | }else if("0200".equals(pushMsg.getCmd())) {//定位信息 |
| | | Map<String,Object> gpsMap = pushMsg.getJsonMap(); |
| | | String carName = MapUtil.getStrVal(gpsMap, "carName","");//获取车牌号 |
| | | /*String carName = MapUtil.getStrVal(gpsMap, "carName","");//获取车牌号 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | System.out.println(sdf.format(new Date())); |
| | | log.error(String.format(" ---->收到定位数据:%s",JSON.toJSONString(gpsMap))); |
| | | log.error(String.format(" ---->收到定位数据:%s",JSON.toJSONString(gpsMap)));*/ |
| | | String carId = (String)gpsMap.get("carId"); |
| | | Map<String,Object> result = ((ArdSyCarServiceImpl)SpringUtils.getBean("ardSyCarServiceImpl")).getArdSyCarAndDeptByCarId(carId);//查询车辆及部门 |
| | | if(result != null){ |
| | | gpsMap.putAll(result); |
| | | String ancestors = (String) gpsMap.get("ancestors");//获取父级部门 |
| | | String[] ancestorsArray = ancestors.split(","); |
| | | if(ancestorsArray.length == 1){//最高级部门 |
| | | String deptId = String.valueOf(gpsMap.get("deptId")); |
| | | Map<String,Map<String,Object>> deptMap = PositionContainer.getDeptPositionMap().get(deptId); |
| | | if(deptMap == null){ |
| | | deptMap = new HashMap(); |
| | | deptMap.put((String)gpsMap.get("carId"),gpsMap); |
| | | PositionContainer.getDeptPositionMap().put(deptId,deptMap); |
| | | }else{ |
| | | deptMap.put((String)gpsMap.get("carId"),gpsMap); |
| | | } |
| | | }else{//其他部门 |
| | | //加入本部门容器 |
| | | String deptId = String.valueOf(gpsMap.get("deptId")); |
| | | Map<String,Map<String,Object>> deptMap = PositionContainer.getDeptPositionMap().get(deptId); |
| | | if(deptMap == null){ |
| | | deptMap = new HashMap(); |
| | | deptMap.put((String)gpsMap.get("carId"),gpsMap); |
| | | PositionContainer.getDeptPositionMap().put(deptId,deptMap); |
| | | }else{ |
| | | deptMap.put((String)gpsMap.get("carId"),gpsMap); |
| | | } |
| | | //加入父级部门容器 |
| | | for(int i = 1;i <= ancestorsArray.length - 1;i++){ |
| | | String deptIdp = ancestorsArray[i]; |
| | | Map<String,Map<String,Object>> deptMapp = PositionContainer.getDeptPositionMap().get(deptIdp); |
| | | if(deptMapp == null){ |
| | | deptMapp = new HashMap(); |
| | | deptMapp.put((String)gpsMap.get("carId"),gpsMap); |
| | | PositionContainer.getDeptPositionMap().put(deptIdp,deptMapp); |
| | | }else{ |
| | | deptMapp.put((String)gpsMap.get("carId"),gpsMap); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * 请加入三方集成方的业务逻辑 |
| | |
| | | }else if("0300".equals(pushMsg.getCmd())) {//报警消息 |
| | | Map<String,Object> alarmMap = pushMsg.getJsonMap(); |
| | | String carName = MapUtil.getStrVal(alarmMap, "carName","");//获取车牌号 |
| | | log.error(String.format(" ---->收到报警数据:%s",JSON.toJSONString(alarmMap))); |
| | | //log.error(String.format(" ---->收到报警数据:%s",JSON.toJSONString(alarmMap))); |
| | | /** |
| | | * |
| | | * 请加入三方集成方的业务逻辑 |
| | |
| | | }else if("0401".equals(pushMsg.getCmd())) {//透传消息 |
| | | Map<String,Object> dataMap = pushMsg.getJsonMap(); |
| | | String carName = MapUtil.getStrVal(dataMap, "carName","");//获取车牌号 |
| | | log.error(String.format(" ---->收到透传数据:%s",JSON.toJSONString(dataMap))); |
| | | //log.error(String.format(" ---->收到透传数据:%s",JSON.toJSONString(dataMap))); |
| | | /** |
| | | * |
| | | * 请加入三方集成方的业务逻辑 |