| | |
| | | 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.*; |
| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | @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(); |
| | |
| | | } |
| | | 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); |
| | |
| | | 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()); |