| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dtflys.forest.annotation.Var; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ruoyi.app.application.domain.ArdAppApplication; |
| | | import com.ruoyi.app.application.mapper.ArdAppApplicationMapper; |
| | | import com.ruoyi.app.position.mapper.ArdAppPositionMapper; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | |
| | | import com.ruoyi.sy.domain.ArdAccessFence; |
| | | import com.ruoyi.sy.param.ArdSyCarParam; |
| | | import com.ruoyi.sy.vo.ArdSyCarVo; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import com.ruoyi.utils.gis.Point; |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | |
| | | RedisCache redisCache; |
| | | @Resource |
| | | private ArdSyCarDayMapper ardSyCarDayMapper; |
| | | |
| | | @Resource |
| | | private ArdAppApplicationMapper ardAppApplicationMapper; |
| | | |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @Value("${minio.endpoint}") |
| | | private String minioEndpoint; |
| | |
| | | newList.add(ardSyCarVoList.get(i)); |
| | | } |
| | | } |
| | | ardSyCarVoList.remove(newList); |
| | | ardSyCarVoList.removeAll(newList); |
| | | } |
| | | return AjaxResult.success(new PageInfo<>(ardSyCarVoList)); |
| | | }else { |
| | |
| | | |
| | | @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 = 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 = 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @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; |
| | | } |
| | | /** |
| | | * 获取范围内的车辆信息(多边形) |
| | |
| | | return sYClient.getAlarmHPfmCountDetail(syURL,carId,sessionId,startTime,endTime); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getOnlineSYCarPosition(String soilderId) { |
| | | Map<String,Object> result = new HashMap(); |
| | | ArdSyUser ardSyUserPara = new ArdSyUser(); |
| | | ardSyUserPara.setSysUserId(soilderId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara); |
| | | if(ardSyUserList.size() == 0){ |
| | | result.put("code","0"); |
| | | result.put("msg","登录用户未挂接三一车辆账号"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | ArdAppApplication ardAppApplicationPara = new ArdAppApplication(); |
| | | ardAppApplicationPara.setSoilderId(soilderId); |
| | | ardAppApplicationPara.setApplicationType("SYCar"); |
| | | ardAppApplicationPara.setState("1"); |
| | | List<ArdAppApplication> ardAppApplicationList = ardAppApplicationMapper.selectArdAppApplicationList(ardAppApplicationPara); |
| | | if(ardAppApplicationList.size() == 0){ |
| | | result.put("code","0"); |
| | | result.put("msg","登录用户未经指挥端同意"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | SysUser sysUser = userMapper.selectUserById(soilderId);//获取系统用户 |
| | | List<Long> deptIdList = new ArrayList(); |
| | | deptIdList.add(sysUser.getDeptId()); |
| | | deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//递归查询下属部门主键 |
| | | List<String> carIdList = ardSyCarMapper.selectArdSyCarByDeptIds(deptIdList); |
| | | String carIds = ""; |
| | | for(String carId : carIdList){ |
| | | carIds = carIds + carId + ","; |
| | | } |
| | | carIds = carIds.substring(0,carIds.length() - 1); |
| | | String syURL = ""; |
| | | List<SysConfig> sysConfigResult = sysConfigMapper.selectByType("syCarPT"); |
| | | if(sysConfigResult.size() > 0){ |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | }else{ |
| | | result.put("code","0"); |
| | | result.put("msg","三一车辆url没有录入"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUserList.get(0).getPassword()); |
| | | Map<String,Object> syLoginResult = sYClient.logIn(syURL, passwordMd5, ardSyUserList.get(0).getUserId()); |
| | | String sessionId = (String) syLoginResult.get("sessionId"); |
| | | Map<String,Object> carNearPositionResult = sYClient.getCarNearPositionByCarId(syURL, carIds, ardSyUserList.get(0).getUserId(),sessionId); |
| | | if(((String)carNearPositionResult.get("rspCode")).equals("1")){ |
| | | result.put("code","1"); |
| | | result.put("msg","三一车辆查询成功"); |
| | | List<Map<String,Object>> SYCarPositionList = (List<Map<String, Object>>) carNearPositionResult.get("list"); |
| | | //筛选在线 |
| | | SYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("在线")).collect(Collectors.toList()); |
| | | for(Map<String,Object> sycar : SYCarPositionList){ |
| | | Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId")); |
| | | sycar.putAll(map); |
| | | } |
| | | result.put("SYCarPositionList",SYCarPositionList); |
| | | return result; |
| | | }else{ |
| | | result.put("code","0"); |
| | | result.put("msg","三一车辆查询失败"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){ |
| | | deptIdListr.addAll(deptIdList); |
| | | List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList); |
| | | if(result.size() != 0){ |
| | | deptIdListr.addAll(result); |
| | | result = getOwnAndChildrenDeptIdList(result,deptIdListr); |
| | | } |
| | | deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList()); |
| | | return deptIdListr; |
| | | } |
| | | } |