From 733d48f803a002033c5f1d6c22dcc799bf1b724c Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Tue, 23 Sep 2025 14:09:20 +0800
Subject: [PATCH] 功能改造

---
 gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml                 |   24 +++++++-----
 gkhy-common/src/main/java/com/gkhy/common/constant/Constants.java                            |    2 +
 gkhy-system/src/main/java/com/gkhy/system/domain/Hazards.java                                |    4 ++
 gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java |   14 +++---
 gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java                  |   26 +++++++-----
 gkhy-system/src/main/java/com/gkhy/system/service/impl/HazardsServiceImpl.java               |   30 +++++++++++---
 6 files changed, 65 insertions(+), 35 deletions(-)

diff --git a/gkhy-common/src/main/java/com/gkhy/common/constant/Constants.java b/gkhy-common/src/main/java/com/gkhy/common/constant/Constants.java
index caa0ce2..7d01386 100644
--- a/gkhy-common/src/main/java/com/gkhy/common/constant/Constants.java
+++ b/gkhy-common/src/main/java/com/gkhy/common/constant/Constants.java
@@ -175,4 +175,6 @@
             "org.springframework", "org.apache", "com.gkhy.common.utils.file", "com.gkhy.common.config", "com.gkhy.generator" };
 
     public static final String SYS_ADMIN= "sys_admin";
+
+    public static final String PLACE_SAFETY_OFFICER= "place_safety_officer";
 }
diff --git a/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java b/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java
index 70f6d2f..b88ad23 100644
--- a/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java
+++ b/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java
@@ -89,12 +89,16 @@
     @NotBlank(message = "复查结果不能为空")
     private String examinationResults;
 
-    @ApiModelProperty(value = "复查人员id",required = true)
+    @ApiModelProperty(value = "复查人员id",hidden = true)
     @TableField("re_check_user_id")
-    @NotNull(message = "复查人员id不能为空")
     private Long reCheckUserId;
 
-    @ApiModelProperty("复查人员")
+    @ApiModelProperty(value = "检查人员",hidden = true)
+    @TableField("check_user")
+    @NotBlank(message = "检查人员不能为空")
+    private String checkUser;
+
+    @ApiModelProperty(value = "复查人员",required = true)
     @TableField("re_check_user")
     private String reCheckUser;
 
@@ -129,14 +133,14 @@
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime updateTime;
 
-    @TableField(exist = false)
-    @ApiModelProperty("参与检查人员")
-    @NotEmpty(message = "参与检查人员不能为空")
-    private List<DailySafetyInspectionUser> dailySafetyInspectionUsers;
-
-    @TableField(exist = false)
-    @ApiModelProperty("参与检查人员id查询条件")
-    private List<Long> searchCheckUserIds;
+//    @TableField(exist = false)
+//    @ApiModelProperty("参与检查人员")
+//    @NotEmpty(message = "参与检查人员不能为空")
+//    private List<DailySafetyInspectionUser> dailySafetyInspectionUsers;
+//
+//    @TableField(exist = false)
+//    @ApiModelProperty("参与检查人员id查询条件")
+//    private List<Long> searchCheckUserIds;
 
     @TableField(exist = false)
     @ApiModelProperty("查询条件检查开始时间")
diff --git a/gkhy-system/src/main/java/com/gkhy/system/domain/Hazards.java b/gkhy-system/src/main/java/com/gkhy/system/domain/Hazards.java
index e8d2e1f..fe1c136 100644
--- a/gkhy-system/src/main/java/com/gkhy/system/domain/Hazards.java
+++ b/gkhy-system/src/main/java/com/gkhy/system/domain/Hazards.java
@@ -132,5 +132,9 @@
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime updateTime;
 
+    @ApiModelProperty("隐患类型 1上报 2整改 3台账")
+    @TableField(exist = false)
+    private String hazardsType;
+
 
 }
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..83444ce 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
@@ -50,10 +50,10 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int saveDailySafetyInspection(DailySafetyInspection inspection) {
-        List<DailySafetyInspectionUser> dailySafetyInspectionUsers = inspection.getDailySafetyInspectionUsers();
-        if (ObjectUtil.isEmpty(dailySafetyInspectionUsers)) {
-            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) {
@@ -73,9 +73,9 @@
             inspection.setUpdateBy(SecurityUtils.getUsername());
             i = dailySafetyInspectionMapper.updateById(inspection);
         }
-        if (i > 0) {
-            saveDailySafetyInspectionUser(dailySafetyInspectionUsers, inspection.getId());
-        }
+//        if (i > 0) {
+//            saveDailySafetyInspectionUser(dailySafetyInspectionUsers, inspection.getId());
+//        }
         return i;
     }
 
diff --git a/gkhy-system/src/main/java/com/gkhy/system/service/impl/HazardsServiceImpl.java b/gkhy-system/src/main/java/com/gkhy/system/service/impl/HazardsServiceImpl.java
index 9968336..53fe0e2 100644
--- a/gkhy-system/src/main/java/com/gkhy/system/service/impl/HazardsServiceImpl.java
+++ b/gkhy-system/src/main/java/com/gkhy/system/service/impl/HazardsServiceImpl.java
@@ -8,7 +8,6 @@
 import com.gkhy.common.core.domain.entity.SysUser;
 import com.gkhy.common.core.domain.model.LoginUser;
 import com.gkhy.common.utils.SecurityUtils;
