jinpengyong
2023-08-11 010f4ba252db180fc7fea4d7cb1b84a0bca7479f
Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into wb
10 files added
20 files modified
1723 ■■■■ changed files
screen-api/pom.xml 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/SysTestController.java 345 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/UAVController.java 434 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/entity/SysTest.java 52 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java 10 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java 4 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java 3 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/HistorySecondUavMapper.java 6 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/SysTestMapper.java 16 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVGetBD.java 24 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVResultDTO.java 43 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/uav/UAVQueryTimeSlotVOs.java 1 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/SysTestService.java 19 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/UAVService.java 13 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/ExcelServiceImpl.java 78 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/HistoryDailyServiceImpl.java 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java 1 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java 47 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java 50 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/UAVServiceImpl.java 509 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/application-cjl.yml 2 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/application-dev.yml 2 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/application-qa.yml 2 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/HistorySecondCruiserMapper.xml 10 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/HistorySecondUavMapper.xml 7 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/SysTestMapper.xml 19 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/word/空气质量日报.docx patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/controller/DeviceAdjustValueController.java 7 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/entity/Device.java 6 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/resources/mapper/DeviceMapper.xml 1 ●●●● patch | view | raw | blame | history
screen-api/pom.xml
@@ -47,7 +47,11 @@
            <artifactId>fastjson</artifactId>
            <version>1.2.66</version>
        </dependency>
        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-spring-boot-starter</artifactId>
            <version>4.0.0</version>
        </dependency>
    </dependencies>
    <build>
screen-api/src/main/java/com/moral/api/controller/SysTestController.java
New file
@@ -0,0 +1,345 @@
package com.moral.api.controller;
import cn.afterturn.easypoi.word.WordExportUtil;
import com.moral.api.entity.SysTest;
import com.moral.api.service.SysTestService;
import com.moral.util.DateUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @ClassName SysTestController
 * @Description TODO
 * @Author @lizijie
 * @Date 2023-08-01 13:45
 * @Version 1.0
 */
