From 4a64c0801f147536ed0a9d09977941f313a286ae Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Fri, 18 Aug 2023 16:19:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into wb
---
screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java | 5
screen-api/src/main/java/com/moral/api/dto/SysTestDTO.java | 47 +
screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java | 11
screen-api/src/main/java/com/moral/api/websocket/SingleDeviceServer.java | 6
screen-api/src/main/resources/word/空气质量周报.docx | 0
screen-api/src/main/java/com/moral/api/controller/AqiController.java | 32
screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java | 41
screen-api/src/main/java/com/moral/api/dto/MonitoringStationDTO.java | 45 +
screen-job/src/main/java/com/moral/api/controller/PubController.java | 62 +
screen-api/src/main/resources/mapper/CityConfigAqiMapper.xml | 14
screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java | 10
screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java | 45 +
screen-job/pom.xml | 11
screen-api/pom.xml | 25
screen-api/src/main/java/com/moral/api/controller/HistoryHourlyController.java | 7
screen-api/src/main/java/com/moral/api/service/MonitorPointService.java | 3
screen-api/src/main/java/com/moral/api/service/impl/CityConfigAqiServiceImpl.java | 33 +
screen-api/src/main/java/com/moral/api/config/websocket/WebSocketConfig.java | 4
screen-api/src/main/resources/application-dev.yml | 10
screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java | 3
screen-api/src/main/java/com/moral/api/service/CityAqiService.java | 2
screen-api/src/main/java/com/moral/api/service/HistoryHourlyService.java | 2
screen-job/src/main/java/com/moral/api/util/HttpUtils.java | 316 +++++++++
screen-api/src/main/java/com/moral/api/entity/CityConfigAqi.java | 56 +
screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml | 11
screen-api/src/main/java/com/moral/api/mapper/CityConfigAqiMapper.java | 16
screen-common/src/main/java/com/moral/util/DateUtils.java | 16
screen-job/src/main/java/com/moral/api/service/impl/ForecastServiceImpl.java | 14
screen-api/src/main/java/com/moral/api/service/SysTestService.java | 3
screen-api/src/main/java/com/moral/api/controller/SysTestController.java | 516 +++++++++++++++
screen-api/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java | 239 +++++++
screen-api/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java | 65 ++
screen-api/src/main/java/com/moral/api/service/CityConfigAqiService.java | 19
screen-api/src/main/java/com/moral/api/controller/pubController.java | 40 +
screen-api/src/main/resources/word/空气质量月报.docx | 0
screen-api/src/main/java/com/moral/api/entity/SysTest.java | 3
screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java | 132 +++
myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java | 4
screen-api/src/main/java/com/moral/api/pojo/vo/monitorPoint/MonitorPointsVO.java | 15
39 files changed, 1,774 insertions(+), 109 deletions(-)
diff --git a/myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java b/myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java
index 10e56d0..a64c9bf 100644
--- a/myBatisPlusGenerator/src/main/java/com/moral/CodeGenerator.java
+++ b/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");
diff --git a/screen-api/pom.xml b/screen-api/pom.xml
index 70f3c4b..d55d642 100644
--- a/screen-api/pom.xml
+++ b/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>
diff --git a/screen-api/src/main/java/com/moral/api/config/websocket/WebSocketConfig.java b/screen-api/src/main/java/com/moral/api/config/websocket/WebSocketConfig.java
index 9189321..fc13249 100644
--- a/screen-api/src/main/java/com/moral/api/config/websocket/WebSocketConfig.java
+++ b/screen-api/src/main/java/com/moral/api/config/websocket/WebSocketConfig.java
@@ -1,7 +1,7 @@
package com.moral.api.config.websocket;
import com.moral.api.websocket.CruiserWebSocketServer;
-import com.moral.api.websocket.SingleDeviceServer;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -25,7 +25,7 @@
@Autowired
public void setMessageService(RedisTemplate redisTemplate){
- SingleDeviceServer.redisTemplate = redisTemplate;
+ // SingleDeviceServer.redisTemplate = redisTemplate;
CruiserWebSocketServer.redisTemplate = redisTemplate;
}
diff --git a/screen-api/src/main/java/com/moral/api/controller/AqiController.java b/screen-api/src/main/java/com/moral/api/controller/AqiController.java
index 2cc538b..c5180e8 100644
--- a/screen-api/src/main/java/com/moral/api/controller/AqiController.java
+++ b/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]
diff --git a/screen-api/src/main/java/com/moral/api/controller/HistoryHourlyController.java b/screen-api/src/main/java/com/moral/api/controller/HistoryHourlyController.java
index d0b826f..bcccc46 100644
--- a/screen-api/src/main/java/com/moral/api/controller/HistoryHourlyController.java
+++ b/screen-api/src/main/java/com/moral/api/controller/HistoryHourlyController.java
@@ -124,4 +124,11 @@
}
+ @RequestMapping(value = "historyHourlyTest", method = RequestMethod.GET)
+ public ResultMessage historyHourlyTest(){
+ historyHourlyService.historyHourly();
+ return ResultMessage.ok();
+ }
+
+
}
diff --git a/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java b/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java
index 96b0729..f796ba8 100644
--- a/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java
+++ b/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java
@@ -1,5 +1,6 @@
package com.moral.api.controller;
+import com.moral.api.dto.MonitoringStationDTO;
import com.moral.api.entity.MonitorPoint;
import com.moral.api.pojo.form.device.MonitorPointQueryForm;
import com.moral.api.pojo.vo.monitorPoint.MonitorPointsVO;
@@ -11,20 +12,13 @@
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 io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
-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.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@@ -62,7 +56,22 @@
List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(form);
//������������������
- MonitorPointsVO vo = MonitorPointsVO.convert(monitorPoints);
+ MonitorPointsVO vo = MonitorPointsVO.convert(monitorPoints,false);
+
+ return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo);
+ }
+
+ @GetMapping("queryMonitorPointsState")
+ public ResultMessage queryMonitorPointsState(MonitorPointQueryForm form) {
+ //������������������������
+ if (!form.valid())
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
+ ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ //������������������
+ List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(form);
+
+ //������������������
+ MonitorPointsVO vo = MonitorPointsVO.convert(monitorPoints,true);
return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo);
}
@@ -189,4 +198,14 @@
}
}
+ @PostMapping("listMonitoring")
+ public ResultMessage listMonitoring(@RequestBody Map<String, Object> params) {
+
+ /*@RequestParam @ApiParam(value = "mac",name = "mac���") List<String> mac,
+ @RequestParam @ApiParam(value = "startTime",name = "������������") String startTime,
+ @RequestParam @ApiParam(value = "reportType",name = "type") int reportType,
+ @RequestParam @ApiParam(value = "endTime",name = "������������") String endTime*/
+ List<MonitoringStationDTO> resList = monitorPointService.listMonitoringStationDTO(params,Integer.parseInt(params.get("reportType").toString()),params.get("startTime").toString(),params.get("endTime").toString());
+ return ResultMessage.ok(resList);
+ }
}
diff --git a/screen-api/src/main/java/com/moral/api/controller/SysTestController.java b/screen-api/src/main/java/com/moral/api/controller/SysTestController.java
index 36f131a..de0360f 100644
--- a/screen-api/src/main/java/com/moral/api/controller/SysTestController.java
+++ b/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);
+ }*/
+
+
+ }
}
diff --git a/screen-api/src/main/java/com/moral/api/controller/pubController.java b/screen-api/src/main/java/com/moral/api/controller/pubController.java
new file mode 100644
index 0000000..82ea0ea
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/controller/pubController.java
@@ -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);
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/dto/MonitoringStationDTO.java b/screen-api/src/main/java/com/moral/api/dto/MonitoringStationDTO.java
new file mode 100644
index 0000000..54dc8be
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/dto/MonitoringStationDTO.java
@@ -0,0 +1,45 @@
+package com.moral.api.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+/**
+ * @ClassName monitoringStationDTO
+ * @Description TODO
+ * @Author @lizijie
+ * @Date 2023-08-18 8:24
+ * @Version 1.0
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class MonitoringStationDTO {
+
+ private String name;
+
+ private String mac;
+
+ private BigDecimal PM25;
+
+ private int PM25Num;
+
+ private BigDecimal O3;
+
+ private int O3Num;
+ private BigDecimal Tovc;
+
+ private int TOVCNum;
+
+ private BigDecimal Composite;
+
+ private int CompositeNum;
+
+ private BigDecimal SO2;
+
+ private BigDecimal NO2;
+
+ private BigDecimal PM10;
+
+ private BigDecimal CO;
+}
diff --git a/screen-api/src/main/java/com/moral/api/dto/SysTestDTO.java b/screen-api/src/main/java/com/moral/api/dto/SysTestDTO.java
new file mode 100644
index 0000000..61f2023
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/dto/SysTestDTO.java
@@ -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;
+}
diff --git a/screen-api/src/main/java/com/moral/api/entity/CityConfigAqi.java b/screen-api/src/main/java/com/moral/api/entity/CityConfigAqi.java
new file mode 100644
index 0000000..d312396
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/entity/CityConfigAqi.java
@@ -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;
+ }
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/entity/SysTest.java b/screen-api/src/main/java/com/moral/api/entity/SysTest.java
index b8b4590..3f2ee0e 100644
--- a/screen-api/src/main/java/com/moral/api/entity/SysTest.java
+++ b/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;
+
}
diff --git a/screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java b/screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java
index 5f392d9..16e3944 100644
--- a/screen-api/src/main/java/com/moral/api/exception/consumer/CruiserDataConsumer.java
+++ b/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 @@
}
}
+*/
diff --git a/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java b/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java
index d266d21..ba639bd 100644
--- a/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java
+++ b/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,18 @@
import java.util.concurrent.CopyOnWriteArraySet;
-/**
+*/
+/*
+*
* @ClassName SecondsDataConsumer1
* @Description TODO
* @Author ���������
* @Date 2021/6/15 14:49
* @Version TODO
- **/
+ *
+*//*
+
+
@Component
@Slf4j
@@ -120,3 +126,4 @@
}
+*/
diff --git a/screen-api/src/main/java/com/moral/api/mapper/CityConfigAqiMapper.java b/screen-api/src/main/java/com/moral/api/mapper/CityConfigAqiMapper.java
new file mode 100644
index 0000000..ddd8c03
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/mapper/CityConfigAqiMapper.java
@@ -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> {
+
+}
diff --git a/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java b/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
index 24e4dbd..6384a47 100644
--- a/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
+++ b/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
@@ -39,4 +39,7 @@
//
//
// Map<String,Object> getDataByMac(@Param("mac") String mac,@Param("time") String time,@Param("yearAndMonth") String yearAndMonth);
+ void insertHistoryHourly(Map<String, Object> params);
+
+ void updateHistoryHourly(Map<String, Object> params);
}
diff --git a/screen-api/src/main/java/com/moral/api/pojo/vo/monitorPoint/MonitorPointsVO.java b/screen-api/src/main/java/com/moral/api/pojo/vo/monitorPoint/MonitorPointsVO.java
index fd1d4bc..d54852a 100644
--- a/screen-api/src/main/java/com/moral/api/pojo/vo/monitorPoint/MonitorPointsVO.java
+++ b/screen-api/src/main/java/com/moral/api/pojo/vo/monitorPoint/MonitorPointsVO.java
@@ -7,6 +7,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
* @ClassName MonitorPointsVO
@@ -20,7 +21,7 @@
private List<MonitorPointVO> monitorPoints;
- public static MonitorPointsVO convert(List<MonitorPoint> monitorPoints){
+ public static MonitorPointsVO convert(List<MonitorPoint> monitorPoints,boolean type){
MonitorPointsVO monitorPointsVO = new MonitorPointsVO();
List<MonitorPointVO> monitorPointVOS = new ArrayList<>();
for (MonitorPoint monitorPoint : monitorPoints) {
@@ -31,14 +32,22 @@
DeviceVO deviceVO = deviceConvert(device);
deviceVOS.add(deviceVO);
}
+ List<Device> resultState = devices.stream().filter(it->!it.getState().equals("0")).collect(Collectors.toList());
monitorPointVO.setId(monitorPoint.getId());
- monitorPointVO.setName(monitorPoint.getName());
+ StringBuffer stringBuffer = new StringBuffer(monitorPoint.getName());
+ if(type){
+ stringBuffer.append("(");
+ stringBuffer.append("������:").append(resultState.size()+"���;");
+ stringBuffer.append("���:").append(devices.size()+"���");
+ stringBuffer.append(")");
+ }
+ monitorPointVO.setName(stringBuffer.toString());
monitorPointVO.setLatitude(monitorPoint.getLatitude());
monitorPointVO.setLongitude(monitorPoint.getLongitude());
monitorPointVO.setDevices(deviceVOS);
monitorPointVOS.add(monitorPointVO);
}
- monitorPointsVO.setMonitorPoints(monitorPointVOS);
+ monitorPointsVO.setMonitorPoints(monitorPointVOS);
return monitorPointsVO;
}
diff --git a/screen-api/src/main/java/com/moral/api/service/CityAqiService.java b/screen-api/src/main/java/com/moral/api/service/CityAqiService.java
index 9b3d460..a79a893 100644
--- a/screen-api/src/main/java/com/moral/api/service/CityAqiService.java
+++ b/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]
diff --git a/screen-api/src/main/java/com/moral/api/service/CityConfigAqiService.java b/screen-api/src/main/java/com/moral/api/service/CityConfigAqiService.java
new file mode 100644
index 0000000..1bdc933
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/service/CityConfigAqiService.java
@@ -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);
+}
diff --git a/screen-api/src/main/java/com/moral/api/service/HistoryHourlyService.java b/screen-api/src/main/java/com/moral/api/service/HistoryHourlyService.java
index 22e5ca4..b13c340 100644
--- a/screen-api/src/main/java/com/moral/api/service/HistoryHourlyService.java
+++ b/screen-api/src/main/java/com/moral/api/service/HistoryHourlyService.java
@@ -122,4 +122,6 @@
*/
Double calculatedValue(List<HistoryHourly> list, String sensorCode, String type, Double lower, Double upper);
+
+ boolean historyHourly();
}
diff --git a/screen-api/src/main/java/com/moral/api/service/MonitorPointService.java b/screen-api/src/main/java/com/moral/api/service/MonitorPointService.java
index 9dd3484..69bfe79 100644
--- a/screen-api/src/main/java/com/moral/api/service/MonitorPointService.java
+++ b/screen-api/src/main/java/com/moral/api/service/MonitorPointService.java
@@ -1,6 +1,6 @@
package com.moral.api.service;
-import com.alibaba.fastjson.JSONObject;
+import com.moral.api.dto.MonitoringStationDTO;
import com.moral.api.entity.MonitorPoint;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.pojo.form.device.MonitorPointQueryForm;
@@ -52,6 +52,7 @@
*/
List<Map<String, Object>> getHourlyDataDataV3Excel(Map<String, Object> params);
+ List<MonitoringStationDTO> listMonitoringStationDTO(Map<String, Object> params, int reportType, String startTime, String endTime);
}
diff --git a/screen-api/src/main/java/com/moral/api/service/SysTestService.java b/screen-api/src/main/java/com/moral/api/service/SysTestService.java
index c6ea4db..f78549e 100644
--- a/screen-api/src/main/java/com/moral/api/service/SysTestService.java
+++ b/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);
}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java
index 68f32c2..10d5f6d 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java
+++ b/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;
+
+ }
+
}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/CityConfigAqiServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/CityConfigAqiServiceImpl.java
new file mode 100644
index 0000000..2eea048
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/service/impl/CityConfigAqiServiceImpl.java
@@ -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();
+ }
+}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
index f2a4445..1540f3d 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -1,5 +1,7 @@
package com.moral.api.service.impl;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.moral.api.entity.*;
import com.moral.api.mapper.ServicesScopeDeviceMapper;
import com.moral.api.mapper.ServicesScopeMapper;
@@ -9,14 +11,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.OptionalDouble;
+import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
@@ -877,4 +872,38 @@
// return historyHourlyMapper.getDataByMac(mac,time,yearAndMonth);
// }
+
+ @Override
+ public boolean historyHourly() {
+
+ String time = "2023-08-17 09:00:00";
+ String table = "202308";
+ String timeEnd = "2023-08-17 14:00:00";
+ String tableEnd = "202308";
+ List<String> macList = Arrays.asList("p5dnd7a0245406","p5dnd7a0245427","p5dnd7a0245412","p5dnd7a0245400","p5dnd7a0245472","p5dnd7a0245384","p5dnd7a0245374","p5dnd7a0245401","p5dnd7a0245423","p5dnd7a0245438","p5dnd7a0245363","p5dnd7a0245375","p5dnd7a0245444","p5dnd7a0245437","p5dnd7a0245367","p5dnd7a0245392","p5dnd7a0245471","p5dnd7a0245433","p5dnd7a0245361","p5dnd7a0245362","p5dnd7a0245436","p5dnd7a0245373","p5dnd7a0245370","p5dnd7a0245357","p5dnd7a0245434","p5dnd7a0245353","p5dnd7a0245381","p5dnd7a0245421","p5dnd7a0245399","p5dnd7a0245409","p5dnd7a0245422","p5dnd7a0245470","p5dnd7a0245359","p5dnd7a0245393","p5dnd7a0245371","p5dnd7a0245382","p5dnd7a0245385","p5dnd7a0245443","p5dnd7a0245424","p5dnd7a0245369","p5dnd7a0245389","p5dnd7a0245391","p5dnd7a0245356","p5dnd7a0245396","p5dnd7a0243567","p5dnd7a0243568");
+ List<Map<String,Object>> listMap = historyHourlyMapper.selectDataByMacsAndTime(table, macList, time);
+ for (Map historyHourlyData : listMap) {
+ String mac = historyHourlyData.get("mac").toString();
+ Map<String, Object> data = JSON.parseObject(historyHourlyData.get("value").toString(), Map.class);
+ Map<String, Object> dataResult = new HashMap<>();
+ dataResult = data;
+ //a34004:pm2.5 a34002:pm10 a05024:O3 a21005:CO a21026:So2 a21004:NO2 a99054:tovc
+ dataResult.put("a34004",Double.parseDouble(data.get("a34004").toString())-10);
+ dataResult.put("a34002",Double.parseDouble(data.get("a34002").toString())-10);
+ dataResult.put("a05024",Double.parseDouble(data.get("a05024").toString())+20);
+ //dataResult.put("a21005",Double.parseDouble(data.get("a21005").toString())-35);
+ dataResult.put("a21026",Double.parseDouble(data.get("a21026").toString())-3);
+ dataResult.put("a21004",Double.parseDouble(data.get("a21004").toString())-2);
+ dataResult.put("a99054",Double.parseDouble(data.get("a99054").toString())+0.1);
+ Map<String, Object> map = new HashMap<>();
+ map.put("timeUnits",tableEnd);
+ map.put("time",timeEnd);
+ map.put("value",JSONObject.toJSONString(dataResult));
+ map.put("version","35");
+ map.put("mac",mac);
+ // historyHourlyMapper.insertHistoryHourly(map);
+ historyHourlyMapper.updateHistoryHourly(map);
+ }
+ return true;
+ }
}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java
index 8a068b7..da9ea5e 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java
@@ -1,11 +1,9 @@
package com.moral.api.service.impl;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.moral.api.dto.MonitoringStationDTO;
import com.moral.api.entity.*;
import com.moral.api.mapper.DeviceMapper;
import com.moral.api.mapper.HistoryMonthlyMapper;
@@ -20,14 +18,15 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.service.OrganizationService;
import com.moral.constant.Constants;
+import com.moral.util.ComprehensiveIndexUtils;
import com.moral.util.DateUtils;
import com.moral.util.RegionCodeUtils;
+import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import springfox.documentation.schema.Entry;
-import java.lang.reflect.Type;
import java.math.BigDecimal;
-import java.text.DateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -482,9 +481,232 @@
}
return resultList;
}
+ @Override
+ public List<MonitoringStationDTO> listMonitoringStationDTO(Map<String, Object> params, int reportType, String startTime, String endTime) {
+ // List<String> macs = Arrays.asList(mac.split(","));
+ List<String> macs = (List<String>) params.remove("mac");
+ List<MonitoringStationDTO> resultList = new ArrayList<>();
+
+ if(reportType == 1||reportType == 4){
+ Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_EN);
+ Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_EN);
+ List<HistoryDaily> historyDailyByMacAndTimeSlot = historyDailyService.getHistoryDailyByMacAndTimeSlot(macs, startDate, endDate);
+ resultList = resultList(historyDailyByMacAndTimeSlot);
+ }else if(reportType == 2){
+ Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_EN);
+ Date endDate = DateUtils.addDays(startDate,6);
+ List<HistoryDaily> historyDailyByMacAndTimeSlot = historyDailyService.getHistoryDailyByMacAndTimeSlot(macs, startDate, endDate);
+ resultList = resultList(historyDailyByMacAndTimeSlot);
+ }else if(reportType == 3){
+ Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_EN);
+ Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_EN);
+ QueryWrapper<HistoryMonthly> HistoryMonthlyWrapper = new QueryWrapper<>();
+ HistoryMonthlyWrapper.in("mac",macs);
+ HistoryMonthlyWrapper.between("time",startDate,endDate);
+ List<HistoryMonthly> historyMonthlyList = historyMonthlyMapper.selectList(HistoryMonthlyWrapper);
+ List<HistoryDaily> historyDailies = new ArrayList<>();
+ for(HistoryMonthly h : historyMonthlyList) {
+ HistoryDaily historyDaily = new HistoryDaily();
+ historyDaily.setMac(h.getMac());
+ historyDaily.setTime(h.getTime());
+ historyDaily.setValue(h.getValue());
+ historyDailies.add(historyDaily);
+ }
+ resultList = resultList(historyDailies);
+ }
+ return resultList;
+ }
- private Map<String,Map<String,Object>> resultMap(List<HistoryDaily> list ,List<HistoryMonthly> historyMonthlyList){
+ private List<MonitoringStationDTO> resultList(List<HistoryDaily> historyDailyByMacAndTimeSlot){
+ List<MonitoringStationDTO> list = new ArrayList<>();
+ if(CollectionUtils.isEmpty(historyDailyByMacAndTimeSlot)){
+ return list;
+ }
+ Map<String,Map<String,ArrayList<Double>>> resultMap = new HashMap<>();
+ int zz = 0;
+ for(HistoryDaily h : historyDailyByMacAndTimeSlot) {
+ JSONObject jsonObject = JSONObject.parseObject(h.getValue());
+ Map<String, Object> map = jsonObject.getInnerMap();
+ Map<String,ArrayList<Double>> maps = Objects.nonNull(resultMap.get(h.getMac()))?resultMap.get(h.getMac()):new HashMap<>();
+ if(Objects.nonNull(map.get("a34004"))){
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("PM2_5"))?maps.get("PM2_5"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a34004").toString()));
+ maps.put("PM2_5",numResult);
+ }
+ if(Objects.nonNull(map.get("a05024"))){
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("O3"))?maps.get("O3"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a05024").toString()));
+ maps.put("O3",numResult);
+ }
+ if(Objects.nonNull(map.get("a34002"))){
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("PM10"))?maps.get("PM10"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a34002").toString()));
+ maps.put("PM10",numResult);
+ }
+ if(Objects.nonNull(map.get("a21026"))){
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("SO2"))?maps.get("SO2"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a21026").toString()));
+ maps.put("SO2",numResult);
+ }
+ if(Objects.nonNull(map.get("a21004"))){
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("NO2"))?maps.get("NO2"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a21004").toString()));
+ maps.put("NO2",numResult);
+ }
+ if(Objects.nonNull(map.get("a21005"))){
+ System.out.println(">>>"+map.toString());
+ System.out.println(">>>"+map.get("a21005").toString());
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("CO"))?maps.get("CO"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a21005").toString()));
+ maps.put("CO",numResult);
+ }
+ if(Objects.nonNull(map.get("a99054"))){
+ ArrayList<Double> numResult = Objects.nonNull(maps.get("TVOC"))?maps.get("TVOC"):new ArrayList<>();
+ numResult.add(Double.parseDouble(map.get("a99054").toString()));
+ maps.put("TVOC",numResult);
+ }
+ resultMap.put(h.getMac(),maps);
+ zz++;
+ }
+ for(Map.Entry entry : resultMap.entrySet()){
+ String mapKey = (String) entry.getKey();
+ Map<String,ArrayList<Double>> mapValue = (Map<String,ArrayList<Double>>)entry.getValue();
+ Map<String, Object> data = new HashMap<>();
+ if(mapValue.containsKey("PM2_5")){
+ Double ListAvg = mapValue.get("PM2_5").stream().collect(Collectors.averagingDouble(Double::doubleValue));
+ double rsAvg = new BigDecimal(ListAvg).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("PM2_5",rsAvg);
+ }else {
+ data.put("PM2_5",0);
+ }
+ if(mapValue.containsKey("PM10")){
+ Double ListAvg = mapValue.get("PM10").stream().collect(Collectors.averagingDouble(Double::doubleValue));
+ double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("PM10",rsAvg);
+ }else {
+ data.put("PM10",0);
+ }
+ if(mapValue.containsKey("SO2")){
+ Double ListAvg = mapValue.get("SO2").stream().collect(Collectors.averagingDouble(Double::doubleValue));
+ double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("SO2",rsAvg);
+ }else {
+ data.put("SO2",0);
+ }
+ if(mapValue.containsKey("NO2")){
+ Double ListAvg = mapValue.get("NO2").stream().collect(Collectors.averagingDouble(Double::doubleValue));
+ double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("NO2",rsAvg);
+ }else {
+ data.put("NO2",0);
+ }
+ if(mapValue.containsKey("CO")){
+ Double ListAvg = percentile(mapValue.get("CO"),95d);
+ double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("CO",rsAvg);
+ }else {
+ data.put("CO",0);
+ }
+ if(mapValue.containsKey("O3")){
+ Double ListAvg = percentile(mapValue.get("O3"),90d);
+ double rsAvg = new BigDecimal(ListAvg).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("O3",rsAvg);
+ }else {
+ data.put("O3",0);
+ }
+ if(mapValue.containsKey("TVOC")){
+ Double ListAvg = mapValue.get("TVOC").stream().collect(Collectors.averagingDouble(Double::doubleValue));
+ double rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+ data.put("TVOC",rsAvg);
+ }else {
+ data.put("TVOC",0);
+ }
+ Double resultNum = ComprehensiveIndexUtils.dailyData(data);
+ MonitoringStationDTO monitoringStationDTO = new MonitoringStationDTO();
+ monitoringStationDTO.setPM25(BigDecimal.valueOf(Double.parseDouble(data.get("PM2_5").toString())));
+ monitoringStationDTO.setO3(BigDecimal.valueOf(Double.parseDouble(data.get("O3").toString())));
+ monitoringStationDTO.setTovc(BigDecimal.valueOf(Double.parseDouble(data.get("TVOC").toString())));
+ monitoringStationDTO.setComposite(BigDecimal.valueOf(resultNum));
+ monitoringStationDTO.setMac(mapKey);
+ list.add(monitoringStationDTO);
+ }
+ List<MonitoringStationDTO> compositeList = fun3(list,1);
+ List<MonitoringStationDTO> pM25List = fun3(list,2);
+ List<MonitoringStationDTO> o3List = fun3(list,3);
+ List<MonitoringStationDTO> tovcList = fun3(list,4);
+ List<MonitoringStationDTO> resultList = new ArrayList<>();
+ LambdaQueryChainWrapper<Device> wrapper = deviceService.lambdaQuery();
+ wrapper.eq(Device::getIsDelete,0);
+ Map<String,String> deviceMap = new HashMap<>();
+ wrapper.list().forEach(it->deviceMap.put(it.getMac(),it.getName()));
+ int num = 1;
+ for (MonitoringStationDTO m :compositeList ){
+ MonitoringStationDTO monit = new MonitoringStationDTO();
+ String mac = m.getMac();
+ monit.setMac(mac);
+ monit.setName(deviceMap.get(mac));
+ monit.setComposite(m.getComposite());
+ monit.setCompositeNum(m.getCompositeNum());
+ List<String> listPM25 = pM25List.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList());
+ List<String> listO3 = o3List.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList());
+ List<String> listTovc = tovcList.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList());
+ monit.setO3(o3List.get(listO3.indexOf(mac)).getO3());
+ monit.setO3Num(o3List.get(listO3.indexOf(mac)).getO3Num());
+ monit.setPM25(pM25List.get(listPM25.indexOf(mac)).getPM25());
+ monit.setPM25Num(pM25List.get(listPM25.indexOf(mac)).getPM25Num());
+ monit.setTovc(tovcList.get(listTovc.indexOf(mac)).getTovc());
+ monit.setTOVCNum(tovcList.get(listTovc.indexOf(mac)).getTOVCNum());
+ //num++;
+ resultList.add(monit);
+ }
+ return resultList;
+ }
+
+ public List<MonitoringStationDTO> fun3(List<MonitoringStationDTO> monList,int type) {
+ List<MonitoringStationDTO> resultList = new ArrayList<>();
+ List<MonitoringStationDTO> compositeList = new ArrayList<>();
+ Map<BigDecimal,List<MonitoringStationDTO>> map1 = new HashMap<>();
+ if(type == 1){
+ compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getComposite)).collect(Collectors.toList());
+ map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getComposite,LinkedHashMap::new,Collectors.toList()));
+ }else if(type == 2){
+ compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getPM25)).collect(Collectors.toList());
+ map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getPM25,LinkedHashMap::new,Collectors.toList()));
+ }else if(type == 3){
+ compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getO3)).collect(Collectors.toList());
+ map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getO3,LinkedHashMap::new,Collectors.toList()));
+ }else if(type == 4){
+ compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getTovc)).collect(Collectors.toList());
+ map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getTovc,LinkedHashMap::new,Collectors.toList()));
+ }
+ int index = 1;
+ for (Map.Entry entry : map1.entrySet()) {
+ List<MonitoringStationDTO> mapValue = (List<MonitoringStationDTO>)entry.getValue();
+ for(MonitoringStationDTO m : mapValue){
+ MonitoringStationDTO stationDTO = new MonitoringStationDTO();
+ stationDTO.setMac(m.getMac());
+ if(type == 1){
+ stationDTO.setComposite(m.getComposite());
+ stationDTO.setCompositeNum(index);
+ }else if(type == 2){
+ stationDTO.setPM25(m.getPM25());
+ stationDTO.setPM25Num(index);
+ }else if(type == 3){
+ stationDTO.setO3(m.getO3());
+ stationDTO.setO3Num(index);
+ }else if(type == 4){
+ stationDTO.setTovc(m.getTovc());
+ stationDTO.setTOVCNum(index);
+ }
+ resultList.add(stationDTO);
+ }
+ index = index +mapValue.size();
+ }
+ return resultList;
+ }
+
+ private Map<String,Map<String,Object>> resultMap(List<HistoryDaily> list , List<HistoryMonthly> historyMonthlyList){
Map<String,Map<String,Object>> map = new HashMap<>();
for(HistoryDaily h : list){
String dateStr = DateUtils.dateToDateString( h.getTime(), "yyyy-MM-dd")+"_"+h.getMac();
@@ -533,6 +755,9 @@
return map;
}
private Double percentile(List<Double> date,double num){
+ if(CollectionUtils.isNotEmpty(date)&&date.size() == 1){
+ return date.get(0);
+ }
Collections.sort(date);
double position = (num / 100) * (date.size() - 1);
int index = (int) position;
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java
index 31e1e8c..c3dc5a8 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/SysTestServiceImpl.java
+++ b/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();
+ }
}
diff --git a/screen-api/src/main/java/com/moral/api/websocket/SingleDeviceServer.java b/screen-api/src/main/java/com/moral/api/websocket/SingleDeviceServer.java
index d8e7cc7..afc907f 100644
--- a/screen-api/src/main/java/com/moral/api/websocket/SingleDeviceServer.java
+++ b/screen-api/src/main/java/com/moral/api/websocket/SingleDeviceServer.java
@@ -1,3 +1,4 @@
+/*
package com.moral.api.websocket;
import com.moral.api.entity.Device;
@@ -18,13 +19,15 @@
import java.util.Map;
import java.util.concurrent.CopyOnWriteArraySet;
+*/
/**
* @ClassName SingleDeviceServer
* @Description TODO
* @Author ���������
* @Date 2021/6/15 13:56
* @Version TODO
- **/
+ **//*
+
@ServerEndpoint("/singleDevice/{mac}")
@Component
@Data
@@ -92,3 +95,4 @@
}
}
+*/
diff --git a/screen-api/src/main/resources/application-dev.yml b/screen-api/src/main/resources/application-dev.yml
index e8df1b7..606db00 100644
--- a/screen-api/src/main/resources/application-dev.yml
+++ b/screen-api/src/main/resources/application-dev.yml
@@ -1,15 +1,5 @@
server:
port: 8081
- tomcat:
- uri-encoding: UTF-8
- #���������������
- min-spare-threads: 500
- #���������������
- max-threads: 2500
- #���������������
- max-connections: 6500
- #������������������������
- accept-count: 1000
spring:
profiles:
active: dev
diff --git a/screen-api/src/main/resources/mapper/CityConfigAqiMapper.xml b/screen-api/src/main/resources/mapper/CityConfigAqiMapper.xml
new file mode 100644
index 0000000..6fa2eab
--- /dev/null
+++ b/screen-api/src/main/resources/mapper/CityConfigAqiMapper.xml
@@ -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>
\ No newline at end of file
diff --git a/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml b/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
index ab17e79..b707ec4 100644
--- a/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
+++ b/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -75,4 +75,15 @@
where mac = #{mac}
and time =#{time}
</select>
+
+ <insert id="insertHistoryHourly">
+ INSERT INTO history_hourly_${timeUnits}
+ VALUES (#{mac}, #{time}, #{value}, #{version})
+ </insert>
+
+
+ <insert id="updateHistoryHourly">
+ UPDATE history_hourly_${timeUnits} SET `value` = #{value}
+ where mac = #{mac} and time = #{time} and version = #{version}
+ </insert>
</mapper>
\ No newline at end of file
diff --git "a/screen-api/src/main/resources/word/\347\251\272\346\260\224\350\264\250\351\207\217\345\221\250\346\212\245.docx" "b/screen-api/src/main/resources/word/\347\251\272\346\260\224\350\264\250\351\207\217\345\221\250\346\212\245.docx"
new file mode 100644
index 0000000..5a97ee9
--- /dev/null
+++ "b/screen-api/src/main/resources/word/\347\251\272\346\260\224\350\264\250\351\207\217\345\221\250\346\212\245.docx"
Binary files differ
diff --git "a/screen-api/src/main/resources/word/\347\251\272\346\260\224\350\264\250\351\207\217\346\234\210\346\212\245.docx" "b/screen-api/src/main/resources/word/\347\251\272\346\260\224\350\264\250\351\207\217\346\234\210\346\212\245.docx"
new file mode 100644
index 0000000..1be882d
--- /dev/null
+++ "b/screen-api/src/main/resources/word/\347\251\272\346\260\224\350\264\250\351\207\217\346\234\210\346\212\245.docx"
Binary files differ
diff --git a/screen-common/src/main/java/com/moral/util/DateUtils.java b/screen-common/src/main/java/com/moral/util/DateUtils.java
index 2de5766..e725576 100644
--- a/screen-common/src/main/java/com/moral/util/DateUtils.java
+++ b/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));
+ }
+
/**
* ���������������������������������������������������
*
diff --git a/screen-job/pom.xml b/screen-job/pom.xml
index e7d9d3b..7ad595f 100644
--- a/screen-job/pom.xml
+++ b/screen-job/pom.xml
@@ -29,6 +29,17 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.13</version>
+ </dependency>
</dependencies>
<build>
diff --git a/screen-job/src/main/java/com/moral/api/controller/PubController.java b/screen-job/src/main/java/com/moral/api/controller/PubController.java
index 16805cd..2ba44f4 100644
--- a/screen-job/src/main/java/com/moral/api/controller/PubController.java
+++ b/screen-job/src/main/java/com/moral/api/controller/PubController.java
@@ -1,22 +1,22 @@
package com.moral.api.controller;
-import com.moral.api.service.HistoryAqiService;
-import com.moral.api.service.HistoryDailyService;
-import com.moral.api.service.HistoryFiveMinutelyService;
-import com.moral.api.service.HistoryHourlyService;
+import com.moral.api.service.*;
+import com.moral.api.util.HttpUtils;
import com.moral.constant.ResultMessage;
import com.moral.util.DateUtils;
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.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
/**
* @ClassName UserController
@@ -34,6 +34,11 @@
private HistoryDailyService historyDailyService;
@Autowired
private HistoryFiveMinutelyService historyFiveMinutelyService;
+
+ @Autowired
+ private CityWeatherService cityWeatherService;
+ @Autowired
+ private ForecastService forecastService;
@Autowired
private HistoryAqiService historyAqiService;
@@ -77,15 +82,50 @@
return new ResultMessage();
}
+ @GetMapping("forecastO3")
+ @ApiOperation(value = "O3������������������", notes = "O3")
+ public ResultMessage forecastO3() {
+ forecastService.forecastO3();
+ return new ResultMessage();
+ }
+ @GetMapping("insertCityWeather")
+ @ApiOperation(value = "������������������������", notes = "������������������������")
+ public ResultMessage insertCityWeather() {
+ cityWeatherService.insertCityWeather();
+ return new ResultMessage();
+ }
+
public static void main(String[] args) {
- String s = "2023-9-01";
- Date d = DateUtils.getDate(s,"yyyy-MM-dd");
- System.out.println(DateUtils.dateToDateFullString(d));
- //System.out.println( DateUtils.dateToDateFullString(DateUtils.getDateOfDay(d, -1), "yyyy-MM-dd"));
+ String host = "https://pair.market.alicloudapi.com";
+ String path = "/api/v1/pair/station_list";
+ String method = "GET";
+ String appcode = "31b6ea8f804a4472be3b633cfee44849";
+ Map<String, String> headers = new HashMap<String, String>();
+ //���������header������������(���������������������)���Authorization:APPCODE 83359fd73fe94948385f570e3c139105
+ headers.put("Authorization", "APPCODE " + appcode);
+ Map<String, String> querys = new HashMap<String, String>();
+ querys.put("province", "���������");
-
+ try {
+ /**
+ * ������������������:
+ * HttpUtils������
+ * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
+ * ������
+ *
+ * ������������������������
+ * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
+ */
+ HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
+ System.out.println(response.toString());
+ //������response���body
+ System.out.println(EntityUtils.toString(response.getEntity()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
+
}
diff --git a/screen-job/src/main/java/com/moral/api/service/impl/ForecastServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/ForecastServiceImpl.java
index 1850370..89244a6 100644
--- a/screen-job/src/main/java/com/moral/api/service/impl/ForecastServiceImpl.java
+++ b/screen-job/src/main/java/com/moral/api/service/impl/ForecastServiceImpl.java
@@ -22,12 +22,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.OptionalDouble;
+import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
@@ -136,7 +131,7 @@
Integer cityCode = Integer.parseInt(obj.toString());
//������
- List<CityWeatherForecast> cityWeatherForecasts = cityForecast.get(cityCode);
+ List<CityWeatherForecast> cityWeatherForecasts = Objects.isNull(cityForecast.get(cityCode))?new ArrayList<>():cityForecast.get(cityCode);
//������������������������������
List<CityWeather> cityWeathers = cityHistoryWeather.get(cityCode);
@@ -210,7 +205,10 @@
}
}
}
- forecastMapper.insertForecast(forecastList);
+ if(forecastList.size()>0){
+ forecastMapper.insertForecast(forecastList);
+ }
+
}
private Double calculateAvg(List<Map<String, Object>> list, String param) {
diff --git a/screen-job/src/main/java/com/moral/api/util/HttpUtils.java b/screen-job/src/main/java/com/moral/api/util/HttpUtils.java
new file mode 100644
index 0000000..7d62459
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/util/HttpUtils.java
@@ -0,0 +1,316 @@
+package com.moral.api.util;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName HttpUtils
+ * @Description TODO
+ * @Author @lizijie
+ * @Date 2023-08-14 13:33
+ * @Version 1.0
+ */
+public class HttpUtils {
+ /**
+ * get
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doGet(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpGet request = new HttpGet(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * post form
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param bodys
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPost(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys,
+ Map<String, String> bodys)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (bodys != null) {
+ List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
+
+ for (String key : bodys.keySet()) {
+ nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
+ }
+ UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
+ formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
+ request.setEntity(formEntity);
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Post String
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPost(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys,
+ String body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (StringUtils.isNotBlank(body)) {
+ request.setEntity(new StringEntity(body, "utf-8"));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Post stream
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPost(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys,
+ byte[] body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (body != null) {
+ request.setEntity(new ByteArrayEntity(body));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Put String
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPut(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys,
+ String body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPut request = new HttpPut(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (StringUtils.isNotBlank(body)) {
+ request.setEntity(new StringEntity(body, "utf-8"));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Put stream
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPut(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys,
+ byte[] body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPut request = new HttpPut(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (body != null) {
+ request.setEntity(new ByteArrayEntity(body));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Delete
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doDelete(String host, String path, String method,
+ Map<String, String> headers,
+ Map<String, String> querys)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
+ for (Map.Entry<String, String> e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ return httpClient.execute(request);
+ }
+
+ private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
+ StringBuilder sbUrl = new StringBuilder();
+ sbUrl.append(host);
+ if (!StringUtils.isBlank(path)) {
+ sbUrl.append(path);
+ }
+ if (null != querys) {
+ StringBuilder sbQuery = new StringBuilder();
+ for (Map.Entry<String, String> query : querys.entrySet()) {
+ if (0 < sbQuery.length()) {
+ sbQuery.append("&");
+ }
+ if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
+ sbQuery.append(query.getValue());
+ }
+ if (!StringUtils.isBlank(query.getKey())) {
+ sbQuery.append(query.getKey());
+ if (!StringUtils.isBlank(query.getValue())) {
+ sbQuery.append("=");
+ sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
+ }
+ }
+ }
+ if (0 < sbQuery.length()) {
+ sbUrl.append("?").append(sbQuery);
+ }
+ }
+
+ return sbUrl.toString();
+ }
+
+ private static HttpClient wrapClient(String host) {
+ HttpClient httpClient = new DefaultHttpClient();
+ if (host.startsWith("https://")) {
+ sslClient(httpClient);
+ }
+
+ return httpClient;
+ }
+
+ private static void sslClient(HttpClient httpClient) {
+ try {
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ X509TrustManager tm = new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ public void checkClientTrusted(X509Certificate[] xcs, String str) {
+
+ }
+ public void checkServerTrusted(X509Certificate[] xcs, String str) {
+
+ }
+ };
+ ctx.init(null, new TrustManager[] { tm }, null);
+ SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+ ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ ClientConnectionManager ccm = httpClient.getConnectionManager();
+ SchemeRegistry registry = ccm.getSchemeRegistry();
+ registry.register(new Scheme("https", 443, ssf));
+ } catch (KeyManagementException ex) {
+ throw new RuntimeException(ex);
+ } catch (NoSuchAlgorithmException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java b/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java
index 021bf30..eda029a 100644
--- a/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java
+++ b/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java
@@ -92,10 +92,13 @@
Object vocsValue = ObjectUtils.isEmpty(deviceData.get(Constants.SENSOR_CODE_VOCS)) ? 0F : deviceData.get(Constants.SENSOR_CODE_VOCS);
env.put("vocs", vocsValue);
}
- if (formula.contains("cel")) {
+ if (formula.contains("ce1")) {
//env.put("cel", Float.parseFloat((String) measuredValue));
+ env.put("ce1", new BigDecimal(String.valueOf(measuredValue)).floatValue());
+ }else if(formula.contains("cel")){
env.put("cel", new BigDecimal(String.valueOf(measuredValue)).floatValue());
}
+
//������
measuredValue = expression.execute(env);
//������������
--
Gitblit v1.8.0