cjl
2024-08-09 a022ae9804d0c2f402711b6b5202319d853919cf
Merge remote-tracking branch 'origin/dev' into cjl
29 files added
11 files modified
1499 ■■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/CruiserController.java 12 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/HeatMapController.java 5 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/entity/SecondCruiserSort.java 52 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/SecondCruiserSortMapper.java 13 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/DataDisplayService.java 2 ●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/DustldService.java 5 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/SecondCruiserSortService.java 7 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java 151 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java 36 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/SecondCruiserSortServiceImpl.java 19 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/DeviceMapper.xml 3 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/SecondCruiserSortMapper.xml 20 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/controller/PubController.java 24 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/CruiserDTO.java 62 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/DustldDTO.java 24 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/HistorySecondCruiser.java 55 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/ManageCoordinate.java 76 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/ManageCoordinateDetail.java 70 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/SecondCruiserSort.java 48 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/SysDictData.java 65 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/entity/SysDictType.java 63 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java 14 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/mapper/ManageCoordinateDetailMapper.java 19 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/mapper/OrganizationMapper.java 6 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/mapper/SecondCruiserSortMapper.java 11 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/mapper/SysDictTypeMapper.java 14 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/HistorySecondCruiserService.java 18 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/ManageCoordinateDetailService.java 14 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/SecondCruiserSortService.java 7 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/SysDictTypeService.java 10 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java 131 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java 203 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/impl/SecondCruiserSortServiceImpl.java 19 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/service/impl/SysDictTypeServiceImpl.java 36 ●●●●● patch | view | raw | blame | history
screen-job/src/main/java/com/moral/api/task/HistoryTableInsertTask.java 44 ●●●●● patch | view | raw | blame | history
screen-job/src/main/resources/mapper/HistorySecondCruiserMapper.xml 33 ●●●●● patch | view | raw | blame | history
screen-job/src/main/resources/mapper/ManageCoordinateDetailMapper.xml 44 ●●●●● patch | view | raw | blame | history
screen-job/src/main/resources/mapper/OrganizationMapper.xml 19 ●●●●● patch | view | raw | blame | history
screen-job/src/main/resources/mapper/SecondCruiserSortMapper.xml 22 ●●●●● patch | view | raw | blame | history
screen-job/src/main/resources/mapper/SysDictTypeMapper.xml 23 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/CruiserController.java
@@ -8,6 +8,7 @@
import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
import com.moral.api.entity.Dustld;
import com.moral.api.entity.SecondCruiserSort;
import com.moral.api.exception.BusinessException;
import com.moral.api.pojo.bo.ExcelBO;
import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO;
@@ -23,6 +24,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -290,6 +292,16 @@
    }
    @GetMapping("sort")
    @ApiOperation("路段排序")
    public ResultMessage sectionRanking(@RequestParam @ApiParam(value = "mac",name = "mac号") String mac,
                                        @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime,
                                        @RequestParam @ApiParam(value = "endTime",name = "结束时间") String endTime){
        List<SecondCruiserSort> sort = dustldService.sort(mac, startTime, endTime);
        return ResultMessage.ok(sort);
    }
    public static void downloadWord(String fileName, Map<String, Object> params, HttpServletResponse response, String newFileName) {
screen-api/src/main/java/com/moral/api/controller/HeatMapController.java
@@ -40,8 +40,9 @@
     public ResultMessage  getHeatMap(@RequestParam @ApiParam(value = "organizationId",name = "组织id") Integer id,
                                      @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime,
                                      @RequestParam @ApiParam(value = "type",name= "因子类型") String type,
                                      @RequestParam @ApiParam(value = "form",name= "时间类型") String form){
         List<HeatMapDTO> heatMapData = dataDisplayService.getHeatMapDataV2(id, startTime, type, form);
                                      @RequestParam @ApiParam(value = "form",name= "时间类型") String form,
                                      @RequestParam @ApiParam(value = "monitorId",name= "站点id") Integer monitorId){
         List<HeatMapDTO> heatMapData = dataDisplayService.getHeatMapDataV2(id, startTime, type, form,monitorId);
         return ResultMessage.ok(ObjectUtils.isEmpty(heatMapData)?"0":heatMapData);
     }
    @GetMapping("queryTime")
screen-api/src/main/java/com/moral/api/entity/SecondCruiserSort.java
New file
@@ -0,0 +1,52 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SecondCruiserSort
 * @date 2024.06.25 15:29
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SecondCruiserSort extends Model<SecondCruiserSort> {
    /**
     * 路段名称
     */
    private  String  road;
    /**
     * 数据
     */
    private  Double  value;
    /**
     * mac号
     */
    private String  mac;
    /**
     * 组织Id
     */
    private Integer  organizationId;
    /**
     * 时间
     */
    private String  time;
    /**
     * 平均值
     */
    @TableField(exist = false)
    private Double avg;
}
screen-api/src/main/java/com/moral/api/mapper/SecondCruiserSortMapper.java
New file
@@ -0,0 +1,13 @@
package com.moral.api.mapper;
import io.lettuce.core.dynamic.annotation.Param;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.SecondCruiserSort;
public interface SecondCruiserSortMapper extends BaseMapper<SecondCruiserSort> {
    List<SecondCruiserSort> getSort(@Param("mac") String mac, @Param("startTime") String startTime,@Param("endTime") String endTime);
}
screen-api/src/main/java/com/moral/api/service/DataDisplayService.java
@@ -51,5 +51,5 @@
    List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form);
    List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form,Integer monitorId);
}
screen-api/src/main/java/com/moral/api/service/DustldService.java
@@ -7,6 +7,8 @@
import java.util.Map;
import com.moral.api.entity.Dustld;
import com.moral.api.entity.SecondCruiserSort;
public interface DustldService {
@@ -26,6 +28,7 @@
    List<Dustld>  selectAll(Map<String, Object> params);
    //路段排序
    List<SecondCruiserSort> sort(String mac, String startTime, String endTime);
}
screen-api/src/main/java/com/moral/api/service/SecondCruiserSortService.java
New file
@@ -0,0 +1,7 @@
package com.moral.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.SecondCruiserSort;
public interface SecondCruiserSortService extends IService<SecondCruiserSort> {
}
screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
@@ -571,10 +571,11 @@
    }
    @Override
    public List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form) {
    public List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form,Integer monitorId) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("start",startTime);
        map.put("type","$."+ type);
        map.put("monitorId",monitorId);
        ArrayList<Integer> list = new ArrayList<>();
        list.add(id);
        ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>();