@Slf4j
@Api(tags = {"测试补偿数据导出"})
@RestController
@RequestMapping("/systest")
public class SysTestController {
    @Autowired
    private SysTestService sysTestService;
    @GetMapping("resultWord")
    public void adresultWordd(HttpServletResponse response,String time) {
        List<SysTest> listAll = sysTestService.listAll(time,"2022-06-22",null);
        if(CollectionUtils.isEmpty(listAll)){
            return;
        }
        Date endTime =listAll.get(0).getTime();
        String endTimeStr = DateUtils.dateToDateString(endTime,DateUtils.yyyyMMdd_EN);
        String  fileName = "空气质量日报.docx";
        Map<String,Object> map = resultMap(listAll);
        //实体转map
       // Map result = JSON.parseObject(JSON.toJSONString(entity), Map.class);
        //        Map<String, Object> result = EasyPoiUtil.entityToMap(entity);
        downloadWord(fileName, map, response,"空气质量日报"+endTimeStr+".docx");
    }
    public static void downloadWord(String fileName, Map<String, Object> params, HttpServletResponse response,String newFileName) {
        String path = getPath(fileName);//我这放 resources包下
        try {
            //获取模板文档
            File rootFile = new File(ResourceUtils.getURL("classpath:").getPath());
            File file= new File(rootFile, path);
            XWPFDocument word = WordExportUtil.exportWord07(file.getPath(), params);
            response.setCharacterEncoding("utf-8");
            response.setContentType("multipart/form-data");
            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(newFileName, "utf-8"));
            OutputStream out = response.getOutputStream();
            word.write(out);
            out.flush();
            out.close();
        } catch (Exception e) {
            log.error ("导出失败,请联系网站管理员!", e);
        }
    }
    public static String getPath(String filename) {
        filename = "/word/" + filename;
        return filename;
    }
    /**
     实体类转Map
     */
    public static Map<String, Object> entityToMap(Object object) {
        Map<String, Object> map = new HashMap<>();
        for (Field field : object.getClass().getDeclaredFields()) {
            try {
                boolean flag = field.isAccessible();
                field.setAccessible(true);
                Object o = field.get(object);
                map.put(field.getName(), o);
                field.setAccessible(flag);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return map;
    }
    private Map<String,Object> resultMap(List<SysTest> listAll){
        String first = "2020-06-22";
        String firstYear = "2020";
        Map<String,Object> resultMap = new HashMap<>();
        Date endTime =listAll.get(0).getTime();
        String endTimeStr = DateUtils.dateToDateString(endTime,DateUtils.yyyy_MM_dd_EN);
        List<String> endTimeList= Arrays.asList(endTimeStr.split("-"));
        if(Integer.parseInt(firstYear)<Integer.parseInt(endTimeList.get(0))){
            firstYear = endTimeList.get(0);
            first = endTimeList.get(0)+"-01-01";
        }
        String firstM = String.valueOf(Integer.parseInt(endTimeList.get(1)));
        String firstD = String.valueOf(Integer.parseInt(endTimeList.get(2)));
        Long day = DateUtils.getQuotByDays(first,endTimeStr)+1  ;
        resultMap.put("年",firstYear);
        resultMap.put("月",firstM);
        resultMap.put("日",firstD);
        resultMap.put("期",day.intValue());
        String name = "沙";
        for(SysTest s : listAll){
            if(s.getName().contains("友")){
                name = "友";
            }else if(s.getName().contains("中")){
                name = "中";
            }else {
                name = "沙";
            }
            resultMap.put(name+"AQI", StringUtils.isNotEmpty(s.getAqi())?s.getAqi():"--");
            resultMap.put(name+"PM10", StringUtils.isNotEmpty(s.getPm10())?s.getPm10():"--");
            resultMap.put(name+"PM2", StringUtils.isNotEmpty(s.getPm25())?s.getPm25():"--");
            resultMap.put(name+"SO2", StringUtils.isNotEmpty(s.getSo2())?s.getSo2():"--");
            resultMap.put(name+"NO2", StringUtils.isNotEmpty(s.getNo2())?s.getNo2():"--");
            resultMap.put(name+"CO", StringUtils.isNotEmpty(s.getCo())?s.getCo():"--");
            resultMap.put(name+"O3", StringUtils.isNotEmpty(s.getO3())?s.getO3():"--");
            resultMap.put(name+"TV", StringUtils.isNotEmpty(s.getVoc())?s.getVoc():"--");
            resultMap.put(name+"S", StringUtils.isNotEmpty(s.getSu())?s.getSu():"--");
        }
        String bodyName = stringButterStr(listAll);
        resultMap.put("主要内容",bodyName);
        return resultMap;
    }
    private String stringButterStr(List<SysTest> listAll){
        // 0 一样1 两高 2两低,3高,低
        int type = 0;
        // TODO: 2023-08-01 第一次循环比较最高值或者最低值
        int aqiHigh = Integer.parseInt(listAll.get(0).getAqi());
        int aqiMiddle = Integer.parseInt(listAll.get(1).getAqi());
        int aqiLow = Integer.parseInt(listAll.get(2).getAqi());
        List<Integer> numList = Arrays.asList(aqiHigh,aqiMiddle,aqiLow);
        StringBuffer stringBuffer = new StringBuffer();
        Set<Integer> stringSet = new HashSet<>(numList);
        List<Integer> listTest = stringSet.stream().collect(Collectors.toList());
        Collections.sort(listTest);
        int aqiHighResult = listTest.get(listTest.size()-1);
        int aqiLowResult = listTest.get(0);
        if(stringSet.size() == 1){
            type = 0;
            stringBuffer.append("整体空气质量(AQI)基本相同,无太大区别。");
            return stringBuffer.toString();
        }else if(stringSet.size() == 3){
            type = 3;
        }else {
            int count = Collections.frequency(numList, listTest.get(0));
            if(count == 1){
                type = 2;
            }else {
                type = 1;
            }
        }
        int sizeHighResult = 0;
        int sizeLowResult = 0;
        String highName = "沙岗村";
        String lowName = "沙岗村";
        //1 两高 2两低
        if(type == 1){
            SysTest ResultAqi = listAll.stream().min(Comparator.comparing(SysTest::getAqi)).get();
            if(ResultAqi.getName().contains("沙岗村")){
                lowName = "沙岗村";
                highName = "友爱村、中间村";
            }else if(ResultAqi.getName().contains("友爱村")){
                lowName = "友爱村";
                highName = "沙岗村、中间村";
            } else if(ResultAqi.getName().contains("中间村")){
                lowName = "中间村";
                highName = "沙岗村、友爱村";
            }
        }else if(type == 2){
            SysTest ResultAqi = listAll.stream().max(Comparator.comparing(SysTest::getAqi)).get();
            if(ResultAqi.getName().contains("沙岗村")){
                highName = "沙岗村";
                lowName = "友爱村、中间村";
            }else if(ResultAqi.getName().contains("友爱村")){
                highName = "沙岗村";
                lowName = "友爱村、中间村";
            } else if(ResultAqi.getName().contains("中间村")){
                highName = "沙岗村";
                lowName = "友爱村、中间村";
            }
        }else if(type == 3){
            if(aqiHigh == aqiHighResult){
                sizeHighResult = 0;
            }
            if(aqiMiddle == aqiHighResult){
                sizeHighResult = 1;
            }
            if(aqiLow == aqiHighResult){
                sizeHighResult = 2;
            }
            if(aqiHigh == aqiLowResult){
                sizeLowResult = 0;
            }
            if(aqiMiddle == aqiLowResult){
                sizeLowResult = 1;
            }
            if(aqiLow == aqiLowResult){
                sizeLowResult = 2;
            }
            SysTest HighResult = listAll.get(sizeHighResult);
            SysTest LowResult = listAll.get(sizeLowResult);
            if(HighResult.getName().contains("友爱村")){
                highName = "友爱村";
            }else if(HighResult.getName().contains("中尖村")){
                highName = "中尖村";
            }
            if(LowResult.getName().contains("友爱村")){
                lowName = "友爱村";
            }else if(LowResult.getName().contains("中尖村")){
                lowName = "中尖村";
            }
        }
        SysTest result0 = listAll.get(0);
        SysTest result1 = listAll.get(1);
        SysTest result2 = listAll.get(2);
        Map<String,String> pm10 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getPm10(),result1.getPm10(),result2.getPm10());
        Map<String,String> pm25 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getPm25(),result1.getPm25(),result2.getPm25());
        Map<String,String> so = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getSo2(),result1.getSo2(),result2.getSo2());
        Map<String,String> no = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getNo2(),result1.getNo2(),result2.getNo2());
        Map<String,String> co = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getCo(),result1.getCo(),result2.getCo());
        Map<String,String> o3 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getO3(),result1.getO3(),result2.getO3());
        stringBuffer.append(highName+"整体空气质量(AQI)较高,"+lowName+"整体空气质量(AQI)较低。");
        if(pm10.isEmpty()&& pm25.isEmpty()&&so.isEmpty()&& no.isEmpty()&& co.isEmpty()&& o3.isEmpty()){
            return stringBuffer.toString();
        }
        stringBuffer.append("其中:");
        if(!pm10.isEmpty()){
            stringBuffer.append("PM10较高的是:"+pm10.get("high")+";较低的是:"+pm10.get("low")+"。");
        }
        if(!pm25.isEmpty()){
            stringBuffer.append("PM2.5较高的是:"+pm25.get("high")+";较低的是:"+pm25.get("low")+"。");
        }
        if(!so.isEmpty()){
            stringBuffer.append("SO2较高的是:"+so.get("high")+";较低的是:"+so.get("low")+"。");
        }
        if(!no.isEmpty()){
            stringBuffer.append("NO2较高的是:"+no.get("high")+";较低的是:"+no.get("low")+"。");
        }
        if(!co.isEmpty()){
            stringBuffer.append("CO较高的是:"+co.get("high")+";较低的是:"+co.get("low")+"。");
        }
        if(!o3.isEmpty()){
            stringBuffer.append("O3较高的是:"+o3.get("high")+";较低的是:"+o3.get("low")+"。");
        }
        return stringBuffer.toString();
    }
    private Map<String,String> nameCode(String name1,String name2,String name3,String nums1,String nums2,String nums3){
        double num1 = StringUtils.isNotEmpty(nums1)?Double.parseDouble(nums1):0;
        double num2 = StringUtils.isNotEmpty(nums2)?Double.parseDouble(nums2):0;
        double num3 = StringUtils.isNotEmpty(nums3)?Double.parseDouble(nums3):0;
        Map<String,String> map = new HashMap<>();
        if(num1 ==num2 && num2 ==num3){
            return map;
        }
        name1 = name1.substring(3,name1.length());
        name2 = name2.substring(3,name2.length());
        name3 = name3.substring(3,name3.length());
        if(num1 ==num2 && num2 < num3){
            map.put("high",name3);
            map.put("low",name1+"、"+name2);
            return map;
        }else if(num1 ==num2 && num2 > num3){
            map.put("low",name3);
            map.put("high",name1+"、"+name2);
            return map;
        }
        if(num1 == num3 && num2 < num3){
            map.put("low",name2);
            map.put("high",name1+"、"+name3);
            return map;
        }else if(num1 == num3 && num2 > num3){
            map.put("high",name2);
            map.put("low",name1+"、"+name3);
            return map;
        }
        if(num2 == num3 && num1 < num2){
            map.put("low",name1);
            map.put("high",name2+"、"+name3);
            return map;
        }else if(num2 == num3 && num1 > num2){
            map.put("high",name1);
            map.put("low",name2+"、"+name3);
            return map;
        }
        List<Double> numList = Arrays.asList(num1,num2,num3);
        int high = numList.indexOf(Collections.max(numList));
        int low = numList.indexOf(Collections.min(numList));
        if(high == 0){
            map.put("high",name1);
        }else if(high == 1){
            map.put("high",name2);
        }else if(high == 2){
            map.put("high",name3);
        }
        if(low == 0){
            map.put("low",name1);
        }else if(low == 1){
            map.put("low",name2);
        }else if(low == 2){
            map.put("low",name3);
        }
        return map;
    }
}
screen-api/src/main/java/com/moral/api/controller/UAVController.java
@@ -3,9 +3,12 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.moral.api.entity.HistorySecondUav;
import com.moral.api.mapper.HistorySecondUavMapper;
import com.moral.api.pojo.dto.uav.UAVGetBD;
import com.moral.api.pojo.dto.uav.UAVGteForDTO;
import com.moral.api.pojo.dto.uav.UAVQueryTimeSlotDTO;
import com.moral.api.pojo.dto.uav.UAVResultDTO;
@@ -15,13 +18,17 @@
import com.moral.api.pojo.vo.uav.UAVQueryTimeSlotVO;
import com.moral.api.pojo.vo.uav.UAVQueryTimeSlotVOs;
import com.moral.api.service.HistorySecondUavService;
import com.moral.api.service.UAVService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.DateUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -29,6 +36,7 @@
import java.awt.geom.Point2D;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @ClassName UAVController
@@ -48,6 +56,8 @@
    HistorySecondUavService historySecondUavService;
    @Autowired
    HistorySecondUavMapper historySecondUavMapper;
    @Autowired
    UAVService uavService;
    /**
    * @Description: 根据批次号查询无人机飞行数据
@@ -68,184 +78,17 @@
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
    }
    @RequestMapping("test")
    public ResultMessage test(){
        //纬度
        ArrayList<Double> flyLatList = new ArrayList<>();
        //经度
        ArrayList<Double> flyLonList = new ArrayList<>();
        HashMap<String, Object> map = new HashMap<>();
        String mac ="p5dnd7a0243592";
        String time1 ="2023-05-14 10:40:00";
        String time2 ="2023-05-14 11:10:00";
        map.put("mac",mac);
        map.put("time1",time1);
        map.put("time2",time2);
//        List<UAVResultDTO> uavResultDTOS = historySecondUavMapper.reList(map);
        QueryWrapper<HistorySecondUav> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("value");
        queryWrapper.eq("mac",mac);
        queryWrapper.between("time",time1,time2);
        List<HistorySecondUav> historySecondUavs = historySecondUavMapper.selectList(queryWrapper);
        for (HistorySecondUav historySecondUav : historySecondUavs) {
            String value = historySecondUav.getValue();
            Map map1 = JSON.parseObject(value, Map.class);
            flyLatList.add(Double.parseDouble(map1.get("flylat").toString()));
            flyLonList.add(Double.parseDouble(map1.get("flylon").toString()));
    @PostMapping("getUav")
    public ResultMessage test(@RequestBody Map<String, Object> params){
        //判断是否缺少参数
        if (!params.containsKey("mac") || !params.containsKey("batch") || !params.containsKey("height1")|| !params.containsKey("uvasize")|| !params.containsKey("height2")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Double maxLat = Collections.max(flyLatList);
        Double maxLon = Collections.max(flyLonList);
        Double minLat = Collections.min(flyLatList);
        Double minLon = Collections.min(flyLonList);
        //大四边形右下
        String leftTop =  minLat +";"+ maxLon;
        //右上
        String rightTop =  maxLat +";"+ maxLon;
        //左下
        String leftBottom = minLat +";" + minLon;
        //左上
        String rightBottom = maxLat +";" + minLon;
        //计算纬度的距离
        double distance1 = getDistance(maxLon, minLat, maxLon, maxLat);
        //计算经度的距离
        double distance2 = getDistance(maxLon, minLat, minLon, minLat);
        ArrayList<UAVGteForDTO> list = new ArrayList<>();
        //小四边形
        String [] lefts =new String[]{maxLon.toString(),minLat.toString()};
        //右上2
        String[] youshang = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, 50);
        //右下2
        String[] youxia = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(youshang[0]), Double.parseDouble(youshang[1]), 50);
        //左下2
        String[] zuoxia = calLocationByDistanceAndLocationAndDirection(180, minLon, maxLat, 50);
        for (int i = 0; i <distance1 ; i+=60) {
            UAVGteForDTO dto1 = new UAVGteForDTO();
            String[] strings2 = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, i);
            String[] strings3 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youshang[0].toString()), Double.parseDouble(youshang[1].toString()), i);
            String[] strings4 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youxia[0].toString()), Double.parseDouble(youxia[1].toString()), i);
            String[] strings5 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(zuoxia[0].toString()), Double.parseDouble(zuoxia[1].toString()), i);
            dto1.setLeftTop(strings2);
            dto1.setRightTop(strings3);
            dto1.setRightBottom(strings4);
            dto1.setLeftBottom(strings5);
            list.add(dto1);
            for (int j = 0; j < distance2; j+=60) {
                UAVGteForDTO dto2 = new UAVGteForDTO();
                String[] strings6 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings2[0].toString()), Double.parseDouble(strings2[1].toString()), j);
                String[] strings7 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings3[0].toString()), Double.parseDouble(strings3[1].toString()), j);
                String[] strings8 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings4[0].toString()), Double.parseDouble(strings4[1].toString()), j);
                String[] strings9 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings5[0].toString()), Double.parseDouble(strings5[1].toString()), j);
                dto2.setLeftTop(strings6);
                dto2.setRightTop(strings7);
                dto2.setRightBottom(strings8);
                dto2.setLeftBottom(strings9);
                if (j!=0){
                list.add(dto2);
        List<UAVResultDTO> uavResultDTOS = uavService.getUav(params);
        if (ObjectUtils.isEmpty(uavResultDTOS)){
            return new ResultMessage(ResponseCodeEnum.SENSOR_IS_NOT_EXIST,"null");
                }
            }
        }
        ArrayList<UAVResultDTO> uavResultDTOS1 = new ArrayList<>();
        for (UAVGteForDTO uavGteForDTO : list) {
            ArrayList<String[]> doubleArrayList = new ArrayList<>();
            doubleArrayList.add(uavGteForDTO.getLeftTop());
            doubleArrayList.add(uavGteForDTO.getLeftBottom());
            doubleArrayList.add(uavGteForDTO.getRightTop());
            doubleArrayList.add(uavGteForDTO.getRightBottom());
            UAVResultDTO result = getResult(doubleArrayList);
            uavResultDTOS1.add(result);
        }
        if (uavResultDTOS1!=null){
            return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS1);
        }
//        ArrayList<List<String>> lists = new ArrayList<>();
        HashMap<String,List<String>> rsMap = new HashMap<>();
//        HashMap<String,List<Map<String,Object>>> rsMap1 = new HashMap<>();
        for (UAVGteForDTO uavGteForDTO : list) {
            ArrayList<String> list1 = new ArrayList<>();
            ArrayList<String[]> doubleArrayList = new ArrayList<>();
            doubleArrayList.add(uavGteForDTO.getLeftTop());
            doubleArrayList.add(uavGteForDTO.getLeftBottom());
            doubleArrayList.add(uavGteForDTO.getRightTop());
            doubleArrayList.add(uavGteForDTO.getRightBottom());
            //获取区域对象
            for (HistorySecondUav historySecondUav : historySecondUavs) {
                String value = historySecondUav.getValue();
                Map map1 = JSON.parseObject(value, Map.class);
                String flylat = map1.get("flylat").toString();
                String flylon = map1.get("flylon").toString();
                //判断点是否在区域内
                boolean flag = isInPolygon(flylon,flylat,doubleArrayList);
                if (flag){
                list1.add(historySecondUav.getValue());
                }
            }
//            lists.add(list1);
//            String result = getResult(doubleArrayList);
//            rsMap.put(result,list1);
        }
        ArrayList<UAVResultDTO> uavResultDTOS = new ArrayList<>();
        Set<String> strings = rsMap.keySet();
        for (String string : strings) {
            UAVResultDTO dto = new UAVResultDTO();
            List<String> list1 = rsMap.get(string);
            ArrayList<Double> TVOCArrayList = new ArrayList<>();
            ArrayList<Double> PM10ArrayList = new ArrayList<>();
            ArrayList<Double> PM25ArrayList = new ArrayList<>();
            ArrayList<Double> SOArrayList = new ArrayList<>();
            ArrayList<Double> NOArrayList = new ArrayList<>();
            ArrayList<Double> QYArrayList = new ArrayList<>();
            ArrayList<Double> COArrayList = new ArrayList<>();
            ArrayList<Double> WDArrayList = new ArrayList<>();
            ArrayList<Double> SHArrayList = new ArrayList<>();
            for (String s : list1) {
                JSONObject jsonObject = JSON.parseObject(s);
                //tvoc
                String a99054 = jsonObject.get("a99054").toString();
                //pm2.5
                String a34004 = jsonObject.get("a34004").toString();
                //二氧化硫
                String a21026 = jsonObject.get("a21026").toString();
                ///二氧化氮
                String a21004 = jsonObject.get("a21004").toString();
//                //气压
//                String a01006 = jsonObject.get("a01006").toString();
//                if (a01006!=null){
//                    QYArrayList.add(Double.parseDouble(a01006));
//                }
                //pm10
                String a34002 = jsonObject.get("a34002").toString();
                //co
                String a21005 = jsonObject.get("a21005").toString();
                //湿度
//                String a01002 = jsonObject.get("a01002").toString();
                //温度
//                String a01001 = jsonObject.get("a01001").toString();
                TVOCArrayList.add(Double.parseDouble(a99054));
                PM10ArrayList.add(Double.parseDouble(a34002));
                PM25ArrayList.add(Double.parseDouble(a34004));
                SOArrayList.add(Double.parseDouble(a21026));
                NOArrayList.add(Double.parseDouble(a21004));
                COArrayList.add(Double.parseDouble(a21005));
//                WDArrayList.add(Double.parseDouble(a01001));
//                SHArrayList.add(Double.parseDouble(a01002));
            }
            double asDouble = COArrayList.stream().mapToInt(Double::intValue).average().getAsDouble();
        }
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),null);
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS);
    }
@@ -282,246 +125,15 @@
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        //处理查询业务
        List<UAVQueryTimeSlotDTO> dtos = historySecondUavService.queryTimeSlot(form);
        if (ObjectUtils.isEmpty(dtos)){
            return new ResultMessage(ResponseCodeEnum.TARGET_IS_NULL,null);
        }
        //封装vo层
        UAVQueryTimeSlotVOs vo = UAVQueryTimeSlotVOs.convert(dtos);
        //返回数据
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
    }
    private static final double EARTH_RADIUS = 6378137;
    private static final double R = 6371e3;
    /** 180° **/
    private static final DecimalFormat df = new DecimalFormat("0.00000000");
    /**
     * 根据一点的坐标与距离,以及方向,计算另外一点的位置
     * @param angle 角度,从正北顺时针方向开始计算
     * @param startLong 起始点经度
     * @param startLat 起始点纬度
     * @param distance 距离,单位m
     * @return
     */
    public static String[] calLocationByDistanceAndLocationAndDirection(double angle, double startLong,double startLat, double distance){
        String[] result = new String[2];
        //将距离转换成经度的计算公式
        double δ = distance/R;
        // 转换为radian,否则结果会不正确
        angle = Math.toRadians(angle);
        startLong = Math.toRadians(startLong);
        startLat = Math.toRadians(startLat);
        double lat = Math.asin(Math.sin(startLat)*Math.cos(δ)+Math.cos(startLat)*Math.sin(δ)*Math.cos(angle));
        double lon = startLong + Math.atan2(Math.sin(angle)*Math.sin(δ)*Math.cos(startLat),Math.cos(δ)-Math.sin(startLat)*Math.sin(lat));
        // 转为正常的10进制经纬度
        lon = Math.toDegrees(lon);
        lat = Math.toDegrees(lat);
        result[0] = df.format(lon);
        result[1] = df.format(lat);
        return result;
    }
    /**
     * 根据经纬度,计算两点间的距离
     *
     * @param longitude1 第一个点的经度
     * @param latitude1  第一个点的纬度
     * @param longitude2 第二个点的经度
     * @param latitude2  第二个点的纬度
     * @return 返回距离 单位米
     */
    public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
        // 纬度
        double lat1 = Math.toRadians(latitude1);
        double lat2 = Math.toRadians(latitude2);
        // 经度
        double lng1 = Math.toRadians(longitude1);
        double lng2 = Math.toRadians(longitude2);
        // 纬度之差
        double a = lat1 - lat2;
        // 经度之差
        double b = lng1 - lng2;
        // 计算两点距离的公式
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
                Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
        // 弧长乘地球半径, 返回单位: 米
        s =  s * EARTH_RADIUS;
        return s;
    }
    public static UAVResultDTO getResult(ArrayList<String[]> doubleArrayList){
        UAVResultDTO uavResultDTO = new UAVResultDTO();
            int total = doubleArrayList.size();
            double X = 0, Y = 0, Z = 0;
            for (int i = 0; i < total; i++) {
                double lat, lon, x, y, z;
                String[] strings = doubleArrayList.get(i);
                lon = Double.parseDouble(strings[0]) * Math.PI / 180;
                lat = Double.parseDouble(strings[1]) * Math.PI / 180;
                x = Math.cos(lat) * Math.cos(lon);
                y = Math.cos(lat) * Math.sin(lon);
                z = Math.sin(lat);
                X += x;
                Y += y;
                Z += z;
            }
            X = X / total;
            Y = Y / total;
            Z = Z / total;
            double Lon = Math.atan2(Y, X);
            double Hyp = Math.sqrt(X * X + Y * Y);
            double Lat = Math.atan2(Z, Hyp);
        double rsLon = Lon * 180 / Math.PI;
        double rsLat = Lat * 180 / Math.PI;
        uavResultDTO.setFlyLon(rsLon);
        uavResultDTO.setFlyLat(rsLat);
//        return rsLon+"_"+rsLat;
        return uavResultDTO;
    }
    /**
     * 将经纬度点集合转换为GeneralPath对象
     *
     * @param points 点集合(有序)
     *
     * @return GeneralPath对象
     */
    public static GeneralPath genGeneralPath(ArrayList<Point2D.Double> points) {
        GeneralPath path = new GeneralPath();
        if (points.size() < 3) {
            return null;
        }
        path.moveTo((float) points.get(0).getX(), (float) points.get(0).getY());
        for (Iterator<Point2D.Double> it = points.iterator(); it.hasNext();) {
            Point2D.Double point = (Point2D.Double) it.next();
            path.lineTo((float) point.getX(), (float) point.getY());
        }
        path.closePath();
        return path;
    }
    /**
     * 判断点是否在多边形内,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回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;
        }
    }
    /**
     * 判断当前位置是否在多边形区域内
     * @param
     * @param doubleArrayList 区域顶点
     * @return
     */
    public static boolean isInPolygon(String X,String Y,ArrayList<String[]> doubleArrayList){
        double p_x =Double.parseDouble(X);
        double p_y =Double.parseDouble(Y);
        Point2D.Double point = new Point2D.Double(p_x, p_y);
        List<Point2D.Double> pointList= new ArrayList<Point2D.Double>();
        for (String[] strings : doubleArrayList) {
            double polygonPoint_x=Double.parseDouble(strings[0]);
            double polygonPoint_y=Double.parseDouble(strings[1]);
            Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x,polygonPoint_y);
            pointList.add(polygonPoint);
        }
        return IsPtInPoly(point,pointList);
    }
    public final static double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
    /**
     * 高德坐标转百度坐标
     *
     * @param gd_lon 经度
     * @param gd_lat 纬度
     * @return
     */
    public static Map<String, String> gd2bd(String gd_lon, String gd_lat) {
        double longitude = Double.parseDouble(gd_lon);
        double latitude = Double.parseDouble(gd_lat);
        Map<String, String> data = new HashMap<>();
        double x = longitude, y = latitude;
        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
        double bd_lon = z * Math.cos(theta) + 0.0065;
        double bd_lat = z * Math.sin(theta) + 0.006;
        data.put("lon", String.valueOf(bd_lon));
        data.put("lat", String.valueOf(bd_lat));
        return data;
    }
}
screen-api/src/main/java/com/moral/api/entity/SysTest.java
New file
@@ -0,0 +1,52 @@
package com.moral.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * <p>
 *
 * </p>
 *
 * @author moral
 * @since 2023-08-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SysTest extends Model<SysTest> {
    private static final long serialVersionUID = 1L;
    private String mac;
    private Date time;
    private String pm25;
    private String pm10;
    private String so2;
    private String no2;
    private String co;
    private String o3;
    private String voc;
    private String name;
    @TableField(exist = false)
    private String aqi;
    @TableField(exist = false)
    private String su;
}
screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java
@@ -1,3 +1,4 @@
package com.moral.api.exception.consumer;
import com.moral.api.utils.AdjustDataUtils;
@@ -25,9 +26,11 @@
import com.moral.api.websocket.CruiserWebSocketServer;
import com.moral.constant.KafkaConstants;
/*
 * 走航车数据消费者
 * */
