From c96bf95e947f7c5c22f98de0418976640a318ac6 Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Tue, 31 Mar 2026 11:03:45 +0800
Subject: [PATCH] 修复

---
 gkhy-system/src/main/resources/mapper/system/SysDeptMapper.xml |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/gkhy-system/src/main/resources/mapper/system/SysDeptMapper.xml b/gkhy-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 8c80410..6914f6b 100644
--- a/gkhy-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/gkhy-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -20,6 +20,7 @@
 		<result property="createTime" column="create_time" />
 		<result property="updateBy"   column="update_by"   />
 		<result property="updateTime" column="update_time" />
+		<result property="safety"    column="safety"    />
 	</resultMap>
 
 	<resultMap id="SysDeptDataResult" type="com.gkhy.system.domain.vo.DeptVo" extends="SysDeptResult">
@@ -27,7 +28,7 @@
 	</resultMap>
 	
 	<sql id="selectDeptVo">
-        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time 
+        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.safety
         from sys_dept d
     </sql>
     
@@ -46,6 +47,9 @@
 		<if test="status != null and status != ''">
 			AND status = #{status}
 		</if>
+		<if test="safety != null and safety != ''">
+			AND safety = #{safety}
+		</if>
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
 		order by d.parent_id, d.order_num
@@ -55,8 +59,12 @@
 
 	<select id="selectDeptData" parameterType="Date" resultMap="SysDeptDataResult">
 		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone,
-			   d.email, d.status, d.del_flag, d.create_by, d.create_time ,
-			   ( select count(*) from daily_safety_inspection where del_flag = 0 and research_group = dept_id and date_format(check_date,'%Y%m') = date_format(#{beginDate},'%Y%m')) check_count
+			   d.email, d.status, d.del_flag, d.create_by, d.create_time ,d.safety,
+<!--			   ( select count(*) from daily_safety_inspection where del_flag = 0 and research_group = dept_id and date_format(check_date,'%Y%m') = date_format(#{beginDate},'%Y%m')) check_count-->
+	(		select COUNT(*) from daily_safety_inspection_dept aa
+		INNER JOIN daily_safety_inspection bb on aa.daily_safety_inspection_id = bb.id and bb.del_flag = 0 and date_format(bb.check_date,'%Y%m') = date_format(#{beginDate},'%Y%m')
+		where aa.dept_id = d.dept_id) check_count
+
 		from sys_dept d
 		where d.del_flag = '0'
 		order by d.parent_id, d.order_num
@@ -78,10 +86,22 @@
 	</select>
     
     <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
-		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
+		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.safety,
 			(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
 		from sys_dept d
 		where d.dept_id = #{deptId}
+	</select>
+
+
+	<select id="selectDeptByIds" parameterType="java.util.ArrayList" resultMap="SysDeptResult">
+		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.safety,
+		(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
+		from sys_dept d
+		where d.dept_id in
+		<foreach collection="array" item="deptId" open="(" separator="," close=")">
+			#{deptId}
+		</foreach>
+		and d.del_flag = '0'
 	</select>
     
     <select id="checkDeptExistUser" parameterType="Long" resultType="int">
@@ -117,6 +137,7 @@
  			<if test="phone != null and phone != ''">phone,</if>
  			<if test="email != null and email != ''">email,</if>
  			<if test="status != null">status,</if>
+			<if test="safety != null">safety,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
  			create_time
  		)values(
@@ -129,6 +150,7 @@
  			<if test="phone != null and phone != ''">#{phone},</if>
  			<if test="email != null and email != ''">#{email},</if>
  			<if test="status != null">#{status},</if>
+			<if test="safety != null">#{safety},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
  			sysdate()
  		)
@@ -145,6 +167,7 @@
  			<if test="phone != null">phone = #{phone},</if>
  			<if test="email != null">email = #{email},</if>
  			<if test="status != null and status != ''">status = #{status},</if>
+			<if test="safety != null">safety = #{safety},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			update_time = sysdate()
  		</set>

--
Gitblit v1.9.2