郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?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.specialWork.repository.SpecialWorkAppointmentInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.specialWork.entity.SpecialWorkAppointmentInfo" id="SpecialWorkAppointmentMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="applyDepId" column="apply_dep_id" jdbcType="INTEGER"/>
        <result property="applyDepName" column="apply_dep_name" jdbcType="VARCHAR"/>
        <result property="appointmentTime" column="appointment_time" jdbcType="TIMESTAMP"/>
        <result property="status" column="status" jdbcType="TINYINT"/>
        <result property="hotWork" column="hot_work" jdbcType="INTEGER"/>
        <result property="groundBreakingOper" column="ground_breaking_oper" jdbcType="INTEGER"/>
        <result property="blindPlatePluggingOper" column="blind_plate_plugging_oper" jdbcType="INTEGER"/>
        <result property="temporaryPowerOper" column="temporary_power_oper" jdbcType="INTEGER"/>
        <result property="workAtHeight" column="work_at_height" jdbcType="INTEGER"/>
        <result property="openCircuitOper" column="open_circuit_oper" jdbcType="INTEGER"/>
        <result property="liftingOper" column="lifting_oper" jdbcType="INTEGER"/>
        <result property="confinedSpaceOper" column="confined_space_oper" jdbcType="INTEGER"/>
        <result property="createUid" column="create_uid" jdbcType="INTEGER"/>
        <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
        <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
        <result property="createUname" column="create_uname" jdbcType="VARCHAR"/>
        <result property="modifiedUname" column="modified_uname" jdbcType="VARCHAR"/>
        <result property="modifiedUid" column="modified_uid" jdbcType="INTEGER"/>
    </resultMap>
 
    <!--查询单个-->
    <select id="queryById" resultMap="SpecialWorkAppointmentMap">
        select
          id, apply_dep_id, apply_dep_name, appointment_time, status, hot_work, ground_breaking_oper, blind_plate_plugging_oper, temporary_power_oper, work_at_height, open_circuit_oper, lifting_oper, confined_space_oper, create_uid, gmt_create, gmt_modified, create_uname, modified_uname, modified_uid
        from special_work_appointment
        where id = #{id} and status = #{status}
    </select>
 
    <!--查询数据-->
    <select id="listByConditions" resultMap="SpecialWorkAppointmentMap">
        select
          id, apply_dep_id, apply_dep_name, appointment_time, status, hot_work, ground_breaking_oper, blind_plate_plugging_oper, temporary_power_oper, work_at_height, open_circuit_oper, lifting_oper, confined_space_oper, create_uid, gmt_create, gmt_modified, create_uname, modified_uname, modified_uid
        from special_work_appointment
        <where>
 
            <if test="query.applyDepId != null">
                and apply_dep_id = #{query.applyDepId}
            </if>
            <if test="query.appointmentTime != null">
                and appointment_time = #{query.appointmentTime}
            </if>
            <if test="query.startTime != null">
                and appointment_time >= #{query.startTime}
            </if>
            <if test="query.endTime != null">
                and appointment_time &lt;= #{query.endTime}
            </if>
            <if test="query.status != null">
                and status = #{query.status}
            </if>
        </where>
        ORDER BY gmt_create DESC
    </select>
 
    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from special_work_appointment
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="applyDepId != null">
                and apply_dep_id = #{applyDepId}
            </if>
            <if test="applyDepName != null and applyDepName != ''">
                and apply_dep_name = #{applyDepName}
            </if>
            <if test="appointmentTime != null">
                and appointment_time = #{appointmentTime}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="hotWork != null">
                and hot_work = #{hotWork}
            </if>
            <if test="groundBreakingOper != null">
                and ground_breaking_oper = #{groundBreakingOper}
            </if>
            <if test="blindPlatePluggingOper != null">
                and blind_plate_plugging_oper = #{blindPlatePluggingOper}
            </if>
            <if test="temporaryPowerOper != null">
                and temporary_power_oper = #{temporaryPowerOper}
            </if>
            <if test="workAtHeight != null">
                and work_at_height = #{workAtHeight}
            </if>
            <if test="openCircuitOper != null">
                and open_circuit_oper = #{openCircuitOper}
            </if>
            <if test="liftingOper != null">
                and lifting_oper = #{liftingOper}
            </if>
            <if test="confinedSpaceOper != null">
                and confined_space_oper = #{confinedSpaceOper}
            </if>
            <if test="createUid != null">
                and create_uid = #{createUid}
            </if>
            <if test="gmtCreate != null">
                and gmt_create = #{gmtCreate}
            </if>
            <if test="gmtModified != null">
                and gmt_modified = #{gmtModified}
            </if>
            <if test="createUname != null and createUname != ''">
                and create_uname = #{createUname}
            </if>
            <if test="modifiedUname != null and modifiedUname != ''">
                and modified_uname = #{modifiedUname}
            </if>
            <if test="modifiedUid != null">
                and modified_uid = #{modifiedUid}
            </if>
        </where>
    </select>
 
    <!--新增所有列-->
    <insert id="saveOne" >
        insert into special_work_appointment(apply_dep_id, apply_dep_name, appointment_time, status, hot_work, ground_breaking_oper, blind_plate_plugging_oper, temporary_power_oper, work_at_height, open_circuit_oper, lifting_oper, confined_space_oper, create_uid, gmt_create, gmt_modified, create_uname, modified_uname, modified_uid)
        values (#{applyDepId}, #{applyDepName}, #{appointmentTime}, #{status}, #{hotWork}, #{groundBreakingOper}, #{blindPlatePluggingOper}, #{temporaryPowerOper}, #{workAtHeight}, #{openCircuitOper}, #{liftingOper}, #{confinedSpaceOper}, #{createUid}, #{gmtCreate}, #{gmtModified}, #{createUname}, #{modifiedUname}, #{modifiedUid})
    </insert>
 
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into special_work_appointment(apply_dep_id, apply_dep_name, appointment_time, status, hot_work, ground_breaking_oper, blind_plate_plugging_oper, temporary_power_oper, work_at_height, open_circuit_oper, lifting_oper, confined_space_oper, create_uid, gmt_create, gmt_modified, create_uname, modified_uname, modified_uid)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.applyDepId}, #{entity.applyDepName}, #{entity.appointmentTime}, #{entity.status}, #{entity.hotWork}, #{entity.groundBreakingOper}, #{entity.blindPlatePluggingOper}, #{entity.temporaryPowerOper}, #{entity.workAtHeight}, #{entity.openCircuitOper}, #{entity.liftingOper}, #{entity.confinedSpaceOper}, #{entity.createUid}, #{entity.gmtCreate}, #{entity.gmtModified}, #{entity.createUname}, #{entity.modifiedUname}, #{entity.modifiedUid})
        </foreach>
    </insert>
 
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into special_work_appointment(apply_dep_id, apply_dep_name, appointment_time, status, hot_work, ground_breaking_oper, blind_plate_plugging_oper, temporary_power_oper, work_at_height, open_circuit_oper, lifting_oper, confined_space_oper, create_uid, gmt_create, gmt_modified, create_uname, modified_uname, modified_uid)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.applyDepId}, #{entity.applyDepName}, #{entity.appointmentTime}, #{entity.status}, #{entity.hotWork}, #{entity.groundBreakingOper}, #{entity.blindPlatePluggingOper}, #{entity.temporaryPowerOper}, #{entity.workAtHeight}, #{entity.openCircuitOper}, #{entity.liftingOper}, #{entity.confinedSpaceOper}, #{entity.createUid}, #{entity.gmtCreate}, #{entity.gmtModified}, #{entity.createUname}, #{entity.modifiedUname}, #{entity.modifiedUid})
        </foreach>
        on duplicate key update
        apply_dep_id = values(apply_dep_id),
        apply_dep_name = values(apply_dep_name),
        appointment_time = values(appointment_time),
        status = values(status),
        hot_work = values(hot_work),
        ground_breaking_oper = values(ground_breaking_oper),
        blind_plate_plugging_oper = values(blind_plate_plugging_oper),
        temporary_power_oper = values(temporary_power_oper),
        work_at_height = values(work_at_height),
        open_circuit_oper = values(open_circuit_oper),
        lifting_oper = values(lifting_oper),
        confined_space_oper = values(confined_space_oper),
        create_uid = values(create_uid),
        gmt_create = values(gmt_create),
        gmt_modified = values(gmt_modified),
        create_uname = values(create_uname),
        modified_uname = values(modified_uname),
        modified_uid = values(modified_uid)
    </insert>
 
    <!--通过主键修改数据-->
    <update id="updateOne">
        update special_work_appointment
        <set>
            <if test="applyDepId != null">
                apply_dep_id = #{applyDepId},
            </if>
            <if test="applyDepName != null and applyDepName != ''">
                apply_dep_name = #{applyDepName},
            </if>
            <if test="appointmentTime != null">
                appointment_time = #{appointmentTime},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="hotWork != null">
                hot_work = #{hotWork},
            </if>
            <if test="groundBreakingOper != null">
                ground_breaking_oper = #{groundBreakingOper},
            </if>
            <if test="blindPlatePluggingOper != null">
                blind_plate_plugging_oper = #{blindPlatePluggingOper},
            </if>
            <if test="temporaryPowerOper != null">
                temporary_power_oper = #{temporaryPowerOper},
            </if>
            <if test="workAtHeight != null">
                work_at_height = #{workAtHeight},
            </if>
            <if test="openCircuitOper != null">
                open_circuit_oper = #{openCircuitOper},
            </if>
            <if test="liftingOper != null">
                lifting_oper = #{liftingOper},
            </if>
            <if test="confinedSpaceOper != null">
                confined_space_oper = #{confinedSpaceOper},
            </if>
            <if test="createUid != null">
                create_uid = #{createUid},
            </if>
            <if test="gmtCreate != null">
                gmt_create = #{gmtCreate},
            </if>
            <if test="gmtModified != null">
                gmt_modified = #{gmtModified},
            </if>
            <if test="createUname != null and createUname != ''">
                create_uname = #{createUname},
            </if>
            <if test="modifiedUname != null and modifiedUname != ''">
                modified_uname = #{modifiedUname},
            </if>
            <if test="modifiedUid != null">
                modified_uid = #{modifiedUid},
            </if>
        </set>
        where id = #{id}
    </update>
 
    <!--通过主键逻辑删除-->
    <update id="updateStatus">
        update special_work_appointment set status = #{status} where id = #{id}
    </update>
    <!--批量删除-->
    <update id="updateStatusByIds">
        update special_work_appointment set status = #{status} where id in
        <foreach collection="idList" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </update>
    <!--统计每个部门各个作业预约情况-->
    <select id="statisticsAppointment" resultType="com.gkhy.safePlatform.specialWork.model.bo.WorkStatisticsBO">
        SELECT apply_dep_id,
               SUM(work_at_height) as heightCount,
               SUM(hot_work)as hotCount,
               SUM(ground_breaking_oper) as groundBreakingCount,
               SUM(blind_plate_plugging_oper) as blindPlatePluggingCount,
               SUM(temporary_power_oper) as temporaryPowerCount,
               SUM(open_circuit_oper) as openCircuitCout,
               SUM(lifting_oper) as liftingCount,
               SUM(confined_space_oper) as confinedSpaceCount,
               SUM( work_at_height + hot_work + temporary_power_oper + open_circuit_oper + lifting_oper + confined_space_oper + blind_plate_plugging_oper + ground_breaking_oper ) as totalCount
        FROM `special_work_appointment`
        <where>
            <if test="query.startTime != null">
                and appointment_time >= #{query.startTime}
            </if>
            <if test="query.endTime != null">
                and appointment_time &lt;= #{query.endTime}
            </if>
            <if test="query.status != null">
                and status = #{query.status}
            </if>
        </where>
        GROUP BY apply_dep_id
        ORDER BY totalCount DESC
    </select>
</mapper>