wjli
2023-05-09 be396e19af86f49cc2c966c73b5f59cd36c7402e
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
<?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.exrick.xboot.your.mapper.OrderTaskMapper">
    <select id="countStatus" resultType="cn.exrick.xboot.your.entity.OrderStatusCount">
 
        SELECT
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '1'.toString()">
            DATE(DATE_FORMAT(DATE_SUB(a.send_date,INTERVAL 1 DAY),'%Y-%m-%d')) warntime,
        </if>
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '2'.toString()">
            WEEK(DATE_FORMAT(DATE_SUB(a.send_date,INTERVAL 1 DAY),'%Y-%m-%d')) warntime,
        </if>
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '3'.toString()">
           MONTH(DATE_FORMAT(DATE_SUB(a.send_date,INTERVAL 1 DAY),'%Y-%m-%d')) warntime,
        </if>
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '4'.toString()">
            YEAR(DATE_FORMAT(DATE_SUB(a.send_date,INTERVAL 1 DAY),'%Y-%m-%d')) warntime,
        </if>
        b.car_no AS carName,
        c.NAME AS line,
        d.NAME AS batch,
        a.send_date,
        e.nickname as username,
        a.id,
        count( a.area_section_id ) AS amount,
        sum( CASE WHEN a.STATUS = 0 THEN 1 ELSE 0 END ) AS notSignCount,
        sum( CASE WHEN a.STATUS = 1 THEN 1 ELSE 0 END ) AS signCount ,
        ( count( a.status = 1 OR NULL )/ count(a.status >= 0 OR NULL ) * 100 ) AS proportion
 
        FROM
        t_order_task a
        LEFT JOIN t_car b ON a.car_id = b.id
        LEFT JOIN t_area c ON a.area_id = c.id
        LEFT JOIN t_area_ection d ON a.area_section_id = d.id
        LEFT JOIN t_user e ON e.id = b.user_id
        <where>
            1=1
            <if test="carId != null and carId != ''" >
                AND a.car_id = #{carId}
            </if>
            <if test="carNo != null and carNo != ''" >
                AND b.car_no = #{carNo}
            </if>
            <if test="name != null and name != ''" >
                AND d.NAME = #{name}
            </if>
            <if test="sendDate != null and sendDate != ''">
                AND  DATE_FORMAT(a.send_date,'%Y-%m-%d') = #{sendDate}
            </if>
            <if test="sendDateStart != null and sendDateStart != ''">
                AND send_date >= #{createTimeFrom}
            </if>
            <if test="sendDateEnd != null and sendDateEnd != ''">
                AND send_date &lt; #{createTimeTo}
            </if>
        </where>
        GROUP BY
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '1'.toString()">
            DATE(a.send_date),
        </if>
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '2'.toString()">
            WEEK(a.send_date,1),
        </if>
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '3'.toString()">
            MONTH(a.send_date),
        </if>
        <if test="StatisticalType!=null and StatisticalType !='' and StatisticalType == '4'.toString()">
            YEAR(a.send_date),
        </if>
        a.area_section_id,
        b.car_no,
        c.NAME,
        d.NAME,
        a.send_date,
        e.nickname,
        a.id
        ORDER BY
        c.NAME ASC,
        a.send_date asc
    </select>
</mapper>