From cb90ecabc282352de587107298804aa14c55819f Mon Sep 17 00:00:00 2001
From: 16639036659 <577530412@qq.com>
Date: Mon, 22 Apr 2024 09:17:11 +0800
Subject: [PATCH] 数据库连接配置调整
---
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java | 41 ++++++++++++++++++++++-------------------
1 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
index 1c21958..8ced11b 100644
--- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
+++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
@@ -1,11 +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.*;
@@ -17,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;
@@ -36,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.*;
@@ -92,12 +82,16 @@
@Autowired
private MonitorDailyReportService monitorDailyReportService;
- //@Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次
+ @Autowired
+ private GasCategoryService gasCategoryService;
+
+ @Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次
+// @Scheduled(cron = "0 0/1 * * * ? ") // 分钟
@Async(value = "SocketTaskExecutor")
public void generateDailyReport() {
LocalDateTime now = LocalDateTime.now();
String startTime = now.format(execformatter);
- RBucket<List<GasCategory>> bucket = redissonClient.getBucket("gas_category_cache_info");
+ RBucket<List<GasCategory>> bucket = redissonClient.getBucket(SystemCacheKeyEnum.KEY_GAS_CATEGORY.getKey());
List<GasCategory> gasCategories = bucket.get();
serialNumber = 4;
logger.info("【##】开始生成日报 ,时间:"+startTime);
@@ -193,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);
@@ -210,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