DataStatisticsMapper.xml 2.05 KB
<?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 Convert(varchar(10),tw.Rq,120) as name, SUM(tw.Jz) as value
        FROM T_Weight tw
        where 1=1
        <if test="params.TruckID != null and params.TruckID != ''">
            and tw.TruckID =  #{params.TruckID}
        </if>
        <if test="params.startDate != null and params.startDate != ''">
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ >= ]]> #{params.startDate}
        </if>
        <if test="params.endDate != null and params.endDate != ''">
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ <= ]]>  #{params.endDate}
        </if>
        <if test="params.startDate == null and params.endDate == null">
            and datediff(week, tw.Rq,getdate())=0
        </if>
        group by Convert(varchar(10),tw.Rq,120)
    </select>


    <select id="countByTable" resultType="cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo">
        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
        FROM T_Weight tw
        left join T_Processes_Truck tpt on tpt.TruckID = tw.TruckID
        where 1=1
        <if test="params.TruckID != null and params.TruckID != ''">
            and tw.TruckID =  #{params.TruckID}
        </if>
        <if test="params.startDate != null and params.startDate != ''">
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ >= ]]> #{params.startDate}
        </if>
        <if test="params.endDate != null and params.endDate != ''">
            and Convert(varchar(10),tw.Rq,120) <![CDATA[ <= ]]>  #{params.endDate}
        </if>
        <if test="params.startDate == null and params.endDate == null">
            and datediff(week, tw.Rq,getdate())=0
        </if>
    </select>









</mapper>