From a4f1e1a9b97f7606347ba1b6a5c5957c3fc28a59 Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Wed, 15 Oct 2025 13:28:37 +0800
Subject: [PATCH] 功能改造

---
 gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java |   46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java b/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java
index 65476dd..42cf000 100644
--- a/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java
+++ b/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java
@@ -9,7 +9,9 @@
 import com.gkhy.common.exception.ServiceException;
 import com.gkhy.common.utils.SecurityUtils;
 import com.gkhy.system.domain.DailySafetyInspection;
+import com.gkhy.system.domain.DailySafetyInspectionDept;
 import com.gkhy.system.domain.DailySafetyInspectionUser;
+import com.gkhy.system.mapper.DailySafetyInspectionDeptMapper;
 import com.gkhy.system.mapper.DailySafetyInspectionMapper;
 import com.gkhy.system.mapper.DailySafetyInspectionUserMapper;
 import com.gkhy.system.mapper.SysDeptMapper;
@@ -40,6 +42,9 @@
     private DailySafetyInspectionUserMapper dailySafetyInspectionUserMapper;
 
     @Autowired
+    private DailySafetyInspectionDeptMapper dailySafetyInspectionDeptMapper;
+
+    @Autowired
     private SysDeptMapper sysDeptMapper;
 
     @Override
@@ -50,18 +55,18 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int saveDailySafetyInspection(DailySafetyInspection inspection) {
-        List<DailySafetyInspectionUser> dailySafetyInspectionUsers = inspection.getDailySafetyInspectionUsers();
-        if (ObjectUtil.isEmpty(dailySafetyInspectionUsers)) {
-            throw new ServiceException("参检人员不能为空");
-        }
-        Long researchGroup = inspection.getResearchGroup();
-        SysDept sysDept = sysDeptMapper.selectDeptById(researchGroup);
-        if (sysDept == null) {
-            throw new ServiceException("部门不存在");
-        }
-        if (!"1".equals(sysDept.getSafety())){
-            throw new ServiceException("所选部门未开启安全检查");
-        }
+//        List<DailySafetyInspectionUser> dailySafetyInspectionUsers = inspection.getDailySafetyInspectionUsers();
+//        if (ObjectUtil.isEmpty(dailySafetyInspectionUsers)) {
+//            throw new ServiceException("参检人员不能为空");
+//        }
+//        Long researchGroup = inspection.getResearchGroup();
+//        SysDept sysDept = sysDeptMapper.selectDeptById(researchGroup);
+//        if (sysDept == null) {
+//            throw new ServiceException("部门不存在");
+//        }
+//        if (!"1".equals(sysDept.getSafety())){
+//            throw new ServiceException("所选部门未开启安全检查");
+//        }
 
         int i = 0;
         if (inspection.getId() == null) {
@@ -73,9 +78,12 @@
             inspection.setUpdateBy(SecurityUtils.getUsername());
             i = dailySafetyInspectionMapper.updateById(inspection);
         }
-        if (i > 0) {
-            saveDailySafetyInspectionUser(dailySafetyInspectionUsers, inspection.getId());
+        if (i > 0){
+            saveDailySafetyInspectionDept(inspection.getDailySafetyInspectionDepts(),inspection.getId());
         }
+//        if (i > 0) {
+//            saveDailySafetyInspectionUser(dailySafetyInspectionUsers, inspection.getId());
+//        }
         return i;
     }
 
@@ -90,7 +98,17 @@
         });
 
     }
+    private void saveDailySafetyInspectionDept(List<DailySafetyInspectionDept> dailySafetyInspectionDepts, Long id) {
 
+        DailySafetyInspectionDept dept = new DailySafetyInspectionDept();
+        dept.setDailySafetyInspectionId(id);
+        dailySafetyInspectionDeptMapper.deleteById(dept);
+        dailySafetyInspectionDepts.forEach(dept1 -> {
+            dept1.setDailySafetyInspectionId(id);
+            dailySafetyInspectionDeptMapper.insert(dept1);
+        });
+
+    }
 
     @Override
     public int deleteDailySafetyInspection(Long id) {

--
Gitblit v1.9.2