| | |
| | | package com.ruoyi.sy.service.impl; |
| | | |
| | | import java.awt.geom.Point2D; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.function.Predicate; |
| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.utils.tools.Point; |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | | import com.ruoyi.sy.domain.ArdSyCarDay; |
| | | import com.ruoyi.sy.mapper.ArdSyCarDayMapper; |
| | |
| | | /** |
| | | * 获取附近范围内的车辆信息 |
| | | */ |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getNearCar(SchedulingParam param) { |
| | | Double longitude = param.getLongitude(); |
| | |
| | | } |
| | | return filteredList; |
| | | } |
| | | /** |
| | | * 获取范围内的车辆信息(多边形) |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getNearCarWithPolygon(SchedulingParam param) { |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | try { |
| | | List<Point> partitionLocation = param.getPartitionLocation(); |
| | | if (partitionLocation == 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); |
| | | } |
| | | } |
| | | //过滤在线车辆 |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | //过滤半径 |
| | | 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")); |
| | | Point point = new Point(); |
| | | point.setLongitude(lng); |
| | | point.setLatitude(lat); |
| | | boolean inPolygon = GisTool.isInPolygon(point, partitionLocation); |
| | | if (inPolygon) { |
| | | carMap.put("longitude", lng); |
| | | carMap.put("latitude", lat); |
| | | filteredList.add(carMap); // 将满足条件的车辆添加到筛选列表中 |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | log.error("获取范围内的车辆信息(多边形)异常:" + ex.getMessage()); |
| | | } |
| | | return filteredList; |
| | | } |
| | | } |