fix
songhuangfeng123
2022-09-20 f1f506172a3edff8d31e4db77b8940f115660919
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?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.safePlatform.emergency.repository.EmergencyDrillExecuteInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoPageDO"
               id="emergencyDrillExecuteInfoPageDOResult">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="status" property="status"/>
        <result column="drill_record_date" property="drillRecordDate"/>
        <result column="drill_plan_id" property="drillPlanId"/>
        <result column="record_user_uid" property="recordUserUid"/>
        <result column="process_desc" property="processDesc"/>
    </resultMap>
 
    <select id="selectEmergencyDrillExecuteList" resultMap="emergencyDrillExecuteInfoPageDOResult">
        SELECT
            a.id,
            a.drill_plan_id,
            b.drill_name as drillName,
            b.drill_address as drillAddress,
            b.drill_way as drillWay,
            b.drill_level as drillLevel,
            b.drill_plan_date as drillPlanDate,
            a.`drill_record_date`,
            c.`name` as emergencyPlanName
        FROM
            emergency_drill_execute a
            LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
            LEFT JOIN emergency_plan c ON b.plan_id = c.id
        WHERE
            a.del_flag = 0
        <if test="query.status != null">and a.status = #{query.status}</if>
    </select>
 
    <insert id="addEmergencyDrillExecute" parameterType="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo"
            keyProperty="id" useGeneratedKeys="true">
        insert into emergency_drill_execute
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="delFlag != null ">del_flag,</if>
            <if test="gmtCreate != null ">gmt_create,</if>
            <if test="gmtModitify != null ">gmt_moditify,</if>
            <if test="createUid != null ">create_uid,</if>
            <if test="updateUid != null ">update_uid,</if>
            <if test="status != null ">status,</if>
            <if test="drillRecordDate != null ">drill_record_date,</if>
            <if test="drillPlanId != null ">drill_plan_id,</if>
            <if test="recordUserUid != null ">record_user_uid,</if>
            <if test="recordUserName != null and recordUserName != ''">`record_user_name`,</if>
            <if test="processDesc != null and processDesc != ''">`process_desc`,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="delFlag != null ">#{delFlag},</if>
            <if test="gmtCreate != null ">#{gmtCreate},</if>
            <if test="gmtModitify != null ">#{gmtModitify},</if>
            <if test="createUid != null ">#{createUid},</if>
            <if test="updateUid != null ">#{updateUid},</if>
            <if test="status != null ">#{status},</if>
            <if test="drillRecordDate != null ">#{drillRecordDate},</if>
            <if test="drillPlanId != null ">#{drillPlanId},</if>
            <if test="recordUserUid != null ">#{recordUserUid},</if>
            <if test="recordUserName != null and recordUserName != ''">#{recordUserName},</if>
            <if test="processDesc != null and processDesc != ''">#{processDesc},</if>
        </trim>
    </insert>
 
 
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoDetailDO"
               id="emergencyDrillExecuteInfoDetailDOResult">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="status" property="status"/>
        <result column="drill_record_date" property="drillRecordDate"/>
        <result column="drill_plan_id" property="drillPlanId"/>
        <result column="record_user_uid" property="recordUserUid"/>
        <result column="record_user_name" property="recordUserName"/>
        <result column="process_desc" property="processDesc"/>
    </resultMap>
 
    <select id="selectEmergencyDrillExecuteById" resultMap="emergencyDrillExecuteInfoDetailDOResult">
        SELECT
            a.id,
            a.`status`,
            a.`drill_record_date`,
            a.`drill_plan_id`,
            a.`record_user_uid`,
            a.record_user_name,
            a.process_desc,
            b.drill_name AS drillName
        FROM
            emergency_drill_execute a
            LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
        WHERE
            a.del_flag = 0
            AND a.id = #{id}
    </select>
 
    <update id="updateEmergencyDrillExecute" parameterType="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo">
        update emergency_drill_execute
        <trim prefix="SET" suffixOverrides=",">
            <if test="gmtModitify != null ">gmt_moditify = #{gmtModitify},</if>
            <if test="updateUid != null ">update_uid = #{updateUid},</if>
            <if test="status != null ">status = #{status},</if>
            <if test="drillRecordDate != null ">drill_record_date=#{drillRecordDate},</if>
            <if test="drillPlanId != null ">drill_plan_id=#{drillPlanId},</if>
            <if test="recordUserUid != null ">record_user_uid=#{recordUserUid},</if>
            <if test="recordUserName != null and recordUserName != ''">record_user_name = #{recordUserName},</if>
            <if test="processDesc != null and processDesc != ''">process_desc=#{processDesc},</if>
 
        </trim>
        where id = #{id}
    </update>
 
    <update id="deleteEmergencyDrillExecute">
        update emergency_drill_execute set del_flag = 1 where id = #{id}
    </update>
 
    <update id="updateStatusById">
        update emergency_drill_execute set status = 1 where id = #{drillExecuteId}
    </update>
 
    <select id="selectEmergencyDrillExecuteIntervalTime" resultType="java.lang.Integer">
        SELECT datediff( now( ), ( SELECT max( gmt_create ) FROM `emergency_drill_execute` ) )
    </select>
 
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountData"
               id="emergencyDrillExecuteCountChart">
        <result column="num" property="num"/>
        <result column="name" property="name"/>
    </resultMap>
 
    <select id="selectByMonthAndDept" resultMap="emergencyDrillExecuteCountChart">
        SELECT
        count( 0 ) AS num,
        DATE_FORMAT( a.gmt_create, '%Y-%m' ) AS `name`
        FROM
        `emergency_drill_execute` a
        LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
        WHERE
        a.del_flag = 0
        AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
        AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
        <if test="deptIds != null " >
        and b.department_id in
            <foreach item="id" collection="deptIds" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT( a.gmt_create, '%Y-%m' )
    </select>
 
    <select id="selectByYearAndDept" resultMap="emergencyDrillExecuteCountChart">
        SELECT
        count( 0 ) AS num,
        DATE_FORMAT( a.gmt_create, '%Y' ) AS `name`
        FROM
        `emergency_drill_execute` a
        LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
        WHERE
        a.del_flag = 0
        AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
        AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
        <if test="deptIds != null " >
            and b.department_id in
            <foreach item="id" collection="deptIds" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT( a.gmt_create, '%Y' )
    </select>
 
 
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountRPC"
               id="emergencyDrillExecuteCountRPC">
        <result column="num" property="num"/>
        <result column="name" property="name"/>
    </resultMap>
    <select id="selectByDayAndDept" resultMap="emergencyDrillExecuteCountRPC">
        SELECT
        count( 0 ) AS num,
        DATE_FORMAT( a.gmt_create, '%d' ) AS `name`
        FROM
        `emergency_drill_execute` a
        LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
        WHERE
        a.del_flag = 0
        AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
        AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
        <if test="deptIds != null " >
            and b.department_id in
            <foreach item="id" collection="deptIds" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT( a.gmt_create, '%Y-%m-%d' ),
        DATE_FORMAT( a.gmt_create, '%d' )
    </select>
 
    <select id="selectByMonthAndDeptForIntegerMonth" resultMap="emergencyDrillExecuteCountRPC">
        SELECT
        count( 0 ) AS num,
        DATE_FORMAT( a.gmt_create, '%m' ) AS `name`
        FROM
        `emergency_drill_execute` a
        LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
        WHERE
        a.del_flag = 0
        AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
        AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
        <if test="deptIds != null " >
            and b.department_id in
            <foreach item="id" collection="deptIds" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY
        DATE_FORMAT( a.gmt_create, '%Y-%m' ),
        DATE_FORMAT( a.gmt_create, '%m' )
    </select>
 
 
    <select id="selectEmergencyDrillExecuteIntervalTimeByDeptId" resultType="java.lang.String">
        SELECT
            DATE_FORMAT( max( a.gmt_create ), '%Y-%m-%d %H:%i:%s' ) AS lastTime
        FROM
            `emergency_drill_execute` a
            INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
            AND b.department_id = #{deptId}
    </select>
 
</mapper>