SopTaskDetailInfoMapper.xml
12.3 KB
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
268
269
270
<?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="cn.com.glsx.dj.mindworkplate.mapper.sop.SopTaskDetailInfoMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.sop.SopTaskDetailInfo" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="sop_task_id" property="sopTaskId" jdbcType="INTEGER" />
<result column="check_date" property="checkDate" jdbcType="VARCHAR" />
<result column="task_status" property="taskStatus" jdbcType="INTEGER" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="push_flag" property="pushFlag" jdbcType="INTEGER"/>
<result column="push_count" property="pushCount" jdbcType="INTEGER"/>
<result column="review_status" property="reviewStatus" jdbcType="INTEGER"/>
<result column="punish_status" property="punishStatus" jdbcType="TINYINT"/>
<result column="punish_flag" property="punishFlag" jdbcType="TINYINT"/>
<result column="business_id" property="businessId" jdbcType="VARCHAR"/>
<result column="complete_time" property="completeTime" jdbcType="TIMESTAMP"/>
<result column="deadline" property="deadline" jdbcType="TIMESTAMP"/>
<result column="punish_type" property="punishType" jdbcType="TINYINT"/>
</resultMap>
<resultMap id="DetailInfoMap" extends="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.dto.sop.SopTaskDetailInsertDTO">
<association property="sopTaskInfo" javaType="cn.com.glsx.dj.mindworkplate.dto.sop.SopTaskInfoDTO">
<result column="sop_id" property="sopId" jdbcType="VARCHAR" />
<result column="staff_uuid" property="staffUuid" jdbcType="VARCHAR" />
<result column="staff_name" property="staffName" jdbcType="VARCHAR" />
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
<result column="task_period" property="taskPeriod" jdbcType="INTEGER" />
<result column="config_id" property="configId" jdbcType="INTEGER" />
</association>
</resultMap>
<resultMap id="pageDetailMap" extends="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.dto.sop.SopTaskDetailPageDTO">
<result column="staff_name" property="staffName" jdbcType="VARCHAR" />
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
<result column="business_scene_type_name" property="businessSceneTypeName" jdbcType="VARCHAR" />
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />
<result column="main_brand" property="mainBrand" jdbcType="VARCHAR" />
<result column="tag_name" property="tagNames" jdbcType="VARCHAR" />
<result column="recording_info_count" property="recordingInfoCount" jdbcType="INTEGER" />
<result column="tag_count" property="tagCount" jdbcType="INTEGER" />
<result column="tag_finish_count" property="tagFinishCount" jdbcType="INTEGER" />
<result column="detail_ids" property="detailIds" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, sop_task_id, check_date, task_status, created_by, created_date, updated_by, updated_date,
deleted_flag
</sql>
<select id="selectDetailByCondition" parameterType="cn.com.glsx.dj.mindworkplate.dto.sop.SopTaskDetailInfoDTO" resultMap="BaseResultMap">
select stdi.id,stdi.sop_task_id, stdi.check_date, stdi.task_status, stdi.business_id
from sop_task_detail_info stdi
inner join sop_task_info sti on stdi.sop_task_id = sti.id and sti.deleted_flag = 'N'
<where>
stdi.deleted_flag = 'N'
<if test="staffPhone != null and staffPhone != ''">
and sti.staff_phone = #{staffPhone}
</if>
<if test="checkDate != null and checkDate != ''">
and stdi.check_date = #{checkDate}
</if>
<if test="createdDate != null">
and date(stdi.check_date) = #{createdDate}
</if>
<if test="taskStatus != null">
and stdi.task_status = #{taskStatus}
</if>
<if test="taskStatusList != null and taskStatusList.size() > 0">
and stdi.task_status in
<foreach item="item" collection="taskStatusList" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
order by stdi.id desc
</select>
<select id="listUnPushedDetailTask" resultMap="DetailInfoMap">
select stdi.id, stdi.check_date,
sti.sop_id,sti.staff_uuid,sti.staff_name,sti.merchant_id,sti.merchant_name,sti.staff_phone,sti.task_period, sti.config_id
from sop_task_detail_info stdi
inner join sop_task_info sti on stdi.sop_task_id = sti.id and sti.deleted_flag = 'N'
where stdi.deleted_flag = 'N' and stdi.task_status = 5 and stdi.push_flag = 0
</select>
<select id="listUnEvaluateDetailTask" resultMap="DetailInfoMap">
select stdi.id, stdi.check_date, stdi.review_status, stdi.task_status as task_status, stdi.created_date as created_date,
sti.sop_id,sti.staff_uuid,sti.staff_name,sti.merchant_id,sti.merchant_name,sti.staff_phone,sti.task_period, sti.config_id
from sop_task_detail_info stdi
inner join sop_task_info sti on stdi.sop_task_id = sti.id and sti.deleted_flag = 'N'
where stdi.deleted_flag = 'N' and stdi.task_status = 1 and stdi.business_id is null and stdi.check_date >= #{queryDate}
</select>
<update id="updatePushFlagById">
update sop_task_detail_info
set push_flag = 1, updated_date = now()
where id = #{id}
</update>
<update id="updateTaskDetailBusinessId">
update sop_task_detail_info
set business_id = #{businessId}, task_status = #{status}, updated_date = now(), complete_time = now()
where id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="updatePunishFlagByIds">
update sop_task_detail_info
set punish_flag = #{status}, updated_date = now()
where id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="batchUpdateReviewStatus">
<foreach collection="list" item="item" separator=";">
update sop_task_detail_info
set review_status = #{item.reviewStatus}, updated_date = #{item.updatedDate}
where id = #{item.id}
</foreach>
</update>
<select id="listSopDetailTask" parameterType="cn.com.glsx.dj.mindworkplate.model.sop.SopTaskDetailInfo" resultMap="DetailInfoMap">
select stdi.*,
sti.sop_id,sti.staff_uuid,sti.staff_name,sti.merchant_id,sti.merchant_name,sti.staff_phone,sti.task_period, sti.config_id
from sop_task_detail_info stdi
inner join sop_task_info sti on stdi.sop_task_id = sti.id and sti.deleted_flag = 'N'
<where>
stdi.deleted_flag = 'N'
<if test="taskStatus != null">
and stdi.task_status = #{taskStatus}
</if>
<if test="checkDate != null and checkDate != ''">
and stdi.check_date = #{checkDate}
</if>
<if test="reviewStatus != null">
and stdi.review_status = #{reviewStatus}
</if>
<if test="pushFlag != null">
and stdi.push_flag = #{pushFlag}
</if>
<if test="pushCount != null">
and stdi.push_count <= #{pushCount}
</if>
<if test="staffPhone != null and staffPhone != ''">
and sti.staff_phone = #{staffPhone}
</if>
<if test="businessId != null and businessId != ''">
and stdi.business_id = #{businessId}
</if>
</where>
</select>
<select id="listSopDetailTaskByIds" resultMap="DetailInfoMap">
select stdi.id, stdi.check_date,stdi.created_by,stdi.push_count,stdi.created_date as created_date,
sti.sop_id,sti.staff_uuid,sti.staff_name,sti.merchant_id,sti.merchant_name,sti.staff_phone,sti.task_period, sti.config_id
from sop_task_detail_info stdi
inner join sop_task_info sti on stdi.sop_task_id = sti.id and sti.deleted_flag = 'N'
where stdi.deleted_flag = 'N' and stdi.id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="pageStudyDetail" resultMap="pageDetailMap" parameterType="cn.com.glsx.dj.mindworkplate.dto.sop.SopTaskDetailPageDTO">
select
info.staff_name, info.staff_phone,
max(info.merchant_name) as merchant_name,
max(info.business_scene_type_name) as business_scene_type_name,
max(info.main_brand) as main_brand,
group_concat(distinct detail.id) as detail_ids,
detail.check_date as check_date,
if(sum(detail.task_status != 2) = 0, 2, 1) as task_status, <!-- 聚合任务状态,全部完成才算完成 -->
case
when sum(coalesce(detail.punish_status, 1) != 3) = 0 then 3
when sum(coalesce(detail.punish_status, 1) = 2) > 0 then 2
else 1
end as punish_status, <!-- 聚合处罚状态,全部已完成,全部未触发,否则处罚中 -->
detail.punish_flag as punish_flag,
detail.punish_type as punish_type,
max(detail.complete_time) as complete_time,
detail.deadline as deadline,
max(detail.created_date) as created_date,
max(detail.updated_date) as updated_date,
group_concat(distinct tag.tag_name) as tag_name,
sum(if(tag.status != 0, 1, 0)) as tag_count,
sum(if(tag.status = 2, 1, 0)) as tag_finish_count,
count(distinct ar.id) as recording_info_count
from sop_task_detail_info detail
left join sop_task_info info on detail.sop_task_id = info.id and info.deleted_flag = 'N'
left join sop_task_detail_agent_ref ar on ar.task_detail_id = detail.id and ar.deleted_flag = 'N'
left join sop_task_detail_tag tag on tag.business_id = detail.business_id and tag.deleted_flag = 'N'
<where>
detail.deleted_flag = 'N'
and detail.task_status not in (0)
<if test="staffName != null and staffName != ''">
and info.staff_name like concat('%', #{staffName}, '%')
</if>
<if test="staffPhone != null and staffPhone != ''">
and info.staff_phone like concat('%', #{staffPhone}, '%')
</if>
<if test="businessSceneTypeName != null and businessSceneTypeName != ''">
and info.business_scene_type_name like concat('%', #{businessSceneTypeName}, '%')
</if>
<if test="merchantName != null and merchantName != ''">
and info.merchant_name like concat('%', #{merchantName}, '%')
</if>
<if test="mainBrand != null and mainBrand != ''">
and info.main_brand like concat('%', #{mainBrand}, '%')
</if>
<if test="punishType != null">
and detail.punish_type = #{punishType}
</if>
<if test="punishStatus != null">
and detail.punish_status = #{punishStatus}
</if>
<if test="taskStatus != null">
and detail.task_status = #{taskStatus}
</if>
<if test="taskStatusList != null and taskStatusList.size() > 0">
and detail.task_status in
<foreach collection="taskStatusList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="checkStartTime != null">
and detail.check_date >= date(#{checkStartTime})
</if>
<if test="checkEndTime != null">
and detail.check_date <= date(#{checkEndTime})
</if>
<if test="finishStartTime != null">
and detail.complete_time >= #{finishStartTime}
</if>
<if test="finishEndTime != null">
and detail.complete_time <= #{finishEndTime}
</if>
</where>
group by info.staff_phone, detail.check_date
order by detail.check_date desc
</select>
<select id="findPadMessageIds" resultType="java.lang.Integer">
select
p.msg_bos_id
from sop_task_detail_info d
inner join sop_task_pad_push p on d.id = p.task_id and p.del_flag = 'N'
where d.deleted_flag = 'N' and d.id in
<foreach item="item" collection="detailIds" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>