heheng
2026-03-19 680a9877fe64c40aced1f4e04ea34056fac204fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?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"/>
        <result column="check_place" property="checkPlace"/>
        <result column="check_room" property="checkRoom"/>
        <result column="research_group" property="researchGroup"/>
        <result column="research_group_name" property="researchGroupName"/>
        <result column="check_content" property="checkContent"/>
        <result column="main_hazard" property="mainHazard"/>
        <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"/>
        <result column="del_flag" property="delFlag"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <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="dailySafetyInspectionDepts" ofType="com.gkhy.system.domain.DailySafetyInspectionDept"
                    column="id = id" select="selectDailySafetyInspectionDepts"/>
    </resultMap>
 
    <resultMap id="dailySafetyInspectionUsers" type="com.gkhy.system.domain.DailySafetyInspectionUser">
        <result column="daily_safety_inspection_id" property="dailySafetyInspectionId"/>
        <result column="check_user_id" property="checkUserId"/>
        <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>
 
 
    <select id="getDailySafetyInspectionList" resultMap="BaseResultMap"
            parameterType="com.gkhy.system.domain.DailySafetyInspection">
        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>-->
        <if test="createById != null ">
            and a.create_by_id = #{createById}
        </if>
        <if test="checkType != null ">
            and a.check_type = #{checkType}
        </if>
        <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 ">
            <!-- 结束时间检索 -->
            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 (a.main_hazard = '无' or a.main_hazard = ' ')
        </if>
        <if test="haveMainHazard != null and haveMainHazard == 1 ">
            and (a.main_hazard != '无' and a.main_hazard != ' ')
        </if>
        <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-->
        <!--            where check_user_id in    <foreach collection="searchCheckUserIds" item="group" open="(" separator="," close=")">-->
        <!--            #{group}-->
        <!--        </foreach>-->
        <!--            )-->
        <!--        </if>-->
        order by a.create_time desc
    </select>
 
 
    <select id="getCheckCount" parameterType="long" resultType="int">
        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>
 
    <select id="getCheckCountList" parameterType="java.util.List" resultType="int">
        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 in
        <foreach collection="list" item="deptId" open="(" separator="," close=")">
            #{deptId}
        </foreach>
          and date_format(b.check_date, '%Y%m') = date_format(now(), '%Y%m')
    </select>
</mapper>