huangzhen
2023-10-19 1f69ad0de4a0abf9b50599146d8f9b6a22e803a3
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
@@ -93,7 +93,7 @@
        String startTime = now.format(execformatter);
        RBucket<List<GasCategory>> bucket = redissonClient.getBucket("gas_category_cache_info");
        List<GasCategory> gasCategories = bucket.get();
        //logger.info("【##】开始生成日报 ,时间:"+startTime);
        logger.info("【##】开始生成日报 ,时间:"+startTime);
        OPCPackage opcPackage = null;
        //加载文档
        XWPFDocument doc = null;
@@ -164,7 +164,8 @@
        } catch (IOException e) {
            e.printStackTrace();
        }
        List<GasConcentration> gasConcentrations = gasConcentrationService.listDatabyTimeSlot(LocalDateTime.now().minusDays(2).with(LocalDate.MIN), 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++) {
                String series = gasCategories.get(i).getMolecularFormula() + "浓度观测结果";
@@ -173,7 +174,8 @@
            }
        }
        List<GasFlux> gasFluxes = gasFluxService.listYesterday();
        //List<GasFlux> gasFluxes = gasFluxService.listYesterday();
        List<GasFlux> gasFluxes = gasFluxService.listYesterdayTenAmToSixPm();
        List<Integer> areaNum = gasFluxes.stream().map(GasFlux::getAreaId).distinct().collect(Collectors.toList());
        List<Region> allRegion = regionService.findAll();
@@ -182,8 +184,8 @@
        Map<Integer, String> regionMap = allRegion.stream()
                .collect(Collectors.toMap(Region::getId, Region::getName));
        if (!CollectionUtils.isEmpty(gasFluxes)) {
            for (int i = 1; i <= 1; i++) {
                for (int j = 0; j < 1; j++) {
            for (int i = 1; i <= areaNum.size(); i++) {
                for (int j = 0; j < 20; j++) {
                    drawBarChart(gasFluxes, fileurl, regionMap.get(i), "柱形图" + gasCategories.get(j).getMolecularFormula(), i, j + 1);
                }
            }
@@ -198,7 +200,7 @@
        MonitorDailyReport save = monitorDailyReportService.save(report);
        if (save == null)
            throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL,"日常报表保存失败");
        //logger.info("【##】日报生成成功!!! ,时间:"+endTime+",所耗时间: "+execTime+"s");
        logger.info("【##】日报生成成功!!! ,时间:"+endTime+",所耗时间: "+execTime+"s");
    }
    public void drawBarChart(List<GasFlux> gasFluxes,String fileurl,String series,String molecularFormula,Integer i,Integer j) {
@@ -432,7 +434,7 @@
    private Map<String, Object> dataMap(List<GasCategory> gasCategories){
        LocalDateTime now = LocalDateTime.now();
        String today = now.format(formatter);
        String yesterday = LocalDateTime.now().plusDays(1).format(formatter);
        String yesterday = LocalDateTime.now().minusDays(1).format(formatter);
        //要替换的map,key为占位符,value为要被替换的值
        Map<String, Object> map = new HashMap<>();
        map.put("${today}", today);