DataStatisticsMapper.xml 2.4 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 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 >  &gt;= #{params.startDate}
        </if>
        <if test="params.endDate != null and params.endDate != ''">
            and tw.Rq >  &lt;= #{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 >  &gt;= #{params.startDate}
        </if>
        <if test="params.endDate != null and params.endDate != ''">
            and tw.Rq >  &lt;= #{params.endDate}
        </if>
        <if test="params.startDate == null and params.endDate == null">
            and datediff(week, tw.Rq,getdate())=0
        </if>
    </select>









</mapper>