heheng
2025-10-15 a4f1e1a9b97f7606347ba1b6a5c5957c3fc28a59
gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gkhy.system.mapper.DailySafetyInspectionMapper">
    <resultMap id="BaseResultMap" type="com.gkhy.system.domain.DailySafetyInspection">
        <id column="id" property="id" />
        <result column="check_date" property="checkDate" />
@@ -27,7 +25,8 @@
        <result column="check_type" property="checkType" />
<!--        <collection  property="dailySafetyInspectionUsers"   ofType="com.gkhy.system.domain.DailySafetyInspectionUser"  column="id = id" select="selectDailySafetyInspectionUsers" />-->
        <collection property="dailySafetyInspectionDepts" ofType="com.gkhy.system.domain.DailySafetyInspectionDept"
                    column="id = id" select="selectDailySafetyInspectionDepts"/>
    </resultMap>
    <resultMap id="dailySafetyInspectionUsers" type="com.gkhy.system.domain.DailySafetyInspectionUser">
@@ -36,8 +35,25 @@
        <result column="check_user" property="checkUser" />
    </resultMap>
    <resultMap id="dailySafetyInspectionDepts" type="com.gkhy.system.domain.DailySafetyInspectionDept">
        <result column="daily_safety_inspection_id" property="dailySafetyInspectionId"/>
        <result column="dept_id" property="deptId"/>
        <result column="dept_name" property="deptName"/>
    </resultMap>
    <select id="selectDailySafetyInspectionDepts" resultMap="dailySafetyInspectionDepts">
        select a.daily_safety_inspection_id, a.dept_id, b.dept_name
        from daily_safety_inspection_dept a
                 left join sys_dept b on a.dept_id = b.dept_id
        where a.daily_safety_inspection_id = #{id}
    </select>
    <select id="selectDailySafetyInspectionUsers" resultMap="dailySafetyInspectionUsers">
        select * from daily_safety_inspection_user where daily_safety_inspection_id = #{id}
        select *
        from daily_safety_inspection_user
        where daily_safety_inspection_id = #{id}
    </select>
@@ -46,17 +62,19 @@
        select a.*,b.dept_name as research_group_name from
        daily_safety_inspection a
        left join sys_dept b on a.research_group = b.dept_id
        where a.del_flag = '0'
        <if test="researchGroup != null ">
            and a.research_group = #{researchGroup}
        </if>
        where a.del_flag = 0
<!--        <if test="researchGroup != null ">-->
<!--            and a.research_group = #{researchGroup}-->
<!--        </if>-->
        <if test="checkType != null ">
            and a.check_type = #{checkType}
        </if>
        <if test="checkBeginDate != null "><!-- 开始时间检索 -->
        <if test="checkBeginDate != null ">
            <!-- 开始时间检索 -->
            AND date_format(a.check_date,'%Y%m%d') &gt;= date_format(#{checkBeginDate},'%Y%m%d')
        </if>
        <if test="checkEndDate != null "><!-- 结束时间检索 -->
        <if test="checkEndDate != null ">
            <!-- 结束时间检索 -->
            AND date_format(a.check_date,'%Y%m%d') &lt;= date_format(#{checkEndDate},'%Y%m%d')
        </if>
        <if test="haveMainHazard != null and haveMainHazard == 0 ">
@@ -68,6 +86,14 @@
        <if test="checkUser != null and checkUser != ''">
            and a.check_user like concat('%',#{checkUser},'%')
        </if>
        <if test="researchGroup != null ">
            and a.id in (
            select distinct daily_safety_inspection_id from daily_safety_inspection_dept
            where dept_id = #{researchGroup}
            )
        </if>
<!--        <if test="searchCheckUserIds != null and !searchCheckUserIds.isEmpty()">-->
<!--            and a.id in (-->
<!--            select distinct daily_safety_inspection_id from daily_safety_inspection_user-->
@@ -81,6 +107,11 @@
    <select id="getCheckCount" parameterType="long" resultType="int">
        select count(*) from daily_safety_inspection where del_flag = 0 and research_group = #{deptId} and date_format(check_date,'%Y%m') = date_format(now(),'%Y%m')
        select count(*)
        from daily_safety_inspection_dept a
            inner join daily_safety_inspection b on a.daily_safety_inspection_id = b.id
        where b.del_flag = 0
          and a.dept_id = #{deptId}
          and date_format(b.check_date, '%Y%m') = date_format(now(), '%Y%m')
    </select>
</mapper>