@@ -685,7 +686,125 @@
                rsHeatMap.add(heatMapDTO);
            }
        }
       if (id==73){
        if (!ObjectUtils.isEmpty(monitorId)){
            if (monitorId==117){
                double lat =33.35001;
                double lng =120.142939;
                for (int i = 0; i <24 ; i++) {
                    for (int j = 0; j < 20; j++) {
                        HeatMapDTO heatMapDTO = new HeatMapDTO();
                        heatMapDTO.setCount(0.0);
                        heatMapDTO.setLat(lat);
                        heatMapDTO.setLng(lng);
                        heatMapDTO.setName("1");
                        heatMapDTO.setMac(i+"10"+j);
                        rsHeatMap.add(heatMapDTO);
                        lng=lng+0.0021;
                        if (j==19){
                            lng=120.142939;
                        }
                    }
                    lat =lat-0.0011;
                }
            } else if (monitorId==118){
                double lat =33.375618;
                double lng =120.14271;
                for (int i = 0; i <24 ; i++) {
                    for (int j = 0; j < 17; j++) {
                        HeatMapDTO heatMapDTO = new HeatMapDTO();
                        heatMapDTO.setCount(0.0);
                        heatMapDTO.setLat(lat);
                        heatMapDTO.setLng(lng);
                        heatMapDTO.setName("1");
                        heatMapDTO.setMac(i+"10"+j);
                        rsHeatMap.add(heatMapDTO);
                        lng=lng+0.0021;
                        if (j==16){
                            lng=120.14271;
                        }
                    }
                    lat =lat-0.0011;
                }
            } else if (monitorId==120){
                double lat =33.410581;
                double lng =120.108739;
                for (int i = 0; i <21 ; i++) {
                    for (int j = 0; j < 15; j++) {
                        HeatMapDTO heatMapDTO = new HeatMapDTO();
                        heatMapDTO.setCount(0.0);
                        heatMapDTO.setLat(lat);
                        heatMapDTO.setLng(lng);
                        heatMapDTO.setName("1");
                        heatMapDTO.setMac(i+"10"+j);
                        rsHeatMap.add(heatMapDTO);
                        lng=lng+0.0021;
                        if (j==14){
                            lng=120.108739;
                        }
                    }
                    lat =lat-0.001;
                }
            }else if (monitorId==121){
                double lat =33.398466;
                double lng =120.153462;
                for (int i = 0; i <13 ; i++) {
                    for (int j = 0; j < 16; j++) {
                        HeatMapDTO heatMapDTO = new HeatMapDTO();
                        heatMapDTO.setCount(0.0);
                        heatMapDTO.setLat(lat);
                        heatMapDTO.setLng(lng);
                        heatMapDTO.setName("1");
                        heatMapDTO.setMac(i+"10"+j);
                        rsHeatMap.add(heatMapDTO);
                        lng=lng+0.00085;
                        if (j==15){
                            lng=120.153462;
                        }
                    }
                    lat =lat-0.001;
                }
            }else if (monitorId==122){
                double lat =33.210894;
                double lng =120.424509;
                for (int i = 0; i <15 ; i++) {
                    for (int j = 0; j < 9; j++) {
                        HeatMapDTO heatMapDTO = new HeatMapDTO();
                        heatMapDTO.setCount(0.0);
                        heatMapDTO.setLat(lat);
                        heatMapDTO.setLng(lng);
                        heatMapDTO.setName("1");
                        heatMapDTO.setMac(i+"10"+j);
                        rsHeatMap.add(heatMapDTO);
                        lng=lng+0.0021;
                        if (j==8){
                            lng=120.424509;
                        }
                    }
                    lat =lat-0.001;
                }
            }else if (monitorId==119){
                double lat =33.384755;
                double lng =120.20625;
                for (int i = 0; i <14 ; i++) {
                    for (int j = 0; j < 12; j++) {
                        HeatMapDTO heatMapDTO = new HeatMapDTO();
                        heatMapDTO.setCount(0.0);
                        heatMapDTO.setLat(lat);
                        heatMapDTO.setLng(lng);
                        heatMapDTO.setName("1");
                        heatMapDTO.setMac(i+"10"+j);
                        rsHeatMap.add(heatMapDTO);
                        lng=lng+0.0021;
                        if (j==11){
                            lng=120.20625;
                        }
                    }
                    lat =lat-0.001;
                }
            }
        }
    /*   if (id==73){
           //亭湖区
           double lat =33.414538;
           double lng =120.066616;
@@ -724,7 +843,7 @@
               }
               lat1 =lat1-0.0022;
           }
       }
       }*/
        return distrinList(rsHeatMap);
    }
