DataStatisticsMapper.xml 2.86 KB
Newer Older
1 2 3 4 5
<?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">
renchao's avatar
renchao committed
6
        SELECT Convert(varchar(10),tw.Rq,120) as name, SUM(tw.Jz) as value
7 8
        FROM T_Weight tw
        where 1=1
renchao's avatar
renchao committed
9 10 11
        <if test="params.TruckID != null and params.TruckID != ''">
            and tw.TruckID =  #{params.TruckID}
        </if>
12 13 14 15 16 17 18 19 20 21 22 23 24
        <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 != ''">
renchao's avatar
renchao committed
25
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ >= ]]> #{params.startDate}
26 27
        </if>
        <if test="params.endDate != null and params.endDate != ''">
renchao's avatar
renchao committed
28
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ <= ]]>  #{params.endDate}
29 30 31 32
        </if>
        <if test="params.startDate == null and params.endDate == null">
            and datediff(week, tw.Rq,getdate())=0
        </if>
renchao's avatar
renchao committed
33
        group by Convert(varchar(10),tw.Rq,120)
34 35 36 37
    </select>


    <select id="countByTable" resultType="cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo">
38
        SELECT  tw.ID as Uid,Convert(varchar(19),tw.Rq,120)as Rq,tw.TruckID,'发货单位' as clientName,tpt.WorkType,tw.Mz,tw.Pz,tw.Jz
39 40 41
        FROM T_Weight tw
        left join T_Processes_Truck tpt on tpt.TruckID = tw.TruckID
        where 1=1
renchao's avatar
renchao committed
42 43 44
        <if test="params.TruckID != null and params.TruckID != ''">
            and tw.TruckID =  #{params.TruckID}
        </if>
45 46 47 48 49 50 51 52 53 54 55 56 57
        <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 != ''">
renchao's avatar
renchao committed
58
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ >= ]]> #{params.startDate}
59 60
        </if>
        <if test="params.endDate != null and params.endDate != ''">
renchao's avatar
renchao committed
61
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ <= ]]>  #{params.endDate}
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        </if>
        <if test="params.startDate == null and params.endDate == null">
            and datediff(week, tw.Rq,getdate())=0
        </if>
    </select>









</mapper>