@Component
@Slf4j
public class CruiserDataConsumer implements ConsumerSeekAware {
@@ -64,8 +67,10 @@
                    continue;
                }
                Double sourceDataD = Double.valueOf(String.valueOf(data.get(code)));
                /*BigDecimal bg = new BigDecimal(sourceDataD);
                bg = bg.setScale(2, BigDecimal.ROUND_FLOOR);*/
                 BigDecimal bg = new BigDecimal(sourceDataD);
                bg = bg.setScale(2, BigDecimal.ROUND_FLOOR);
                String sourceData = String.valueOf(sourceDataD);
                //数据补偿
                //单位转换
@@ -112,3 +117,4 @@
    }
}
screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java
@@ -1,3 +1,4 @@
package com.moral.api.exception.consumer;
import com.alibaba.fastjson.JSON;
@@ -22,6 +23,7 @@
import java.util.Map;
import java.util.concurrent.CopyOnWriteArraySet;
/**
 * @ClassName SecondsDataConsumer1
 * @Description TODO
@@ -29,6 +31,7 @@
 * @Date 2021/6/15 14:49
 * @Version TODO
 **/
@Component
@Slf4j
public class SecondDataConsumer implements ConsumerSeekAware {
@@ -116,3 +119,4 @@
}
screen-api/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java
@@ -28,4 +28,7 @@
    List<Double> getDust(String start,String end,String mac);
    List<Map<String,Object>> getAllCruiserData(Map<String,Object> params);
}
screen-api/src/main/java/com/moral/api/mapper/HistorySecondUavMapper.java
@@ -1,7 +1,11 @@
package com.moral.api.mapper;
import java.util.List;
import java.util.Map;
import com.moral.api.entity.HistorySecondUav;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.pojo.dto.uav.UAVResultDTO;
/**
 * <p>
@@ -13,4 +17,6 @@
 */
public interface HistorySecondUavMapper extends BaseMapper<HistorySecondUav> {
    List<HistorySecondUav> reList(Map<String,Object> map);
}
screen-api/src/main/java/com/moral/api/mapper/SysTestMapper.java
New file
@@ -0,0 +1,16 @@
package com.moral.api.mapper;
import com.moral.api.entity.SysTest;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author moral
 * @since 2023-08-01
 */
public interface SysTestMapper extends BaseMapper<SysTest> {
}
screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVGetBD.java
New file
@@ -0,0 +1,24 @@
package com.moral.api.pojo.dto.uav;
import lombok.Data;
@Data
public class UAVGetBD {
    /**
     * 纬度
     */
    private Double flyLat;
    /**
     * 经度
     */
    private Double flyLon;
    private String time;
    private  String value;
}
screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVResultDTO.java
@@ -17,22 +17,47 @@
     */
    private Double flyLon;
    private Double coAvg;
//    private Double coAvg;
//
//    private Double SO2Avg;
//
//    private Double NO2Avg;
//
//    private Double PM10Avg;
//
//    private Double PM25Avg;
//
//    private Double TVOCAvg;
//
//    private Double O3Avg;
//
//    private Double WDAvg;
//
//    private Double SHAvg;
    private Double SO2Avg;
    private Double NO2Avg;
//    private Double QYAvg;
    private Double PM10Avg;
    private Double PM25Avg;
    private Double a21005;
    private Double TVOCAvg;
    private Double a21026;
    private Double O3Avg;
    private Double a21004;
    private Double WDAvg;
    private Double a34002;
    private Double SHAvg;
    private Double a34004;
    private Double a99054;
    private Double a05024;
    private Double a01001;
    private Double a01002;
    private Double a01006;
}
screen-api/src/main/java/com/moral/api/pojo/vo/uav/UAVQueryTimeSlotVOs.java
@@ -37,6 +37,7 @@
                newMap.put("endTime",DateUtils.dateToDateString(endDate, "yyyy-MM-dd HH:mm:ss"));
                //存入batch批号
                newMap.put("batch", (String) map.get("batch"));
                newMap.put("total",map.get("total").toString());
                timeSlotVo.add(newMap);
            }
            vo.setTimeSlot(timeSlotVo);
screen-api/src/main/java/com/moral/api/service/SysTestService.java
New file
@@ -0,0 +1,19 @@
package com.moral.api.service;
import com.moral.api.entity.SysTest;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
 * <p>
 *  服务类
 * </p>
 *
 * @author moral
 * @since 2023-08-01
 */
public interface SysTestService extends IService<SysTest> {
    List<SysTest> listAll(String startTime,String endTime ,String mac);
}
screen-api/src/main/java/com/moral/api/service/UAVService.java
New file
@@ -0,0 +1,13 @@
package com.moral.api.service;
import java.util.List;
import java.util.Map;
import com.moral.api.pojo.dto.uav.UAVResultDTO;
public interface UAVService {
    List<UAVResultDTO> getUav(Map<String, Object> params);
}
screen-api/src/main/java/com/moral/api/service/impl/ExcelServiceImpl.java
@@ -491,60 +491,60 @@
            HashMap<String, Object> map = new HashMap<>();
            map.put("mac", objects[0]);
            map.put("time", objects[1]);
            // pm2.5
            if (!objects[2].toString().equals("-")){
                map.put("a34004", objects[2]);
            }
            // pm10
            if (!objects[3].toString().equals("-")){
                map.put("a34002", objects[3]);
            }
            // 二氧化硫
            if (!objects[2].toString().equals("--")){
                map.put("a21026", objects[2]);
            if (!objects[4].toString().equals("-")){
                map.put("a21026", objects[4]);
            }
            // 二氧化氮
            if (!objects[3].toString().equals("--")){
                map.put("a21004", objects[3]);
            if (!objects[5].toString().equals("-")){
                map.put("a21004", objects[5]);
            }
            // 一氧化碳
            if (!objects[4].toString().equals("--")){
                map.put("a21005", objects[4]);
            // co
            if (!objects[6].toString().equals("-")){
                map.put("a21005", objects[6]);
            }
            // 臭氧
            if (!objects[5].toString().equals("--")){
                map.put("a05024", objects[5]);
            }
            // PM10
            if (!objects[6].toString().equals("--")){
                map.put("a34002", objects[6]);
            }
            // PM 2.5
            if (!objects[7].toString().equals("--")){
                map.put("a34004", objects[7]);
            // o3
            if (!objects[7].toString().equals("-")){
                map.put("a05024", objects[7]);
            }
            // TVOCs
            if (!objects[8].toString().equals("--")){
                map.put("a99054", objects[8]);
            }
            // 温度
            if (!objects[9].toString().equals("--")){
                map.put("a01001", objects[9]);
            if (!objects[8].toString().equals("-")){
                map.put("a01001", objects[8]);
            }
            // 湿度
            if (!objects[10].toString().equals("--")){
                map.put("a01002", objects[10]);
            if (!objects[9].toString().equals("-")){
                map.put("a01002", objects[9]);
            }
            // 气压
            if (!objects[11].toString().equals("--")){
                map.put("a01006", objects[11]);
            }
            // 风速
            if (!objects[12].toString().equals("--")){
                map.put("a01007", objects[12]);
            if (!objects[10].toString().equals("-")){
                map.put("a01007", objects[10]);
            }
            // 风向
            if (!objects[13].toString().equals("--")){
                map.put("a01008", objects[13]);
            if (!objects[11].toString().equals("-")){
                map.put("a01008", objects[11]);
            }
            // 光照
            if (!objects[14].toString().equals("--")){
                map.put("a00e12", objects[14]);
            // 气压
            if (!objects[12].toString().equals("-")){
                map.put("a01006", objects[12]);
            }
            // 光照强度
            if (!objects[13].toString().equals("-")){
                map.put("a00e12", objects[13]);
            }
            // tvoc
            if (!objects[14].toString().equals("-")){
                map.put("a99054", objects[14]);
            }
//            map.put("颗粒物0.3", objects[15]);
screen-api/src/main/java/com/moral/api/service/impl/HistoryDailyServiceImpl.java
@@ -7,6 +7,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -70,7 +71,10 @@
            result.put("avg", Constants.NULL_VALUE);
            return result;
        }
        result.put("avg", data.get(params.get("sensorCode")));
        double aDouble = Double.parseDouble(data.get(params.get("sensorCode")).toString());
        double v = new BigDecimal(aDouble).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
//        result.put("avg", data.get(params.get("sensorCode")));
        result.put("avg", ""+v);
        return result;
    }
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java
@@ -161,6 +161,7 @@
                    dateMap.put("startTime", slotStartDate);
                    dateMap.put("endTime", slotEndDate);
                    dateMap.put("batch", mKey);
                    dateMap.put("total",mValue.size());
                    timeSlots.add(dateMap);
                });
            });
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java
@@ -211,7 +211,10 @@
        String time2 = params.get("time2").toString();
        String rsTime = getTime(time1, time2);
        list.add(rsTime);
        List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false);
//        List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false);
//        List<Map<String, Object>> maps = HistorySecondCruiserMapper.getCruiserData(params);
        List<Map<String, Object>> maps = HistorySecondCruiserMapper.getAllCruiserData(params);
        if (ObjectUtils.isEmpty(maps)){
            return null;
        }
@@ -223,7 +226,8 @@
            map.put("time1",time3);
            map.put("time2",time4);
            map.put("mac",mac);
            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false);
//            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false);
            List<Map<String, Object>> maps1 = HistorySecondCruiserMapper.getAllCruiserData(params);
            if (ObjectUtils.isEmpty(maps1)){
                return null;
            }
@@ -239,7 +243,8 @@
            map.put("time1",time5);
            map.put("time2",time6);
            map.put("mac",mac);
            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false);
//            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false);
            List<Map<String, Object>> maps1 = HistorySecondCruiserMapper.getAllCruiserData(params);
            if (ObjectUtils.isEmpty(maps1)){
                return null;
            }
