1 files added
	
		
		10 files modified
	
	
 
	
	
	
	
	
	
	
	
 |  |  | 
 |  |  |                 String value = historyHourly.getValue(); | 
 |  |  |                 Map map = JSON.parseObject(value, Map.class); | 
 |  |  |                 map1.put("时间",DateUtils.dateToDateString(historyHourly.getTime())); | 
 |  |  |                 map1.put("pm25",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004")); | 
 |  |  |                 map1.put("pm10",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002")); | 
 |  |  |                 map1.put("二氧化氮",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004")); | 
 |  |  |                 map1.put("二氧化硫",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026")); | 
 |  |  |                 map1.put("一氧化碳",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005")); | 
 |  |  |                 map1.put("气压",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006")); | 
 |  |  |                 map1.put("温度",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001")); | 
 |  |  |                 map1.put("湿度",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002")); | 
 |  |  |                 map1.put("tvoc",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054")); | 
 |  |  |                 map1.put("甲醛",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); | 
 |  |  |                 map1.put("硫化氢",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); | 
 |  |  |                 map1.put("氨气",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); | 
 |  |  |                 map1.put("pm25ug/m³",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004")); | 
 |  |  |                 map1.put("pm10ug/m³",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002")); | 
 |  |  |                 map1.put("二氧化氮ug/m³",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004")); | 
 |  |  |                 map1.put("二氧化硫ug/m³",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026")); | 
 |  |  |                 map1.put("一氧化碳ug/m³",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005")); | 
 |  |  |                 map1.put("气压hpa",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006")); | 
 |  |  |                 map1.put("温度℃",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001")); | 
 |  |  |                 map1.put("湿度%",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002")); | 
 |  |  |                 map1.put("tvocmg/m³",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054")); | 
 |  |  |                 map1.put("甲醛mg/m³",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); | 
 |  |  |                 map1.put("硫化氢ppm",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); | 
 |  |  |                 map1.put("氨气ug/m³",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); | 
 |  |  |                 rsMap.add(map1); | 
 |  |  |             } | 
 |  |  |         }else { | 
 |  |  | 
 |  |  |                 String value = historyFiveMinutely.getValue(); | 
 |  |  |                 Map map = JSON.parseObject(value, Map.class); | 
 |  |  |                 map1.put("时间",DateUtils.dateToDateString(historyFiveMinutely.getTime())); | 
 |  |  |                 map1.put("pm25",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004")); | 
 |  |  |                 map1.put("pm10",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002")); | 
 |  |  |                 map1.put("二氧化氮",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004")); | 
 |  |  |                 map1.put("二氧化硫",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026")); | 
 |  |  |                 map1.put("一氧化碳",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005")); | 
 |  |  |                 map1.put("气压",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006")); | 
 |  |  |                 map1.put("温度",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001")); | 
 |  |  |                 map1.put("湿度",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002")); | 
 |  |  |                 map1.put("tvoc",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054")); | 
 |  |  |                 map1.put("甲醛",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); | 
 |  |  |                 map1.put("硫化氢",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); | 
 |  |  |                 map1.put("氨气",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); | 
 |  |  |                 map1.put("pm25ug/m³",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004")); | 
 |  |  |                 map1.put("pm10ug/m³",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002")); | 
 |  |  |                 map1.put("二氧化氮ug/m³",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004")); | 
 |  |  |                 map1.put("二氧化硫ug/m³",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026")); | 
 |  |  |                 map1.put("一氧化碳ug/m³",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005")); | 
 |  |  |                 map1.put("气压hpa",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006")); | 
 |  |  |                 map1.put("温度℃",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001")); | 
 |  |  |                 map1.put("湿度%",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002")); | 
 |  |  |                 map1.put("tvocmg/m³",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054")); | 
 |  |  |                 map1.put("甲醛ug/m³",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); | 
 |  |  |                 map1.put("硫化氢ppm",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); | 
 |  |  |                 map1.put("氨气ug/m³",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); | 
 |  |  |                 rsMap.add(map1); | 
 |  |  |             } | 
 |  |  |         } | 
 
 |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | 
 |  |  | import com.moral.api.entity.ManageCoordinate; | 
 |  |  | import com.moral.api.mapper.ManageCoordinateMapper; | 
 |  |  | import com.moral.api.pojo.form.coordinate.CoordinateCode; | 
 |  |  | import com.moral.api.service.ManageCoordinateService; | 
 |  |  | import com.moral.constant.ResponseCodeEnum; | 
 |  |  | import com.moral.constant.ResultMessage; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ManageCoordinateService manageCoordinateService; | 
 |  |  |     @Autowired | 
 |  |  |     private ManageCoordinateMapper manageCoordinateMapper; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改路段信息 | 
 |  |  |      * | 
 |  |  |      * @param manageCoordinate | 
 |  |  |      * @param coordinateCode | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @PostMapping("updateCruiserRoad") | 
 |  |  |     public ResultMessage updateCruiserRoad(@RequestBody ManageCoordinate manageCoordinate) { | 
 |  |  |         if (ObjectUtils.isEmpty(manageCoordinate)) { | 
 |  |  |     public ResultMessage updateCruiserRoad(@RequestBody CoordinateCode coordinateCode) { | 
 |  |  |         if (ObjectUtils.isEmpty(coordinateCode)) { | 
 |  |  |             return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
 |  |  |         } | 
 |  |  |         manageCoordinateService.updateCoordinate(manageCoordinate); | 
 |  |  |         manageCoordinateService.updateCoordinate(coordinateCode); | 
 |  |  |         return ResultMessage.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         List<ManageCoordinate> manageCoordinates = manageCoordinateService.selectCoordinate(name, mac); | 
 |  |  |         return ResultMessage.ok(manageCoordinates); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据id查询路段信息 | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping("query") | 
 |  |  |     public ResultMessage query(Integer id){ | 
 |  |  |         ManageCoordinate manageCoordinate = manageCoordinateService.query(id); | 
 |  |  |         if (ObjectUtils.isEmpty(manageCoordinate)){ | 
 |  |  |             return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), | 
 |  |  |                     ResponseCodeEnum.TARGET_IS_NULL.getMsg()); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.ok(manageCoordinate); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |         Map<String,Object> rsMap = manageCoordinateDetailService.selectCoordinate(params); | 
 |  |  |         return ResultMessage.ok(rsMap); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("queryAll") | 
 |  |  |     @ApiImplicitParams(value = { | 
 |  |  |             @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "mac", value = "mac号", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "time1", value = "开始时间,2021-08-18", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "time2", value = "结束时间,2021-08-18", required = true, paramType = "query", dataType = "String") | 
 |  |  |     }) | 
 |  |  |     public ResultMessage queryAll(@RequestBody Map<String,Object> params){ | 
 |  |  |         manageCoordinateDetailService.queryAll(params); | 
 |  |  |         return ResultMessage.ok(); | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  | import lombok.EqualsAndHashCode; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
 |  |  | import com.baomidou.mybatisplus.annotation.TableField; | 
 |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
 |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private  Integer organizationId; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 经纬度点位 | 
 |  |  |      */ | 
 |  |  |     private  String value; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 百度经纬度点位 | 
 |  |  |      */ | 
 |  |  |     private  String bdValue; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 84经纬度点位 | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     private List<HashMap<String, Object>> values; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 百度经纬度点位 | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     private List<HashMap<String, Object>> bdValues; | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | package com.moral.api.mapper; | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.ManageCoordinate; | 
 |  |  | import com.moral.api.entity.Organization; | 
 |  |  | import com.moral.api.entity.SpecialDevice; | 
 |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
 |  |  | 
 |  |  |  | 
 |  |  |     Organization selectOrgByMac(String mac); | 
 |  |  |  | 
 |  |  |     List<ManageCoordinate> selectCoordinate(String mac); | 
 |  |  |  | 
 |  |  | } | 
 
| New file | 
 |  |  | 
 |  |  | package com.moral.api.pojo.form.coordinate; | 
 |  |  |  | 
 |  |  | import lombok.Data; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
 |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * Description //todo | 
 |  |  |  * | 
 |  |  |  * @author swb | 
 |  |  |  * @ClassName CoordinateCode | 
 |  |  |  * @date 2024.04.18 14:09 | 
 |  |  |  */ | 
 |  |  | @Data | 
 |  |  | public class CoordinateCode { | 
 |  |  |  | 
 |  |  |     private static final long serialVersionUID = 1L; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 路段id | 
 |  |  |      */ | 
 |  |  |     private  Integer coordinateId; | 
 |  |  |     /** | 
 |  |  |      * 起点名称 | 
 |  |  |      */ | 
 |  |  |     private  String startPoint; | 
 |  |  |     /** | 
 |  |  |      * 终点名称 | 
 |  |  |      */ | 
 |  |  |     private  String endPoint; | 
 |  |  |     /** | 
 |  |  |      *是否删除 | 
 |  |  |      */ | 
 |  |  |     private  Integer isDel; | 
 |  |  |     /** | 
 |  |  |      * 创建时间 | 
 |  |  |      */ | 
 |  |  |     private Date createTime; | 
 |  |  |     /** | 
 |  |  |      * 修改时间 | 
 |  |  |      */ | 
 |  |  |     private Date  updateTime; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改人id | 
 |  |  |      * | 
 |  |  |      */ | 
 |  |  |     private  Integer updateUserId; | 
 |  |  |     /** | 
 |  |  |      * 修改人名称 | 
 |  |  |      */ | 
 |  |  |     private  String updayeUserName; | 
 |  |  |  | 
 |  |  |     private  Integer organizationId; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 84经纬度点位 | 
 |  |  |      */ | 
 |  |  |     private List<HashMap<String, Object>> value; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 百度经纬度点位 | 
 |  |  |      * | 
 |  |  |      */ | 
 |  |  |     private List<HashMap<String, Object>> bdValue; | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | package com.moral.api.service; | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
 |  |  | 
 |  |  |     Integer insertCoordinate(Map<String,Object> params); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     Map<String,Object> selectCoordinate(Map<String,Object> params); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     Integer batchAll(Map<String,Object> params); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 所有数据批量添加 | 
 |  |  |      * @param params | 
 |  |  |      */ | 
 |  |  |     void queryAll(Map<String,Object> params); | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
 |  |  | import com.moral.api.entity.ManageCoordinate; | 
 |  |  | import com.moral.api.pojo.form.coordinate.CoordinateCode; | 
 |  |  |  | 
 |  |  | public interface ManageCoordinateService extends IService<ManageCoordinate> { | 
 |  |  |     /** | 
 |  |  | 
 |  |  |     Integer interCoordinate(Map<String,Object> params); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     void updateCoordinate(ManageCoordinate manageCoordinate); | 
 |  |  |     void updateCoordinate(CoordinateCode coordinateCode); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     void deleteCoordinate(Integer id); | 
 |  |  | 
 |  |  |  | 
 |  |  |     List<ManageCoordinate> selectCoordinate(String name,String mac); | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据id查询路段信息 | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     ManageCoordinate query(Integer id); | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | package com.moral.api.service.impl; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
 |  |  | import com.moral.api.entity.ManageAccount; | 
 |  |  | import com.moral.api.entity.ManageCoordinate; | 
 |  |  | import com.moral.api.entity.ManageCoordinateDetail; | 
 |  |  | import com.moral.api.entity.SpecialDevice; | 
 |  |  | import com.moral.api.mapper.HistorySecondCruiserMapper; | 
 |  |  | import com.moral.api.mapper.ManageCoordinateDetailMapper; | 
 |  |  | import com.moral.api.mapper.SpecialDeviceMapper; | 
 |  |  | import com.moral.api.pojo.dto.cruiser.CruiserDTO; | 
 |  |  | import com.moral.api.pojo.redisBean.AccountInfoDTO; | 
 |  |  | import com.moral.api.service.ManageCoordinateDetailService; | 
 |  |  | 
 |  |  | import org.springframework.web.context.request.RequestContextHolder; | 
 |  |  | import org.springframework.web.context.request.ServletRequestAttributes; | 
 |  |  | import javax.servlet.http.HttpServletRequest; | 
 |  |  |  | 
 |  |  | import java.awt.geom.Point2D; | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.concurrent.TimeUnit; | 
 |  |  | import java.util.regex.Matcher; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RedisTemplate redisTemplate; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SpecialDeviceMapper specialDeviceMapper; | 
 |  |  |     /** | 
 |  |  |      * 新增经纬度 | 
 |  |  |      * @param params | 
 |  |  | 
 |  |  |         } | 
 |  |  |         return 200; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 所有数据批量添加 | 
 |  |  |      * | 
 |  |  |      * @param params | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void queryAll(Map<String, Object> params) { | 
 |  |  |         //获取路段信息 | 
 |  |  |         List<ManageCoordinate> coordinates = specialDeviceMapper.selectCoordinate(params.get("mac").toString()); | 
 |  |  |         //获取走航车数据 | 
 |  |  |         List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); | 
 |  |  |         cruiserInfo = cruiserInfo.stream().distinct().collect(Collectors.toList()); | 
 |  |  |         List<ManageCoordinateDetail> result = new ArrayList<>(); | 
 |  |  |             for (ManageCoordinate coordinate : coordinates) { | 
 |  |  |                 String value = coordinate.getValue(); | 
 |  |  |                 if (!ObjectUtils.isEmpty(value)){ | 
 |  |  |                     List<Map<String, Object>> parse = (List<Map<String, Object>>) JSONArray.parse(value); | 
 |  |  |  | 
 |  |  |                     for (int i = 0; i < cruiserInfo.size(); i++) { | 
 |  |  |                         CruiserDTO cruiserDTO = cruiserInfo.get(i); | 
 |  |  |                         if (ObjectUtils.isEmpty(cruiserDTO)){ | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         Double flyLat = cruiserDTO.getFlyLat(); | 
 |  |  |                         Double flyLon = cruiserDTO.getFlyLon(); | 
 |  |  |                         if (ObjectUtils.isEmpty(flyLat)||ObjectUtils.isEmpty(flyLon)){ | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         boolean inPolygon = isInPolygon(flyLon, flyLat, parse); | 
 |  |  |                        if (inPolygon){ | 
 |  |  |                            LambdaQueryWrapper<ManageCoordinateDetail> wr = new LambdaQueryWrapper<>(); | 
 |  |  |                            wr.eq(ManageCoordinateDetail::getLongitude,flyLon); | 
 |  |  |                            wr.eq(ManageCoordinateDetail::getLatitude,flyLat); | 
 |  |  |                            List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(wr); | 
 |  |  |                            if (ObjectUtils.isEmpty(manageCoordinateDetails)){ | 
 |  |  |                                ManageCoordinateDetail rsDTO = new ManageCoordinateDetail(); | 
 |  |  |                                rsDTO.setLatitude(flyLat); | 
 |  |  |                                rsDTO.setLongitude(flyLon); | 
 |  |  |                                rsDTO.setState("2"); | 
 |  |  |                                rsDTO.setCreateTime(new Date()); | 
 |  |  |                                rsDTO.setUpdateTime(new Date()); | 
 |  |  |                                rsDTO.setCoordinateId(coordinate.getCoordinateId()); | 
 |  |  |                                result.add(rsDTO); | 
 |  |  |                                cruiserInfo.remove(i); | 
 |  |  |                                i--; | 
 |  |  |                            } | 
 |  |  |                        } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |           } | 
 |  |  |         if(!CollectionUtils.isEmpty(result)){ | 
 |  |  |             this.saveBatch(result); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 判断当前位置是否在多边形区域内 | 
 |  |  |      * @param | 
 |  |  |      * @param mapList 区域顶点 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static boolean isInPolygon(Double X,Double Y,List<Map<String, Object>> mapList){ | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         Point2D.Double point = new Point2D.Double(X, Y); | 
 |  |  |         List<Point2D.Double> pointList= new ArrayList<Point2D.Double>(); | 
 |  |  |  | 
 |  |  |         for (Map<String, Object> param : mapList) { | 
 |  |  |             //纬度 | 
 |  |  |             String lat = param.get("lat").toString(); | 
 |  |  |             //经度 | 
 |  |  |             String lng = param.get("lng").toString(); | 
 |  |  |             Point2D.Double polygonPoint = new Point2D.Double(Double.parseDouble(lng),Double.parseDouble(lat)); | 
 |  |  |             pointList.add(polygonPoint); | 
 |  |  |         } | 
 |  |  |         return IsPtInPoly(point,pointList); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 判断点是否在多边形内,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true | 
 |  |  |      * @param point 检测点 | 
 |  |  |      * @param pts   多边形的顶点 | 
 |  |  |      * @return      点在多边形内返回true,否则返回false | 
 |  |  |      */ | 
 |  |  |     public static boolean IsPtInPoly(Point2D.Double point, List<Point2D.Double> pts){ | 
 |  |  |  | 
 |  |  |         int N = pts.size(); | 
 |  |  |         boolean boundOrVertex = true; //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true | 
 |  |  |         int intersectCount = 0;//cross points count of x | 
 |  |  |         double precision = 2e-10; //浮点类型计算时候与0比较时候的容差 | 
 |  |  |         Point2D.Double p1, p2;//neighbour bound vertices | 
 |  |  |         Point2D.Double p = point; //当前点 | 
 |  |  |  | 
 |  |  |         p1 = pts.get(0);//left vertex | 
 |  |  |         for(int i = 1; i <= N; ++i){//check all rays | 
 |  |  |             if(p.equals(p1)){ | 
 |  |  |                 return boundOrVertex;//p is an vertex | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             p2 = pts.get(i % N); | 
 |  |  |             if(p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)){ | 
 |  |  |                 p1 = p2; | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if(p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)){ | 
 |  |  |                 if(p.y <= Math.max(p1.y, p2.y)){ | 
 |  |  |                     if(p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)){ | 
 |  |  |                         return boundOrVertex; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if(p1.y == p2.y){ | 
 |  |  |                         if(p1.y == p.y){ | 
 |  |  |                             return boundOrVertex; | 
 |  |  |                         }else{//before ray | 
 |  |  |                             ++intersectCount; | 
 |  |  |                         } | 
 |  |  |                     }else{ | 
 |  |  |                         double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; | 
 |  |  |                         if(Math.abs(p.y - xinters) < precision){ | 
 |  |  |                             return boundOrVertex; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         if(p.y < xinters){ | 
 |  |  |                             ++intersectCount; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             }else{ | 
 |  |  |                 if(p.x == p2.x && p.y <= p2.y){ | 
 |  |  |                     Point2D.Double p3 = pts.get((i+1) % N); | 
 |  |  |                     if(p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)){ | 
 |  |  |                         ++intersectCount; | 
 |  |  |                     }else{ | 
 |  |  |                         intersectCount += 2; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             p1 = p2; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if(intersectCount % 2 == 0){//偶数在多边形外 | 
 |  |  |             return false; | 
 |  |  |         } else { //奇数在多边形内 | 
 |  |  |             return true; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  | package com.moral.api.service.impl; | 
 |  |  |  | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.util.ObjectUtils; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSON; | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
 |  |  | 
 |  |  | import com.moral.api.mapper.ManageCoordinateDetailMapper; | 
 |  |  | import com.moral.api.mapper.ManageCoordinateMapper; | 
 |  |  | import com.moral.api.mapper.SpecialDeviceMapper; | 
 |  |  | import com.moral.api.pojo.form.coordinate.CoordinateCode; | 
 |  |  | import com.moral.api.service.DeviceService; | 
 |  |  | import com.moral.api.service.ManageCoordinateDetailService; | 
 |  |  | import com.moral.api.service.ManageCoordinateService; | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改路段 | 
 |  |  |      * @param manageCoordinate | 
 |  |  |      * @param coordinateCode | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void updateCoordinate(ManageCoordinate manageCoordinate) { | 
 |  |  |     public void updateCoordinate(CoordinateCode coordinateCode) { | 
 |  |  |         ManageCoordinate manageCoordinate = new ManageCoordinate(); | 
 |  |  |         BeanUtils.copyProperties(coordinateCode,manageCoordinate); | 
 |  |  |         manageCoordinate.setUpdateTime(new Date()); | 
 |  |  |         List<HashMap<String, Object>> value = coordinateCode.getValue(); | 
 |  |  |         String s = JSON.toJSONString(value); | 
 |  |  |         manageCoordinate.setValue(s); | 
 |  |  |         manageCoordinate.setBdValue(JSON.toJSONString(coordinateCode.getBdValue())); | 
 |  |  |         manageCoordinateMapper.updateById(manageCoordinate); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         queryWrapper.eq("is_del",0); | 
 |  |  |         queryWrapper.orderByDesc("coordinate_id"); | 
 |  |  |         List<ManageCoordinate> manageCoordinates = manageCoordinateMapper.selectList(queryWrapper); | 
 |  |  |         manageCoordinates.forEach(it->{ | 
 |  |  |             String value = it.getValue(); | 
 |  |  |             String bdValue = it.getBdValue(); | 
 |  |  |             if (!ObjectUtils.isEmpty(value)  &&  !ObjectUtils.isEmpty(bdValue)){ | 
 |  |  | //                List<HashMap<String, Object>> hashMaps = (List<HashMap<String, Object>>)JSON.parseObject(value,List.class); | 
 |  |  |                 List<HashMap<String, Object>> parse = (List<HashMap<String, Object>>) JSONArray.parse(value); | 
 |  |  |                 it.setValues(parse); | 
 |  |  |                 it.setBdValues((List<HashMap<String, Object>>) JSONArray.parse(bdValue)); | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  |         return manageCoordinates; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据id查询路段信息 | 
 |  |  |      * | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public ManageCoordinate query(Integer id) { | 
 |  |  |         ManageCoordinate manageCoordinate = manageCoordinateMapper.selectById(id); | 
 |  |  |         return manageCoordinate; | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  |         WHERE id = (SELECT organization_id FROM special_device WHERE mac = #{mac}) | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="selectCoordinate" resultType="com.moral.api.entity.ManageCoordinate"> | 
 |  |  |         SELECT * FROM manage_coordinate WHERE organization_id = (SELECT organization_id from special_device WHERE mac=#{mac} | 
 |  |  |         ) AND is_del =0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  | </mapper> |