From 05628d269dff7ad4f2e9d3419b05b4e7e5768797 Mon Sep 17 00:00:00 2001 From: luoyisheng <yangdongji@argo-ai.cn> Date: 星期三, 12 二月 2025 14:19:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- medicalWaste-system/src/main/java/com/sinata/system/service/biz/TaskService.java | 34 +++++++++++++++++++++------------- 1 files changed, 21 insertions(+), 13 deletions(-) diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/biz/TaskService.java b/medicalWaste-system/src/main/java/com/sinata/system/service/biz/TaskService.java index 63bc257..539195e 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/biz/TaskService.java +++ b/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,20 +114,24 @@ } // 创建预警记录并保存 - List<MwWarningRecord> warningRecordList = recordList.stream().map(item -> { - Long id = item.getId(); - String medicalWasteNumber = item.getMedicalWasteNumber(); - String hospitalName = item.getHospitalName(); - String msg = String.format("%s医废超过%d小时未出库", item.getWasteTypeStr(), configItem.getValue()); - String currentValue = String.valueOf(DateUtils.timeDistanceHour(new Date(), item.getCollectTime())); - 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()); + 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(); + String msg = String.format("%s医废超过%d小时未出库", item.getWasteTypeStr(), configItem.getValue()); + String currentValue = String.valueOf(DateUtils.timeDistanceHour(new Date(), item.getCollectTime())); + Long departmentId = item.getDepartmentId(); + String configValue = configItem.getValue().toString(); + return getMwWarningRecord(WarningTypeEnum.CHECKOUT_TIMEOUT_WARNING.getCode(), id, medicalWasteNumber, hospitalName, msg, departmentId, currentValue, configValue); + } + 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; } -- Gitblit v1.7.1