| | |
| | | listObjetcName.add(map); |
| | | } |
| | | }catch(Exception e){ |
| | | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return listObjetcName; |
| | |
| | | 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 + "_")){ |
| | |
| | | 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("停止追踪"); |
| | |
| | | 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) { |
| | |
| | | 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("用户离线,停止追踪"); |
| | | } |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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("用户离线,停止追踪"); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getNearCar(SchedulingParam param) { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | Integer radius = param.getSealingRadius(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | if (radius == null) { |
| | | log.debug("半径距离为空"); |
| | | return null; |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | ArdSyUser syUser = new ArdSyUser(); |
| | | syUser.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser); |
| | | if (ardSyUserList.size() == 0) { |
| | | log.debug("用户未挂接三一车辆"); |
| | | return null; |
| | | } |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | String syUrl = redisCache.getCacheObject("sys_config:syCarPT"); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | try { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | Integer radius = param.getSealingRadius(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | if (radius == null) { |
| | | log.debug("半径距离为空"); |
| | | return null; |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | ArdSyUser syUser = new ArdSyUser(); |
| | | syUser.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser); |
| | | if (ardSyUserList.size() == 0) { |
| | | log.debug("用户未挂接三一车辆"); |
| | | return null; |
| | | } |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | String syUrl = redisCache.getCacheObject("sys_config:syCarPT"); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | |
| | | Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list"); |
| | | List<Map<String, Object>> allList = new ArrayList<>(); |
| | | for (Map<String, Object> team : listMap) { |
| | | String teamId = (String) team.get("teamId"); |
| | | Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | allList.addAll(list); |
| | | Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list"); |
| | | List<Map<String, Object>> allList = new ArrayList<>(); |
| | | for (Map<String, Object> team : listMap) { |
| | | String teamId = (String) team.get("teamId"); |
| | | Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | allList.addAll(list); |
| | | } |
| | | } |
| | | } |
| | | //过滤在线车辆 |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | //过滤半径 |
| | | for (Map<String, Object> carMap : onlineList) { |
| | | String carId = (String) carMap.get("carId"); |
| | | Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list"); |
| | | Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng")); |
| | | Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat")); |
| | | double distance = GisUtil.getDistance( new double[]{longitude,latitude}, new double[]{lng, lat}); |
| | | if (distance <= radius) { |
| | | carMap.put("longitude",lng); |
| | | carMap.put("latitude",lat); |
| | | filteredList.add(carMap); // 将满足条件的车辆添加到筛选列表中 |
| | | //过滤在线车辆 |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | //过滤半径 |
| | | for (Map<String, Object> carMap : onlineList) { |
| | | String carId = (String) carMap.get("carId"); |
| | | Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list"); |
| | | Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng")); |
| | | Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat")); |
| | | double distance = GisUtil.getDistance(new double[]{longitude, latitude}, new double[]{lng, lat}); |
| | | if (distance <= radius) { |
| | | carMap.put("longitude", lng); |
| | | carMap.put("latitude", lat); |
| | | filteredList.add(carMap); // 将满足条件的车辆添加到筛选列表中 |
| | | } |
| | | } |
| | | return filteredList; |
| | | }catch (Exception e) |
| | | { |
| | | log.error("获取附近范围内的车辆信息异常:"+e.getMessage()); |
| | | return null; |
| | | } |
| | | return filteredList; |
| | | } |
| | | /** |
| | | * 获取范围内的车辆信息(多边形) |