From ae65b5c41e294bd3c5e18f91423f9fb90179d145 Mon Sep 17 00:00:00 2001 From: lishiwei <3230787218@qq.com> Date: Mon, 20 Jul 2026 09:11:37 +0800 Subject: [PATCH] =?UTF-8?q?feat():=20=E4=BF=AE=E6=94=B9=E6=A0=B8=E5=AE=9E?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=B5=8B=E5=80=BC=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=AF=BC=E5=87=BA=E6=97=B6=E9=97=B4=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...afetyEnvironmentalInspectionUpdateExe.java | 23 +++++++++++++++++++ ...SafetyEnvironmentalInspectionQueryExe.java | 15 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java index b056bde..ded6f83 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java @@ -119,12 +119,35 @@ public class SafetyEnvironmentalInspectionUpdateExe { // 删除检查核实人数据 及对应待办信息 List deleteUserList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(safetyEnvironmentalInspectionE.getInspectionId(),2); + // 保存旧核实记录的状态,用于重建后恢复 + Map oldVerifyStatusMap = deleteUserList.stream() + .filter(u -> u.getUserId() != null) + .collect(Collectors.toMap( + SafetyEnvironmentalInspectionUserDO::getUserId, + u -> u.getStatus() != null ? u.getStatus() : 0, + (existing, replacement) -> existing)); for (SafetyEnvironmentalInspectionUserDO deleteUser : deleteUserList){ messageNoticeExe.sendMessageDeleteEvent(deleteUser.getId()); } safetyEnvironmentalInspectionUserRepository.deleteByInspectionId(safetyEnvironmentalInspectionE.getInspectionId(), 2); // 新增检查核实人数据 safetyEnvironmentalInspectionUserRepository.batchInsert(BeanUtil.copyToList(insUserList, SafetyEnvironmentalInspectionUserDO.class)); + // 恢复之前已核实的用户状态 + if (!oldVerifyStatusMap.isEmpty()) { + List newUserList = + safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(safetyEnvironmentalInspectionE.getInspectionId(), 2); + for (SafetyEnvironmentalInspectionUserDO newUser : newUserList) { + Integer oldStatus = oldVerifyStatusMap.get(newUser.getUserId()); + if (oldStatus != null && oldStatus > 0) { + SafetyEnvironmentalInspectionUserDO updateDO = new SafetyEnvironmentalInspectionUserDO(); + updateDO.setInspectionId(safetyEnvironmentalInspectionE.getInspectionId()); + updateDO.setUserId(newUser.getUserId()); + updateDO.setType(2); + updateDO.setStatus(oldStatus); + safetyEnvironmentalInspectionUserRepository.editUserInfo(updateDO); + } + } + } // 删除检查内容 List deleteContentList = safetyEnvironmentalInspectionContentRepository.listAllByInspectionId(safetyEnvironmentalInspectionE.getInspectionId()); diff --git a/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java b/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java index 8c98050..55a6732 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java @@ -37,6 +37,7 @@ import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -192,6 +193,20 @@ public class SafetyEnvironmentalInspectionQueryExe { inspection.setStatusName(InspectionStatusEnum.getNameByStatus(inspection.getStatus())); }); List safetyEnvironmentalInspectionExportEntities = safetyEnvironmentalInspectionCoConvertor.converDOsToExcelEntitys(safetyEnvironmentalInspectionDOs); + // 填充检查时间(timeStart - timeEnd) + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + for (int i = 0; i < safetyEnvironmentalInspectionExportEntities.size(); i++) { + SafetyEnvironmentalInspectionDO inspectionDO = safetyEnvironmentalInspectionDOs.get(i); + String timeStart = inspectionDO.getTimeStart() != null ? inspectionDO.getTimeStart().format(dtf) : ""; + String timeEnd = inspectionDO.getTimeEnd() != null ? inspectionDO.getTimeEnd().format(dtf) : ""; + if (!timeStart.isEmpty() && !timeEnd.isEmpty()) { + safetyEnvironmentalInspectionExportEntities.get(i).setCheckTime(timeStart + "-" + timeEnd); + } else if (!timeStart.isEmpty()) { + safetyEnvironmentalInspectionExportEntities.get(i).setCheckTime(timeStart); + } else if (!timeEnd.isEmpty()) { + safetyEnvironmentalInspectionExportEntities.get(i).setCheckTime(timeEnd); + } + } try { ExcelUtils.exportExcel(httpServletResponse, SafetyEnvironmentalInspectionExportEntity.class, "安全环保检查信息", safetyEnvironmentalInspectionExportEntities); } catch (IOException e) {