@@ -743,21 +862,23 @@
            ArrayList<Double> doubleArrayList = new ArrayList<>();
            ArrayList<GeoCoordinate> geoCoordinates = new ArrayList<>();
            List<HeatMapDTO> heatMapDTOS = collect.get(integer);
            for (HeatMapDTO heatMapDTO : heatMapDTOS) {
                GeoCoordinate geoCoordinate = new GeoCoordinate();
                doubleArrayList.add(heatMapDTO.getCount());
            if (heatMapDTOS.size()>1){
                for (HeatMapDTO heatMapDTO : heatMapDTOS) {
                    GeoCoordinate geoCoordinate = new GeoCoordinate();
                    doubleArrayList.add(heatMapDTO.getCount());
//                heatMapDTO.setCount(heatMapDTO.getCount());
                if (type.equals("a21026")){
                    heatMapDTO.setCount(1.0);
                }else {
                    heatMapDTO.setCount(0.0);
                }
                    if (type.equals("a21026")){
                        heatMapDTO.setCount(1.0);
                    }else {
                        heatMapDTO.setCount(0.0);
                    }
                geoCoordinate.setLongitude(heatMapDTO.getLng());
                geoCoordinate.setLatitude(heatMapDTO.getLat());
                geoCoordinates.add(geoCoordinate);
                    geoCoordinate.setLongitude(heatMapDTO.getLng());
                    geoCoordinate.setLatitude(heatMapDTO.getLat());
                    geoCoordinates.add(geoCoordinate);
                }
            }
            if (!ObjectUtils.isEmpty(doubleArrayList)){
            if (!ObjectUtils.isEmpty(doubleArrayList) &&doubleArrayList.size()>1){
                HeatMapDTO heatMapDTO = new HeatMapDTO();
                //计算均值集合
                double asDouble = doubleArrayList.stream().mapToDouble(Double::valueOf).max().getAsDouble();
screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java
@@ -1,7 +1,9 @@
package com.moral.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.moral.api.config.Interceptor.UserHelper;
import com.moral.api.entity.SecondCruiserSort;
import com.moral.api.entity.SysDictData;
import com.moral.api.exception.BusinessException;
import com.moral.api.mapper.*;
@@ -51,6 +53,9 @@
    @Autowired
    private DustldMapper dustldMapper;
    @Autowired
    private SecondCruiserSortMapper secondCruiserSortMapper;
    /**
     * 保存日报信息
@@ -459,6 +464,37 @@
        return dustlds;
    }
    /**
     * 路段排序
     * @param mac
     * @param startTime
     * @param endTime
     * @return
     */
    @Override
    public List<SecondCruiserSort> sort(String mac, String startTime, String endTime) {
        SysDictData list = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER.getValue(),"dustld");
        List<SecondCruiserSort> secondCruiserSorts = secondCruiserSortMapper.getSort(mac, startTime, endTime);
        //校准尘负荷
        if (!ObjectUtils.isEmpty(secondCruiserSorts)){
            for (SecondCruiserSort secondCruiserSort : secondCruiserSorts) {
                if(list.getDataValue().contains(",")){
                    List<String> resultStr = Arrays.asList(list.getDataValue().split(","));
                    if(resultStr.size() % 2 ==0){
//                        secondCruiserSort.setAvg(numAvg(resultStr,BigDecimal.valueOf(secondCruiserSort.getAvg())).doubleValue());
                        secondCruiserSort.setAvg((double) Math.round(numAvg(resultStr, BigDecimal.valueOf(secondCruiserSort.getAvg())).doubleValue()));
                    }
                }else {
                    BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Double.parseDouble(list.getDataValue())):BigDecimal.ZERO;
//                    secondCruiserSort.setAvg(BigDecimal.valueOf(secondCruiserSort.getAvg()).add(dataValue).doubleValue());
                    secondCruiserSort.setAvg((double) Math.round(BigDecimal.valueOf(secondCruiserSort.getAvg()).add(dataValue).doubleValue()));
                }
            }
        }
        return secondCruiserSorts;
    }
    //获取图片地址
    private String getList(String path, List<MultipartFile> files1) {
screen-api/src/main/java/com/moral/api/service/impl/SecondCruiserSortServiceImpl.java
New file
@@ -0,0 +1,19 @@
package com.moral.api.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.entity.SecondCruiserSort;
import com.moral.api.mapper.SecondCruiserSortMapper;
import com.moral.api.service.SecondCruiserSortService;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SecondCruiserSortServiceImpl
 * @date 2024.06.28 09:14
 */
@Service
public class SecondCruiserSortServiceImpl extends ServiceImpl<SecondCruiserSortMapper, SecondCruiserSort> implements SecondCruiserSortService {
}
screen-api/src/main/resources/mapper/DeviceMapper.xml
@@ -251,6 +251,9 @@
        FROM
        device as d
        inner JOIN organization o on o.id = d.organization_id and o.is_delete = 0
        <if test="monitorId !=null and monitorId !=''">
            and monitor_point_id =#{monitorId}
        </if>
        <if test="organizationIds != null and organizationIds.size !=0">
            and organization_id in
            <foreach collection="organizationIds" item="id" index="index" open="(" close=")" separator=",">
screen-api/src/main/resources/mapper/SecondCruiserSortMapper.xml
New file
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.api.mapper.SecondCruiserSortMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.SecondCruiserSort">
        <result column="road" property="road"/>
        <result column="time" property="time"/>
        <result column="value" property="value"/>
        <result column="mac" property="mac"/>
        <result column="organization_id" property="organizationId"/>
    </resultMap>
    <select id="getSort" resultType="com.moral.api.entity.SecondCruiserSort">
        select road,avg(value) as "avg",time,mac from second_cruiser_sort
        where mac =#{mac} and time BETWEEN #{startTime} and #{endTime} GROUP BY road ORDER BY avg DESC
    </select>
</mapper>
screen-job/src/main/java/com/moral/api/controller/PubController.java
@@ -54,6 +54,12 @@
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private ManageCoordinateDetailService manageCoordinateDetailService;
    @Autowired
    private HistorySecondCruiserService historySecondCruiserService;
    private final EmailSpringUtil emailSpringUtil;
    private final CityWeatherForecastService cityWeatherForecastService;
@@ -160,6 +166,24 @@
        return new ResultMessage();
    }
    @GetMapping("secondCruiserSort")
    @ApiOperation(value = "走航车排名", notes = "走航车排名")
    public ResultMessage secondCruiserSort() {
        String startTime ="2024-06-06 00:07:01";
        String endTime ="2024-06-06 23:07:01";
        historySecondCruiserService.sort(startTime,endTime);
        return new ResultMessage();
    }
    @GetMapping("insertCoordinateDetail")
    @ApiOperation(value = "路段录入", notes = "路段录入")
    public ResultMessage insertCoordinateDetail() {
        String startTime ="2024-06-06 00:07:01";
        String endTime ="2024-06-06 23:07:01";
        manageCoordinateDetailService.insertCoordinateDetail(startTime,endTime);
        return new ResultMessage();
    }
    public static void main(String[] args) {
        String host = "https://pair.market.alicloudapi.com";
screen-job/src/main/java/com/moral/api/entity/CruiserDTO.java
New file
@@ -0,0 +1,62 @@
package com.moral.api.entity;
import lombok.Data;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName CruiserDTO
 * @date 2024.06.19 09:15
 */
@Data
public class CruiserDTO {
    /**
     * 数据时间
     */
    private String time;
    /**
     * 纬度
     */
    @JsonProperty(value = "flylat")
    private Double flyLat;
    /**
     * 经度
     */
    @JsonProperty(value = "flylon")
    private Double flyLon;
    private String data;
    private String state;
    public CruiserDTO() {
        this.state = "1"; // 设置state字段默认值为1
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CruiserDTO cruiser = (CruiserDTO) o;
        //当type、color 内容都相等的时候,才返回true
        return Objects.equals(flyLat, cruiser.flyLat) &&
                Objects.equals(flyLon, cruiser.flyLon);
    }
    @Override
    public int hashCode() {
        return Objects.hash(flyLat, flyLon);
    }
}
screen-job/src/main/java/com/moral/api/entity/DustldDTO.java
New file
@@ -0,0 +1,24 @@
package com.moral.api.entity;
import lombok.Data;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName DustldDTO
 * @date 2024.06.25 14:25
 */
@Data
public class DustldDTO {
    private String name;
    //纬度
    private String flyLat;
    //经度
    private String flyLon;
    //尘负荷
    private Double  data;
}
screen-job/src/main/java/com/moral/api/entity/HistorySecondCruiser.java
New file
@@ -0,0 +1,55 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName HistorySecondCruiser
 * @date 2024.06.25 14:33
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class HistorySecondCruiser extends Model<HistorySecondCruiser> {
    private static final long serialVersionUID = 1L;
    /**
     * 设备mac
     */
    private String mac;
    /**
     * 数据时间
     */
    private Date time;
    /**
     * 数据
     */
    private String value;
    /**
     * 此数据所属组织id
     */
    private Integer organizationId;
    /**
     * 数据批次
     */
    private Date batch;
    @Override
    protected Serializable pkVal() {
        return null;
    }
}
screen-job/src/main/java/com/moral/api/entity/ManageCoordinate.java
New file
@@ -0,0 +1,76 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName ManageCoordinate
 * @date 2024.06.19 09:13
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ManageCoordinate extends Model<ManageCoordinate> {
    private static final long serialVersionUID = 1L;
    /**
     * 路段id
     */
    @TableId(value = "coordinate_id", type = IdType.AUTO)
    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;
    /**
     * 经纬度点位
     */
    private  String value;
    /**
     * 百度经纬度点位
     */
    private  String bdValue;
}
screen-job/src/main/java/com/moral/api/entity/ManageCoordinateDetail.java
New file
@@ -0,0 +1,70 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
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;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName ManageCoordinateDetail
 * @date 2024.06.19 09:21
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ManageCoordinateDetail  extends Model<ManageCoordinateDetail> {
    private static final long serialVersionUID = 1L;
    /**
     * 经纬度id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private  Integer id;
    /**
     * 路段id
     */
    private  Integer coordinateId;
    /**
     * 经度
     */
    private  Double longitude;
    /**
     *纬度
     */
    private  Double latitude;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 修改时间
     */
    private Date  updateTime;
    /**
     * 修改人id
     *
     */
    private  Integer updateUserId;
    /**
     * 修改人名称
     */
    private  String updayeUserName;
    private String state;
    @TableField(exist = false)
    private  String code;
}
screen-job/src/main/java/com/moral/api/entity/SecondCruiserSort.java
New file
@@ -0,0 +1,48 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.moral.util.DateUtils;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SecondCruiserSort
 * @date 2024.06.25 15:29
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SecondCruiserSort extends Model<SecondCruiserSort> {
    /**
     * 路段名称
     */
    private  String  road;
    /**
     * 数据
     */
    private  Double  value;
    /**
     * mac号
     */
    private String  mac;
    /**
     * 组织Id
     */
    private Integer  organizationId;
    /**
     * 时间
     */
    private String  time;
/*    public SecondCruiserSort() {
        this.time =DateUtils.getDateStringOfDay(-1,"yyyy-MM-dd HH:00:00"); // 构造函数中设置默认值
    }*/
}
screen-job/src/main/java/com/moral/api/entity/SysDictData.java
New file
@@ -0,0 +1,65 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
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;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SysDictData
 * @date 2024.06.25 14:01
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SysDictData  extends Model<SysDictData> {
    private static final long serialVersionUID = 1L;
    /**
     * 序号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 数据类型Id
     */
    private Integer dictTypeId;
    /**
     * 数据编码
     */
    @TableField("dataKey")
    private String dataKey;
    /**
     * 数据值
     */
    @TableField("dataValue")
    private String dataValue;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 是否删除
     */
    private String isDelete;
}
screen-job/src/main/java/com/moral/api/entity/SysDictType.java
New file
@@ -0,0 +1,63 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SysDictType
 * @date 2024.06.25 14:05
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SysDictType  extends Model<SysDictType> {
    private static final long serialVersionUID = 1L;
    /**
     * 序号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 类型
     */
    private String name;
    /**
     * 描述
     */
    private String desc;
    /**
     * 系统内置 无法更改
     */
    private Integer system;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 是否删除
     */
    private String isDelete;
}
screen-job/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java
New file
@@ -0,0 +1,14 @@
package com.moral.api.mapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.HistorySecondCruiser;
public interface HistorySecondCruiserMapper extends BaseMapper<HistorySecondCruiser> {
    List<Map<String,Object>> getDusts(Map<String,Object> params);
    List<HistorySecondCruiser> getResult(String startTime,String endTime);
}
screen-job/src/main/java/com/moral/api/mapper/ManageCoordinateDetailMapper.java
New file
@@ -0,0 +1,19 @@
package com.moral.api.mapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.CruiserDTO;
import com.moral.api.entity.DustldDTO;
import com.moral.api.entity.ManageCoordinate;
import com.moral.api.entity.ManageCoordinateDetail;
public interface ManageCoordinateDetailMapper extends BaseMapper<ManageCoordinateDetail> {
    List<ManageCoordinate> selectCoordinate();
    List<CruiserDTO> getCruiserInfo(Map<String,Object> params);
    List<DustldDTO> CompareTo(Integer orgId);
}
screen-job/src/main/java/com/moral/api/mapper/OrganizationMapper.java
@@ -1,5 +1,9 @@
package com.moral.api.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import com.moral.api.entity.Organization;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -13,4 +17,6 @@
 */
public interface OrganizationMapper extends BaseMapper<Organization> {
    List<Integer> orgIdSpecialDevList(@Param("organizationId") Integer organizationId, @Param("mac") String mac);
}
screen-job/src/main/java/com/moral/api/mapper/SecondCruiserSortMapper.java
New file
@@ -0,0 +1,11 @@
package com.moral.api.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.SecondCruiserSort;
public interface SecondCruiserSortMapper extends BaseMapper<SecondCruiserSort> {
    void insertAll(List<SecondCruiserSort> list);
}
screen-job/src/main/java/com/moral/api/mapper/SysDictTypeMapper.java
New file
@@ -0,0 +1,14 @@
package com.moral.api.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.SysDictData;
import com.moral.api.entity.SysDictType;
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
    List<SysDictData> selectCodeList(@Param("code") String code, @Param("id") String id);
}
screen-job/src/main/java/com/moral/api/service/HistorySecondCruiserService.java
New file
@@ -0,0 +1,18 @@
package com.moral.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.HistorySecondCruiser;
/**
 * <p>
 * 走航车秒数据表 服务类
 * </p>
 *
 * @author moral
 * @since 2021-09-13
 */
public interface HistorySecondCruiserService extends IService<HistorySecondCruiser> {
    void sort(String startTime,String endTime);
}
screen-job/src/main/java/com/moral/api/service/ManageCoordinateDetailService.java
New file
@@ -0,0 +1,14 @@
package com.moral.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.ManageCoordinateDetail;
public interface ManageCoordinateDetailService extends IService<ManageCoordinateDetail> {
    /**
     * 路段信息录入
     */
    void insertCoordinateDetail(String startTime,String endTime);
}
screen-job/src/main/java/com/moral/api/service/SecondCruiserSortService.java
New file
@@ -0,0 +1,7 @@
package com.moral.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.SecondCruiserSort;
public interface SecondCruiserSortService extends IService<SecondCruiserSort> {
}
screen-job/src/main/java/com/moral/api/service/SysDictTypeService.java
New file
@@ -0,0 +1,10 @@
package com.moral.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.SysDictData;
import com.moral.api.entity.SysDictType;
public interface SysDictTypeService extends IService<SysDictType> {
    SysDictData listOne(String code, String dataKey);
}
screen-job/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java
New file
@@ -0,0 +1,131 @@
package com.moral.api.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.entity.DustldDTO;
import com.moral.api.entity.HistorySecondCruiser;
import com.moral.api.entity.SecondCruiserSort;
import com.moral.api.mapper.HistorySecondCruiserMapper;
import com.moral.api.mapper.ManageCoordinateDetailMapper;
import com.moral.api.mapper.OrganizationMapper;
import com.moral.api.mapper.SecondCruiserSortMapper;
import com.moral.api.service.HistorySecondCruiserService;
import com.moral.util.DateUtils;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName HistorySecondCruiserServiceImpl
 * @date 2024.06.25 14:41
 */
@Service
@Slf4j
public class HistorySecondCruiserServiceImpl extends ServiceImpl<HistorySecondCruiserMapper, HistorySecondCruiser> implements HistorySecondCruiserService {
    @Autowired
    private HistorySecondCruiserMapper historySecondCruiserMapper;
    @Autowired
    private OrganizationMapper organizationMapper;
    @Autowired
    private ManageCoordinateDetailMapper manageCoordinateDetailMapper;
    @Autowired
    private SecondCruiserSortMapper secondCruiserSortMapper;
    @Override
    @Transactional
    public void sort(String startTime, String endTime) {
        if (ObjectUtils.isEmpty(startTime)&&ObjectUtils.isEmpty(endTime)){
            //当前时间的前一个小时
            startTime = DateUtils.getDateStringOfHour(-2, "yyyy-MM-dd HH:00:00");
            //获取当前时间
            endTime = DateUtils.getCurDate("yyyy-MM-dd HH:00:00");
        }
        List<HistorySecondCruiser> result = historySecondCruiserMapper.getResult(startTime, endTime);
        //
        ArrayList<SecondCruiserSort> list1 = new ArrayList<>();
        if (!ObjectUtils.isEmpty(result)){
            for (HistorySecondCruiser historySecondCruiser : result) {
                String mac = historySecondCruiser.getMac();
                Integer organizationId = historySecondCruiser.getOrganizationId();
                List<Integer> orgList = organizationMapper.orgIdSpecialDevList(organizationId, mac);
                if(CollectionUtils.isEmpty(orgList)){
                    return;
                }
                HashMap<String, Object> params = new HashMap<>();
                params.put("mac",mac);
                params.put("startTime",startTime);
                params.put("endTime",endTime);
                List<Map<String, Object>> dusts = historySecondCruiserMapper.getDusts(params);
                Map<String, List<DustldDTO>> collect = manageCoordinateDetailMapper.CompareTo(orgList.get(0)).stream().collect(Collectors.groupingBy(o -> o.getName()));
                if (ObjectUtils.isEmpty(dusts) || ObjectUtils.isEmpty(collect)){
                    return;
                }
                Set<String> strings = collect.keySet();
                for (String string : strings) {
                    SecondCruiserSort secondCruiserSort = new SecondCruiserSort();
                    ArrayList<Double> doubleArrayList = new ArrayList<>();
                    List<DustldDTO> dustldDTOS = collect.get(string);
                    for (DustldDTO dustldDTO : dustldDTOS) {
                        String flyLat = dustldDTO.getFlyLat();
                        String flyLon = dustldDTO.getFlyLon();
                        if (flyLon==null && flyLat==null){
                            continue;
                        }
                        double latDouble1 = Double.parseDouble(flyLat);
                        double lonDouble1 = Double.parseDouble(flyLon);
                        for (Map<String, Object> dust : dusts) {
                            String flyLat1 = Objects.nonNull(dust.get("flyLat")) ? dust.get("flyLat").toString() :"0";
                            String flyLon1 = Objects.nonNull(dust.get("flyLon")) ? dust.get("flyLon").toString() :"0";
                            double latDouble = Double.parseDouble(flyLat1);
                            double lonDouble = Double.parseDouble(flyLon1);
//                    String flyLon1 = dust.get("flyLon").toString();
                            if (latDouble1==latDouble && lonDouble1==lonDouble){
                                Double dustld = Objects.nonNull(dust.get("dustld"))?Double.parseDouble(dust.get("dustld").toString()):0d;
                                doubleArrayList.add(dustld);
                                break;
                            }
                        }
                    }
                    if (ObjectUtils.isEmpty(doubleArrayList)){
                        continue;
                    }
                    Double ListAva = doubleArrayList.stream() .collect(Collectors.averagingDouble(Double::doubleValue));
                    double rsAvg = new BigDecimal(ListAva).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
                    secondCruiserSort.setRoad(string);
                    secondCruiserSort.setValue(rsAvg);
                    secondCruiserSort.setMac(mac);
                    secondCruiserSort.setOrganizationId(organizationId);
                    secondCruiserSort.setTime(endTime);
                    list1.add(secondCruiserSort);
                }
            }
        }
        if (!ObjectUtils.isEmpty(list1)){
//            log.info(list1.size()+"");
            secondCruiserSortMapper.insertAll(list1);
        }
    }
}
screen-job/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
New file
@@ -0,0 +1,203 @@
package com.moral.api.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.entity.CruiserDTO;
import com.moral.api.entity.ManageCoordinate;
import com.moral.api.entity.ManageCoordinateDetail;
import com.moral.api.mapper.ManageCoordinateDetailMapper;
import com.moral.api.service.ManageCoordinateDetailService;
import com.moral.util.DateUtils;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName ManageCoordinateDetailServiceImpl
 * @date 2024.06.19 09:23
 */
@Service
@Slf4j
public class ManageCoordinateDetailServiceImpl  extends ServiceImpl<ManageCoordinateDetailMapper, ManageCoordinateDetail> implements ManageCoordinateDetailService {
    @Autowired
    private ManageCoordinateDetailMapper manageCoordinateDetailMapper;
    @Override
    @Transactional
    public void insertCoordinateDetail(String startTime,String endTime) {
        HashMap<String, Object> params = new HashMap<>();
        if (ObjectUtils.isEmpty(startTime)&&ObjectUtils.isEmpty(endTime)){
            //当前时间的前一天
             startTime = DateUtils.getDateStringOfDay(-1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
            //获取当前时间
             endTime = DateUtils.getCurDate(DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
        }
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        //获取路段信息
        List<ManageCoordinate> coordinates = manageCoordinateDetailMapper.selectCoordinate();
        //获取走航车数据
        List<CruiserDTO> cruiserInfo = manageCoordinateDetailMapper.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);
//            log.info(result.size()+"");
        }
    }
    /**
     * 判断当前位置是否在多边形区域内
     * @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;
        }
    }
}
screen-job/src/main/java/com/moral/api/service/impl/SecondCruiserSortServiceImpl.java
New file
@@ -0,0 +1,19 @@
package com.moral.api.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.entity.SecondCruiserSort;
import com.moral.api.mapper.SecondCruiserSortMapper;
import com.moral.api.service.SecondCruiserSortService;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SecondCruiserSortServiceImpl
 * @date 2024.06.26 14:29
 */
@Service
public class SecondCruiserSortServiceImpl extends ServiceImpl<SecondCruiserSortMapper, SecondCruiserSort> implements SecondCruiserSortService {
}
screen-job/src/main/java/com/moral/api/service/impl/SysDictTypeServiceImpl.java
New file
@@ -0,0 +1,36 @@
package com.moral.api.service.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.entity.SysDictData;
import com.moral.api.entity.SysDictType;
import com.moral.api.mapper.SysDictTypeMapper;
import com.moral.api.service.SysDictTypeService;
/**
 * Description //todo
 *
 * @author swb
 * @ClassName SysDictTypeServiceImpl
 * @date 2024.06.25 14:10
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
    @Override
    public SysDictData listOne(String code, String dataKey) {
        List<SysDictData> list = this.baseMapper.selectCodeList(code,dataKey);
        SysDictData sysDictData = new SysDictData();
        if (CollectionUtils.isNotEmpty(list)) {
            return list.get(0);
        }
        sysDictData.setDataValue("0");
        return sysDictData;
    }
}
screen-job/src/main/java/com/moral/api/task/HistoryTableInsertTask.java
@@ -7,7 +7,10 @@
import com.moral.api.service.HistoryFiveMinutelyService;
import com.moral.api.service.HistoryHourlyService;
import com.moral.api.service.HistoryMonthlyService;
import com.moral.api.service.HistorySecondCruiserService;
import com.moral.api.service.HistoryWeeklyService;
import com.moral.api.service.ManageCoordinateDetailService;
import com.moral.api.service.impl.HistorySecondCruiserServiceImpl;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
@@ -32,6 +35,14 @@
    @Autowired
    private HistoryMonthlyService historyMonthlyService;
    @Autowired
    private ManageCoordinateDetailService manageCoordinateDetailService;
    @Autowired
    private HistorySecondCruiserService historySecondCruiserService;
    //5分钟数据统计
    @XxlJob("insertHistoryFiveMinutely")
@@ -143,4 +154,37 @@
    }
    /**
     * 路段信息录入
     * @return
     */
    @XxlJob("manageCoordinateDetail")
    public ReturnT manageCoordinateDetail(){
        try {
            manageCoordinateDetailService.insertCoordinateDetail(null,null);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
    /**
     * 走航车路段排名
     * @return
     */
    @XxlJob("secondCruiserSort")
    public ReturnT secondCruiserSort(){
        try {
            historySecondCruiserService.sort(null,null);
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
}
screen-job/src/main/resources/mapper/HistorySecondCruiserMapper.xml
New file
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.api.mapper.HistorySecondCruiserMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.HistorySecondCruiser">
        <result column="mac" property="mac"/>
        <result column="time" property="time"/>
        <result column="value" property="value"/>
        <result column="organization_id" property="organizationId"/>
        <result column="batch" property="batch"/>
    </resultMap>
    <select id="getDusts" resultType="java.util.Map">
        SELECT
            value ->>'$.flylat' as flyLat,value ->>'$.flylon' as flyLon,value ->>'$.dustld' as dustld,
            `time`
        FROM `history_second_cruiser`
        WHERE mac = #{mac}
          AND `time` <![CDATA[>=]]> #{startTime}
          AND `time` <![CDATA[<]]> #{endTime}
    </select>
    <select id="getResult" resultType="com.moral.api.entity.HistorySecondCruiser">
        SELECT
            distinct mac,organization_id
        FROM `history_second_cruiser`
        WHERE
           `time` <![CDATA[>=]]> #{startTime}
          AND `time` <![CDATA[<=]]> #{endTime}
    </select>
</mapper>
screen-job/src/main/resources/mapper/ManageCoordinateDetailMapper.xml
New file
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.api.mapper.ManageCoordinateDetailMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.ManageCoordinateDetail">
        <id column="id" property="id" />
        <result column="coordinate_id" property="coordinateId" />
        <result column="longitude" property="longitude" />
        <result column="latitude" property="latitude" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="update_user_id" property="updateUserId" />
        <result column="updaye_user_name" property="updayeUserName" />
    </resultMap>
    <select id="selectCoordinate" resultType="com.moral.api.entity.ManageCoordinate">
        SELECT * FROM manage_coordinate WHERE  is_del =0
    </select>
    <select id="getCruiserInfo" resultType="com.moral.api.entity.CruiserDTO">
        select  DATE_FORMAT(`time`, #{dateFormat}) AS time,value ->>'$.flylat' as flyLat,value ->>'$.flylon' as flyLon
        from history_second_cruiser
        WHERE
        `time` <![CDATA[>=]]> #{startTime}
        AND `time` <![CDATA[<=]]> #{endTime}
        order by time
    </select>
    <select id="CompareTo" resultType="com.moral.api.entity.DustldDTO">
        SELECT
            mc.start_point as name ,
            md.longitude as flyLon,
            md.latitude as  flyLat
        FROM
            manage_coordinate AS mc
                LEFT JOIN manage_coordinate_detail AS md ON mc.coordinate_id = md.coordinate_id
        WHERE
            mc.is_del =0
          and mc.organization_id=#{orgId}
    </select>
</mapper>
screen-job/src/main/resources/mapper/OrganizationMapper.xml
@@ -26,4 +26,23 @@
                    <result column="is_delete" property="isDelete" />
        </resultMap>
    <select id="orgIdSpecialDevList" resultType="java.lang.Integer">
        select organization_id from special_device where organization_id in (
            SELECT id FROM (
                               SELECT id, parent_id, name FROM organization  WHERE id = #{organizationId}
                               UNION ALL
                               SELECT i.id, i.parent_id, i.name
                               FROM organization  i
                                        INNER JOIN (
                                   SELECT * FROM (
                                                     SELECT id, parent_id, name FROM organization  WHERE id = #{organizationId}
                                                     UNION ALL
                                                     SELECT id, parent_id, name FROM organization WHERE parent_id = #{organizationId}
                                                 ) t1
                               ) t2 ON i.parent_id = t2.id
                               where i.is_delete = 0
                           ) t3 ) and mac = #{mac} and is_delete = 0
    </select>
</mapper>
screen-job/src/main/resources/mapper/SecondCruiserSortMapper.xml
New file
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.api.mapper.SecondCruiserSortMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.SecondCruiserSort">
        <result column="road" property="road"/>
        <result column="time" property="time"/>
        <result column="value" property="value"/>
        <result column="mac" property="mac"/>
        <result column="organization_id" property="organizationId"/>
    </resultMap>
    <insert id="insertAll">
        INSERT INTO second_cruiser_sort (road,time,value,mac,organization_id)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.road},#{item.time},#{item.value},#{item.mac},#{item.organizationId})
        </foreach>
    </insert>
</mapper>
screen-job/src/main/resources/mapper/SysDictTypeMapper.xml
New file
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.api.mapper.SysDictTypeMapper">
        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.moral.api.entity.SysDictType">
                    <id column="id" property="id" />
                    <result column="name" property="name" />
                    <result column="desc" property="desc" />
                    <result column="system" property="system" />
                    <result column="create_time" property="createTime" />
                    <result column="update_time" property="updateTime" />
                    <result column="is_delete" property="isDelete" />
        </resultMap>
    <select id="selectCodeList" resultType="com.moral.api.entity.SysDictData">
        select t1.id,t1.dict_type_id,t1.dataKey,t1.dataValue from sys_dict_type t
                             left join sys_dict_data t1 on t1.dict_type_id = t.id
        where t.is_delete = 0 and t.name = #{code} and t1.dataKey = #{id} and t1.is_delete = 0
        order by t1.create_time desc
    </select>
</mapper>