131ad9be
wangqian
首页统计接口
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<?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.zteits.urbanops.module.garden.dal.mysql.homepage.HomepageSummaryMapper">
<select id="countInspectionPlanByCompanyId" resultType="java.util.Map" parameterType="java.lang.Long">
SELECT
SUM(CASE WHEN t.finish_state = 1 THEN 1 ELSE 0 END) AS unfinishedCount,
SUM(CASE WHEN t.finish_state = 2 THEN 1 ELSE 0 END) AS finishedCount,
SUM(CASE WHEN t.finish_state = 3 THEN 1 ELSE 0 END) AS invalidCount,
SUM(CASE WHEN t.finish_state = 4 THEN 1 ELSE 0 END) AS terminatedCount,
COUNT(1) AS totalCount
FROM
garden_inspection_plan t
<where>
t.deleted = 0
<if test="companyId != null">
|
bf21758e
wangqian
首页统计接口修改
|
17
|
AND t.company_id = #{companyId}
|
131ad9be
wangqian
首页统计接口
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
</if>
</where>
</select>
<select id="countMaintainPlanByCompanyId" resultType="java.util.Map" parameterType="java.lang.Long">
SELECT
SUM(CASE WHEN t.finish_state = 1 THEN 1 ELSE 0 END) AS unfinishedCount,
SUM(CASE WHEN t.finish_state = 2 THEN 1 ELSE 0 END) AS finishedCount,
SUM(CASE WHEN t.finish_state = 3 THEN 1 ELSE 0 END) AS invalidCount,
SUM(CASE WHEN t.finish_state = 4 THEN 1 ELSE 0 END) AS terminatedCount,
COUNT(1) AS totalCount
FROM
garden_maintain_plan t
<where>
t.deleted = 0
<if test="companyId != null">
|
bf21758e
wangqian
首页统计接口修改
|
34
|
AND t.company_id = #{companyId}
|
131ad9be
wangqian
首页统计接口
|
35
36
37
38
39
40
41
42
43
44
45
46
|
</if>
</where>
</select>
<select id="countInProgressWorkOrder" resultType="java.util.Map" parameterType="java.lang.Long">
SELECT
t.busi_line as busiLine,
COUNT(1) AS totalCount
FROM
workorder_main_info t
<where>
t.deleted = 0
|
ad64c285
wangqian
工单趋势图时间及工单统计状态修改
|
47
|
AND t.buz_status NOT IN ('200', '140')
|
131ad9be
wangqian
首页统计接口
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<if test="companyId != null">
AND t.worker_company_id = #{companyId}
</if>
</where>
GROUP BY
t.busi_line
</select>
<select id="countCompletedWorkOrder" resultType="java.util.Map" parameterType="java.lang.Long">
SELECT
CASE WHEN t.worker_id IS NOT NULL THEN 'validOrder'
ELSE 'invalidOrder'
END AS workorder_valid_status,
COUNT(1) AS totalCount
FROM
workorder_main_info t
<where>
t.deleted = 0
|
ad64c285
wangqian
工单趋势图时间及工单统计状态修改
|
66
|
AND t.buz_status IN ('200', '140')
|
131ad9be
wangqian
首页统计接口
|
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
|
<if test="companyId != null">
AND t.worker_company_id = #{companyId}
</if>
</where>
GROUP BY
CASE WHEN t.worker_id IS NOT NULL THEN 'validOrder'
ELSE 'invalidOrder'
END
</select>
<!-- 巡查计划次数统计-->
<select id="countInspectionPlanNumByBusiLine" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo">
select v.date_value dateValue,
busi_line as busiLine ,
IFNULL(SUM(plan_num), 0) AS inspectionPlanNum,
IFNULL(sum(plan_finish_num),0) AS inspectionPlanFinishNum
from view_statics_times v
left join garden_inspection_plan_detail t
on v.date_value = DATE_FORMAT(t.end_time , '%Y-%m-%d') and deleted =0 and finish_state NOT IN (3, 4)
<if test="companyId != null">
AND company_id = #{companyId}
</if>
<where>
<if test="beginTime != null and beginTime != ''">
AND v.date_value >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
93
|
AND v.date_value <= #{endTime}
|
131ad9be
wangqian
首页统计接口
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
</if>
</where>
group by v.date_value,busi_line
</select>
<!-- 养护计划次统计-->
<select id="countMaintainPlanNumByBusiLine" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitTaskStatisticsRespVo">
select v.date_value,
busi_line as busiLine ,
IFNULL(SUM(plan_num), 0) AS maintainPlanNum,
IFNULL(sum(plan_finish_num),0) as maintainPlanFinishNum
from view_statics_times v
left join garden_maintain_plan_detail t
on v.date_value = DATE_FORMAT(t.end_time , '%Y-%m-%d') and busi_line='yl' and deleted =0 and finish_state NOT IN (3, 4)
<if test="companyId != null">
AND company_id = #{companyId}
</if>
<where>
<if test="beginTime != null and beginTime != ''">
AND v.date_value >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
115
|
AND v.date_value <= #{endTime}
|
131ad9be
wangqian
首页统计接口
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
</if>
</where>
group by v.date_value,busi_line
</select>
<select id="countRatioByOrderType" resultType="java.util.Map">
SELECT
t.order_type AS orderType,
COUNT(1) AS totalCount
FROM
workorder_main_info t
<where>
deleted = 0
<if test="companyId != null">
and t.worker_company_id = #{companyId}
</if>
<if test="beginTime != null and beginTime != ''">
AND t.create_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
136
|
AND t.create_time <= #{endTime}
|
131ad9be
wangqian
首页统计接口
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
</if>
</where>
GROUP BY
t.order_type
</select>
<select id="countRatioBySourceId" resultType="java.util.Map">
SELECT
t.source_id as sourceId,
COUNT(1) AS totalCount
FROM
workorder_main_info t
<where>
deleted = 0
<if test="companyId != null">
and t.worker_company_id = #{companyId}
</if>
<if test="beginTime != null and beginTime != ''">
AND t.create_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
157
|
AND t.create_time <= #{endTime}
|
131ad9be
wangqian
首页统计接口
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
</if>
</where>
GROUP BY
t.source_id
</select>
<select id="countRatioByPressingType" resultType="java.util.Map" >
SELECT
t.pressing_type as pressingType,
COUNT(1) AS totalCount
FROM
workorder_main_info t
<where>
deleted = 0
<if test="companyId != null">
and t.worker_company_id = #{companyId}
</if>
<if test="beginTime != null and beginTime != ''">
AND t.create_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
178
|
AND t.create_time <= #{endTime}
|
131ad9be
wangqian
首页统计接口
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
</if>
</where>
GROUP BY
t.pressing_type
</select>
<select id="countWorkOrderDistribution" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderRespVo">
SELECT
t.worker_company_id as companyId ,
sum(case when t.order_type='Q' or t.order_type='C' then 1 else 0 end) as patrolWorkOrde,
sum(case when t.order_type='A' then 1 else 0 end) as aiWorkOrde,
sum(case when t.order_type='W' then 1 else 0 end) as gridWorkOrder,
sum(case when t.order_type='O' then 1 else 0 end) as outhWorkOrderO
FROM
workorder_main_info t
<where>
deleted = 0
<if test="companyId != null">
and t.worker_company_id = #{companyId}
</if>
<if test="beginTime != null and beginTime != ''">
AND t.create_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
202
|
AND t.create_time <= #{endTime}
|
131ad9be
wangqian
首页统计接口
|
203
204
205
206
207
|
</if>
</where>
GROUP BY
t.worker_company_id
</select>
|
b4059112
wangqian
子公司工单分布按来源统计
|
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
|
<select id="countWorkOrderDistributionBySource" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.CommitWorkOrderSourceRespVo">
SELECT
t.worker_company_id AS companyId,
-- source_id=1:巡查工单
SUM(CASE WHEN t.source_id = 1 THEN 1 ELSE 0 END) AS patrolCount,
-- source_id=2:游客居民工单
SUM(CASE WHEN t.source_id = 2 THEN 1 ELSE 0 END) AS touristResidentCount,
-- source_id=3:12345工单
SUM(CASE WHEN t.source_id = 3 THEN 1 ELSE 0 END) AS otherCount,
-- source_id=4:网格工单
SUM(CASE WHEN t.source_id = 4 THEN 1 ELSE 0 END) AS gridCount,
-- source_id=5:大区经理工单
SUM(CASE WHEN t.source_id = 5 THEN 1 ELSE 0 END) AS regionalManagerCount,
-- source_id=6:AI工单
SUM(CASE WHEN t.source_id = 6 THEN 1 ELSE 0 END) AS aiCount
FROM
workorder_main_info t
<where>
deleted = 0
<if test="companyId != null">
and t.worker_company_id = #{companyId}
</if>
<if test="beginTime != null and beginTime != ''">
AND t.create_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
234
|
AND t.create_time <= #{endTime}
|
b4059112
wangqian
子公司工单分布按来源统计
|
235
236
237
238
239
|
</if>
</where>
GROUP BY
t.worker_company_id
</select>
|
131ad9be
wangqian
首页统计接口
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
<!--热量图-->
<select id="countWorkOrderHeatmap" resultType="java.util.Map" >
SELECT
t.lat, t.lon, COUNT(1) AS totalCount
FROM
workorder_main_info t
<where>
t.deleted = 0
<if test="companyId != null">
and t.worker_company_id = #{companyId}
</if>
</where>
GROUP BY
t.lat,t.lon
</select>
<select id="countWorkOrderTrend" resultType="com.zteits.urbanops.module.garden.controller.admin.homepage.vo.WorkOrderTrendRespVo">
|
68c7f886
wangqian
app首页统计修改
|
257
258
|
SELECT
DATE_FORMAT(t.create_time , '%Y-%m-%d') as dateValue,
|
131ad9be
wangqian
首页统计接口
|
259
260
261
262
|
t.busi_line as busiLine,
t.worker_company_id as companyId,
<choose>
<when test='queryState != null and queryState eq "1"'>
|
68c7f886
wangqian
app首页统计修改
|
263
|
sum(CASE WHEN DATE_FORMAT(t.create_time , '%Y-%m-%d') = #{currentDate} THEN 1 ELSE 0 END) as totalCount
|
131ad9be
wangqian
首页统计接口
|
264
265
|
</when>
<when test='queryState != null and queryState eq "2"'>
|
68c7f886
wangqian
app首页统计修改
|
266
|
sum(CASE WHEN t.buz_status != '200' THEN 1 ELSE 0 END) as totalCount
|
131ad9be
wangqian
首页统计接口
|
267
268
|
</when>
<when test='queryState != null and queryState eq "3"'>
|
68c7f886
wangqian
app首页统计修改
|
269
|
sum(CASE WHEN t.buz_status = '200' THEN 1 ELSE 0 END) as totalCount
|
131ad9be
wangqian
首页统计接口
|
270
271
|
</when>
</choose>
|
68c7f886
wangqian
app首页统计修改
|
272
273
274
275
|
FROM workorder_main_info t
WHERE deleted = 0
<if test="companyId != null and companyId != ''">
AND t.worker_company_id = #{companyId}
|
b324584b
wangqian
首页统计接口修改
|
276
|
</if>
|
68c7f886
wangqian
app首页统计修改
|
277
|
<if test="beginTime != null and beginTime != ''">
|
4dd66bb7
wangqian
工单趋势图时间修改
|
278
|
AND t.create_time >= #{beginTime}
|
68c7f886
wangqian
app首页统计修改
|
279
280
|
</if>
<if test="endTime != null and endTime != ''">
|
4dd66bb7
wangqian
工单趋势图时间修改
|
281
|
AND t.create_time <= #{endTime}
|
68c7f886
wangqian
app首页统计修改
|
282
283
|
</if>
GROUP BY DATE_FORMAT(t.create_time , '%Y-%m-%d'), t.busi_line, t.worker_company_id
|
131ad9be
wangqian
首页统计接口
|
284
285
|
</select>
|
586017da
wangqian
app首页接口
|
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
<!--已完成任务数量-->
<select id="countcompletedTask" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.TaskCompletionStatusRspVo">
-- 按日期分组,汇总巡检+养护计划提交总数
SELECT
commit_date AS commitDate,
SUM(commit_count) AS completedNum
FROM (
SELECT
DATE_FORMAT(finish_time,'%Y-%m-%d') AS commit_date,
COUNT(id) AS commit_count
FROM garden_inspection_plan_commit
WHERE user_id = #{userId}
<if test="beginTime != null and beginTime != ''">
AND finish_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
302
|
AND finish_time <= #{endTime}
|
586017da
wangqian
app首页接口
|
303
304
305
306
307
308
309
310
311
312
313
314
|
</if>
GROUP BY DATE_FORMAT(finish_time,'%Y-%m-%d')
UNION ALL
SELECT
DATE_FORMAT(finish_time,'%Y-%m-%d') AS commit_date,
COUNT(id) AS commit_count
FROM garden_maintain_plan_commit
WHERE user_id = #{userId}
<if test="beginTime != null and beginTime != ''">
AND finish_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
315
|
AND finish_time <= #{endTime}
|
586017da
wangqian
app首页接口
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
</if>
GROUP BY DATE_FORMAT(finish_time,'%Y-%m-%d')
) AS temp_total
GROUP BY commit_date
ORDER BY commit_date;
</select>
<!--未完成任务数量-->
<select id="countpendingTask" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.TaskCompletionStatusRspVo" >
-- 按日期分组,汇总巡检+养护计划未完成/已过期任务总数
SELECT
commit_date AS commitDate,
SUM(unfinished_count) AS countpendingNum
FROM (
SELECT
DATE_FORMAT(a.begin_time, '%Y-%m-%d') AS commit_date,
COUNT(*) AS unfinished_count
FROM
garden_inspection_plan_detail a
INNER JOIN garden_inspection_plan_role b ON a.batch_no = b.batch_no
|
9bf5e48a
wangqian
app首页接口
|
335
336
|
WHERE -- a.finish_state IN (1, 3) -- 1:未完成;3:已过期
b.role_id IN
|
586017da
wangqian
app首页接口
|
337
338
339
340
341
342
343
|
<foreach collection='roleIds' item='roleId' open='(' close=')' separator=','>
#{roleId}
</foreach>
<if test="beginTime != null and beginTime != ''">
AND a.begin_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
344
|
AND a.end_time <= #{endTime}
|
586017da
wangqian
app首页接口
|
345
346
347
348
349
350
351
352
353
354
355
356
|
</if>
GROUP BY
DATE_FORMAT(a.begin_time, '%Y-%m-%d')
UNION ALL
SELECT
DATE_FORMAT(a.begin_time, '%Y-%m-%d') AS commit_date,
COUNT(*) AS unfinished_count
FROM
garden_maintain_plan_detail a
INNER JOIN garden_maintain_plan_role b ON a.batch_no = b.batch_no
|
9bf5e48a
wangqian
app首页接口
|
357
358
|
WHERE -- a.finish_state IN (1, 3) -- 1:未完成;3:已过期
b.role_id IN
|
586017da
wangqian
app首页接口
|
359
360
361
362
363
364
365
|
<foreach collection='roleIds' item='roleId' open='(' close=')' separator=','>
#{roleId}
</foreach>
<if test="beginTime != null and beginTime != ''">
AND a.begin_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
71ea4fbe
wangqian
app首页接口
|
366
|
AND a.end_time <= #{endTime}
|
586017da
wangqian
app首页接口
|
367
368
369
370
371
372
373
374
375
376
377
|
</if>
GROUP BY
DATE_FORMAT(a.begin_time, '%Y-%m-%d')
) AS temp_total
GROUP BY
commit_date
ORDER BY
commit_date;
</select>
<!--已完成任务详情-->
<select id="queryCompletedTaskDetails" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.TaskDetailsRspVo" >
|
ae00707d
wangqian
静态地址配置
|
378
|
|
71ea4fbe
wangqian
app首页接口
|
379
|
SELECT taskName, busiDateTime, pressingType
|
586017da
wangqian
app首页接口
|
380
|
FROM (
|
ae00707d
wangqian
静态地址配置
|
381
|
-- 巡查已办理
|
71ea4fbe
wangqian
app首页接口
|
382
|
SELECT B.plan_name as taskName,A.finish_time as busiDateTime, null as pressingType
|
586017da
wangqian
app首页接口
|
383
|
from garden_inspection_plan_commit a , garden_inspection_plan b
|
71ea4fbe
wangqian
app首页接口
|
384
385
|
where a.batch_no=b.batch_no
and user_id = #{userId}
|
586017da
wangqian
app首页接口
|
386
387
|
union all
-- 养护已办理
|
71ea4fbe
wangqian
app首页接口
|
388
|
SELECT b.plan_name as taskName,a.finish_time as busiDateTime, null as pressingType
|
586017da
wangqian
app首页接口
|
389
|
from garden_maintain_plan_commit a , garden_maintain_plan b
|
71ea4fbe
wangqian
app首页接口
|
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
where a.batch_no=b.batch_no
and user_id = #{userId}
union all
-- 工单已办
SELECT
res.order_name as taskName, res.create_time as busiDateTime, res.pressing_type as pressingType
FROM (
SELECT
m.order_name,m.create_time, m.pressing_type,
ROW_NUMBER() OVER (
PARTITION BY m.order_no
ORDER BY t.START_TIME_ DESC, t.ID_ DESC
) AS rn
FROM act_hi_taskinst t
LEFT JOIN workorder_main_info m ON t.PROC_INST_ID_ = m.process_instance_id AND m.deleted = 0
|
b540c6a7
wangqian
app首页已完成修改
|
405
|
WHERE t.state_ ='completed'
|
71ea4fbe
wangqian
app首页接口
|
406
407
408
|
AND t.ASSIGNEE_ = #{userId}
) res
WHERE res.rn = 1
|
586017da
wangqian
app首页接口
|
409
410
411
412
413
|
) t
ORDER BY busiDateTime DESC
</select>
<!--待办任务详情-->
<select id="queryPendingTaskDetails" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.TaskDetailsRspVo" >
|
71ea4fbe
wangqian
app首页接口
|
414
|
SELECT taskName, busiDateTime, pressingType
|
586017da
wangqian
app首页接口
|
415
|
FROM (
|
b6ced151
wangqian
app首页统计修改
|
416
417
|
SELECT
a.plan_name as taskName,c.begin_time as busiDateTime,null as pressingType
|
71ea4fbe
wangqian
app首页接口
|
418
|
from garden_inspection_plan a
|
b6ced151
wangqian
app首页统计修改
|
419
420
421
422
|
INNER JOIN garden_inspection_plan_role b on a.batch_no=b.batch_no
inner join garden_inspection_plan_detail c on a.batch_no=c.batch_no
where a.deleted = b.deleted and a.deleted = 0
and c.finish_state = 1
|
fef7a423
wangqian
app首页统计修改
|
423
424
|
and c.begin_time <= #{currentDate}
AND c.end_time >= #{currentDate}
|
b6ced151
wangqian
app首页统计修改
|
425
426
427
428
429
430
431
432
433
|
and a.dept_id = #{deptId}
AND b.role_id IN
<foreach collection='roleIds' item='roleId' open='(' close=')' separator=','>
#{roleId}
</foreach>
union all
SELECT
|
fef7a423
wangqian
app首页统计修改
|
434
|
a.plan_name as taskName,c.begin_time as busiDateTime, null as pressingType
|
b6ced151
wangqian
app首页统计修改
|
435
436
437
438
439
|
from garden_maintain_plan a
INNER JOIN garden_maintain_plan_role b on a.batch_no=b.batch_no
inner join garden_maintain_plan_detail c on a.batch_no=c.batch_no
where a.deleted=b.deleted and a.deleted = 0
and c.finish_state = 1
|
fef7a423
wangqian
app首页统计修改
|
440
441
|
and c.begin_time <= #{currentDate}
AND c.end_time >= #{currentDate}
|
b6ced151
wangqian
app首页统计修改
|
442
443
444
445
446
447
|
and a.dept_id = #{deptId}
AND b.role_id IN
<foreach collection='roleIds' item='roleId' open='(' close=')' separator=','>
#{roleId}
</foreach>
|
71ea4fbe
wangqian
app首页接口
|
448
|
union all
|
b6ced151
wangqian
app首页统计修改
|
449
|
|
71ea4fbe
wangqian
app首页接口
|
450
451
452
453
454
455
|
SELECT
m.order_name as taskName ,m.create_time as busiDateTime , m.pressing_type as pressingType
FROM act_ru_task t
LEFT JOIN workorder_main_info m ON t.PROC_INST_ID_ = m.process_instance_id AND m.deleted = 0
WHERE t.SUSPENSION_STATE_ = 1 and m.order_name is not null
AND t.ASSIGNEE_ = #{userId}
|
586017da
wangqian
app首页接口
|
456
457
458
|
) t
ORDER BY busiDateTime DESC
</select>
|
9bf5e48a
wangqian
app首页接口
|
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
<!--巡查已完成任务数量-->
<select id="countInspCompletedTask" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.CommonTaskStatusVo">
SELECT
user_id as userId,
COUNT(*) AS totalCount
FROM garden_inspection_plan_commit
WHERE 1=1
<if test="beginTime != null and beginTime != ''">
AND finish_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND finish_time <= #{endTime}
</if>
GROUP BY user_id
</select>
<!--养护已完成任务数量-->
<select id="countMtCompletedTask" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.CommonTaskStatusVo">
SELECT
user_id as userId,
COUNT(*) AS totalCount
FROM garden_maintain_plan_commit
WHERE 1=1
<if test="beginTime != null and beginTime != ''">
AND finish_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND finish_time <= #{endTime}
</if>
GROUP BY user_id
</select>
<!--养护未完成任务数量-->
<select id="countMtPendingTask" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.CommonTaskStatusVo" >
SELECT
role_id as roleId,
COUNT(*) AS totalCount
FROM
garden_maintain_plan_detail a
INNER JOIN garden_maintain_plan_role b ON a.batch_no = b.batch_no
|
b6ced151
wangqian
app首页统计修改
|
499
|
WHERE a.deleted = 0 and a.finish_state = 1 and a.dept_id = #{deptId} -- 1:未完成;3:已过期
|
9bf5e48a
wangqian
app首页接口
|
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
|
<if test="beginTime != null and beginTime != ''">
AND a.begin_time <= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND a.end_time >= #{endTime}
</if>
GROUP BY role_id
</select>
<!--巡查未完成任务数量-->
<select id="countInspPendingTask" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.CommonTaskStatusVo" >
SELECT
role_id as roleId,
COUNT(*) AS totalCount
FROM
garden_inspection_plan_detail a
INNER JOIN garden_inspection_plan_role b ON a.batch_no = b.batch_no
|
b6ced151
wangqian
app首页统计修改
|
516
|
WHERE a.deleted = 0 and a.finish_state = 1 and a.dept_id = #{deptId} -- 1:未完成;3:已过期
|
9bf5e48a
wangqian
app首页接口
|
517
518
519
520
|
<if test="beginTime != null and beginTime != ''">
AND a.begin_time <= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
|
573fae09
wangqian
app首页统计修改
|
521
|
AND a.end_time >= #{endTime}
|
9bf5e48a
wangqian
app首页接口
|
522
523
524
525
526
527
528
529
|
</if>
GROUP BY role_id
</select>
<!--工单待办数量-->
<select id="countWorkOrderPending" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.CommonTaskStatusVo" >
select
t.ASSIGNEE_ as userId,
|
573fae09
wangqian
app首页统计修改
|
530
|
count(*) AS totalCount
|
9bf5e48a
wangqian
app首页接口
|
531
532
533
534
535
536
537
538
539
540
541
542
543
|
FROM act_ru_task t
LEFT JOIN workorder_main_info m ON t.PROC_INST_ID_ = m.process_instance_id AND m.deleted = 0
WHERE t.SUSPENSION_STATE_ = 1
<if test="beginTime != null and beginTime != ''">
and t.create_time_ >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
and t.create_time_ <= #{endTime}
</if>
group by t.ASSIGNEE_
</select>
<!--工单已办数量-->
<select id="countWorkOrderCompleted" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.CommonTaskStatusVo" >
|
573fae09
wangqian
app首页统计修改
|
544
|
select t.userId,count(*) AS totalCount
|
9bf5e48a
wangqian
app首页接口
|
545
|
FROM (
|
c7d2e3b7
wangqian
app首页统计修改
|
546
547
|
select
m.order_no,t.ASSIGNEE_ as userId
|
9bf5e48a
wangqian
app首页接口
|
548
549
|
FROM act_hi_taskinst t
LEFT JOIN workorder_main_info m ON t.PROC_INST_ID_ = m.process_instance_id AND m.deleted = 0
|
dea31e5f
wangqian
app首页统计修改
|
550
|
WHERE t.state_ ='completed'
|
9bf5e48a
wangqian
app首页接口
|
551
552
553
554
555
556
|
<if test="beginTime != null and beginTime != ''">
and t.END_TIME_ >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
and t.END_TIME_ <= #{endTime}
</if>
|
c7d2e3b7
wangqian
app首页统计修改
|
557
|
group by m.order_no,t.ASSIGNEE_
|
9bf5e48a
wangqian
app首页接口
|
558
|
) t
|
9bf5e48a
wangqian
app首页接口
|
559
560
|
group by t.userId
</select>
|
f4d685a4
wangqian
app首页统计修改
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
<!--获取用户信息-->
<select id="getUserAll" resultType="com.zteits.urbanops.module.garden.dal.dataobject.taskstatistics.TaskStatisticsDO" >
WITH RECURSIVE dept_recursive AS (
-- 基准层:二级公司(parent_id='100')
SELECT id, name, parent_id, id as companyId, name as companyName
FROM system_dept
WHERE parent_id = '100'
UNION ALL
-- 递归层:子部门关联上级,继承二级公司信息
SELECT d.id, d.name, d.parent_id, dr.companyId, dr.companyName
FROM system_dept d
INNER JOIN dept_recursive dr ON d.parent_id = dr.id
)
-- 关联用户表查询
SELECT
#{busiDate} as busiDate,
u.busi_line as busiLine,
u.dept_id as deptId,
dr.companyId, -- 二级归属公司ID
dr.companyName, -- 二级归属公司名称
GROUP_CONCAT(r.role_id SEPARATOR ',') AS roleIds,
u.id as userId,
u.nickname as username
FROM system_users u
INNER JOIN system_user_role r ON u.id = r.user_id
INNER JOIN dept_recursive dr ON u.dept_id = dr.id
GROUP BY u.id, u.nickname, u.dept_id, u.busi_line, dr.companyId, dr.companyName;
</select>
|
7f393877
wangqian
app首页统计
|
590
591
592
593
594
595
596
597
598
599
|
<!--app工单数量汇总-->
<select id="countWorkOrder" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.AppWorkOrderSummaryVo">
SELECT
w.worker_company_id AS companyId,
d.name AS companyName,
COUNT(*) AS total,
SUM(CASE WHEN w.status = 2 THEN 1 ELSE 0 END) AS finish,
SUM(CASE WHEN w.status != 2 THEN 1 ELSE 0 END) AS ongoing
FROM system_dept d
|
bcce1d95
wangqian
首页查询详情图片数组bug修改
|
600
|
LEFT JOIN workorder_main_info w ON w.worker_company_id = d.id and w.deleted = 0
|
7f393877
wangqian
app首页统计
|
601
602
603
604
605
|
WHERE w.order_type !='Q'
<!-- queryType = 1 时,才拼接 督察工单(IWO开头)条件 -->
<if test='queryType != null and queryType == "1"'>
AND w.order_no LIKE 'IWO%'
</if>
|
f65d0db3
wangqian
app首页统计详情页面修改,区分督...
|
606
607
608
|
<if test="userId != null">
AND w.user_id = #{userId}
</if>
|
7f393877
wangqian
app首页统计
|
609
610
611
612
613
614
615
616
617
|
<if test="beginTime != null and beginTime != ''">
AND w.create_time >= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND w.create_time <= #{endTime}
</if>
GROUP BY w.worker_company_id, d.name
</select>
|
5618a89b
王彪总
feat(garden): 新增任...
|
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
|
<!-- 查询今日待办任务(含 GPS 坐标) -->
<select id="queryPendingTaskDetailsWithGps" resultType="com.zteits.urbanops.module.garden.controller.app.homepage.vo.TaskDistanceSortRespVO">
SELECT taskName, busiDateTime, pressingType, taskLat, taskLon, taskType, taskSubType
FROM (
SELECT
a.plan_name AS taskName,
c.begin_time AS busiDateTime,
NULL AS pressingType,
(CAST(r.starting_latitude AS DECIMAL(18,10))
+ CAST(r.end_latitude AS DECIMAL(18,10))) / 2 AS taskLat,
(CAST(r.starting_longitude AS DECIMAL(18,10))
+ CAST(r.end_longitude AS DECIMAL(18,10))) / 2 AS taskLon,
'inspection' AS taskType,
a.plan_type_id AS taskSubType
FROM garden_inspection_plan a
INNER JOIN garden_inspection_plan_role b ON a.batch_no = b.batch_no
INNER JOIN garden_inspection_plan_detail c ON a.batch_no = c.batch_no
LEFT JOIN garden_road r ON a.road_id = r.id AND r.deleted = 0
WHERE a.deleted = 0
AND c.finish_state = 1
AND c.begin_time <= #{currentDate}
AND c.end_time >= #{currentDate}
AND a.dept_id = #{deptId}
AND b.role_id IN
<foreach collection='roleIds' item='roleId' open='(' close=')' separator=','>
#{roleId}
</foreach>
AND r.starting_latitude IS NOT NULL AND r.starting_latitude != ''
UNION ALL
SELECT
a.plan_name AS taskName,
c.begin_time AS busiDateTime,
NULL AS pressingType,
(CAST(r.starting_latitude AS DECIMAL(18,10))
+ CAST(r.end_latitude AS DECIMAL(18,10))) / 2 AS taskLat,
(CAST(r.starting_longitude AS DECIMAL(18,10))
+ CAST(r.end_longitude AS DECIMAL(18,10))) / 2 AS taskLon,
'maintain' AS taskType,
a.plan_type_id AS taskSubType
FROM garden_maintain_plan a
INNER JOIN garden_maintain_plan_role b ON a.batch_no = b.batch_no
INNER JOIN garden_maintain_plan_detail c ON a.batch_no = c.batch_no
LEFT JOIN garden_road r ON a.road_id = r.id AND r.deleted = 0
WHERE a.deleted = 0
AND c.finish_state = 1
AND c.begin_time <= #{currentDate}
AND c.end_time >= #{currentDate}
AND a.dept_id = #{deptId}
AND b.role_id IN
<foreach collection='roleIds' item='roleId' open='(' close=')' separator=','>
#{roleId}
</foreach>
AND r.starting_latitude IS NOT NULL AND r.starting_latitude != ''
UNION ALL
SELECT
m.order_name AS taskName,
m.create_time AS busiDateTime,
m.pressing_type AS pressingType,
m.lat AS taskLat,
m.lon AS taskLon,
'workorder' AS taskType,
m.order_type AS taskSubType
FROM act_ru_task t
LEFT JOIN workorder_main_info m
ON t.PROC_INST_ID_ = m.process_instance_id AND m.deleted = 0
WHERE t.SUSPENSION_STATE_ = 1
AND m.order_name IS NOT NULL
AND t.ASSIGNEE_ = #{userId}
) t
</select>
<select id="countTeamCompletedToday" resultType="java.util.Map">
SELECT
u.id AS userId,
u.nickname AS userName,
COALESCE(insp.cnt, 0) + COALESCE(mt.cnt, 0)
+ COALESCE(wo.cnt, 0) AS completedCount
FROM system_users u
LEFT JOIN (
SELECT user_id, COUNT(*) AS cnt
FROM garden_inspection_plan_commit
WHERE DATE(finish_time) = CURDATE()
GROUP BY user_id
) insp ON u.id = insp.user_id
LEFT JOIN (
SELECT user_id, COUNT(*) AS cnt
FROM garden_maintain_plan_commit
WHERE DATE(finish_time) = CURDATE()
GROUP BY user_id
) mt ON u.id = mt.user_id
LEFT JOIN (
SELECT t.ASSIGNEE_ AS user_id, COUNT(DISTINCT m.order_no) AS cnt
FROM act_hi_taskinst t
LEFT JOIN workorder_main_info m
ON t.PROC_INST_ID_ = m.process_instance_id AND m.deleted = 0
WHERE t.state_ = 'completed'
AND DATE(t.END_TIME_) = CURDATE()
GROUP BY t.ASSIGNEE_
) wo ON u.id = wo.user_id
WHERE u.dept_id = #{deptId}
AND u.deleted = 0
</select>
|
7f393877
wangqian
app首页统计
|
724
|
|
131ad9be
wangqian
首页统计接口
|
725
|
</mapper>
|