MDdMapper.xml
26.4 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<?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.hotent.lpg.manage.dao.MDdDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.hotent.lpg.common.model.WDd">
<id column="ID_" property="id" />
<result column="REF_ID_" property="refId" />
<result column="F_dddh" property="fDddh" />
<result column="F_sfhy" property="fSfhy" />
<result column="F_ddly" property="fDdly" />
<result column="F_zffs" property="fZffs" />
<result column="F_psfs" property="fPsfs" />
<result column="F_ddzt" property="fDdzt" />
<result column="F_mjly" property="fMjly" />
<result column="F_bz" property="fBz" />
<result column="F_czID" property="fCzid" />
<result column="F_qyID" property="fQyid" />
<result column="F_sjwcsj" property="fSjwcsj" />
<result column="F_xdrID" property="fXdrid" />
<result column="F_cjr" property="fCjr" />
<result column="F_gxr" property="fGxr" />
<result column="F_form_data_rev_" property="fFormDataRev" />
<result column="F_psrID" property="fPsrid" />
<result column="F_psrmc" property="fPsrmc" />
<result column="F_psrdh" property="fPsrdh" />
<result column="F_ddlx" property="fDdlx" />
<result column="F_cjsj" property="fCjsj" />
<result column="F_gxsj" property="fGxsj" />
<result column="F_xdrlx" property="fXdrlx" />
<result column="F_ddje" property="fDdje" />
<result column="F_czmc" property="fCzmc" />
<result column="F_hymc" property="fHymc" />
<result column="F_hydh" property="fHydh" />
<result column="F_hyyhID" property="fHyyhid" />
<result column="F_xdrmc" property="fXdrmc" />
<result column="F_shlxr" property="fShlxr" />
<result column="F_shlxrdh" property="fShlxrdh" />
<result column="F_shsf" property="fShsf" />
<result column="F_shs" property="fShs" />
<result column="F_shq" property="fShq" />
<result column="F_shjd" property="fShjd" />
<result column="F_shxxdz" property="fShxxdz" />
<result column="F_shtysbm" property="fShtysbm" />
<result column="F_sfzh" property="fSfzh" />
<result column="F_hylx" property="fHylx" />
<result column="F_shdzjd" property="fShdzjd" />
<result column="F_shdzwd" property="fShdzwd" />
</resultMap>
<resultMap id="wddMap1" extends="BaseResultMap" type="com.hotent.lpg.common.model.WDd">
<collection property="ddxqList" ofType="com.hotent.lpg.common.model.WDdxq"
select="com.hotent.lpg.dao.WDdxqDao.listByFDdid"
column="{ddID = ID_}">
</collection>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID_, REF_ID_, F_dddh, F_sfhy, F_ddly, F_zffs, F_psfs, F_ddzt, F_mjly, F_bz, F_czID,
F_qyID, F_sjwcsj, F_xdrID, F_cjr, F_gxr, F_form_data_rev_, F_psrID, F_psrmc, F_psrdh,
F_ddlx, F_cjsj, F_gxsj, F_xdrlx, F_ddje, F_czmc, F_hymc, F_hydh, F_hyyhID,
F_xdrmc, F_shlxr, F_shlxrdh, F_shsf, F_shs,
F_shq, F_shjd, F_shxxdz,F_shtysbm,F_sfzh,F_hylx,F_shdzjd,F_shdzwd
</sql>
<select id="selectPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_dd
${ew.customSqlSegment}
</select>
<select id="selectList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_dd
${ew.customSqlSegment}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_dd
where
ID_ = #{id}
</select>
<select id="staffOrderPage" resultMap="wddMap1">
select w_dd.* from w_dd w_dd
<where>
<if test="query1.khdh != null and query1.khdh != ''">
and (
(w_dd.F_shlxrdh like concat('%',#{query1.khdh},'%'))
or (w_dd.F_shlxr like concat('%',#{query1.khdh},'%'))
or (w_dd.F_sfzh like concat('%',#{query1.khdh},'%'))
or (w_dd.F_hymc like concat('%',#{query1.khdh},'%'))
or (w_dd.F_shsf like concat('%',#{query1.khdh},'%'))
or (w_dd.F_shs like concat('%',#{query1.khdh},'%'))
or (w_dd.F_shq like concat('%',#{query1.khdh},'%'))
or (w_dd.F_shjd like concat('%',#{query1.khdh},'%'))
or (w_dd.F_shxxdz like concat('%',#{query1.khdh},'%'))
or (w_dd.F_dddh like concat('%',#{query1.khdh},'%'))
)
</if>
<if test="query1.qptm != null and query1.qptm != ''">
and w_dd.ID_ in (select w_ddpsxq.F_ddID from w_ddpsxq w_ddpsxq inner join w_qpxx w_qpxx on w_qpxx.ID_ = w_ddpsxq.F_qpID where w_qpxx.F_qptm = #{query1.qptm})
</if>
<if test="query1.zt != null and query1.zt != ''">
and w_dd.F_ddzt = #{query1.zt}
</if>
<if test="list != null and list.size() > 0">
and w_dd.F_czID in
<foreach collection="list" item="czId" open="(" close=")" separator=",">
#{czId}
</foreach>
</if>
<if test="list == null or list.size() == 0">
<if test="query2.fSsqyid != null and query2.fSsqyid != ''">
and w_dd.F_qyID = #{query2.fSsqyid}
</if>
<if test="query2.fSsczid != null and query2.fSsczid != ''">
and w_dd.F_czID = #{query2.fSsczid}
</if>
</if>
</where>
order by w_dd.F_cjsj desc
</select>
<select id="statistics" resultType="com.hotent.lpg.manage.vo.StaffStatisticsVO">
select
date_format(temp2.date_time,'%m/%d') as rq,
ifnull(temp1.num,0)as num,
#{ddly} as ddly
from (
select count(*)num, date_format(F_sjwcsj,'%Y/%m/%d') as date_time ,f_ddly from w_dd w_dd
where (F_sjwcsj between #{startDate} and #{endDate}) and f_ddly = #{ddly}
<if test="orgIdList != null and orgIdList.size() > 0">
and F_czID in
<foreach collection="orgIdList" item="orgId" open="(" close=")" separator=",">
#{orgId}
</foreach>
</if>
<if test="orgIdList == null or orgIdList.size() == 0">
and F_psrID = #{query.id}
</if>
group by date_format(F_sjwcsj,'%Y/%m/%d')
) temp1
right join
(
SELECT
date_format(#{startDate} + INTERVAL (t3.i * 100 + t2.i * 10 + t1.i) day,'%Y/%m/%d') as date_time
FROM
(SELECT 0 i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t1,
(SELECT 0 i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t2,
(SELECT 0 i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t3
WHERE
(date_format(#{startDate} + INTERVAL (t3.i * 100 + t2.i * 10 + t1.i) day ,'%Y/%m/%d')) <= date_format(#{endDate},'%Y/%m/%d')
) temp2 on temp2.date_time = temp1.date_time order by temp2.date_time
</select>
<select id="ptOrderStatistics" resultType="com.hotent.lpg.manage.vo.PtOrderStatisticsVO">
<if test="type != null and type == '1'.toString()">
select
temp1.F_ddly as lx,
concat(temp2.dateStr,':00') as dateStr,
ifnull(temp3.number,0) number
from
(
select '线上下单' as F_ddly
union
select '无单配送'
union
select '帮助下单'
)temp1
join
(
SELECT 0 dateStr UNION ALL SELECT 01 UNION ALL SELECT 02 UNION ALL SELECT 03 UNION ALL SELECT 04 UNION ALL SELECT 05 UNION ALL SELECT 06 UNION ALL SELECT 07 UNION ALL SELECT 08 UNION ALL SELECT 09
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19
UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23
) temp2 on 1 = 1
left join
(
select
w_dd.F_ddly,
count(w_dd.F_ddly) number,
date_format(w_dd.F_sjwcsj,'%H') as dateStr
from w_dd w_dd
where w_dd.F_ddzt = '204'
and date_format(w_dd.F_sjwcsj,'%Y%m%d') = date_format(sysdate() ,'%Y%m%d')
and w_dd.ID_ in (select F_ddID from w_ddpsxq wd)
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_dd.F_ddly ,date_format(w_dd.F_sjwcsj,'%H')
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_ddly = temp1.F_ddly
order by temp2.dateStr asc,temp3.f_ddly asc
</if>
<if test="type != null and type == '2'.toString()">
select
temp1.F_ddly as lx,
date_format(temp2.dateStr,'%Y.%m.%d') as dateStr,
ifnull(temp3.number,0) number
from
(
select '线上下单' as F_ddly
union
select '无单配送'
union
select '帮助下单'
)temp1
join
(
SELECT
date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day,'%Y%m%d') as dateStr
FROM
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t1,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t2,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t3
WHERE
(date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day ,'%Y%m%d')) <= date_format(#{endDate_str},'%Y%m%d')
)temp2 on 1 = 1
left join
(
select
w_dd.F_ddly,
count(w_dd.F_ddly) number,
date_format(w_dd.F_sjwcsj,'%Y%m%d') as dateStr
from w_dd w_dd
where w_dd.F_ddzt = '204'
and week(w_dd.F_sjwcsj) = week(sysdate())
and w_dd.ID_ in (select F_ddID from w_ddpsxq wd)
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_dd.F_ddly ,date_format(w_dd.F_sjwcsj,'%Y%m%d')
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_ddly = temp1.F_ddly
order by temp2.dateStr asc,temp3.f_ddly asc
</if>
<if test="type != null and type == '3'.toString()">
select
temp1.F_ddly as lx,
date_format(temp2.dateStr,'%Y.%m.%d') as dateStr,
ifnull(temp3.number,0) number
from
(
select '线上下单' as F_ddly
union
select '无单配送'
union
select '帮助下单'
)temp1
join
(
SELECT
date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day,'%Y%m%d') as dateStr
FROM
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t1,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t2,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t3
WHERE
(date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day ,'%Y%m%d')) <= date_format(#{endDate_str},'%Y%m%d')
)temp2 on 1 = 1
left join
(
select
w_dd.F_ddly,
count(w_dd.F_ddly) number,
date_format(w_dd.F_sjwcsj,'%Y%m%d') as dateStr
from w_dd w_dd
where w_dd.F_ddzt = '204'
and month(w_dd.F_sjwcsj) = month(sysdate())
and w_dd.ID_ in (select F_ddID from w_ddpsxq wd)
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_dd.F_ddly ,date_format(w_dd.F_sjwcsj,'%Y%m%d')
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_ddly = temp1.F_ddly
order by temp2.dateStr asc,temp3.f_ddly asc
</if>
<if test="type != null and type == '4'.toString()">
select
temp1.F_ddly as lx,
concat(year(sysdate()),'.',temp2.dateStr) as dateStr,
ifnull(temp3.number,0) number
from
(
select '线上下单' as F_ddly
union
select '无单配送'
union
select '帮助下单'
)temp1
join
(
SELECT '1' dateStr UNION ALL SELECT '2' UNION ALL SELECT '3' UNION ALL SELECT '4' UNION ALL SELECT '5' UNION ALL SELECT '6' UNION ALL SELECT '7'
UNION ALL SELECT '8' UNION ALL SELECT '9' UNION ALL SELECT '10' UNION ALL SELECT '11' UNION ALL SELECT '12'
)temp2 on 1 = 1
left join
(
select
w_dd.F_ddly,
count(w_dd.F_ddly) number,
month(w_dd.F_sjwcsj) as dateStr
from w_dd w_dd
where w_dd.F_ddzt = '204'
and year(w_dd.F_sjwcsj) = year(sysdate())
and w_dd.ID_ in (select F_ddID from w_ddpsxq wd)
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_dd.F_ddly ,month(w_dd.F_sjwcsj)
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_ddly = temp1.F_ddly
order by temp2.dateStr asc,temp3.f_ddly asc
</if>
</select>
<select id="ptQpStatistics" resultType="com.hotent.lpg.manage.vo.PtOrderStatisticsVO">
<if test="type != null and type == '1'.toString()">
select
temp1.F_qpgg as lx,
concat(temp2.dateStr,':00') as dateStr,
ifnull(temp3.number,0) number
from
(
select distinct w_qpxx.F_qpgg from w_qpxx where w_qpxx.F_qpgg is not null
)temp1
join
(
SELECT 0 dateStr UNION ALL SELECT 01 UNION ALL SELECT 02 UNION ALL SELECT 03 UNION ALL SELECT 04 UNION ALL SELECT 05 UNION ALL SELECT 06 UNION ALL SELECT 07 UNION ALL SELECT 08 UNION ALL SELECT 09
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19
UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23
) temp2 on 1 = 1
left join
(
select
w_qpxx.F_qpgg,
count(w_qpxx.F_qpgg) number,
date_format(w_dd.F_sjwcsj,'%H') as dateStr
from w_dd w_dd
inner join w_ddpsxq w_ddpsxq on w_ddpsxq.F_ddID = w_dd.ID_
inner join w_qpxx w_qpxx on w_qpxx.ID_ = w_ddpsxq.F_qpID
where w_dd.F_ddzt = '204'
and date_format(w_dd.F_sjwcsj,'%Y%m%d') = date_format(sysdate() ,'%Y%m%d')
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_qpxx.F_qpgg ,date_format(w_dd.F_sjwcsj,'%H')
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_qpgg = temp1.F_qpgg
order by temp2.dateStr asc,temp3.F_qpgg asc
</if>
<if test="type != null and type == '2'.toString()">
select
temp1.F_qpgg as lx,
date_format(temp2.dateStr,'%Y.%m.%d') as dateStr,
ifnull(temp3.number,0) number
from
(
select distinct w_qpxx.F_qpgg from w_qpxx where w_qpxx.F_qpgg is not null
)temp1
join
(
SELECT
date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day,'%Y%m%d') as dateStr
FROM
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t1,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t2,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t3
WHERE
(date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day ,'%Y%m%d')) <= date_format(#{endDate_str},'%Y%m%d')
)temp2 on 1 = 1
left join
(
select
w_qpxx.F_qpgg,
count(w_qpxx.F_qpgg) number,
date_format(w_dd.F_sjwcsj,'%Y%m%d') as dateStr
from w_dd w_dd
inner join w_ddpsxq w_ddpsxq on w_ddpsxq.F_ddID = w_dd.ID_
inner join w_qpxx w_qpxx on w_qpxx.ID_ = w_ddpsxq.F_qpID
where w_dd.F_ddzt = '204'
and week(w_dd.F_sjwcsj) = week(sysdate())
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_qpxx.F_qpgg ,date_format(w_dd.F_sjwcsj,'%Y%m%d')
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_qpgg = temp1.F_qpgg
order by temp2.dateStr asc,temp3.F_qpgg asc
</if>
<if test="type != null and type == '3'.toString()">
select
temp1.F_qpgg as lx,
date_format(temp2.dateStr,'%Y.%m.%d') as dateStr,
ifnull(temp3.number,0) number
from
(
select distinct w_qpxx.F_qpgg from w_qpxx where w_qpxx.F_qpgg is not null
)temp1
join
(
SELECT
date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day,'%Y%m%d') as dateStr
FROM
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t1,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t2,
(SELECT 0 dateStr UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) t3
WHERE
(date_format(#{startDate_str} + INTERVAL (t3.dateStr * 100 + t2.dateStr * 10 + t1.dateStr) day ,'%Y%m%d')) <= date_format(#{endDate_str},'%Y%m%d')
)temp2 on 1 = 1
left join
(
select
w_qpxx.F_qpgg,
count(w_qpxx.F_qpgg) number,
date_format(w_dd.F_sjwcsj,'%Y%m%d') as dateStr
from w_dd w_dd
inner join w_ddpsxq w_ddpsxq on w_ddpsxq.F_ddID = w_dd.ID_
inner join w_qpxx w_qpxx on w_qpxx.ID_ = w_ddpsxq.F_qpID
where w_dd.F_ddzt = '204'
and month(w_dd.F_sjwcsj) = month(sysdate())
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_qpxx.F_qpgg ,date_format(w_dd.F_sjwcsj,'%Y%m%d')
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_qpgg = temp1.F_qpgg
order by temp2.dateStr asc,temp3.F_qpgg asc
</if>
<if test="type != null and type == '4'.toString()">
select
temp1.F_qpgg as lx,
concat(year(sysdate()),'.',temp2.dateStr) as dateStr,
ifnull(temp3.number,0) number
from
(
select distinct w_qpxx.F_qpgg from w_qpxx where w_qpxx.F_qpgg is not null
)temp1
join
(
SELECT '1' dateStr UNION ALL SELECT '2' UNION ALL SELECT '3' UNION ALL SELECT '4' UNION ALL SELECT '5' UNION ALL SELECT '6' UNION ALL SELECT '7'
UNION ALL SELECT '8' UNION ALL SELECT '9' UNION ALL SELECT '10' UNION ALL SELECT '11' UNION ALL SELECT '12'
)temp2 on 1 = 1
left join
(
select
w_qpxx.F_qpgg,
count(w_qpxx.F_qpgg) number,
month(w_dd.F_sjwcsj) as dateStr
from w_dd w_dd
inner join w_ddpsxq w_ddpsxq on w_ddpsxq.F_ddID = w_dd.ID_
inner join w_qpxx w_qpxx on w_qpxx.ID_ = w_ddpsxq.F_qpID
where w_dd.F_ddzt = '204'
and year(w_dd.F_sjwcsj) = year(sysdate())
<if test="qyId != null and qyId != ''">
and w_dd.F_qyID = #{qyId}
</if>
<if test="qzId != null and qzId != ''">
and w_dd.F_czID = #{qzId}
</if>
group by w_qpxx.F_qpgg ,month(w_dd.F_sjwcsj)
)temp3 on temp3.dateStr = temp2.dateStr and temp3.F_qpgg = temp1.F_qpgg
order by temp2.dateStr asc,temp3.F_qpgg asc
</if>
</select>
<select id="hyOrderPage" resultMap="wddMap1">
select * from w_dd w_dd
<where>
<if test="query.fHyyhid != null and query.fHyyhid != ''">
and w_dd.F_hyyhID = #{query.fHyyhid}
</if>
<if test="list != null and list.size() > 0">
and w_dd.F_czID in
<foreach collection="list" item="czId" open="(" close=")" separator=",">
#{czId}
</foreach>
</if>
<if test="list == null or list.size() == 0">
<if test="query.fCzid != null and query.fCzid != ''">
and w_dd.F_czID = #{query.fCzid}
</if>
<if test="query.fQyid != null and query.fQyid != ''">
and w_dd.F_qyID = #{query.fQyid}
</if>
</if>
</where>
order by w_dd.F_cjsj desc
</select>
<select id="orderPage" resultMap="wddMap1">
select * from w_dd w_dd
<where>
<if test="query.fDdzt != null and query.fDdzt != ''">
and w_dd.F_ddzt = #{query.fDdzt}
</if>
<if test="query.fDddh != null and query.fDddh != ''">
and (w_dd.F_dddh like concat('%',#{query.fDddh},'%') or w_dd.F_sfzh like concat('%',#{query.fDddh},'%') or w_dd.F_hymc like concat('%',#{query.fDddh},'%') or w_dd.F_hydh like concat('%',#{query.fDddh},'%') )
</if>
<if test="list != null and list.size() > 0">
and w_dd.F_czID in
<foreach collection="list" item="orgId" open="(" close=")" separator=",">
#{orgId}
</foreach>
</if>
</where>
order by w_dd.F_cjsj desc
</select>
<select id="yearDelivery" resultType="java.lang.Integer">
select count(*) from w_dd where F_czID = #{czId} and F_ddzt = '204' and year(F_cjsj) = year(SYSDATE())
</select>
<select id="monthDelivery" resultType="java.lang.Integer">
select count(*) from w_dd where F_czID = #{czId} and F_ddzt = '204' and month(F_cjsj) = month(SYSDATE())
</select>
<select id="monthDeliveryOnMonth" resultType="java.lang.Double">
select
ROUND(ifnull(
sum(case when MONTH(F_cjsj) = MONTH(SYSDATE()) and year(F_cjsj) = year(SYSDATE()) then 1 else 0 end )
/
sum(case when MONTH(F_cjsj) = MONTH(SYSDATE())-1 and year(F_cjsj) = year(SYSDATE()) then 1 else 0 end )
,0),2)
from w_dd where F_czID = #{czId} and F_ddzt = '204'
</select>
<select id="allMonthDelivery" resultType="java.util.HashMap">
SELECT
monthStr,
(select count(*) from w_dd where F_czID = #{czId} and YEAR(F_cjsj) = YEAR(SYSDATE()) and MONTH(F_cjsj) = monthStr and F_ddzt = '204') as monthDelivery
FROM
(SELECT 1 monthStr UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12) t1
WHERE
monthStr <= MONTH(SYSDATE())
</select>
<select id="userNumberByCzId" resultType="java.lang.String">
select distinct F_hyyhID from w_dd where F_czID = #{czId}
</select>
</mapper>