| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> carTrajectory(Map<String, Object> params) { |
| | | public List<Map<String, Object>> carTrajectory(Map<String, Object> params,boolean type) { |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | |
| | | if (lon < 70 || lon > 150 || lat < 20 || lat > 60) { |
| | | return true; |
| | | } |
| | | o.putAll(value); |
| | | if(type){ |
| | | o.putAll(value); |
| | | }else { |
| | | |
| | | } |
| | | |
| | | return false; |
| | | }); |
| | | /*for (Map<String, Object> map:data) { |
| | |
| | | }*/ |
| | | return filterData(data); |
| | | } |
| | | |
| | | @Override |
| | | public SpecialDevice getSpecialDeviceMapByMac(String mac) { |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper(); |
| | |
| | | String time2 = params.get("time2").toString(); |
| | | String rsTime = getTime(time1, time2); |
| | | list.add(rsTime); |
| | | List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params); |
| | | List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false); |
| | | if (ObjectUtils.isEmpty(maps)){ |
| | | return null; |
| | | } |
| | |
| | | map.put("time1",time3); |
| | | map.put("time2",time4); |
| | | map.put("mac",mac); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | if (ObjectUtils.isEmpty(maps1)){ |
| | | return null; |
| | | } |
| | |
| | | map.put("time1",time5); |
| | | map.put("time2",time6); |
| | | map.put("mac",mac); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | if (ObjectUtils.isEmpty(maps1)){ |
| | | return null; |
| | | } |
| | |
| | | result.add(map); |
| | | } |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | | //范围取均值 |
| | | private List<Map<String, Object>> filterData(List<Map<String, Object>> data, List<Map<String, Object>> result) { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | |
| | | Map<String,List<Object>> map = new HashMap<>(); |
| | | result.forEach(it->map.put(it.get(Constants.SENSOR_CODE_LON).toString()+ "_"+Constants.SENSOR_CODE_LAT.toString(),Arrays.asList(it))); |
| | | // 坐标在50 以内分组 |
| | | for (Map<String, Object> mapData : data) { |
| | | for (Map.Entry<String, List<Object>> entry : map.entrySet()) { |
| | | double lng1 = Double.parseDouble(mapData.get(Constants.SENSOR_CODE_LON).toString()); |
| | | double lat1 = Double.parseDouble(mapData.get(Constants.SENSOR_CODE_LAT).toString()); |
| | | String[] mapKey = entry.getKey().split("_"); |
| | | List<Object> mapValue = entry.getValue(); |
| | | double lng2 = Double.parseDouble(mapKey[0]); |
| | | double lat2 = Double.parseDouble(mapKey[1]); |
| | | double distance = GeodesyUtils.getDistance(lat1, lng1, lat2, lng2); |
| | | if (distance < dis) { |
| | | mapValue.add(mapData); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | } |