StatisticalSummaryMapper.xml 11.8 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
<?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.iocoder.yudao.module.delivery.mapper.StatisticalSummaryMapper">
    <select id="GetStatisticalSummary"
            resultType="cn.iocoder.yudao.module.delivery.entity.orderdata.StatisticalSummary">
        select c.order_id,
        sum(sum_quantity) as sumBox,
        sum(if(c.transport_id = 1, sum_volume, 0)) as sumM3,
        sum(if(c.transport_id = 3, sum_weight, 0)) as sumKG,
        ROUND(sum(IF(c.transport_id = 1,
        c.sum_volume / (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'M3' LIMIT 1),
        round(c.sum_weight / (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'KG' LIMIT 1), 2))),
        2) as sumV,
        sum(if(cf.is_new = 1, sum_quantity, 0)) as sumBoxNew,
        sum(if(cf.is_new = 1, if(c.transport_id = 1, sum_volume, 0), 0)) as sumM3New,
        sum(if(cf.is_new = 1, if(c.transport_id = 3, sum_weight, 0), 0)) as sumKGNew,
        round(sum(if(cf.is_new = 1, IF(c.transport_id = 1, c.sum_volume /
        (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'M3' LIMIT 1),
        round(c.sum_weight /
        (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'KG' LIMIT 1),
        2)), 0)), 2) as sumVNew,
        sum(if(cf.is_new = 0, sum_quantity, 0)) as sumBoxOld,
        sum(if(cf.is_new = 0, if(c.transport_id = 1, sum_volume, 0), 0)) as sumM3Old,
        sum(if(cf.is_new = 0, if(c.transport_id = 3, sum_weight, 0), 0)) as sumKGOld,
        round(sum(if(cf.is_new = 0, IF(c.transport_id = 1, c.sum_volume /
        (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'M3' LIMIT 1),
        round(c.sum_weight /
        (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'KG' LIMIT 1),
        2)), 0)), 2) as sumVOld
        from ecw_order c
        left join (SELECT ewl.id AS line_id,
        ew_start.id AS start_warehouse_id,
        ew_dest.id AS dst_warehouse_id,
        ew_start.title_zh AS start_title_zh,
        ew_dest.title_zh AS dst_warehouse_name,
        r_dest.title_zh as muDiGuo,
        r_dest.id as muDiGuoID,
        r_sdest.title_zh as muDiShi,
        r_sdest.id as muDiShiID,
        ew_start.title_zh AS start_warehouse_name
        FROM ecw_warehouse_line ewl
        LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
        LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
        left join ecw_region r_dest on ew_dest.guojia = r_dest.id
        LEFT JOIN ecw_region r_sdest on ew_dest.shi = r_sdest.id
        ) w ON w.line_id = c.line_id
        left join ecw_channel channel on channel.channel_id = c.channel_id and channel.deleted = 0
        left join ecw_order_consignor nor on nor.order_id = c.order_id and nor.deleted = 0
        left join ecw_customer cf on cf.id = nor.customer_id and cf.deleted = 0
        left join ecw_order_consignee nee on nee.order_id = c.order_id and nee.deleted = 0
        left join ecw_customer sh on sh.id = nee.customer_id and sh.deleted = 0
        <include refid="WherePage"></include>

    </select>

    <sql id="WherePage">
        <where>
            and c.deleted = 0
            <if test="orderNo!=null and orderNo!=''">
                <!--订单编号-->
                <if test="SearchType1!=null and SearchType1!=''">
                    <choose>
                        <when test="SearchType1 =='in'.toString()">
                            and c.order_no like concat('%',#{orderNo},'%')
                        </when>
                        <when test="SearchType1 =='notin'.toString()">
                            and c.order_no not like concat('%',#{orderNo},'%')
                        </when>
                        <when test="SearchType1 =='eq'.toString()">
                            and c.order_no= #{orderNo}
                        </when>
                        <when test="SearchType1 =='noeq'.toString()">
                            and c.order_no!= #{orderNo}
                        </when>
                        <otherwise>
                            and c.order_no= #{orderNo}
                        </otherwise>
                    </choose>
                </if>
            </if>
            <if test="tidanNo!=null and tidanNo!=''">
                <!--提单编号-->
                <if test="SearchType2!=null and SearchType2!=''">
                    <choose>
                        <when test="SearchType2 =='in'.toString()">
                            and c.tidan_no like concat('%',#{tidanNo},'%')
                        </when>
                        <when test="SearchType2 =='notin'.toString()">
                            and c.tidan_no not like concat('%',#{tidanNo},'%')
                        </when>
                        <when test="SearchType2 =='eq'.toString()">
                            and c.tidan_no= #{tidanNo}
                        </when>
                        <when test="SearchType2 =='noeq'.toString()">
                            and c.tidan_no!= #{tidanNo}
                        </when>
                        <otherwise>
                            and c.tidan_no= #{tidanNo}
                        </otherwise>
                    </choose>
                </if>
            </if>
            <if test="fhNumber!=null and fhNumber!=''">
                <!--发货人编号-->
                <if test="SearchType3!=null and SearchType3!=''">
                    <choose>
                        <when test="SearchType3 =='in'.toString()">
                            and cf.number like concat('%',#{fhNumber},'%')
                        </when>
                        <when test="SearchType3 =='notin'.toString()">
                            and cf.number not like concat('%',#{fhNumber},'%')
                        </when>
                        <when test="SearchType3 =='eq'.toString()">
                            and cf.number=#{fhNumber}
                        </when>
                        <when test="SearchType3 =='noeq'.toString()">
                            and cf.number!= #{fhNumber}
                        </when>
                        <otherwise>
                            and cf.number= #{fhNumber}
                        </otherwise>
                    </choose>
                </if>
            </if>
            <if test="shNumber!=null and shNumber!=''">
                <!--收货人编号-->
                <if test="SearchType4!=null and SearchType4!=''">
                    <choose>
                        <when test="SearchType4 =='in'.toString()">
                            and sh.number like concat('%',#{shNumber},'%')
                        </when>
                        <when test="SearchType4 =='notin'.toString()">
                            and sh.number not like concat('%',#{shNumber},'%')
                        </when>
                        <when test="SearchType4 =='eq'.toString()">
                            and sh.number= #{shNumber}
                        </when>
                        <when test="SearchType4 =='noeq'.toString()">
                            and sh.number!= #{shNumber}
                        </when>
                        <otherwise>
                            and sh.number= #{shNumber}
                        </otherwise>
                    </choose>
                </if>
            </if>
            <if test="marks!=null and marks!=''">
                <!--唛头-->
                <if test="SearchType5!=null and SearchType5!=''">
                    <choose>
                        <when test="SearchType5 =='in'.toString()">
                            and c.marks like concat('%',#{marks},'%')
                        </when>
                        <when test="SearchType5 =='notin'.toString()">
                            and c.marks not like concat('%',#{marks},'%')
                        </when>
                        <when test="SearchType5 =='eq'.toString()">
                            and c.marks=#{marks}
                        </when>
                        <when test="SearchType5 =='noeq'.toString()">
                            and c.marks!= #{marks}
                        </when>
                        <otherwise>
                            and c.marks= #{marks}
                        </otherwise>
                    </choose>
                </if>
            </if>
            <if test="salesmanId!=null and salesmanId!=''">
                <!--客户经理-->
                and c.salesman_id= #{salesmanId}
            </if>
            <if test="status!=null and status!=''">
                <!--订单状态-->
                and c.status= #{status}
            </if>
            <if test="transportId!=null and transportId!=''">
                <!--运输方式查询条件-->
                and c.transport_id= #{transportId}
            </if>
            <if test="startWarehouseId!=null and startWarehouseId!=''">
                <!--始发仓-->
                and w.start_warehouse_id= #{startWarehouseId}
            </if>
            <if test="muDiGuo!=null and muDiGuo!=''">
                <!--目的国-->
                and w.muDiGuoID= #{muDiGuo}
            </if>
            <if test="muDiShi!=null and muDiShi!=''">
                <!--目的城市-->
                and w.muDiShiID= #{muDiShi}
            </if>
            <if test="dstwarehouseid!=null and dstwarehouseid!=''">
                <!--目的仓-->
                and w.dst_warehouse_id= #{dstwarehouseid}
            </if>
            <if test="isCargoControl!=null">
                <!--是否控货 注意整型值的判断-->
                and c.is_cargo_control= #{isCargoControl}
            </if>
            <if test="zpType!=null and zpType!=''">
                <!--重泡货类型-->
                and c.order_type= #{zpType}
            </if>
            <if test="drawee!=null and drawee!=''">
                <!--付款方-->
                and c.drawee= #{drawee}
            </if>
            <if test="shippingChannelId!=null and shippingChannelId!=''">
                <!--渠道-->
                and c.channel_id= #{shippingChannelId}
            </if>
            <if test="ResourceType!=null and ResourceType!=''">
                <!--资源类型-->
                and c.channel_id= #{ResourceType}
            </if>
            <if test="YeJiType!=null and YeJiType!=''">
                <!--业绩类型-->
                and c.channel_id= #{YeJiType}
            </if>
            <if test="dateSearch1!=null and dateSearch1!=''
              and sdate1!=null and sdate1!='' and edate2!=null and edate2!=''">
                <!--订单创建时间-->
                and c.create_time BETWEEN #{sdate1} AND #{edate2}
            </if>
            <if test="dataSearch3!=null and dataSearch3!=''">
                <if test="dataSearch1!=null and dataSearch1!=''">
                    <if test="dataSearch2=null and dataSearch2!=''">
                        <!--数据筛选-->
                        <choose>
                            <when test="dataSearch1 =='1'.toString()">
                                <!--入仓箱数-->
                            </when>
                            <when test="dataSearch1 =='2'.toString()">
                                <!--入仓体积-->
                            </when>
                            <when test="dataSearch1 =='3'.toString()">
                                <!--入仓重量-->
                            </when>
                            <when test="dataSearch1 =='3'.toString()">
                                <!--重/泡标准-->
                            </when>
                            <when test="dataSearch1 =='3'.toString()">
                                <!--提货率-->
                            </when>
                        </choose>
                    </if>
                </if>
            </if>
        </where>
    </sql>


</mapper>