@@ -459,20 +464,28 @@
        for (Map<String, Object> map : maps) {
//            String flylon = map.get("flylon").toString();
//            String flylat = map.get("flylat").toString();
//            String s = flylon + "-" + flylat;
//            if (Double.parseDouble(map.get("a34004").toString())>200){
//
//            }
            pm25List.add(Double.parseDouble(map.get("a34004").toString()));
            pm10List.add(Double.parseDouble(map.get("a34002").toString()));
            COList.add(Double.parseDouble(map.get("a21005").toString()));
            SO2List.add(Double.parseDouble(map.get("a21026").toString()));
            NO2List.add(Double.parseDouble(map.get("a21004").toString()));
            O3List.add(Double.parseDouble(map.get("a05024").toString()));
            VOCList.add(Double.parseDouble(map.get("a99054").toString()));
            Map value = JSON.parseObject(map.get("value").toString(), Map.class);
            if (!ObjectUtils.isEmpty(value.get("a34004"))){
                pm25List.add(Double.parseDouble(value.get("a34004").toString()));
            }
            if (!ObjectUtils.isEmpty(value.get("a34002"))){
                pm10List.add(Double.parseDouble(value.get("a34002").toString()));
            }
            if (!ObjectUtils.isEmpty(value.get("a21005"))){
                COList.add(Double.parseDouble(value.get("a21005").toString()));
            }
            if (!ObjectUtils.isEmpty(value.get("a21026"))){
                SO2List.add(Double.parseDouble(value.get("a21026").toString()));
            }
            if (!ObjectUtils.isEmpty(value.get("a21004"))){
                NO2List.add(Double.parseDouble(value.get("a21004").toString()));
            }
            if (!ObjectUtils.isEmpty(value.get("a05024"))){
                O3List.add(Double.parseDouble(value.get("a05024").toString()));
            }
            if (!ObjectUtils.isEmpty(value.get("a99054"))){
                VOCList.add(Double.parseDouble(value.get("a99054").toString()));
            }
        }
        //获取平均值
screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java
New file
@@ -0,0 +1,50 @@
package com.moral.api.service.impl;
import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moral.api.entity.SysTest;
import com.moral.api.mapper.SysTestMapper;
import com.moral.api.service.SysTestService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.utils.AqiUtils;
import com.moral.util.DateUtils;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author moral
 * @since 2023-08-01
 */
