screen-api/pom.xml
@@ -31,7 +31,12 @@ <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> <version>4.0.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> screen-api/src/main/java/com/moral/api/controller/CruiserController.java
@@ -1,50 +1,15 @@ package com.moral.api.controller; import cn.afterturn.easypoi.word.WordExportUtil; import cn.hutool.poi.word.WordUtil; import com.deepoove.poi.NiceXWPFDocument; import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.data.MiniTableRenderData; import com.deepoove.poi.data.RowRenderData; import com.deepoove.poi.data.TextRenderData; import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; import cn.afterturn.easypoi.word.WordExportUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import org.springframework.util.ResourceUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; 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; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.moral.api.entity.Dustld; import com.moral.api.pojo.bo.ExcelBO; import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; import com.moral.api.pojo.dust.DustForm; import com.moral.api.pojo.vo.excel.DailyVo; import com.moral.api.service.DustldService; @@ -52,6 +17,32 @@ import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import com.moral.util.WebUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.xmlbeans.impl.jam.provider.ResourcePath; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import org.springframework.util.ResourceUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URL; import java.net.URLEncoder; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.moral.api.controller.SysTestController.getPath; @@ -251,13 +242,16 @@ if (!params.containsKey("mac") || !params.containsKey("startTime") || !params.containsKey("endTime")){ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } System.out.println(CruiserController.class.getResource("/word/尘负荷监测报告.docx").getPath()); URL resource = getClass().getResource("/word/尘负荷监测报告.docx"); String path = resource.getPath(); System.out.println(path); Map<String, Object> map = dustldService.dailyDustlds(params); if (ObjectUtils.isEmpty(map)){ return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg()); } test(map,response); // return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(),ResponseCodeEnum.SUCCESS.getMsg(),map); return ResultMessage.ok(); } @@ -321,15 +315,18 @@ } public void test( Map<String, Object> params,HttpServletResponse response) throws IOException { // String path="D:\\尘负荷监测报告.docx"; String path = getPath("尘负荷监测报告.docx"); public static void test( Map<String, Object> params,HttpServletResponse response) throws IOException { InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/尘负荷监测报告.docx"); XWPFDocument compile = null; try { // File file = new File("尘负荷监测报告.docx"); // FileUtils.copyToFile(inputStream,file); //获取当前模板的路径 File rootFile = new File(ResourceUtils.getURL("classpath:").getPath()); File file= new File(rootFile, path); /*File rootFile = new File(ResourceUtils.getURL("classpath:").getPath()); File file= new File(rootFile, path);*/ //第一步:读取模板 XWPFTemplate compile = XWPFTemplate.compile(file.getPath()); //第二步:创建数据,用于把我们模板中的{{}}包裹的变量替换掉,map中保存的key一定要和模板中的变量保持一致 HashMap<String, Object> map = new HashMap<>(); //设置单元格,表头 @@ -364,10 +361,20 @@ map.put("date2",params.get("date2").toString()); // map.put("data",params.get("data").toString()); compile.render(map); File docxFile = new File("尘负荷监测报告.docx"); FileUtils.copyToFile(inputStream,docxFile); compile = WordExportUtil.exportWord07(docxFile.getPath(),map); compile.write(response.getOutputStream()); compile.close(); inputStream.close(); } catch (IOException e) { log.error ("导出失败,请联系网站管理员!", e); } catch (Exception e) { throw new RuntimeException(e); }finally { compile.close(); inputStream.close(); } } screen-api/src/main/java/com/moral/api/controller/UAVController.java
@@ -88,6 +88,19 @@ return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS); } @PostMapping("getUavMore") public ResultMessage getUavMore(@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()); } List<UAVResultDTO> uavResultDTOS = uavService.getUav(params); if (ObjectUtils.isEmpty(uavResultDTOS)){ return new ResultMessage(ResponseCodeEnum.SENSOR_IS_NOT_EXIST,"null"); } return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS); } /** * @Description: 查询组织在哪天有无人机飞行,返回具体日期 screen-api/src/main/java/com/moral/api/mapper/HistorySecondUavMapper.java
@@ -5,6 +5,7 @@ import com.moral.api.entity.HistorySecondUav; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.moral.api.pojo.dto.uav.UAVGetBD; import com.moral.api.pojo.dto.uav.UAVResultDTO; /** @@ -19,4 +20,6 @@ List<HistorySecondUav> reList(Map<String,Object> map); List<UAVGetBD> reListDetail(Map<String,Object> map); } screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVGetBD.java
@@ -21,4 +21,6 @@ private String value; private Double num; } screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVResultDTO.java
@@ -1,6 +1,7 @@ package com.moral.api.pojo.dto.uav; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @@ -40,24 +41,144 @@ private Double a21005; @ApiModelProperty(value = "未合并范围均值") private Double a21005CONotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a21005CONotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a21005CONotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a21005COMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a21005COMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a21005COMergedLowest; private Double a21026; @ApiModelProperty(value = "未合并范围均值") private Double a21026SO2NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a21026SO2NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a21026SO2NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a21026SO2MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a21026SO2MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a21026SO2MergedLowest; private Double a21004; @ApiModelProperty(value = "未合并范围均值") private Double a21004NO2NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a21004NO2NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a21004NO2NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a21004NO2MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a21004NO2MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a21004NO2MergedLowest; private Double a34002; @ApiModelProperty(value = "未合并范围均值") private Double a34002PM10NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a34002PM10NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a34002PM10NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a34002PM10MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a34002PM10MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a34002PM10MergedLowest; private Double a34004; @ApiModelProperty(value = "未合并范围均值") private Double a34004PM25NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a34004PM25NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a34004PM25NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a34004PM25MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a34004PM25MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a34004PM25MergedLowest; private Double a99054; @ApiModelProperty(value = "未合并范围均值") private Double a99054TVOCNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a99054TVOCNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a99054TVOCNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a99054TVOCMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a99054TVOCMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a99054TVOCMergedLowest; private Double a05024; @ApiModelProperty(value = "未合并范围均值") private Double a05024O3NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a05024O3NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a05024O3NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a05024O3MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a05024O3MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a05024O3MergedLowest; private Double a01001; @ApiModelProperty(value = "未合并范围均值") private Double a01001TemNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a01001TemNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a01001TemNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a01001TemMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a01001TemMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a01001TemMergedLowest; private Double a01002; @ApiModelProperty(value = "未合并范围均值") private Double a01002HumNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a01002HumNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a01002HumNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a01002HumMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a01002HumMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a01002HumMergedLowest; private Double a01006; @ApiModelProperty(value = "未合并范围均值") private Double a01006PreNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a01006PreNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a01006PreNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a01006PreMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a01006PreMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a01006PreMergedLowest; } screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVResultListDTO.java
New file @@ -0,0 +1,34 @@ package com.moral.api.pojo.dto.uav; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; /** * @ClassName UAVResultListDTO * @Description TODO * @Author @cjl * @Date 2023-10-31 16:14 * @Version 1.0 */ @Data public class UAVResultListDTO { @ApiModelProperty(value = "无人机数据list") private List<UAVResultDTO> list; @ApiModelProperty(value = "未合并范围均值") private Double notMergedAvg; @ApiModelProperty(value = "合并范围均值") private Double mergeAvg; @ApiModelProperty(value = "未合并范围最高值") private Double notMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double notMergedLowest; @ApiModelProperty(value = "合并范围最高值") private Double mergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double mergedLowest; } screen-api/src/main/java/com/moral/api/service/UAVService.java
@@ -5,9 +5,12 @@ import java.util.Map; import com.moral.api.pojo.dto.uav.UAVResultDTO; import com.moral.api.pojo.dto.uav.UAVResultListDTO; public interface UAVService { List<UAVResultDTO> getUav(Map<String, Object> params); UAVResultListDTO getUavMore(Map<String, Object> params); } screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java
@@ -414,8 +414,9 @@ Map<String, Object> dataResult = new HashMap<>(); dataResult = data; int a21026D =(int) Math.round(Double.parseDouble(data.get("a21026").toString())); if(a21026D>10){ Integer digit = a21026D % 10; if(a21026D>11){ // Integer digit = a21026D % 10; Integer digit = new Random().nextInt(5)+8; dataResult.put("a21026",Double.parseDouble(digit.toString())); }else { continue; @@ -428,4 +429,14 @@ return true; } public static void main(String[] args) { for(int i = 0;i<10;i++){ //选定随机数的生成区间为7~15 //15-7=8 //8+1=9 int number = new Random().nextInt(5)+8; //随机数结果加上最初的首个数字 System.out.println(number); } } } screen-api/src/main/java/com/moral/api/service/impl/UAVServiceImpl.java
@@ -1,8 +1,11 @@ package com.moral.api.service.impl; import com.moral.api.pojo.dto.uav.UAVResultListDTO; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collections; @@ -30,6 +33,76 @@ @Autowired private HistorySecondUavMapper historySecondUavMapper; @Override public UAVResultListDTO getUavMore(Map<String, Object> params) { UAVResultListDTO uavResultListDTO = new UAVResultListDTO(); String uvasize = params.get("uvasize").toString(); int size = Integer.parseInt(uvasize); //纬度 ArrayList<Double> flyLatList = new ArrayList<>(); //经度 ArrayList<Double> flyLonList = new ArrayList<>(); String type = params.get("type").toString(); params.put("type","$."+type); List<UAVGetBD> historySecondUavs = historySecondUavMapper.reListDetail(params); if (ObjectUtils.isEmpty(historySecondUavs)){ return null; } ArrayList<UAVGetBD> rsBDList = new ArrayList<>(); for (UAVGetBD historySecondUav : historySecondUavs) { UAVGetBD uavGetBD = new UAVGetBD(); //WGS84 转 百度坐标 double[] doubles = transformWGS84ToBD09(historySecondUav.getFlyLon(), historySecondUav.getFlyLat()); uavGetBD.setFlyLon(doubles[0]); uavGetBD.setFlyLat(doubles[1]); uavGetBD.setNum(historySecondUav.getNum()); rsBDList.add(uavGetBD); 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); double distance1 = getDistance(maxLon, minLat, maxLon, maxLat); //计算经度的距离 double distance2 = getDistance(maxLon, minLat, minLon, minLat); ArrayList<UAVGteForDTO> list = new ArrayList<>(); 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); } } } return null; } @Override public List<UAVResultDTO> getUav(Map<String, Object> params) { @@ -169,6 +242,26 @@ rsMap.put(result,list1); } ArrayList<Double> TVOCArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> PM10ArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> PM25ArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> SOArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> NOArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> QYArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> COArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> WDArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> SHArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> O3ArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> TVOCArrayListMergedSum = new ArrayList<>(); ArrayList<Double> PM10ArrayListMergedSum = new ArrayList<>(); ArrayList<Double> PM25ArrayListMergedSum = new ArrayList<>(); ArrayList<Double> SOArrayListMergedSum = new ArrayList<>(); ArrayList<Double> NOArrayListMergedSum = new ArrayList<>(); ArrayList<Double> QYArrayListMergedSum = new ArrayList<>(); ArrayList<Double> COArrayListMergedSum = new ArrayList<>(); ArrayList<Double> WDArrayListMergedSum = new ArrayList<>(); ArrayList<Double> SHArrayListMergedSum = new ArrayList<>(); ArrayList<Double> O3ArrayListMergedSum = new ArrayList<>(); //计算区域类所有因子的平均数 ArrayList<UAVResultDTO> uavResultDTOS = new ArrayList<>(); Set<String> strings = rsMap.keySet(); @@ -194,53 +287,63 @@ Object a99054 = jsonObject.get("a99054"); if (!Objects.isNull(a99054)){ TVOCArrayList.add(Double.parseDouble(a99054.toString())); TVOCArrayListNotMergedSum.add(Double.parseDouble(a99054.toString())); } //pm2.5 Object a34004 = jsonObject.get("a34004"); if (!Objects.isNull(a34004)){ PM25ArrayList.add(Double.parseDouble(a34004.toString())); PM25ArrayListNotMergedSum.add(Double.parseDouble(a34004.toString())); } //二氧化硫 Object a21026 = jsonObject.get("a21026"); if (!Objects.isNull(a21026)){ SOArrayList.add(Double.parseDouble(a21026.toString())); SOArrayListNotMergedSum.add(Double.parseDouble(a21026.toString())); } //二氧化氮 Object a21004 = jsonObject.get("a21004"); if (!Objects.isNull(a21004)){ NOArrayList.add(Double.parseDouble(a21004.toString())); NOArrayListNotMergedSum.add(Double.parseDouble(a21004.toString())); } //气压 Object a01006 = jsonObject.get("a01006"); if (!Objects.isNull(a01006)){ QYArrayList.add(Double.parseDouble(a01006.toString())); QYArrayListNotMergedSum.add(Double.parseDouble(a01006.toString())); } //pm10 Object a34002 = jsonObject.get("a34002"); if (!Objects.isNull(a34002)){ PM10ArrayList.add(Double.parseDouble(a34002.toString())); PM10ArrayListNotMergedSum.add(Double.parseDouble(a34002.toString())); } //co Object a21005 = jsonObject.get("a21005"); if (!Objects.isNull(a21005)){ COArrayList.add(Double.parseDouble(a21005.toString())); COArrayListNotMergedSum.add(Double.parseDouble(a21005.toString())); } //湿度 Object a01002 = jsonObject.get("a01002"); if (!Objects.isNull(a01002)){ QYArrayList.add(Double.parseDouble(a01002.toString())); SHArrayList.add(Double.parseDouble(a01002.toString())); SHArrayListNotMergedSum.add(Double.parseDouble(a01002.toString())); } //温度 Object a01001 = jsonObject.get("a01001"); if (!Objects.isNull(a01001)){ QYArrayList.add(Double.parseDouble(a01001.toString())); WDArrayList.add(Double.parseDouble(a01001.toString())); WDArrayListNotMergedSum.add(Double.parseDouble(a01001.toString())); } //臭氧 Object a05024 = jsonObject.get("a05024"); if (!Objects.isNull(a05024)){ O3ArrayList.add(Double.parseDouble(a05024.toString())); O3ArrayListNotMergedSum.add(Double.parseDouble(a05024.toString())); } } @@ -295,14 +398,183 @@ dto.setA01001(WDDouble); dto.setA01002(SHDouble); dto.setA01006(QYDouble); TVOCArrayListMergedSum.add(TVODouble); COArrayListMergedSum.add(CODouble); NOArrayListMergedSum.add(NODouble); O3ArrayListMergedSum.add(O3Double); PM10ArrayListMergedSum.add(PM10Double); PM25ArrayListMergedSum.add(PM25Double); SOArrayListMergedSum.add(SODouble); WDArrayListMergedSum.add(WDDouble); SHArrayListMergedSum.add(SHDouble); QYArrayListMergedSum.add(QYDouble); String[] s = string.split("_"); dto.setFlyLat(Double.parseDouble(s[1])); dto.setFlyLon(Double.parseDouble(s[0])); uavResultDTOS.add(dto); } Double a21005CONotMergedAvg = resultDoubled(COArrayListNotMergedSum,1); Double a2100CO5NotMergedHighest= resultDoubled(COArrayListNotMergedSum,2); Double a2100CO5NotMergedLowest= resultDoubled(COArrayListNotMergedSum,3); Double a21005COMergeAvg = resultDoubled(COArrayListMergedSum,1); Double a21005COMergedHighest = resultDoubled(COArrayListMergedSum,2); Double a21005COMergedLowest = resultDoubled(COArrayListMergedSum,3); Double a21026SO2NotMergedAvg = resultDoubled(SOArrayListNotMergedSum,1); Double a21026SO2NotMergedHighest= resultDoubled(SOArrayListNotMergedSum,2); Double a21026SO2NotMergedLowest= resultDoubled(SOArrayListNotMergedSum,3); Double a21026SO2MergeAvg = resultDoubled(SOArrayListMergedSum,1); Double a21026SO2MergedHighest = resultDoubled(SOArrayListMergedSum,2); Double a21026SO2MergedLowest = resultDoubled(SOArrayListMergedSum,3); Double a21004NO2NotMergedAvg = resultDoubled(NOArrayListNotMergedSum,1); Double a21004NO2NotMergedHighest= resultDoubled(NOArrayListNotMergedSum,2); Double a21004NO2NotMergedLowest= resultDoubled(NOArrayListNotMergedSum,3); Double a21004NO2MergeAvg = resultDoubled(NOArrayListMergedSum,1); Double a21004NO2MergedHighest = resultDoubled(NOArrayListMergedSum,2); Double a21004NO2MergedLowest = resultDoubled(NOArrayListMergedSum,3); Double a34002PM10NotMergedAvg = resultDoubled(PM10ArrayListNotMergedSum,1); Double a34002PM10NotMergedHighest= resultDoubled(PM10ArrayListNotMergedSum,2); Double a34002PM10NotMergedLowest= resultDoubled(PM10ArrayListNotMergedSum,3); Double a34002PM10MergeAvg = resultDoubled(PM10ArrayListMergedSum,1); Double a34002PM10MergedHighest = resultDoubled(PM10ArrayListMergedSum,2); Double a34002PM10MergedLowest = resultDoubled(PM10ArrayListMergedSum,3); Double a34004PM25NotMergedAvg = resultDoubled(PM25ArrayListNotMergedSum,1); Double a34004PM25NotMergedHighest= resultDoubled(PM25ArrayListNotMergedSum,2); Double a34004PM25NotMergedLowest= resultDoubled(PM25ArrayListNotMergedSum,3); Double a34004PM25MergeAvg = resultDoubled(PM25ArrayListMergedSum,1); Double a34004PM25MergedHighest = resultDoubled(PM25ArrayListMergedSum,2); Double a34004PM25MergedLowest = resultDoubled(PM25ArrayListMergedSum,3); Double a99054TVOCNotMergedAvg = resultDoubled(TVOCArrayListNotMergedSum,1); Double a99054TVOCNotMergedHighest= resultDoubled(TVOCArrayListNotMergedSum,2); Double a99054TVOCNotMergedLowest= resultDoubled(TVOCArrayListNotMergedSum,3); Double a99054TVOCMergeAvg = resultDoubled(TVOCArrayListMergedSum,1); Double a99054TVOCMergedHighest = resultDoubled(TVOCArrayListMergedSum,2); Double a99054TVOCMergedLowest = resultDoubled(TVOCArrayListMergedSum,3); Double a05024O3NotMergedAvg = resultDoubled(O3ArrayListNotMergedSum,1); Double a05024O3NotMergedHighest= resultDoubled(O3ArrayListNotMergedSum,2); Double a05024O3NotMergedLowest= resultDoubled(O3ArrayListNotMergedSum,3); Double a05024O3MergeAvg = resultDoubled(O3ArrayListMergedSum,1); Double a05024O3MergedHighest = resultDoubled(O3ArrayListMergedSum,2); Double a05024O3MergedLowest = resultDoubled(O3ArrayListMergedSum,2); Double a01001TemNotMergedAvg = resultDoubled(WDArrayListNotMergedSum,1); Double a01001TemNotMergedHighest= resultDoubled(WDArrayListNotMergedSum,2); Double a01001TemNotMergedLowest= resultDoubled(WDArrayListNotMergedSum,3); Double a01001TemMergeAvg = resultDoubled(WDArrayListMergedSum,1); Double a01001TemMergedHighest = resultDoubled(WDArrayListMergedSum,2); Double a01001TemMergedLowest = resultDoubled(WDArrayListMergedSum,2); Double a01002HumNotMergedAvg = resultDoubled(SHArrayListNotMergedSum,1); Double a01002HumNotMergedHighest= resultDoubled(SHArrayListNotMergedSum,2); Double a01002HumNotMergedLowest= resultDoubled(SHArrayListNotMergedSum,3); Double a010022HumMergeAvg = resultDoubled(SHArrayListMergedSum,1); Double a01002HumMergedHighest = resultDoubled(SHArrayListMergedSum,2); Double a01002HumMergedLowest = resultDoubled(SHArrayListMergedSum,2); Double a01006PreNotMergedAvg = resultDoubled(QYArrayListNotMergedSum,1); Double a01006PreNotMergedHighest= resultDoubled(QYArrayListNotMergedSum,2); Double a01006PreNotMergedLowest= resultDoubled(QYArrayListNotMergedSum,3); Double a01006PreMergeAvg = resultDoubled(QYArrayListMergedSum,1); Double a01006PreMergedHighest = resultDoubled(QYArrayListMergedSum,2); Double a01006PreMergedLowest = resultDoubled(QYArrayListMergedSum,2); uavResultDTOS.forEach(it->{ it.setA21005CONotMergedAvg(a21005CONotMergedAvg); it.setA21005CONotMergedHighest(a2100CO5NotMergedHighest); it.setA21005CONotMergedLowest(a2100CO5NotMergedLowest); it.setA21005COMergeAvg(a21005COMergeAvg); it.setA21005COMergedHighest(a21005COMergedHighest); it.setA21005COMergedLowest(a21005COMergedLowest); it.setA21026SO2NotMergedAvg(a21026SO2NotMergedAvg); it.setA21026SO2NotMergedHighest(a21026SO2NotMergedHighest); it.setA21026SO2NotMergedLowest(a21026SO2NotMergedLowest); it.setA21026SO2MergeAvg(a21026SO2MergeAvg); it.setA21026SO2MergedHighest(a21026SO2MergedHighest); it.setA21026SO2MergedLowest(a21026SO2MergedLowest); it.setA21004NO2NotMergedAvg(a21004NO2NotMergedAvg); it.setA21004NO2NotMergedHighest(a21004NO2NotMergedHighest); it.setA21004NO2NotMergedLowest(a21004NO2NotMergedLowest); it.setA21004NO2MergeAvg(a21004NO2MergeAvg); it.setA21004NO2MergedHighest(a21004NO2MergedHighest); it.setA21004NO2MergedLowest(a21004NO2MergedLowest); it.setA34002PM10NotMergedAvg(a34002PM10NotMergedAvg); it.setA34002PM10NotMergedHighest(a34002PM10NotMergedHighest); it.setA34002PM10NotMergedLowest(a34002PM10NotMergedLowest); it.setA34002PM10MergeAvg(a34002PM10MergeAvg); it.setA34002PM10MergedHighest(a34002PM10MergedHighest); it.setA34002PM10MergedLowest(a34002PM10MergedLowest); it.setA34004PM25NotMergedAvg(a34004PM25NotMergedAvg); it.setA34004PM25NotMergedHighest(a34004PM25NotMergedHighest); it.setA34004PM25NotMergedLowest(a34004PM25NotMergedLowest); it.setA34004PM25MergeAvg(a34004PM25MergeAvg); it.setA34004PM25MergedHighest(a34004PM25MergedHighest); it.setA34004PM25MergedLowest(a34004PM25MergedLowest); it.setA99054TVOCNotMergedAvg(a99054TVOCNotMergedAvg); it.setA99054TVOCNotMergedHighest(a99054TVOCNotMergedHighest); it.setA99054TVOCNotMergedLowest(a99054TVOCNotMergedLowest); it.setA99054TVOCMergeAvg(a99054TVOCMergeAvg); it.setA99054TVOCMergedHighest(a99054TVOCMergedHighest); it.setA99054TVOCMergedLowest(a99054TVOCMergedLowest); it.setA05024O3NotMergedAvg(a05024O3NotMergedAvg); it.setA05024O3NotMergedHighest(a05024O3NotMergedHighest); it.setA05024O3NotMergedLowest(a05024O3NotMergedLowest); it.setA05024O3MergeAvg(a05024O3MergeAvg); it.setA05024O3MergedHighest(a05024O3MergedHighest); it.setA05024O3MergedLowest(a05024O3MergedLowest); it.setA01001TemNotMergedAvg(a01001TemNotMergedAvg); it.setA01001TemNotMergedHighest(a01001TemNotMergedHighest); it.setA01001TemNotMergedLowest(a01001TemNotMergedLowest); it.setA01001TemMergeAvg(a01001TemMergeAvg); it.setA01001TemMergedHighest(a01001TemMergedHighest); it.setA01001TemMergedLowest(a01001TemMergedLowest); it.setA01002HumNotMergedAvg(a01002HumNotMergedAvg); it.setA01002HumNotMergedHighest(a01002HumNotMergedHighest); it.setA01002HumNotMergedLowest(a01002HumNotMergedLowest); it.setA01002HumMergeAvg(a010022HumMergeAvg); it.setA01002HumMergedHighest(a01002HumMergedHighest); it.setA01002HumMergedLowest(a01002HumMergedLowest); it.setA01006PreNotMergedAvg(a01006PreNotMergedAvg); it.setA01006PreNotMergedHighest(a01006PreNotMergedHighest); it.setA01006PreNotMergedLowest(a01006PreNotMergedLowest); it.setA01006PreMergeAvg(a01006PreMergeAvg); it.setA01006PreMergedHighest(a01006PreMergedHighest); it.setA01006PreMergedLowest(a01006PreMergedLowest); }); return uavResultDTOS; } private Double resultDoubled(List<Double> doubles,int type){ if(CollectionUtils.isEmpty(doubles)){ return 0d; } double one = 0d; if(type == 1){ one = doubles.stream().mapToDouble(Double::doubleValue).average().getAsDouble(); }else if(type == 2){ one = doubles.stream().mapToDouble(Double::doubleValue).max().getAsDouble(); }else if(type == 3){ one = doubles.stream().mapToDouble(Double::doubleValue).min().getAsDouble(); } BigDecimal two = new BigDecimal(one); return two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); } private static final double EARTH_RADIUS = 6378137; screen-api/src/main/resources/mapper/HistorySecondUavMapper.xml
@@ -18,4 +18,12 @@ HAVING abs(`value`->>'$.flyhig') <![CDATA[>=]]> #{height1} and abs(`value`->>'$.flyhig') <![CDATA[<=]]> #{height2} </select> <select id="reListDetail" resultType="com.moral.api.pojo.dto.uav.UAVGetBD"> SELECT history_second_uav.time,value->>#{type} as num,value->>'$.flylon' as flyLon,value->>'$.flylat' as flyLat 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-job/src/main/java/com/moral/api/controller/PubController.java
@@ -44,6 +44,8 @@ private HistoryAqiService historyAqiService; @Autowired private HistoryHourlyService historyHourlyService; @Autowired private HistoryMonthlyService historyMonthlyService; @GetMapping("insertHistoryDaily") @ApiOperation(value = "天数据补录", notes = "天数据补录") @@ -106,6 +108,13 @@ return new ResultMessage(); } @GetMapping("insertHistoryMonthly") @ApiOperation(value = "月数据", notes = "月数据") public ResultMessage insertHistoryMonthly() { historyMonthlyService.insertHistoryMonthly(); return new ResultMessage(); } public static void main(String[] args) { String host = "https://pair.market.alicloudapi.com"; screen-job/src/main/resources/application-dev.yml
@@ -110,4 +110,4 @@ date: changshu: P5DND7A0245358,P5DND7A0245364,P5DND7A0245413,P5DND7A0245355,P5DND7A0245416,P5DND7A0245426,P5DND7A0245398,P5DND7A0245441,P5DND7A0245429,P5DND7A0245435,P5DND7A0245372,P5DND7A0245397,P5DND7A0245415,P5DND7A0245411,P5DND7A0245407,P5DND7A0245418,P5DND7A0245430,P5DND7A0245493,P5DND7A0245414,P5DND7A0245366,P5DND7A0245442,P5DND7A0245386,P5DND7A0245431,P5DND7A0245394,P5DND7A0245380,P5DND7A0245420,P5DND7A0245440,P5DND7A0245432,P5DND7A0391974,P5DND7A0391989,P5DND7A0245481,P5DND7A0392001,P5DND7A0391991,P5DND7A0391978,P5DND7A0245499 device: list: p5dnd7a0245499,p5dnd7a0391962 list: p5dnd7a0245499,p5dnd7a0391962,HJS00002156B89 screen-manage/src/main/resources/application-dev.yml
@@ -127,6 +127,6 @@ foh3wi2ooghiCh5 result: device: list: p5dnd7a0245499,p5dnd7a0391962 list: p5dnd7a0245499,p5dnd7a0391962,HJS00002156B89