| | |
| | | |
| | | @Override |
| | | public List<Map<String, String>> getAllCarModel() { |
| | | boolean exsit = MinioUtil.exitsBucket("sycar"); |
| | | boolean exsit = MinioUtil.exitsBucket("system"); |
| | | if (exsit) { |
| | | List<Map<String, String>> listObjetcName = new ArrayList<>(); |
| | | try { |
| | | // ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder().prefix("carmodel/").bucket("sycar").build(); |
| | | Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("sycar","carmodel"); |
| | | //Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("sycar","carmodel"); |
| | | Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("system","model/car"); |
| | | for (Result<Item> result : myObjects) { |
| | | Item item = result.get(); |
| | | Map<String, String> map = new HashMap(); |
| | | String[] strArr = item.objectName().split("/"); |
| | | map.put("carType", strArr[1]); |
| | | map.put("carModel", "sycar/" + item.objectName()); |
| | | /*switch (item.objectName()) { |
| | | case "carmodel/aodi.glb": |
| | | map.put("carType", "奥迪"); |
| | | break; |
| | | case "carmodel/baolai.glb": |
| | | map.put("carType", "宝来"); |
| | | break; |
| | | case "carmodel/bieke.glb": |
| | | map.put("carType", "别克"); |
| | | break; |
| | | case "carmodel/bus1.glb": |
| | | map.put("carType", "大客车"); |
| | | break; |
| | | case "carmodel/car.glb": |
| | | map.put("carType", "小型车"); |
| | | break; |
| | | case "carmodel/fire(1).glb": |
| | | map.put("carType", "消防车"); |
| | | break; |
| | | case "carmodel/fute.glb": |
| | | map.put("carType", "福特"); |
| | | break; |
| | | case "carmodel/jingche_a.glb": |
| | | map.put("carType", "警车"); |
| | | break; |
| | | case "carmodel/jiuhu.glb": |
| | | map.put("carType", "救护车"); |
| | | break; |
| | | case "carmodel/oil.glb": |
| | | map.put("carType", "油罐车"); |
| | | break; |
| | | case "carmodel/truck.glb": |
| | | map.put("carType", "工程用车"); |
| | | break; |
| | | case "carmodel/van1.glb": |
| | | map.put("carType", "大货车"); |
| | | break; |
| | | default: |
| | | break; |
| | | }*/ |
| | | listObjetcName.add(map); |
| | | try{ |
| | | String carType = strArr[2]; |
| | | if(!carType.contains(".")){ |
| | | map.put("carType", carType); |
| | | map.put("carModel", "system/" + item.objectName()); |
| | | listObjetcName.add(map); |
| | | } |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return listObjetcName; |
| | | } catch (Exception ex) { |
| | |
| | | public Map<String, Object> getArdSyCarAndDeptByCarId(String carId) { |
| | | Map<String, Object> result = ardSyCarMapper.getArdSyCarAndDeptByCarId(carId); |
| | | if (result != null) { |
| | | if (result.get("carPicture") != null) { |
| | | /*if (result.get("carPicture") != null) { |
| | | if (!((String) result.get("carPicture")).equals("")) { |
| | | /*String url = ((String) result.get("carPicture")).split("sycar")[0]; |
| | | String carModel = url + (String) result.get("carModel");*/ |
| | | String carModel = this.minioEndpoint + "/" + (String) result.get("carModel"); |
| | | result.put("carModel", carModel); |
| | | } |
| | | }*/ |
| | | if(result.get("carModel") != null || "".equals(result.get("carModel"))){ |
| | | String carModel = this.minioEndpoint + "/" + (String) result.get("carModel"); |
| | | result.put("carModel", carModel); |
| | | } |
| | | } |
| | | return result; |
| | |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | Map<String, Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | //result0 = sYClient.getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | try { |
| | | result0 = getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | } catch (Exception e) { |
| | | return Results.error("查询历史数据数量过多导致超时,请缩小范围查询!"); |
| | | } |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) result0.get("list"); |
| | | if (list.isEmpty()) { |
| | | return Results.succeed(); |
| | |
| | | m.putAll(sgnMap); |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | } |
| | | |
| | | public static Map<String,Object> getCarGPSTrack(String syURL,String carId,String startTime,String endTime,String maxSpeed,String sessionId){ |
| | | OkHttpClient okHttpClient = new OkHttpClient(); |
| | | |
| | | Request request = new Request.Builder() |
| | | .url(syURL + "/gps-web/api/get_gps_h.jsp?carId=" + carId + "&startTime=" + startTime + "&endTime=" + endTime + "&sessionId=" + sessionId) |
| | | .build(); |
| | | |
| | | Response response = null; |
| | | try { |
| | | response = okHttpClient.newCall(request).execute(); |
| | | } catch (IOException e1) { |
| | | // TODO Auto-generated catch block |
| | | e1.printStackTrace(); |
| | | } |
| | | |
| | | response.headers(); //响应头 |
| | | |
| | | ResponseBody responseBody = response.body(); |
| | | |
| | | try { |
| | | String message = responseBody.string();// 响应体 |
| | | Map<String,Object> map = (Map<String, Object>) JSON.parse(message); |
| | | //System.out.println(message); |
| | | return map; |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | return new HashMap(); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public Results chaseCarByCarId(String usersId, String carId, String cycle) { |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | }else{ |
| | | return Results.error("没有挂接三一车辆用户"); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("三一车辆地址未录入"); |
| | | } |
| | | |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | | sessionId = key; |
| | | } |
| | | } |
| | | if(sessionId.equals("")){//没有session就返回失败 |
| | | return Results.error("追踪失败"); |
| | | } |
| | | try { |
| | | /*Map<String,Map<String,Object>> map = new HashMap(); |
| | | map.put(carId,new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId,map);*/ |
| | | if (cycle.equals("0")) { |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//停止追踪,改为定时30s推送 |
| | | System.out.println("停止追踪"); |
| | | } |
| | | return Results.succeed("停止追踪"); |
| | | } else { |
| | |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time"); |
| | | String time = ""; |
| | | if(distanceSYResult.size() != 0){ |
| | | time = distanceSYResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("三一车辆定时未录入"); |
| | | } |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//开始追踪,改为定时推送 |
| | | |
| | | Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//查询当前车辆位置 |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | | position.put("elng",position.get("lng")); |
| | | position.put("elat",position.get("lat")); |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//定时推送实时位置 |
| | | Timer carPositionTimer = new Timer(sessionId);//定时推送实时位置 |
| | | TimerTask carPositionTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | |
| | | if (position.size() != 0) { |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | //WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | | sessionId = key; |
| | | } |
| | | } |
| | | if(sessionId.equals("")){//用户离线释放资源 |
| | | String sessionId = Thread.currentThread().getName(); |
| | | if(ONLINE_USER_SESSIONS.get(sessionId) == null){//用户离线释放资源 |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = ardSyUser.getPassword(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | } |
| | | if(!userId.equals("") && !password.equals("") && !syURL.equals("")){ |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//停止追踪,改为定时30s |
| | | } |
| | | System.out.println("用户离线,停止追踪"); |
| | | } |
| | | } |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time"); |
| | | String time = ""; |
| | | if(distanceSYResult.size() != 0){ |
| | | time = distanceSYResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("三一车辆定时未录入"); |
| | | } |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//开始追踪,改为定时推送 |
| | | |
| | | Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//查询当前车辆位置 |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | | position.put("elng",position.get("lng")); |
| | | position.put("elat",position.get("lat")); |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//定时推送实时位置 |
| | | Timer carPositionTimer = new Timer(sessionId);//定时推送实时位置 |
| | | TimerTask carPositionTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | |
| | | if (position.size() != 0) { |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | //WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | | sessionId = key; |
| | | } |
| | | } |
| | | if(sessionId.equals("")){//用户离线释放资源 |
| | | String sessionId = Thread.currentThread().getName(); |
| | | if(ONLINE_USER_SESSIONS.get(sessionId) == null){//用户离线释放资源 |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = ardSyUser.getPassword(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | } |
| | | if(!userId.equals("") && !password.equals("") && !syURL.equals("")){ |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//停止追踪,改为定时30s |
| | | } |
| | | System.out.println("用户离线,停止追踪"); |
| | | } |
| | | } |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |