From d4020168658efdee89a633083cd9c14b06c4d863 Mon Sep 17 00:00:00 2001
From: zhangf <1603559716@qq.com>
Date: Wed, 11 Sep 2024 17:09:10 +0800
Subject: [PATCH] 修改消息推送时间间隔
---
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java | 36 +++++++++++++++++++-----------------
1 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
index fdc1deb..8ced11b 100644
--- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
+++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
@@ -1,12 +1,9 @@
package com.gkhy.fourierSpecialGasMonitor.schedule;
-import com.alibaba.fastjson.JSON;
import com.gkhy.fourierSpecialGasMonitor.Application;
-import com.gkhy.fourierSpecialGasMonitor.commons.enums.ForeignResultCode;
import com.gkhy.fourierSpecialGasMonitor.commons.enums.ResultCode;
import com.gkhy.fourierSpecialGasMonitor.commons.enums.SystemCacheKeyEnum;
import com.gkhy.fourierSpecialGasMonitor.commons.exception.BusinessException;
-import com.gkhy.fourierSpecialGasMonitor.commons.exception.DataReceiveException;
import com.gkhy.fourierSpecialGasMonitor.config.file.ReportFilePathConfig;
import com.gkhy.fourierSpecialGasMonitor.entity.*;
import com.gkhy.fourierSpecialGasMonitor.service.*;
@@ -18,18 +15,12 @@
import org.apache.poi.xddf.usermodel.chart.*;
import org.apache.poi.xddf.usermodel.text.XDDFTextBody;
import org.apache.poi.xwpf.usermodel.*;
-import org.apache.xmlbeans.XmlException;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -37,16 +28,14 @@
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import javax.annotation.PostConstruct;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.lang.reflect.Field;
-import java.net.URL;
-import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
@@ -93,7 +82,11 @@
@Autowired
private MonitorDailyReportService monitorDailyReportService;
+ @Autowired
+ private GasCategoryService gasCategoryService;
+
@Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次
+// @Scheduled(cron = "0 0/1 * * * ? ") // 分钟
@Async(value = "SocketTaskExecutor")
public void generateDailyReport() {
LocalDateTime now = LocalDateTime.now();
@@ -194,9 +187,10 @@
}
List<GasConcentration> gasConcentrations = gasConcentrationService.listDatabyTimeSlot(LocalDateTime.of(now.minusDays(1).toLocalDate(), LocalTime.MIN)
, LocalDateTime.of(now.minusDays(1).toLocalDate(), LocalTime.MAX));
+ // 绘制折线图
if (!CollectionUtils.isEmpty(gasConcentrations)) {
- //for (int i = 0; i < 30; i++) {
- for (int i = 0; i < gasCategories.size(); i++) {
+ List<GasCategory> gasCategoryForReport = gasCategoryService.findGasCategoryForReport();
+ for (int i = 0; i < gasCategoryForReport.size(); i++) {
String series = gasCategories.get(i).getMolecularFormula() + "浓度观测结果";
String title = gasCategories.get(i).getMolecularFormula();
drawLineChart(gasConcentrations, fileurl, series, title, gasCategories.get(i).getMolecularFormula(), i);
@@ -211,16 +205,24 @@
throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"区域信息为空");
Map<Integer, String> regionMap = allRegion.stream()
.collect(Collectors.toMap(Region::getId, Region::getName));
+ // 绘制柱状图
if (!CollectionUtils.isEmpty(gasFluxes)) {
- for (int j = 0; j < gasCategories.size(); j++) {
+// for (int j = 0; j < gasCategories.size(); j++) {
+// for (int i = 1; i <= areaNum.size(); i++) {
+// //for (int j = 0; j < 20; j++) {
+// int finalI = i;
+// List<GasFlux> gasFluxesByArea = gasFluxes.stream().filter(gasFlux -> gasFlux.getAreaId() == finalI)
+// .collect(Collectors.toList());
+// drawBarChart(gasFluxesByArea, fileurl, regionMap.get(i), gasCategories.get(j).getMolecularFormula(), i, j + 1);
+// }
+// }
for (int i = 1; i <= areaNum.size(); i++) {
//for (int j = 0; j < 20; j++) {
int finalI = i;
List<GasFlux> gasFluxesByArea = gasFluxes.stream().filter(gasFlux -> gasFlux.getAreaId() == finalI)
.collect(Collectors.toList());
- drawBarChart(gasFluxesByArea, fileurl, regionMap.get(i), gasCategories.get(j).getMolecularFormula(), i, j + 1);
+ drawBarChart(gasFluxesByArea, fileurl, regionMap.get(i), gasCategories.get(0).getMolecularFormula(), i, 1);
}
- }
}
String endTime = LocalDateTime.now().format(execformatter);
long execTime = ChronoUnit.SECONDS.between(now, LocalDateTime.now());
--
Gitblit v1.9.2