@Service
public class SysTestServiceImpl extends ServiceImpl<SysTestMapper, SysTest> implements SysTestService {
    @Override
    public List<SysTest> listAll(String startTime,String endTime, String mac) {
        QueryWrapper<SysTest> queryWrapper = new QueryWrapper<>();
       // queryWrapper.between(!StringUtils.isEmpty(startTime)&&!StringUtils.isEmpty(endTime),"time",startTime,endTime);
        queryWrapper.eq(!StringUtils.isEmpty(startTime),"time", DateUtils.convertDate(startTime));
        queryWrapper.eq(!StringUtils.isEmpty(mac),"mac",mac);
        queryWrapper.orderByAsc("time","mac");
        List<SysTest> listAll = this.baseMapper.selectList(queryWrapper);
        for(SysTest s : listAll){
            Map<String,Object> map = new HashMap<>();
            map.put("PM2_5",s.getPm25());
            map.put("PM10",s.getPm10());
            map.put("CO",s.getCo());
            map.put("SO2",s.getSo2());
            map.put("NO2",s.getNo2());
            map.put("O3",s.getO3());
            Map<String,Object> getAqi = AqiUtils.getAqi(map);
            s.setSu(getAqi.get("SU").toString());
            s.setAqi(getAqi.get("AQI").toString());
        }
        return listAll;
    }
}
screen-api/src/main/java/com/moral/api/service/impl/UAVServiceImpl.java
New file
@@ -0,0 +1,509 @@
package com.moral.api.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.moral.api.entity.HistorySecondUav;
import com.moral.api.mapper.HistorySecondUavMapper;
import com.moral.api.pojo.dto.uav.UAVGetBD;
import com.moral.api.pojo.dto.uav.UAVGteForDTO;
import com.moral.api.pojo.dto.uav.UAVResultDTO;
import com.moral.api.service.UAVService;
import com.moral.util.DateUtils;
@Service
public class UAVServiceImpl implements UAVService {
    @Autowired
    private HistorySecondUavMapper historySecondUavMapper;
    @Override
    public List<UAVResultDTO> getUav(Map<String, Object> params) {
        String uvasize = params.get("uvasize").toString();
        int size = Integer.parseInt(uvasize);
        //纬度
        ArrayList<Double> flyLatList = new ArrayList<>();
        //经度
        ArrayList<Double> flyLonList = new ArrayList<>();
        List<HistorySecondUav> historySecondUavs = historySecondUavMapper.reList(params);
        if (ObjectUtils.isEmpty(historySecondUavs)){
            return null;
        }
        ArrayList<UAVGetBD> rsBDList = new ArrayList<>();
        for (HistorySecondUav historySecondUav : historySecondUavs) {
            UAVGetBD uavGetBD = new UAVGetBD();
            String value = historySecondUav.getValue();
            JSONObject jsonObject = JSONObject.parseObject(value);
            String flylon = jsonObject.get("flylon").toString();
            String flylat = jsonObject.get("flylat").toString();
            //WGS84 转 百度坐标
            double[] doubles = transformWGS84ToBD09(Double.parseDouble(flylon), Double.parseDouble(flylat));
            uavGetBD.setFlyLon(doubles[0]);
            uavGetBD.setFlyLat(doubles[1]);
            uavGetBD.setTime(DateUtils.dateToDateString(historySecondUav.getTime()));
            uavGetBD.setValue(value);
            rsBDList.add(uavGetBD);
//            flyLatList.add(Double.parseDouble(flylat));
//            flyLonList.add(Double.parseDouble(flylon));
            flyLatList.add(doubles[1]);
            flyLonList.add(doubles[0]);
        }
        //获取最大最小的经纬度
        Double maxLat = Collections.max(flyLatList);
        Double maxLon = Collections.max(flyLonList);
        Double minLat = Collections.min(flyLatList);
        Double minLon = Collections.min(flyLonList);
        //大四边形右下
//        String leftTop =  minLat +";"+ maxLon;
        //右上
//        String rightTop =  maxLat +";"+ maxLon;
        //左下
//        String leftBottom = minLat +";" + minLon;
        //左上
//        String rightBottom = maxLat +";" + minLon;
        //计算纬度的距离
        double distance1 = getDistance(maxLon, minLat, maxLon, maxLat);
        //计算经度的距离
        double distance2 = getDistance(maxLon, minLat, minLon, minLat);
        ArrayList<UAVGteForDTO> list = new ArrayList<>();
        //小四边形
//        String [] lefts =new String[]{maxLon.toString(),minLat.toString()};
        //右上2
        String[] youshang = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, size);
        //右下2
        String[] youxia = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(youshang[0]), Double.parseDouble(youshang[1]), size);
        //左下2
        String[] zuoxia = calLocationByDistanceAndLocationAndDirection(180, minLon, maxLat, size);
        for (int i = 0; i <distance2 ; i+=size) {
            UAVGteForDTO dto1 = new UAVGteForDTO();
            String[] strings2 = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, i);
            String[] strings3 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youshang[0].toString()), Double.parseDouble(youshang[1].toString()), i);
            String[] strings4 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youxia[0].toString()), Double.parseDouble(youxia[1].toString()), i);
            String[] strings5 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(zuoxia[0].toString()), Double.parseDouble(zuoxia[1].toString()), i);
            dto1.setLeftTop(strings2);
            dto1.setRightTop(strings3);
            dto1.setRightBottom(strings4);
            dto1.setLeftBottom(strings5);
            list.add(dto1);
            for (int j = 0; j < distance1; j+=size) {
                UAVGteForDTO dto2 = new UAVGteForDTO();
                String[] strings6 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings2[0].toString()), Double.parseDouble(strings2[1].toString()), j);
                String[] strings7 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings3[0].toString()), Double.parseDouble(strings3[1].toString()), j);
                String[] strings8 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings4[0].toString()), Double.parseDouble(strings4[1].toString()), j);
                String[] strings9 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings5[0].toString()), Double.parseDouble(strings5[1].toString()), j);
                dto2.setLeftTop(strings6);
                dto2.setRightTop(strings7);
                dto2.setRightBottom(strings8);
                dto2.setLeftBottom(strings9);
                if (j!=0){
                    list.add(dto2);
                }
            }
        }
        HashMap<String,List<String>> rsMap = new HashMap<>();
        List<String>  stringList = new ArrayList<>();
        for (UAVGteForDTO uavGteForDTO : list) {
            ArrayList<String> list1 = new ArrayList<>();
            ArrayList<String[]> doubleArrayList = new ArrayList<>();
            doubleArrayList.add(uavGteForDTO.getLeftTop());
            doubleArrayList.add(uavGteForDTO.getLeftBottom());
            doubleArrayList.add(uavGteForDTO.getRightTop());
            doubleArrayList.add(uavGteForDTO.getRightBottom());
            String[] leftTops = uavGteForDTO.getLeftTop();
            String[] rightBottoms = uavGteForDTO.getRightBottom();
            Double x1 = Double.parseDouble(leftTops[0]);
            Double x2 = Double.parseDouble(rightBottoms[0]);
            Double y1 = Double.parseDouble(leftTops[1]);
            Double y2 = Double.parseDouble(rightBottoms[1]);
            //获取区域对象
//            for (int i = 0; i < historySecondUavs.size(); i++) {
//                HistorySecondUav historySecondUav = historySecondUavs.get(i);
//                String value = historySecondUav.getValue();
//                Map map1 = JSON.parseObject(value, Map.class);
//                String flylat = map1.get("flylat").toString();
//                String flylon = map1.get("flylon").toString();
//                //判断点是否在区域内
//                boolean flag = isInPolygon(flylon,flylat,x1,x2,y1,y2);
//                if (flag){
//                    String time = DateUtils.dateToDateString(historySecondUav.getTime());
//                    //historySecondUavs.remove(i);
//                    if(!stringList.contains(time)){
//                        list1.add(historySecondUav.getValue());
//                        stringList.add(time);
//                    }
//                }
//            }
            for (UAVGetBD uavGetBD : rsBDList) {
                boolean flag = isInPolygon(uavGetBD.getFlyLon().toString(),uavGetBD.getFlyLat().toString(),x1,x2,y1,y2);
                if (flag){
                    String time = uavGetBD.getTime();
                    //historySecondUavs.remove(i);
                    if(!stringList.contains(time)){
                        list1.add(uavGetBD.getValue());
                        stringList.add(time);
                    }
                }
            }
            //获取中心点坐标
            String result = getResult(doubleArrayList);
            rsMap.put(result,list1);
        }
        //计算区域类所有因子的平均数
        ArrayList<UAVResultDTO> uavResultDTOS = new ArrayList<>();
        Set<String> strings = rsMap.keySet();
        for (String string : strings) {
            UAVResultDTO dto = new UAVResultDTO();
            List<String> list1 = rsMap.get(string);
            if (ObjectUtils.isEmpty(list1)){
                continue;
            }
            ArrayList<Double> TVOCArrayList = new ArrayList<>();
            ArrayList<Double> PM10ArrayList = new ArrayList<>();
            ArrayList<Double> PM25ArrayList = new ArrayList<>();
            ArrayList<Double> SOArrayList = new ArrayList<>();
            ArrayList<Double> NOArrayList = new ArrayList<>();
            ArrayList<Double> QYArrayList = new ArrayList<>();
            ArrayList<Double> COArrayList = new ArrayList<>();
            ArrayList<Double> WDArrayList = new ArrayList<>();
            ArrayList<Double> SHArrayList = new ArrayList<>();
            ArrayList<Double> O3ArrayList = new ArrayList<>();
            for (String s : list1) {
                JSONObject jsonObject = JSON.parseObject(s);
                //tvoc
                Object a99054 = jsonObject.get("a99054");
                if (!Objects.isNull(a99054)){
                    TVOCArrayList.add(Double.parseDouble(a99054.toString()));
                }
                //pm2.5
                Object a34004 = jsonObject.get("a34004");
                if (!Objects.isNull(a34004)){
                    PM25ArrayList.add(Double.parseDouble(a34004.toString()));
                }
                //二氧化硫
                Object a21026 = jsonObject.get("a21026");
                if (!Objects.isNull(a21026)){
                    SOArrayList.add(Double.parseDouble(a21026.toString()));
                }
                //二氧化氮
                Object a21004 = jsonObject.get("a21004");
                if (!Objects.isNull(a21004)){
                    NOArrayList.add(Double.parseDouble(a21004.toString()));
                }
                //气压
                Object a01006 = jsonObject.get("a01006");
                if (!Objects.isNull(a01006)){
                    QYArrayList.add(Double.parseDouble(a01006.toString()));
                }
                //pm10
                Object a34002 = jsonObject.get("a34002");
                if (!Objects.isNull(a34002)){
                    PM10ArrayList.add(Double.parseDouble(a34002.toString()));
                }
                //co
                Object a21005 = jsonObject.get("a21005");
                if (!Objects.isNull(a21005)){
                    COArrayList.add(Double.parseDouble(a21005.toString()));
                }
                //湿度
                Object a01002 = jsonObject.get("a01002");
                if (!Objects.isNull(a01002)){
                    QYArrayList.add(Double.parseDouble(a01002.toString()));
                }
                //温度
                Object a01001 = jsonObject.get("a01001");
                if (!Objects.isNull(a01001)){
                    QYArrayList.add(Double.parseDouble(a01001.toString()));
                }
                //臭氧
                Object a05024 = jsonObject.get("a05024");
                if (!Objects.isNull(a05024)){
                    O3ArrayList.add(Double.parseDouble(a05024.toString()));
                }
            }
            double WDDouble =0.0;
            double SHDouble =0.0;
            double QYDouble =0.0;
            double CODouble =0.0;
            double TVODouble =0.0;
            double PM10Double =0.0;
            double PM25Double =0.0;
            double SODouble =0.0;
            double NODouble =0.0;
            double O3Double =0.0;
            if (COArrayList.size()>0){
                CODouble = COArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (TVOCArrayList.size()>0){
                TVODouble = TVOCArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (PM10ArrayList.size()>0){
                PM10Double = PM10ArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (PM25ArrayList.size()>0){
                PM25Double = PM25ArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (SOArrayList.size()>0){
                SODouble = SOArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (NOArrayList.size()>0){
                NODouble = NOArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (WDArrayList.size()>0){
                WDDouble = WDArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (SHArrayList.size()>0){
                SHDouble = SHArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (QYArrayList.size()>0){
                QYDouble = QYArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            if (O3ArrayList.size()>0){
                O3Double = O3ArrayList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
            }
            dto.setA21005(CODouble);
            dto.setA21004(NODouble);
            dto.setA05024(O3Double);
            dto.setA99054(TVODouble);
            dto.setA34002(PM10Double);
            dto.setA34004(PM25Double);
            dto.setA21026(SODouble);
            dto.setA01001(WDDouble);
            dto.setA01002(SHDouble);
            dto.setA01006(QYDouble);
            String[] s = string.split("_");
            dto.setFlyLat(Double.parseDouble(s[1]));
            dto.setFlyLon(Double.parseDouble(s[0]));
            uavResultDTOS.add(dto);
        }
        return uavResultDTOS;
    }
    private static final double EARTH_RADIUS = 6378137;
    private static final double R = 6371e3;
    /** 180° **/
    private static final DecimalFormat df = new DecimalFormat("0.00000000");
    /**
     * 根据一点的坐标与距离,以及方向,计算另外一点的位置
     * @param angle 角度,从正北顺时针方向开始计算
     * @param startLong 起始点经度
     * @param startLat 起始点纬度
     * @param distance 距离,单位m
     * @return
     */
    public static String[] calLocationByDistanceAndLocationAndDirection(double angle, double startLong,double startLat, double distance){
        String[] result = new String[2];
        //将距离转换成经度的计算公式
        double δ = distance/R;
        // 转换为radian,否则结果会不正确
        angle = Math.toRadians(angle);
        startLong = Math.toRadians(startLong);
        startLat = Math.toRadians(startLat);
        double lat = Math.asin(Math.sin(startLat)*Math.cos(δ)+Math.cos(startLat)*Math.sin(δ)*Math.cos(angle));
        double lon = startLong + Math.atan2(Math.sin(angle)*Math.sin(δ)*Math.cos(startLat),Math.cos(δ)-Math.sin(startLat)*Math.sin(lat));
        // 转为正常的10进制经纬度
        lon = Math.toDegrees(lon);
        lat = Math.toDegrees(lat);
        result[0] = df.format(lon);
        result[1] = df.format(lat);
        return result;
    }
    /**
     * 根据经纬度,计算两点间的距离
     *
     * @param longitude1 第一个点的经度
     * @param latitude1  第一个点的纬度
     * @param longitude2 第二个点的经度
     * @param latitude2  第二个点的纬度
     * @return 返回距离 单位米
     */
    public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
        // 纬度
        double lat1 = Math.toRadians(latitude1);
        double lat2 = Math.toRadians(latitude2);
        // 经度
        double lng1 = Math.toRadians(longitude1);
        double lng2 = Math.toRadians(longitude2);
        // 纬度之差
        double a = lat1 - lat2;
        // 经度之差
        double b = lng1 - lng2;
        // 计算两点距离的公式
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
                Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
        // 弧长乘地球半径, 返回单位: 米
        s =  s * EARTH_RADIUS;
        return s;
    }
    //获取中心点
    public static String getResult(ArrayList<String[]> doubleArrayList){
        int total = doubleArrayList.size();
        double X = 0, Y = 0, Z = 0;
        for (int i = 0; i < total; i++) {
            double lat, lon, x, y, z;
            String[] strings = doubleArrayList.get(i);
            lon = Double.parseDouble(strings[0]) * Math.PI / 180;
            lat = Double.parseDouble(strings[1]) * Math.PI / 180;
            x = Math.cos(lat) * Math.cos(lon);
            y = Math.cos(lat) * Math.sin(lon);
            z = Math.sin(lat);
            X += x;
            Y += y;
            Z += z;
        }
        X = X / total;
        Y = Y / total;
        Z = Z / total;
        double Lon = Math.atan2(Y, X);
        double Hyp = Math.sqrt(X * X + Y * Y);
        double Lat = Math.atan2(Z, Hyp);
        DecimalFormat decimalFormat = new DecimalFormat("#.00000000");
        double rsLon = Lon * 180 / Math.PI;
        double rsLat = Lat * 180 / Math.PI;
//        double[] doubles = transformWGS84ToGCJ02(rsLon, rsLat);
//        String s = transformGCJ02ToBD09(doubles[0], doubles[1]);
        return decimalFormat.format(rsLon)+"_"+decimalFormat.format(rsLat);
//        return rsLon+"_"+rsLat;
//        return s;
    }
    /**
     * 求点是否在这个区域类
     * @param X
     * @param Y
     * @param x1
     * @param x2
     * @param y1
     * @param y2
     * @return
     */
    public boolean isInPolygon(String X,String Y,double x1,double x2,double y1,double y2){
        boolean result = false;
        double x =Double.parseDouble(X);
        double y =Double.parseDouble(Y);
        if(x >= Math.min(x1, x2) && x <= Math.max(x1, x2) ){
            if(y >= Math.min(y1, y2) && y <= Math.max(y1, y2)){
                result = true;
            }
        }
        return result;
    }
    private static final double x_PI = 3.14159265358979324 * 3000.0 / 180.0;
    private static final double PI = 3.1415926535897932384626;
    private static final double a = 6378245.0;
    private static final double ee = 0.00669342162296594323;
    /**
     * WGS84 坐标 转 GCJ02
     *
     * @param lng 经度
     * @param lat 纬度
     * @return GCJ02 坐标:[经度,纬度]
     */
    public static double[] transformWGS84ToGCJ02(double lng, double lat) {
        if (outOfChina(lng, lat)) {
            return new double[]{lng, lat};
        } else {
            double dLat = transformLat(lng - 105.0, lat - 35.0);
            double dLng = transformLng(lng - 105.0, lat - 35.0);
            double redLat = lat / 180.0 * PI;
            double magic = Math.sin(redLat);
            magic = 1 - ee * magic * magic;
            double sqrtMagic = Math.sqrt(magic);
            dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI);
            dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(redLat) * PI);
            double mgLat = lat + dLat;
            double mgLng = lng + dLng;
            return new double[]{mgLng, mgLat};
        }
    }
    private static double transformLat(double lng, double lat) {
        double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
        ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
        ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
        return ret;
    }
    private static double transformLng(double lng, double lat) {
        double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
        ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
        ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
        return ret;
    }
    /**
     * 判断坐标是否不在国内
     *
     * @param lng 经度
     * @param lat 纬度
     * @return 坐标是否在国内
     */
    public static boolean outOfChina(double lng, double lat) {
        return (lng < 72.004 || lng > 137.8347) || (lat < 0.8293 || lat > 55.8271);
    }
    /**
     * GCJ02 转百度坐标
     *
     * @param lng GCJ02 经度
     * @param lat GCJ02 纬度
     * @return 百度坐标:[经度,纬度]
     */
    public static double[] transformGCJ02ToBD09(double lng, double lat) {
        double z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
        double theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI);
        double bd_lng = z * Math.cos(theta) + 0.0065;
        double bd_lat = z * Math.sin(theta) + 0.006;
        return new double[]{bd_lng, bd_lat};
    }
    /**
     * WGS84 转 百度坐标BD09
     *
     * @param lng 经度
     * @param lat 纬度
     * @return BD09 坐标:[经度,纬度]
     */
    public static double[] transformWGS84ToBD09(double lng, double lat) {
        double[] lngLat = transformWGS84ToGCJ02(lng, lat);
        return transformGCJ02ToBD09(lngLat[0], lngLat[1]);
    }
}
screen-api/src/main/resources/application-cjl.yml
@@ -16,6 +16,8 @@
    include: bulletin, specialCity, announcement
  application:
    name: screen-api
  main:
    allow-bean-definition-overriding: true
  redis:
    host: r-bp1xdlb9wfc6zt0msppd13.redis.rds.aliyuncs.com
    port: 6379
screen-api/src/main/resources/application-dev.yml
@@ -16,6 +16,8 @@
    include: bulletin, specialCity, announcement
  application:
    name: screen-api
  main:
    allow-bean-definition-overriding: true
  redis:
    host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com
    port: 6379
screen-api/src/main/resources/application-qa.yml
@@ -18,6 +18,8 @@
    include: bulletin, specialCity, announcement
  application:
    name: screen-api
  main:
    allow-bean-definition-overriding: true
  redis:
    host: r-bp1hez4g7rkqjswpaypd1.redis.rds.aliyuncs.com
    port: 6379
screen-api/src/main/resources/mapper/HistorySecondCruiserMapper.xml
@@ -57,4 +57,14 @@
          AND `time` <![CDATA[>=]]> #{start}
          AND `time` <![CDATA[<=]]> #{end}
    </select>
    <select id="getAllCruiserData" resultType="java.util.Map">
        SELECT
        `value`
        FROM `history_second_cruiser`
        WHERE mac = #{mac}
        AND `time` <![CDATA[>=]]> #{time1}
        AND `time` <![CDATA[<=]]> #{time2}
    </select>
</mapper>
screen-api/src/main/resources/mapper/HistorySecondUavMapper.xml
@@ -11,4 +11,11 @@
                    <result column="batch" property="batch" />
        </resultMap>
    <select id="reList" resultType="com.moral.api.entity.HistorySecondUav">
        SELECT history_second_uav.time,`value`
        FROM history_second_uav WHERE mac = #{mac}
        AND batch = #{batch}
        HAVING abs(`value`->>'$.flyhig') <![CDATA[>=]]> #{height1}
        and  abs(`value`->>'$.flyhig') <![CDATA[<=]]> #{height2}
    </select>
</mapper>
screen-api/src/main/resources/mapper/SysTestMapper.xml
New file
@@ -0,0 +1,19 @@
<?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.SysTestMapper">
        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.moral.api.entity.SysTest">
                    <result column="mac" property="mac" />
                    <result column="time" property="time" />
                    <result column="pm25" property="pm25" />
                    <result column="pm10" property="pm10" />
                    <result column="so2" property="so2" />
                    <result column="no2" property="no2" />
                    <result column="co" property="co" />
                    <result column="o3" property="o3" />
                    <result column="voc" property="voc" />
                    <result column="name" property="name" />
        </resultMap>
</mapper>
screen-api/src/main/resources/word/??????.docx
Binary files differ
screen-manage/src/main/java/com/moral/api/controller/DeviceAdjustValueController.java
@@ -1,25 +1,18 @@
package com.moral.api.controller;
import com.alibaba.fastjson.JSON;
import com.moral.api.entity.DeviceAdjustValue;
import com.moral.api.pojo.dto.adjust.AdjustDTO;
import com.moral.api.pojo.form.adjust.AdjustForm;
import com.moral.api.service.DeviceAdjustValueService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
import com.sun.org.apache.regexp.internal.RE;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
screen-manage/src/main/java/com/moral/api/entity/Device.java
@@ -145,6 +145,8 @@
    * */
    @TableField(exist = false)
    private Version version;
    /*
     *序号
     * */
    private Integer devNum;
}
screen-manage/src/main/resources/mapper/DeviceMapper.xml
@@ -26,6 +26,7 @@
        <result column="is_delete" property="isDelete"/>
        <result column="extend" property="extend"/>
        <result column="town_code" property="townCode"/>
        <result column="dev_num" property="devNum"/>
    </resultMap>
    <resultMap id="resultMap" type="com.moral.api.pojo.vo.device.DeviceVO" extends="BaseResultMap">