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
<?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.wise.sc.acquisition.business.mapper.DataStatisticsMapper">
<select id="countByPhoto" resultType="cn.wise.sc.acquisition.business.model.vo.DataStatisticsVo">
SELECT tw.Rq as name, SUM(tw.Jz) as value
FROM T_Weight tw
where 1=1
<if test="params.cycle == 1 ">
and datediff(week, tw.Rq,getdate())=0
</if>
<if test="params.cycle == 2 ">
and datediff(month, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 3 ">
and datediff(quarter, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 4 ">
and datediff(year, tw.Rq,getdate())=0
</if>
<if test="params.startDate != null and params.startDate != ''">
and tw.Rq > >= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and tw.Rq > <= #{params.endDate}
</if>
<if test="params.startDate == null and params.endDate == null">
and datediff(week, tw.Rq,getdate())=0
</if>
group by tw.Rq
</select>
<select id="countByTable" resultType="cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo">
SELECT tw.Uid,tw.Rq,tw.Sj,tw.TruckID,'发货单位' as clientName,tpt.WorkType,tw.Mz,tw.Pz,tw.Jz
FROM T_Weight tw
left join T_Processes_Truck tpt on tpt.TruckID = tw.TruckID
where 1=1
<if test="params.cycle == 1 ">
and datediff(week, tw.Rq,getdate())=0
</if>
<if test="params.cycle == 2 ">
and datediff(month, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 3 ">
and datediff(quarter, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 4 ">
and datediff(year, tw.Rq,getdate())=0
</if>
<if test="params.startDate != null and params.startDate != ''">
and tw.Rq > >= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and tw.Rq > <= #{params.endDate}
</if>
<if test="params.startDate == null and params.endDate == null">
and datediff(week, tw.Rq,getdate())=0
</if>
</select>
</mapper>