myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java
@@ -43,7 +43,7 @@ // 全局配置 GlobalConfig gc = new GlobalConfig(); //String projectPath = System.getProperty("user.dir"); String projectPath="C:\\Users\\cdl\\Desktop\\comProject\\newProject\\moral\\screen-api"; String projectPath="D:\\gitproject\\newmoral\\screen-api"; gc.setOutputDir(projectPath + "/src/main/java"); gc.setAuthor("moral"); gc.setOpen(false); @@ -67,7 +67,7 @@ // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setUrl("jdbc:mysql://rm-bp1pr3rx9m3fnkwsk8o.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"); dsc.setUrl("jdbc:mysql://121.199.44.85:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"); //dsc.setUrl("jdbc:mysql://rm-bp1pr3rx9m3fnkwsk8o.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai"); dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setUsername("root"); screen-api/pom.xml
@@ -24,11 +24,6 @@ <!-- easyexcel--> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.0.1</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.0.1</version> </dependency> @@ -52,6 +47,26 @@ <artifactId>easypoi-spring-boot-starter</artifactId> <version>4.0.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-base</artifactId> <version>4.1.0</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>19.0</version> </dependency> <dependency> <groupId>org.jfree</groupId> <artifactId>jcommon</artifactId> <version>1.0.24</version> </dependency> <dependency> <groupId>org.jfree</groupId> <artifactId>jfreechart</artifactId> <version>1.5.0</version> </dependency> </dependencies> <build> screen-api/src/main/java/com/moral/api/controller/AqiController.java
@@ -8,18 +8,12 @@ import com.moral.api.service.CityAqiDailyService; import com.moral.api.service.CityAqiYearlyService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Required; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import java.util.*; @@ -60,6 +54,28 @@ return ResultMessage.ok(response); } @GetMapping("compareO3New") @ApiOperation(value = "预测和实测臭氧对比New", notes = "预测和实测臭氧对比New") public ResultMessage compareO3New(@RequestParam @ApiParam(value = "regionCode",name = "城市code") String regionCode, @RequestParam @ApiParam(value = "time",name = "日期") String time) { Map<String, Object> params = new HashMap<>(); params.put("regionCode",regionCode); params.put("time",time); List<Map<String, Object>> response = cityAqiService.measuredCompareForecastOfO3(params); return ResultMessage.ok(response); } @GetMapping("getO38H") @ApiOperation(value = "预测和实测臭氧对比New", notes = "预测和实测臭氧对比New") public ResultMessage getO38H(@RequestParam @ApiParam(value = "regionCode",name = "城市code") String regionCode, @RequestParam @ApiParam(value = "time",name = "日期") String time) { Map<String, Object> params = new HashMap<>(); params.put("regionCode",regionCode); params.put("time",time); List<Map<String, Object>> response = cityAqiService.measuredCompareForecastOfO3_8H(params); return ResultMessage.ok(response); } /** * @Description: 查询最新的6参和aqi数据 * @Param: [regionCode] screen-api/src/main/java/com/moral/api/controller/SysTestController.java
@@ -1,6 +1,11 @@ package com.moral.api.controller; import cn.afterturn.easypoi.entity.ImageEntity; import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.moral.api.dto.SysTestDTO; import com.moral.api.entity.SysTest; import com.moral.api.service.SysTestService; import com.moral.util.DateUtils; @@ -9,18 +14,28 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtils; import org.jfree.chart.JFreeChart; import org.jfree.chart.StandardChartTheme; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; 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.awt.*; import java.io.*; import java.lang.reflect.Field; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.*; import java.util.List; import java.util.stream.Collectors; /** @@ -40,39 +55,120 @@ @GetMapping("resultWord") public void adresultWordd(HttpServletResponse response,String time) { List<SysTest> listAll = sysTestService.listAll(time,"2022-06-22",null); public void adresultWordd(HttpServletResponse response,String time,String endTime) { // for(int i = 495;i<1095;i++){ List<SysTest> listAll = sysTestService.listAll(time,endTime,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); downloadWord(fileName, map, response,"空气质量日报"+endTimeStr+".docx");*/ // time = DateUtils.dateToDateString(DateUtils.addDays(endTime,1),DateUtils.yyyy_MM_dd_EN); // } } @GetMapping("excelM") public void excelM(HttpServletResponse response,String time,String endTime) { // for(int i = 495;i<1095;i++){ String ks = "2020-06-01"; Date ksDate = DateUtils.convertDate(ks); List<SysTest> result = new ArrayList<>(); for(int i = 0;i<37;i++){ Date jsDate = DateUtils.getLastDayOfCurrMonth(ksDate); List<SysTest> listAll = sysTestService.listAllAvg(DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN),DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN),null); System.out.println("开始:"+DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN)); System.out.println("结束:"+DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN)); ksDate = DateUtils.addMonths(ksDate,1); result.addAll(listAll); } if(CollectionUtils.isEmpty(result)){ return; } String path = "D:\\空气质量月数据.xls"; WriteSheet build = EasyExcel.writerSheet("因子信息").head(SysTestDTO.class).build(); // 创建 easyexcel 的写出类构造器 参数 告诉构造器,我的excel将来要写到哪里,以及execl中数据是基于哪个java对象模板创建的 ExcelWriter excelWriter = EasyExcel.write(path, SysTestDTO.class).build(); excelWriter.write(result, build); excelWriter.finish(); } @GetMapping("excelDay") public void excelDay(HttpServletResponse response,String time,String endTime) { List<SysTest> listAll = sysTestService.listAll(time,endTime,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"); String path = "D:\\空气质量日数据.xls"; WriteSheet build = EasyExcel.writerSheet("因子信息").head(SysTestDTO.class).build(); // 创建 easyexcel 的写出类构造器 参数 告诉构造器,我的excel将来要写到哪里,以及execl中数据是基于哪个java对象模板创建的 ExcelWriter excelWriter = EasyExcel.write(path, SysTestDTO.class).build(); excelWriter.write(listAll, build); excelWriter.finish(); } @GetMapping("resultWordWeek") public void resultWordWeek(HttpServletResponse response) { String ks = "2020-06-22"; Date ksDate = DateUtils.convertDate(ks); for(int i = 0;i<157;i++){ Date jsDate = DateUtils.addDays(ksDate,6); String time = DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN); String endTime = DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN); List<SysTest> listAll = sysTestService.listAllAvg(time,endTime,null); if(CollectionUtils.isEmpty(listAll)){ return; } String fileName = "空气质量周报.docx"; String time1 = DateUtils.dateToDateString(ksDate,"yyyy.MM.dd"); String endTime1= DateUtils.dateToDateString(jsDate,"yyyy.MM.dd"); Map<String,Object> map = resultWeekMap(listAll,i+1,time1+"-"+endTime1); downloadWord(fileName, map, response,"空气质量周报"+time+".docx"); ksDate = DateUtils.addDays(ksDate,7); } } @GetMapping("resultWordMonth") public void resultWordMonth(HttpServletResponse response) { String ks = "2020-06-01"; Date ksDate = DateUtils.convertDate(ks); for(int i = 0;i<37;i++){ Date jsDate = DateUtils.getLastDayOfCurrMonth(ksDate);; String time = DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN); String endTime = DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN); List<SysTest> listAll = sysTestService.listAllAvg(time,endTime,null); if(CollectionUtils.isEmpty(listAll)){ return; } List<SysTest> listDay = sysTestService.listAll(time,endTime,null); String fileName = "空气质量月报.docx"; String time1 = DateUtils.dateToDateString(ksDate,"yyyy年MM月"); Long days = DateUtils.getQuotByDays(DateUtils.dateToDateString(listDay.get(0).getTime()),DateUtils.dateToDateString(listDay.get(listDay.size()-1).getTime())); Map<String,Object> map = resultWeekMap(listAll,time1,listDay,days.intValue()); downloadWord(fileName, map, response,"空气质量月报"+time1+".docx"); ksDate = DateUtils.addMonths(ksDate,1); } } public static void downloadWord(String fileName, Map<String, Object> params, HttpServletResponse response,String newFileName) { String path = getPath(fileName);//我这放 resources包下 try { //获取模板文档 OutputStream out = new FileOutputStream("E:\\home\\mon\\" + newFileName); 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(); //OutputStream out = response.getOutputStream(); word.write(out); out.flush(); out.close(); @@ -146,9 +242,272 @@ resultMap.put(name+"S", StringUtils.isNotEmpty(s.getSu())?s.getSu():"--"); } String bodyName = stringButterStr(listAll); //日报 String bodyName = stringButterStr(listAll); resultMap.put("主要内容",bodyName); return resultMap; } private Map<String,Object> resultWeekMap(List<SysTest> listAll,int week,String weekTime){ Map<String,Object> resultMap = new HashMap<>(); resultMap.put("周",week); resultMap.put("日期",weekTime); 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 = stringButterStrWeek(listAll); HashMap<String, Integer> datas = new HashMap<>(3); datas.put("一号",10); datas.put("二号",20); datas.put("三号",40); ImageEntity imageEntity = pieChart("测试",datas, 500, 300); resultMap.put("主要内容",imageEntity); return resultMap; } private Map<String,Object> resultWeekMap(List<SysTest> listAll,String weekTime,List<SysTest> listDay,int days){ Map<String,Object> resultMap = new HashMap<>(); resultMap.put("日期",weekTime); 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 = stringButterStrWeek(listAll); /*HashMap<String, Integer> datas = new HashMap<>(3); datas.put("一号",10); datas.put("二号",20); datas.put("三号",40); ImageEntity imageEntity = pieChart("测试",datas, 500, 300);*/ // resultMap.put("主要内容",imageEntity); resultMap.putAll(month(listDay,days+1)); return resultMap; } private Map<String,Object> month(List<SysTest> listDay, int days){ Map<String,Object> map = new HashMap<>(); map.put("沙优良",0); map.put("友优良",0); map.put("沙优",0); map.put("沙良",0); map.put("沙轻",0); map.put("沙中",0); map.put("沙重",0); map.put("沙严",0); map.put("友优",0); map.put("友良",0); map.put("友轻",0); map.put("友中",0); map.put("友重",0); map.put("友严",0); map.put("中优",0); map.put("中良",0); map.put("中轻",0); map.put("中中",0); map.put("中重",0); map.put("中严",0); Map<String,Integer> map1 = new HashMap<>(); Map<String,Integer> map11 = new HashMap<>(); Map<String,Integer> map111 = new HashMap<>(); Map<String,Integer> map2 = new HashMap<>(); Map<String,Integer> map22 = new HashMap<>(); Map<String,Integer> map222 = new HashMap<>(); List<Integer> list1 = Arrays.asList(0,0); List<Integer> list2 = Arrays.asList(0,0); List<Integer> list3 = Arrays.asList(0,0); String name = "沙"; String levelName = "优"; for(SysTest s : listDay){ if(s.getName().contains("友")){ name = "友"; }else if(s.getName().contains("中")){ name = "中"; }else { name = "沙"; } if(Double.parseDouble(s.getAqi()) <= 50){ levelName = "优"; }else if(Double.parseDouble(s.getAqi()) <= 100){ levelName = "良"; }else if(Double.parseDouble(s.getAqi()) <= 150){ levelName = "轻"; }else if(Double.parseDouble(s.getAqi()) <= 200){ levelName = "中"; }else if(Double.parseDouble(s.getAqi()) <= 300){ levelName = "重"; }else { levelName = "严"; } if(StringUtils.isNotEmpty(s.getSu()) && s.getName().contains("沙")){ s.setSu(s.getSu().equals("-")?"无":s.getSu()); if(map1.containsKey(s.getSu())){ map1.put(s.getSu(),map1.get(s.getSu())+1); }else { map1.put(s.getSu(),1); } } if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("友")){ s.setSu(s.getSu().equals("-")?"无":s.getSu()); if(map11.containsKey(s.getSu())){ map11.put(s.getSu(),map11.get(s.getSu())+1); }else { map11.put(s.getSu(),1); } } if(StringUtils.isNotEmpty(s.getSu())&&s.getName().contains("中")){ s.setSu(s.getSu().equals("-")?"无":s.getSu()); if(map111.containsKey(s.getSu())){ map111.put(s.getSu(),map111.get(s.getSu())+1); }else { map111.put(s.getSu(),1); } } if(Double.parseDouble(s.getAqi()) <= 100){ if(map.containsKey(name+"优良")){ map.put(name+"优良",Integer.parseInt(map.get(name+"优良").toString())+1); }else { map.put(name+"优良",1); } }else { if(map.containsKey(name+"污染")){ map.put(name+"污染",Integer.parseInt(map.get(name+"污染").toString())+1); }else { map.put(name+"污染",1); } if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("沙") && s.getSu().contains("PM2.5")){ list1.set(0,list1.get(0)+1); }else if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("沙") && s.getSu().contains("O3")){ list1.set(1,list1.get(1)+1); } if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("友") && s.getSu().contains("PM2.5")){ list2.set(0,list2.get(0)+1); }else if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("友") && s.getSu().contains("O3")){ list2.set(1,list2.get(1)+1); } if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("中") && s.getSu().contains("PM2.5")){ list3.set(0,list3.get(0)+1); }else if(StringUtils.isNotEmpty(s.getSu())&& s.getName().contains("中") && s.getSu().contains("O3")){ list3.set(1,list3.get(1)+1); } } if(map.containsKey(name+levelName)){ map.put(name+levelName,Integer.parseInt(map.get(name+levelName).toString())+1); }else { map.put(name+levelName,1); } String level = levelName; if(level.equals("轻")){ level = "轻度污染"; }else if(level.equals("中")){ level = "中度污染"; }else if(level.equals("重")){ level = "重度污染"; }else if(level.equals("严")){ level = "严重污染"; } if(s.getName().contains("沙")){ if(map2.containsKey(levelName)){ map2.put(levelName,map2.get(levelName)+1); }else { map2.put(levelName,1); } }else if(s.getName().contains("友")){ if(map22.containsKey(levelName)){ map22.put(levelName,map22.get(levelName)+1); }else { map22.put(levelName,1); } }else if(s.getName().contains("中")){ if(map222.containsKey(levelName)){ map222.put(levelName,map222.get(levelName)+1); }else { map222.put(levelName,1); } } } BigDecimal zb1 = BigDecimal.valueOf(Integer.parseInt(map.get("沙优良").toString())*100).divide(BigDecimal.valueOf(days),2,BigDecimal.ROUND_HALF_UP); map.put("沙优良占比",zb1.toString()+"%"); BigDecimal zb2 = BigDecimal.valueOf(Integer.parseInt(map.get("友优良").toString())*100).divide(BigDecimal.valueOf(days),2,BigDecimal.ROUND_HALF_UP); map.put("友优良占比",zb2.toString()+"%"); BigDecimal zb3 = BigDecimal.valueOf(Integer.parseInt(map.get("中优良").toString())*100).divide(BigDecimal.valueOf(days),2,BigDecimal.ROUND_HALF_UP); map.put("中优良占比",zb3.toString()+"%"); ImageEntity imageEntity2 = pieChart("空气质量等级占比分布图",map2, 500, 300); map.put("沙空气饼图",imageEntity2); ImageEntity imageEntity22 = pieChart("空气质量等级占比分布图",map22, 500, 300); map.put("友空气饼图",imageEntity22); ImageEntity imageEntity222 = pieChart("空气质量等级占比分布图",map222, 500, 300); map.put("中空气饼图",imageEntity222); ImageEntity imageEntity1 = pieChart("首要污染物占比分布图",map1, 500, 300); map.put("沙首污饼图",imageEntity1); ImageEntity imageEntity11 = pieChart("首要污染物占比分布图",map11, 500, 300); map.put("友首污饼图",imageEntity11); ImageEntity imageEntity111 = pieChart("首要污染物占比分布图",map111, 500, 300); map.put("中首污饼图",imageEntity111); StringBuffer buffer = new StringBuffer(); if(!list1.get(0).equals(0)){ BigDecimal num = BigDecimal.valueOf(list1.get(0)*100).divide(BigDecimal.valueOf(Integer.parseInt(map.get("沙污染").toString())),2,BigDecimal.ROUND_HALF_UP); buffer.append("PM2.5(占比"+num+"%),"); } if(!list1.get(1).equals(0)){ BigDecimal num = BigDecimal.valueOf(list1.get(1)*100).divide(BigDecimal.valueOf(Integer.parseInt(map.get("沙污染").toString())),2,BigDecimal.ROUND_HALF_UP); buffer.append("O3(占比"+num+"%),"); } map.put("沙污染占比",buffer.toString().length()>0?"首要污染物为"+buffer.toString():new StringBuffer()); StringBuffer buffer1 = new StringBuffer(); if(!list2.get(0) .equals(0)){ BigDecimal num = BigDecimal.valueOf(list2.get(0)*100).divide(BigDecimal.valueOf(Integer.parseInt(map.get("友污染").toString())),2,BigDecimal.ROUND_HALF_UP); buffer1.append("PM2.5(占比"+num+"%),"); } if(!list2.get(1) .equals(0)){ BigDecimal num = BigDecimal.valueOf(list2.get(1)*100).divide(BigDecimal.valueOf(Integer.parseInt(map.get("友污染").toString())),2,BigDecimal.ROUND_HALF_UP); buffer1.append("O3(占比"+num+"%),"); } map.put("友污染占比",buffer1.toString().length()>0?"首要污染物为"+buffer1.toString():new StringBuffer()); StringBuffer buffer2 = new StringBuffer(); if(!list3.get(0) .equals(0)){ BigDecimal num = BigDecimal.valueOf(list3.get(0)*100).divide(BigDecimal.valueOf(Integer.parseInt(map.get("中污染").toString())),2,BigDecimal.ROUND_HALF_UP); buffer2.append("PM2.5(占比"+num+"%),"); } if(!list3.get(1).equals(0)){ BigDecimal num = BigDecimal.valueOf(list3.get(1)*100).divide(BigDecimal.valueOf(Integer.parseInt(map.get("中污染").toString())),2,BigDecimal.ROUND_HALF_UP); buffer2.append("O3(占比"+num+"%),"); } map.put("中污染占比",buffer2.toString().length()>0?"首要污染物为"+buffer2.toString():new StringBuffer()); return map; } private String stringButterStr(List<SysTest> listAll){ @@ -279,7 +638,41 @@ } private String stringButterStrWeek(List<SysTest> listAll){ StringBuffer stringBuffer = new StringBuffer(); 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()); 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; @@ -338,8 +731,89 @@ return map; } private static String tempImgPath="E:\\home\\image\\tempJfree.jpg"; private static byte[] imgToByte(){ File file = new File(tempImgPath); byte[] buffer = null; try { FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); byte[] b = new byte[1000]; int n; while ((n = fis.read(b)) != -1) { bos.write(b, 0, n); } fis.close(); bos.close(); buffer = bos.toByteArray(); } catch (IOException e) { log.error(e.getMessage()); } //删除临时文件 //file.delete(); return buffer; } public ImageEntity pieChart(String title, Map<String, Integer> datas, int width, int height) { //创建主题样式 StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); //设置标题字体 standardChartTheme.setExtraLargeFont(new Font("宋体", Font.BOLD, 20)); //设置图例的字体 standardChartTheme.setRegularFont(new Font("宋体", Font.PLAIN, 15)); //设置轴向的字体 standardChartTheme.setLargeFont(new Font("宋体", Font.PLAIN, 15)); //设置主题样式 ChartFactory.setChartTheme(standardChartTheme); //根据jfree生成一个本地饼状图 DefaultPieDataset pds = new DefaultPieDataset(); datas.forEach(pds::setValue); //图标标题、数据集合、是否显示图例标识、是否显示tooltips、是否支持超链接 JFreeChart chart = ChartFactory.createPieChart(title, pds, true, false, false); //设置抗锯齿 chart.setTextAntiAlias(false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setNoDataMessage("暂无数据"); //忽略无值的分类 plot.setIgnoreNullValues(true); plot.setBackgroundAlpha(0f); //设置标签阴影颜色 plot.setShadowPaint(new Color(255,255,255)); //设置标签生成器(默认{0}) plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1})/{2}")); try { ChartUtils.saveChartAsJPEG(new File(tempImgPath), chart, width, height); } catch (IOException e1) { log.error("生成饼状图失败!"); } ImageEntity imageEntity = new ImageEntity(imgToByte(), width, height); Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!"); return imageEntity; } public static void main(String[] args) { String ks = "2020-06-01"; Date ksDate = DateUtils.convertDate(ks); for(int i = 0;i<37;i++){ Date jsDate = DateUtils.getLastDayOfCurrMonth(ksDate); System.out.println("开始:"+DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN)); System.out.println("结束:"+DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN)); ksDate = DateUtils.addMonths(ksDate,1); } /*String ks = "2020-06-22"; Date ksDate = DateUtils.convertDate(ks); for(int i = 0;i<157;i++){ Date jsDate = DateUtils.addDays(ksDate,6); System.out.println("开始:"+DateUtils.dateToDateString(ksDate,DateUtils.yyyy_MM_dd_EN)); System.out.println("结束:"+DateUtils.dateToDateString(jsDate,DateUtils.yyyy_MM_dd_EN)); ksDate = DateUtils.addDays(ksDate,7); }*/ } } screen-api/src/main/java/com/moral/api/controller/pubController.java
New file @@ -0,0 +1,40 @@ package com.moral.api.controller; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.moral.api.entity.CityConfigAqi; import com.moral.api.service.CityConfigAqiService; import com.moral.constant.ResultMessage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.List; /** * @ClassName pubController * @Description TODO * @Author @lizijie * @Date 2023-08-11 14:35 * @Version 1.0 */ @RestController @RequestMapping("/pub") @CrossOrigin(origins = "*", maxAge = 3600) @Api(tags = {"公共"}) public class pubController { @Autowired private CityConfigAqiService cityConfigAqiService; @GetMapping("cityAll") public ResultMessage airQualityBulletin(@RequestParam(required = false) @ApiParam(value = "regionCode",name = "城市code") String regionCode, @RequestParam(required = false) @ApiParam(value = "regionName",name = "城市名称") String regionName) { List<CityConfigAqi> list = cityConfigAqiService.listAll(regionCode,regionName); return ResultMessage.ok(list); } } screen-api/src/main/java/com/moral/api/dto/SysTestDTO.java
New file @@ -0,0 +1,47 @@ package com.moral.api.dto; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import lombok.EqualsAndHashCode; import java.util.Date; /** * @ClassName SysTestDTO * @Description TODO * @Author @lizijie * @Date 2023-08-02 17:22 * @Version 1.0 */ @Data @EqualsAndHashCode(callSuper = false) public class SysTestDTO { private static final long serialVersionUID = 1L; /*@ExcelProperty("月份") private String mon;*/ @ExcelProperty("名称") private String name; /* private String mac;*//**/ @ExcelProperty("时间") private Date time; @ExcelProperty("PM10") private String pm10; @ExcelProperty("PM2.5") private String pm25; @ExcelProperty("SO2") private String so2; @ExcelProperty("NO2") private String no2; @ExcelProperty("CO") private String co; @ExcelProperty("O3") private String o3; @ExcelProperty("TVOC") private String voc; @ExcelProperty("AQI") private String aqi; @ExcelProperty("首污") private String su; } screen-api/src/main/java/com/moral/api/entity/CityConfigAqi.java
New file @@ -0,0 +1,56 @@ package com.moral.api.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; /** * <p> * 城市配置表,用于从第三方接口获取数据 * </p> * * @author moral * @since 2023-08-11 */ @Data @EqualsAndHashCode(callSuper = false) public class CityConfigAqi extends Model<CityConfigAqi> { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 城市code */ private Integer cityCode; /** * 城市名字 */ private String cityName; /** * 从墨迹获取数据 */ private Integer cityId; /** * 逻辑删除,0:不删除;1:删除 */ private String isDelete; @Override protected Serializable pkVal() { return this.id; } } screen-api/src/main/java/com/moral/api/entity/SysTest.java
@@ -49,4 +49,7 @@ @TableField(exist = false) private String su; @TableField(exist = false) private String mon; } screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java
@@ -1,3 +1,4 @@ /* package com.moral.api.exception.consumer; @@ -27,9 +28,11 @@ import com.moral.constant.KafkaConstants; */ /* * 走航车数据消费者 * */ * *//* @Component @Slf4j @@ -118,3 +121,4 @@ } } */ screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java
@@ -1,3 +1,4 @@ /* package com.moral.api.exception.consumer; @@ -24,13 +25,15 @@ import java.util.concurrent.CopyOnWriteArraySet; */ /** * @ClassName SecondsDataConsumer1 * @Description TODO * @Author 陈凯裕 * @Date 2021/6/15 14:49 * @Version TODO **/ **//* @Component @Slf4j @@ -120,3 +123,4 @@ } */ screen-api/src/main/java/com/moral/api/mapper/CityConfigAqiMapper.java
New file @@ -0,0 +1,16 @@ package com.moral.api.mapper; import com.moral.api.entity.CityConfigAqi; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 城市配置表,用于从第三方接口获取数据 Mapper 接口 * </p> * * @author moral * @since 2023-08-11 */ public interface CityConfigAqiMapper extends BaseMapper<CityConfigAqi> { } screen-api/src/main/java/com/moral/api/service/CityAqiService.java
@@ -22,6 +22,8 @@ //臭氧实测和预测对比 List<Map<String, Object>> measuredCompareForecastOfO3(Map<String, Object> params); List<Map<String, Object>> measuredCompareForecastOfO3_8H(Map<String, Object> params); /** * @Description: 根据地区码查询aqi以及6参 * @Param: [regionCode] screen-api/src/main/java/com/moral/api/service/CityConfigAqiService.java
New file @@ -0,0 +1,19 @@ package com.moral.api.service; import com.moral.api.entity.CityConfigAqi; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** * <p> * 城市配置表,用于从第三方接口获取数据 服务类 * </p> * * @author moral * @since 2023-08-11 */ public interface CityConfigAqiService extends IService<CityConfigAqi> { List<CityConfigAqi> listAll(String regionCode,String regionName); } screen-api/src/main/java/com/moral/api/service/SysTestService.java
@@ -16,4 +16,7 @@ public interface SysTestService extends IService<SysTest> { List<SysTest> listAll(String startTime,String endTime ,String mac); List<SysTest> listAllAvg(String startTime,String endTime ,String mac); } screen-api/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java
@@ -1,5 +1,6 @@ package com.moral.api.service.impl; import com.alibaba.excel.util.StringUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -146,6 +147,34 @@ } return result; } @Override public List<Map<String, Object>> measuredCompareForecastOfO3_8H(Map<String, Object> params) { String regionCode = params.get("regionCode").toString(); String time = params.get("time").toString(); Date endTime = DateUtils.getDate(time+" "+"23:00:00",DateUtils.yyyy_MM_dd_HH_mm_ss_EN); Date startDate = DateUtils.getDate(time+" "+"00:00:00",DateUtils.yyyy_MM_dd_HH_mm_ss_EN); Date startTime = DateUtils.addHours(startDate,-7); //预测数据 QueryWrapper<Forecast> forecastQueryWrapper = new QueryWrapper<>(); forecastQueryWrapper.select("time", "value") .eq("city_code", regionCode) .between("time",startTime,endTime) .orderByAsc("time"); List<Map<String, Object>> forecastData = forecastMapper.selectMaps(forecastQueryWrapper); //实测数据 QueryWrapper<CityAqi> cityAqiQueryWrapper = new QueryWrapper<>(); cityAqiQueryWrapper.select("time", "value") .eq("city_code", regionCode) .between("time",startTime,endTime).orderByAsc("time"); List<Map<String, Object>> measuredData = cityAqiMapper.selectMaps(cityAqiQueryWrapper); List<Map<String, Object>> result = getO3_8H(forecastData,0,time); result.addAll(getO3_8H(measuredData,1,time)); return result; } @Override public Map<String, Object> queryCityAqiByRegionCode(Integer regionCode) { @@ -1386,4 +1415,40 @@ } return s; } public List<Map<String, Object>> getO3_8H(List<Map<String, Object>> data , int type,String day) { List<Map<String, Object>> list = new ArrayList<>(); for(int i = 0 ;i<=23;i++){ Map<String, Object> map = new HashMap<>(); if(type == 0){ map.put("type","预测"); }else { map.put("type","实测"); } String times = day+" "+i; Date endDate = DateUtils.getDate(times,DateUtils.yyyy_MM_dd_HH_EN); Date startDate = DateUtils.addHours(DateUtils.getDate(day+" "+i,DateUtils.yyyy_MM_dd_HH_EN),-7); List<Double> value = new ArrayList<>(); for(Map<String, Object> m : data){ Date time = (Date) m.get("time"); if(DateUtils.isTimeBeforE(time,startDate) && DateUtils.isTimeBeforE(endDate,time)){ Map<String, Object> sensorValue = JSONObject.parseObject((String) m.get("value"), Map.class); Double o3 = Double.parseDouble(sensorValue.get("O3").toString()); value.add(o3); } } if (value.size() < 6) { continue; } double average = value.stream().mapToDouble(aDouble -> aDouble).summaryStatistics().getAverage(); map.put("O3", new BigDecimal(average).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue()); map.put("time",times); list.add(map); } return list; } } screen-api/src/main/java/com/moral/api/service/impl/CityConfigAqiServiceImpl.java
New file @@ -0,0 +1,33 @@ package com.moral.api.service.impl; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.moral.api.entity.CityConfigAqi; import com.moral.api.mapper.CityConfigAqiMapper; import com.moral.api.service.CityConfigAqiService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 城市配置表,用于从第三方接口获取数据 服务实现类 * </p> * * @author moral * @since 2023-08-11 */ @Service public class CityConfigAqiServiceImpl extends ServiceImpl<CityConfigAqiMapper, CityConfigAqi> implements CityConfigAqiService { @Override public List<CityConfigAqi> listAll(String regionCode, String regionName) { LambdaQueryChainWrapper<CityConfigAqi> wrapper = lambdaQuery(); wrapper.eq(StringUtils.isNotEmpty(regionCode),CityConfigAqi::getCityCode,regionCode); wrapper.like(StringUtils.isNotEmpty(regionName),CityConfigAqi::getCityName,regionName); wrapper.eq(CityConfigAqi::getIsDelete,0); wrapper.orderByAsc(CityConfigAqi::getCityCode,CityConfigAqi::getCityId); return wrapper.list(); } } screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java
@@ -8,11 +8,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.moral.api.utils.AqiUtils; import com.moral.util.DateUtils; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; /** * <p> @@ -28,8 +29,11 @@ @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)); if(!StringUtils.isEmpty(startTime)&&!StringUtils.isEmpty(endTime)){ queryWrapper.between(!StringUtils.isEmpty(startTime)&&!StringUtils.isEmpty(endTime),"time",DateUtils.convertDate(startTime),DateUtils.convertDate(endTime)); }else if(!StringUtils.isEmpty(startTime)){ 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); @@ -47,4 +51,122 @@ } return listAll; } @Override public List<SysTest> listAllAvg(String startTime, String endTime, String mac) { Date time = DateUtils.convertDate(startTime); QueryWrapper<SysTest> queryWrapper = new QueryWrapper<>(); if(!StringUtils.isEmpty(startTime)&&!StringUtils.isEmpty(endTime)){ queryWrapper.between(!StringUtils.isEmpty(startTime)&&!StringUtils.isEmpty(endTime),"time",DateUtils.convertDate(startTime),DateUtils.convertDate(endTime)); }else if(!StringUtils.isEmpty(startTime)){ 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); return resultList(listAll,time); } private List<SysTest> resultList(List<SysTest> listAll,Date time){ List<SysTest> list = new ArrayList<>(); if(CollectionUtils.isEmpty(listAll)) { return list; } String mon = DateUtils.dateToDateString(time,DateUtils.yyyy_MM_EN); List<String> nameList = new ArrayList<>(); Map<String, ArrayList<Double>> map = new HashMap<>(); for(SysTest s : listAll) { if(nameList.size()<4 && !nameList.contains(s.getName())){ nameList.add(s.getName()); SysTest sysTest = new SysTest(); sysTest.setName(s.getName()); sysTest.setMon(mon); list.add(sysTest); } String pm10 = s.getName()+"_pm10"; ArrayList<Double> pm10D = Objects.nonNull(map.get(pm10))?map.get(pm10):new ArrayList<>(); pm10D.add(Double.parseDouble(s.getPm10())); map.put(pm10,pm10D); String pm25 = s.getName()+"_pm25"; ArrayList<Double> pm25D = Objects.nonNull(map.get(pm25))?map.get(pm25):new ArrayList<>(); pm25D.add(Double.parseDouble(s.getPm25())); map.put(pm25,pm25D); String o2 = s.getName()+"_o2"; ArrayList<Double> o2D = Objects.nonNull(map.get(o2))?map.get(o2):new ArrayList<>(); o2D.add(Double.parseDouble(s.getSo2())); map.put(o2,o2D); String no = s.getName()+"_no"; ArrayList<Double> noD = Objects.nonNull(map.get(no))?map.get(no):new ArrayList<>(); noD.add(Double.parseDouble(s.getNo2())); map.put(no,noD); String co = s.getName()+"_co"; ArrayList<Double> coD = Objects.nonNull(map.get(co))?map.get(co):new ArrayList<>(); coD.add(Double.parseDouble(s.getCo())); map.put(co,coD); String o3 = s.getName()+"_o3"; ArrayList<Double> o3D = Objects.nonNull(map.get(o3))?map.get(o3):new ArrayList<>(); o3D.add(Double.parseDouble(s.getO3())); map.put(o3,o3D); String tv = s.getName()+"_tv"; ArrayList<Double> tvD = Objects.nonNull(map.get(tv))?map.get(tv):new ArrayList<>(); tvD.add(Double.parseDouble(s.getVoc())); map.put(tv,tvD); } for(SysTest s : list){ String name = s.getName(); if(map.containsKey(name+"_pm10")){ Double ListAvg = map.get(name+"_pm10").stream().collect(Collectors.averagingDouble(Double::doubleValue)); double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); s.setPm10(String.valueOf(rsAvg)); } if(map.containsKey(name+"_pm25")){ Double ListAvg = map.get(name+"_pm25").stream().collect(Collectors.averagingDouble(Double::doubleValue)); double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); s.setPm25(String.valueOf(rsAvg)); } if(map.containsKey(name+"_o2")){ Double ListAvg = map.get(name+"_o2").stream().collect(Collectors.averagingDouble(Double::doubleValue)); double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); s.setSo2(String.valueOf(rsAvg)); } if(map.containsKey(name+"_no")){ Double ListAvg = map.get(name+"_no").stream().collect(Collectors.averagingDouble(Double::doubleValue)); double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); s.setNo2(String.valueOf(rsAvg)); } if(map.containsKey(name+"_tv")){ Double ListAvg = map.get(name+"_tv").stream().collect(Collectors.averagingDouble(Double::doubleValue)); double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); s.setVoc(String.valueOf(rsAvg)); } if(map.containsKey(name+"_co")){ double rsAvg = percentile(map.get(name+"_co"),95d); s.setCo(String.valueOf(rsAvg)); } if(map.containsKey(name+"_o3")){ double rsAvg = percentile(map.get(name+"_o3"),90d); s.setO3(String.valueOf(rsAvg)); } } return list; } private Double percentile(List<Double> date,double num){ Collections.sort(date); double position = (num / 100) * (date.size() - 1); int index = (int) position; // 获取小数部分的位置索引 double fraction = position - index; // 获取百分位值 double percentileValue = date.get(index) + fraction * (date.get(index + 1) - date.get(index)); return new BigDecimal(percentileValue).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); } } screen-api/src/main/resources/mapper/CityConfigAqiMapper.xml
New file @@ -0,0 +1,14 @@ <?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.CityConfigAqiMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.moral.api.entity.CityConfigAqi"> <id column="id" property="id" /> <result column="city_code" property="cityCode" /> <result column="city_name" property="cityName" /> <result column="city_id" property="cityId" /> <result column="is_delete" property="isDelete" /> </resultMap> </mapper> screen-api/src/main/resources/word/??????.docxBinary files differ
screen-api/src/main/resources/word/??????.docxBinary files differ
screen-common/src/main/java/com/moral/util/DateUtils.java
@@ -507,6 +507,14 @@ } } public static boolean isTimeBeforE(Date nows, Date date) { long hous = nows.getTime() - date.getTime(); if (hous >= 0) { return true; } else { return false; } } /** * 将小时数换算成返回以毫秒为单位的时间 * @@ -1064,6 +1072,14 @@ return getDate(dateToDateString(cal.getTime(), yyyy_MM_dd_EN)); } public static Date getLastDayOfCurrMonth(Date time) { Calendar cal = Calendar.getInstance(); cal.setTime(time); cal.add(Calendar.MONTH, 1); cal.set(Calendar.DAY_OF_MONTH, 0); return getDate(dateToDateString(cal.getTime(), yyyy_MM_dd_EN)); } /** * 根据日期追加的天数,得到一个新日期 *