-import com.gkhy.system.domain.DailySafetyInspection;
 import com.gkhy.system.domain.Hazards;
 import com.gkhy.system.domain.dto.HazardsEditDTO;
 import com.gkhy.system.mapper.HazardsMapper;
@@ -17,7 +16,6 @@
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -38,8 +36,22 @@
 
     @Override
     public List<Hazards> getHazardsList(Hazards hazards) {
+        if (hazards != null && "2".equals(hazards.getHazardsType())){
+            boolean b = check2Per();
+            if (!b){
+                hazards.setReformUserId(SecurityUtils.getUserId());
+            }
+        }
         return hazardsMapper.getHazardsList(hazards);
     }
+
+    boolean check2Per(){
+        if (SecurityUtils.isAdmin(SecurityUtils.getUserId()) || SecurityUtils.hasRole(Constants.SYS_ADMIN) || SecurityUtils.hasRole(Constants.PLACE_SAFETY_OFFICER)){
+            return true;
+        }
+        return false;
+    }
+
 
     @Override
     public int saveHazards(Hazards inspection) {
@@ -75,13 +87,17 @@
     private void checkPer(){
         boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
         if (!admin){
-            LoginUser loginUser = SecurityUtils.getLoginUser();
-            SysUser user = loginUser.getUser();
-            List<SysRole> roles = user.getRoles();
-            long sysAdmin = roles.stream().filter(role -> role.getRoleKey().equals(Constants.SYS_ADMIN)).count();
-            if (sysAdmin == 0){
+            boolean placeSafetyOfficer = SecurityUtils.hasRole(Constants.SYS_ADMIN);
+            if (!placeSafetyOfficer){
                 throw new RuntimeException("没有权限");
             }
+//            LoginUser loginUser = SecurityUtils.getLoginUser();
+//            SysUser user = loginUser.getUser();
+//            List<SysRole> roles = user.getRoles();
+//            long sysAdmin = roles.stream().filter(role -> role.getRoleKey().equals(Constants.SYS_ADMIN)).count();
+//            if (sysAdmin == 0){
+//                throw new RuntimeException("没有权限");
+//            }
         }
 
     }
diff --git a/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml b/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
index e573dcc..d525dbe 100644
--- a/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
+++ b/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
@@ -15,6 +15,7 @@
         <result column="rectification_measures" property="rectificationMeasures" />
         <result column="examination_results" property="examinationResults" />
         <result column="re_check_user_id" property="reCheckUserId" />
+        <result column="check_user" property="checkUser" />
         <result column="re_check_user" property="reCheckUser" />
         <result column="re_check_date" property="reCheckDate" />
         <result column="remark" property="remark" />
@@ -25,7 +26,7 @@
         <result column="update_time" property="updateTime" />
         <result column="check_type" property="checkType" />
 
-        <collection  property="dailySafetyInspectionUsers"   ofType="com.gkhy.system.domain.DailySafetyInspectionUser"  column="id = id" select="selectDailySafetyInspectionUsers" />
+<!--        <collection  property="dailySafetyInspectionUsers"   ofType="com.gkhy.system.domain.DailySafetyInspectionUser"  column="id = id" select="selectDailySafetyInspectionUsers" />-->
 
     </resultMap>
 
@@ -59,19 +60,22 @@
             AND date_format(a.check_date,'%Y%m%d') &lt;= date_format(#{checkEndDate},'%Y%m%d')
         </if>
         <if test="haveMainHazard != null and haveMainHazard == 0 ">
-            and (main_hazard = '无' or main_hazard = ' ')
+            and (a.main_hazard = '无' or a.main_hazard = ' ')
         </if>
         <if test="haveMainHazard != null and haveMainHazard == 1 ">
-            and (main_hazard != '无' and main_hazard != ' ')
+            and (a.main_hazard != '无' and a.main_hazard != ' ')
         </if>
-        <if test="searchCheckUserIds != null and !searchCheckUserIds.isEmpty()">
-            and a.id in (
-            select distinct daily_safety_inspection_id from daily_safety_inspection_user
-            where check_user_id in    <foreach collection="searchCheckUserIds" item="group" open="(" separator="," close=")">
-            #{group}
-        </foreach>
-            )
+        <if test="checkUser != null and checkUser != ''">
+            and a.check_user like concat('%',#{checkUser},'%')
         </if>
+<!--        <if test="searchCheckUserIds != null and !searchCheckUserIds.isEmpty()">-->
+<!--            and a.id in (-->
+<!--            select distinct daily_safety_inspection_id from daily_safety_inspection_user-->
+<!--            where check_user_id in    <foreach collection="searchCheckUserIds" item="group" open="(" separator="," close=")">-->
+<!--            #{group}-->
+<!--        </foreach>-->
+<!--            )-->
+<!--        </if>-->
         order by a.create_time desc
     </select>
 

--
Gitblit v1.9.2