郑永安
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
<?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.safeCheck.repository.SafeCheckTaskRepository" >
    <resultMap id="BaseResultMap" type="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask" >
        <id column="id" property="id" />
        <result column="uuid" property="uuid"/>
        <result column="delete_status" property="deleteStatus" />
        <result column="task_type" property="taskType" />
        <result column="task_status" property="taskStatus"/>
        <result column="file_address" property="fileAddress" />
        <result column="task_claim" property="taskClaim"/>
        <result column="task_claim_time" property="taskClaimTime"/>
        <result column="result_status" property="resultStatus" />
        <result column="check_cycle" property="checkCycle" />
        <result column="check_cycle_unit" property="checkCycleUnit" />
        <result column="exec_user_id" property="execUserId" />
        <result column="exec_user_name" property="execUserName" />
        <result column="exec_classgroup_id" property="execClassgroupId" />
        <result column="exec_classgroup_name" property="execClassgroupName" />
        <result column="exec_dep_id" property="execDepId" />
        <result column="points_length" property="pointsLength" />
        <result column="start_time" property="startTime" />
        <result column="valid_time" property="validTime" />
        <result column="notice_time" property="noticeTime" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="create_user_name" property="createUserName" />
        <result column="unit_id" property="unitId" />
        <result column="enterprise_id" property="enterpriseId" />
        <result column="enterprise_uuid" property="enterpriseUuid" />
        <result column="unit_uuid" property="unitUuid" />
        <result column="result_desc" property="resultDesc" />
        <result column="check_work_id" property="checkWorkId" />
        <result column="check_work_uuid" property="checkWorkUuid" />
        <result column="task_name" property="taskName" />
        <result column="report_time" property="reportTime" />
    </resultMap>
    <sql id="allTaskFields">
        id,uuid,delete_status,task_type,file_address,task_status,task_claim,task_claim_time,result_status,exec_user_id,exec_user_name,exec_classgroup_id,exec_classgroup_name,points_length,exec_dep_id,start_time,valid_time,notice_time
            ,gmt_create,create_user_name,unit_id,enterprise_id,enterprise_uuid,unit_uuid,result_desc,check_work_id,check_work_uuid,task_name,report_time,check_cycle,check_cycle_unit
    </sql>
 
    <update id="updateTaskStatus" parameterType="int">
        update safe_check_task
        <set>
            <if test="taskStatus != null">
                task_status = #{taskStatus}
            </if>
        </set>
        where id = #{taskId} and delete_status = 0 and task_status = #{oldTaskStatus}
    </update>
 
 
    <update id="updateTaskClaimById">
        update safe_check_task
        <set>
            <if test="task.taskClaim != null">
                task_claim = #{task.taskClaim},
            </if>
            <if test="task.taskClaimTime != null">
                task_claim_time = #{task.taskClaimTime},
            </if>
            <if test="task.execUserId != null">
                exec_user_id = #{task.execUserId},
            </if>
            <if test="task.execUserName != null">
                exec_user_name = #{task.execUserName},
            </if>
            <if test="task.enterpriseId != null">
                enterprise_id = #{task.enterpriseId}
            </if>
        </set>
        where id = #{task.id} and delete_status = 0 and task_status in (1,2)
    </update>
 
    <update id="updateTaskCheckResultByTaskId">
        update safe_check_task
        <set>
            <if test="taskCheckResult != null">
                result_status = #{taskCheckResult},
            </if>
            <if test="commitTime != null">
                report_time = #{commitTime},
            </if>
            <if test="taskStatus != null">
                task_status = #{taskStatus}
            </if>
            where id = #{taskId} and delete_status = 0 and task_status = 2
        </set>
    </update>
 
    <select id="getTaskById" resultMap="BaseResultMap">
        select
        <include refid="allTaskFields"></include>
        from safe_check_task
        where id = #{id}  and delete_status = 0
    </select>
    
    <resultMap id="findByGroupIdAndTime" type="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTaskMobileDO">
        <id column="id" property="id" />
        <result column="task_name" property="taskName" />
        <result column="task_type" property="taskType" />
        <result column="task_status" property="taskStatus"/>
        <result column="file_address" property="fileAddress" />
        <result column="exec_user_id" property="execUserId"/>
        <result column="exec_user_name" property="execUserName" />
        <result column="task_claim" property="taskClaim" />
        <result column="check_cycle_unit" property="checkCycleUnit" />
        <result column="check_cycle" property="checkCycle" />
        <result column="points_length" property="pointsLength" />
        <result column="exec_classgroup_id" property="execClassgroupId" />
        <result column="start_time" property="startTime" />
        <result column="valid_time" property="validTime" />
        <result column="create_user_name" property="createUserName" />
        <result column="gmt_create" property="gmtCreate" />
        <collection property="points"
                    javaType="ArrayList"
                    ofType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTaskAndQuota"
                    column="id"
                    select="com.gkhy.safePlatform.safeCheck.repository.SafeCheckTaskAndQuotaRepository.findTaskAndQuotaByTaskId">
        </collection>
    </resultMap>
    <select id="listUserTaskByPage" resultMap="findByGroupIdAndTime">
        select * from safe_check_task
        ${ew.customSqlSegment}
    </select>
 
 
    <resultMap id="allTaskFieldsAddRowNumver" type="com.gkhy.safePlatform.safeCheck.entity.SafeCheckeGrByStatusOrByTimeDO" extends="BaseResultMap">
        <result column="serial_number" property="serialNumber" />
    </resultMap>
    <select id="listTaskByPageGrByStatusOrByTime"
            resultMap="allTaskFieldsAddRowNumver">
            SELECT t.*,ROW_NUMBER()
                over (partition by t.task_status ORDER BY t.valid_time DESC) "serial_number"
            from safe_check_task as t ${ew.customSqlSegment}
    </select>
 
    <select id="getTaskByWorkIdAndTaskStartTime"
            resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask">
        select
        <include refid="allTaskFields"></include>
        from safe_check_task
        where check_work_id  = #{workId} and start_time = #{nextCheckTime} and delete_status = #{deleteStatus}
    </select>
 
 
    <select id="getTaskByTaskIdAndTaskStatus"
            resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask">
        select
        <include refid="allTaskFields"></include>
        from safe_check_task
        where id = #{taskId} and task_status = #{taskStatus} and delete_status = 0
    </select>
 
 
    <select id="listNoCheckTaskByValidTime" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask">
        select
        <include refid="allTaskFields"></include>
        from safe_check_task
        <where>
            delete_status = 0
            <if test="zeroPointDateTime != null">
                and valid_time &gt;= #{zeroPointDateTime}
            </if>
            <if test="nowTime != null">
                and valid_time &lt;= #{nowTime}
            </if>
            <if test="taskStatus != null">
                and task_status = #{taskStatus}
            </if>
            <if test="depIds != null">
                and exec_dep_id in
                <foreach item="dep" index="index" collection="depIds" open="(" separator="," close=")">
                    #{dep}
                </foreach>
            </if>
        </where>
        ORDER BY valid_time DESC
    </select>
 
 
    <select id="listAbnormalTaskByValidTime" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask">
        select
        <include refid="allTaskFields"></include>
        from safe_check_task
        <where>
            delete_status = 0
            <if test="zeroPointDateTime != null">
                and report_time &gt;= #{zeroPointDateTime}
            </if>
            <if test="nowTime != null">
                and report_time &lt;= #{nowTime}
            </if>
            <if test="taskStatus != null">
                and task_status = #{taskStatus}
            </if>
            <if test="taskResultCode != null">
                and result_status = #{taskResultCode}
            </if>
            <if test="depIds != null">
                and exec_dep_id in
                <foreach item="dep" index="index" collection="depIds" open="(" separator="," close=")">
                    #{dep}
                </foreach>
            </if>
        </where>
        ORDER BY valid_time DESC
    </select>
 
 
    <resultMap id="findByGroupIdOrDepIdOrStatus" type="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTaskDataMobileDO">
        <id column="id" property="id" />
        <result column="task_name" property="taskName" />
        <result column="task_type" property="taskType" />
        <result column="task_status" property="taskStatus"/>
        <result column="file_address" property="fileAddress" />
        <result column="exec_user_id" property="execUserId"/>
        <result column="exec_user_name" property="execUserName" />
        <result column="task_claim" property="taskClaim" />
        <result column="check_cycle_unit" property="checkCycleUnit" />
        <result column="check_cycle" property="checkCycle" />
        <result column="points_length" property="pointsLength" />
        <result column="exec_classgroup_id" property="execClassgroupId" />
        <result column="start_time" property="startTime" />
        <result column="valid_time" property="validTime" />
        <result column="create_user_name" property="createUserName" />
        <result column="gmt_create" property="gmtCreate" />
        <collection property="points"
                    javaType="ArrayList"
                    ofType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckTaskAndQuota"
                    column="id"
                    select="com.gkhy.safePlatform.safeCheck.repository.SafeCheckTaskAndQuotaRepository.findTaskAndQuotaByTaskId">
        </collection>
    </resultMap>
    <select id="listTaskDataByCondition" resultMap="findByGroupIdOrDepIdOrStatus">
        select *
        from
             safe_check_task ${ew.customSqlSegment}
    </select>
 
</mapper>