16639036659
2024-04-10 b15ad90d858e5b6745f76921054b5d5a62b59627
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
@@ -35,6 +35,7 @@
import java.lang.reflect.Field;
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.*;
@@ -80,6 +81,9 @@
    @Autowired
    private MonitorDailyReportService monitorDailyReportService;
    @Autowired
    private GasCategoryService gasCategoryService;
    @Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次
//    @Scheduled(cron = "0 0/1 * * * ? ")    // 分钟
@@ -183,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);
@@ -200,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());