zhuo
2025-03-28 01ed57def0d052ae87d95022013c64c760082610
cnas-require/src/main/java/com/ruoyi/require/task/FeTempHumDateSchedule.java
@@ -93,7 +93,9 @@
            // 查询试验区域
            FeTempHumDate feTempHumDate = feTempHumDateMapper.selectOne(Wrappers.<FeTempHumDate>lambdaQuery()
                    .eq(FeTempHumDate::getMonthDate, formattedDate)
                    .eq(FeTempHumDate::getTestAreaName, collectLaboratory.getLaboratory()));
                    .eq(FeTempHumDate::getTestAreaName, collectLaboratory.getLaboratory())
                    .orderByDesc(FeTempHumDate::getCreateTime)
                    .last("limit 1"));
            Integer dateId = feTempHumDate.getDateId();
            // 判断今天是否有温湿度记录
            FeTempHumRecord feTempHumRecord = record(dateId);
@@ -130,7 +132,9 @@
                .eq(FeTempHumRecord::getDateId, dateId)
                // 记录时间在今天之内
                .eq(FeTempHumRecord::getRecordDate, today)
                .between(FeTempHumRecord::getMorningTestTime, start, end));
                .between(FeTempHumRecord::getMorningTestTime, start, end)
                .orderByDesc(FeTempHumRecord::getTempHumId)
                .last("limit 1"));
    }
    /**
@@ -163,7 +167,9 @@
            // 查询试验区域
            FeTempHumDate feTempHumDate = feTempHumDateMapper.selectOne(Wrappers.<FeTempHumDate>lambdaQuery()
                    .eq(FeTempHumDate::getMonthDate, formattedDate)
                    .eq(FeTempHumDate::getTestAreaName, collectLaboratory.getLaboratory()));
                    .eq(FeTempHumDate::getTestAreaName, collectLaboratory.getLaboratory())
                    .orderByDesc(FeTempHumDate::getCreateTime)
                    .last("limit 1"));
            Integer dateId = feTempHumDate.getDateId();
            // 查询今天是否有温湿度记录
            FeTempHumRecord feTempHumRecord = record(dateId);
@@ -200,6 +206,49 @@
    }
    /**
     * 星期天执行添加空白数据
     * 获取温度湿度
     */
//    @Scheduled(cron = "0/5 * * * * *")
    @Scheduled(cron = "0 0 9 * * 7") //
    public void task3() {
        checkLaboratoriesSchedule();
        // 获取所有的实验室
        List<CollectLaboratory> collectLaboratories = collectLaboratoryMapper.selectList(null);
        // 遍历获取实验室编号 获取温湿度 保存在对应的
        for (CollectLaboratory collectLaboratory : collectLaboratories) {
            // 查询试验区域
            FeTempHumDate feTempHumDate = feTempHumDateMapper.selectOne(Wrappers.<FeTempHumDate>lambdaQuery()
                    .eq(FeTempHumDate::getMonthDate, formattedDate)
                    .eq(FeTempHumDate::getTestAreaName, collectLaboratory.getLaboratory())
                    .orderByDesc(FeTempHumDate::getCreateTime)
                    .last("limit 1"));
            Integer dateId = feTempHumDate.getDateId();
            // 判断今天是否有温湿度记录
            // 获取今天的日期
            LocalDate today = LocalDate.now();
            // 查询今天是否有温湿度记录
            Long count = feTempHumRecordMapper.selectCount(Wrappers.<FeTempHumRecord>lambdaQuery()
                    // 哪个实验室
                    .eq(FeTempHumRecord::getDateId, dateId)
                    // 记录时间在今天之内
                    .eq(FeTempHumRecord::getRecordDate, today));
            // 查询出来就代表今天记录过了就不记录
            if (!count.equals(0L)) {
                // 有温度湿度记录就不记录
                continue;
            }
            // 创建今天温湿度记录对象 记录上午温度湿度
            FeTempHumRecord newFeTempHumRecord = new FeTempHumRecord();
            newFeTempHumRecord.setRecordDate(LocalDate.now());
            newFeTempHumRecord.setDateId(dateId);
            feTempHumRecordMapper.insert(newFeTempHumRecord);
        }
    }
    /**
     * 根据实验室编号获取温度湿度
     *
     * @param collectTemperatureHumidity 温度湿度数据