luoyisheng
2025-02-12 05628d269dff7ad4f2e9d3419b05b4e7e5768797
medicalWaste-system/src/main/java/com/sinata/system/service/biz/TaskService.java
@@ -97,7 +97,10 @@
            log.info("【出库超时预警】:没有暂存的医废记录,跳过定时任务执行");
            return;
        }
        //查询所有出库超时预警
        List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery()
                .eq(MwWarningRecord::getType, WarningTypeEnum.CHECKOUT_TIMEOUT_WARNING.getCode())
                .list();
        // 遍历配置项并处理预警
        for (MwWarningConfigItem configItem : configItems) {
            // 过滤出需要预警的记录
@@ -111,7 +114,9 @@
            }
            // 创建预警记录并保存
            List<MwWarningRecord> warningRecordList = recordList.stream().map(item -> {
            List<MwWarningRecord> warningRecordSaveList = recordList.stream().map(item -> {
                long count = warningRecordList.stream().filter(record -> record.getWarningTargetId().equals(item.getId())).count();
                if (count == 0L) {
                Long id = item.getId();
                String medicalWasteNumber = item.getMedicalWasteNumber();
                String hospitalName = item.getHospitalName();
@@ -120,11 +125,13 @@
                Long departmentId = item.getDepartmentId();
                String configValue = configItem.getValue().toString();
                return getMwWarningRecord(WarningTypeEnum.CHECKOUT_TIMEOUT_WARNING.getCode(), id, medicalWasteNumber, hospitalName, msg, departmentId, currentValue, configValue);
            }).collect(Collectors.toList());
                }
                return null;
            }).filter(Objects::nonNull).collect(Collectors.toList());
            // 批量保存预警记录
            if (!warningRecordList.isEmpty()) {
                mwWarningRecordService.saveBatch(warningRecordList);
            if (!warningRecordSaveList.isEmpty()) {
                mwWarningRecordService.saveBatch(warningRecordSaveList);
            }
        }
    }
@@ -154,6 +161,7 @@
        warningRecord.setNormalRange(normalRange);
        warningRecord.setStatus(WarningStatusEnum.UNRESOLVED.getCode());
        warningRecord.setWarnTime(new Date());
        warningRecord.setCreateTime(new Date());
        return warningRecord;
    }