| | |
| | | |
| | | private static Map<String, Map<String,Map<String,Object>>> deptPositionMap = new HashMap();//依部门存放实施车辆位置:deptId,carId,车辆位置 |
| | | |
| | | public static Map<String, Map<String, Map<String,Object>>> getDeptPositionMap() { |
| | | public static synchronized Map<String, Map<String, Map<String,Object>>> getDeptPositionMap() { |
| | | return deptPositionMap; |
| | | } |
| | | |
| | | public static void setDeptPositionMap(Map<String, Map<String, Map<String,Object>>> deptPositionMap) { |
| | | public static synchronized void setDeptPositionMap(Map<String, Map<String, Map<String,Object>>> deptPositionMap) { |
| | | PositionContainer.deptPositionMap = deptPositionMap; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | deptMap.put((String)gpsMap.get("carId"),gpsMap);//首次加入容器,再次去重 |
| | | PositionContainer.getDeptPositionMap().put(deptId,deptMap); |
| | | }else{ |
| | | }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); |
| | | } |
| | | deptMap.put((String)gpsMap.get("carId"),gpsMap);//首次加入容器,再次去重 |
| | | PositionContainer.getDeptPositionMap().put(deptId,deptMap); |
| | | //加入父级部门容器 |
| | | for(int i = 1;i <= ancestorsArray.length - 1;i++){ |
| | | String deptIdp = String.valueOf(gpsMap.get(ancestorsArray[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); |
| | | } |
| | | deptMapp.put((String)gpsMap.get("carId"),gpsMap);//首次加入容器,再次去重 |
| | | PositionContainer.getDeptPositionMap().put(deptIdp,deptMap); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void sendMassage() { |
| | | try { |
| | | PushClientImplPosition client = new PushClientImplPosition(); |
| | | client.setLog(false);//是否打印明文 |
| | | client.setLog(true);//是否打印明文 |
| | | client.setHost(this.ip);//服务器IP |
| | | client.setPort(10100);//服务器端口 |
| | | client.setUserName(this.userId);//系统用户名 |
| | |
| | | SysUser sysUser = userMapper.selectUserById(key); |
| | | String deptId = String.valueOf(sysUser.getDeptId()); |
| | | Map<String,Map<String,Object>> map = PositionContainer.getDeptPositionMap().get(deptId); |
| | | List<Map<String,Object>> positionList = (List<Map<String, Object>>) map.values(); |
| | | if(positionList.size() != 0){ |
| | | Map<Integer,Object> data = new HashMap(); |
| | | data.put(30000,positionList); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(positionList)); |
| | | } |
| | | System.out.println("/////////////"); |
| | | System.out.println(PositionContainer.getDeptPositionMap()); |
| | | Map<Integer,Object> data = new HashMap(); |
| | | data.put(30000, map.values()); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |