Commit d1ac13e4 authored by 332784038@qq.com's avatar 332784038@qq.com

调整统计查询sql

parent 440c2ff3
......@@ -542,6 +542,9 @@
</select>
<sql id="orderQuerySql">
<if test="query.hasConsignee != null ">
AND has_consignee = #{query.hasConsignee}
</if>
<if test="query.status != null">
AND o.`status` = #{query.status}
</if>
......@@ -1048,6 +1051,9 @@
</sql>
<sql id="myOrderQuerySql">
<if test="query.hasConsignee != null ">
AND has_consignee = #{query.hasConsignee}
</if>
<if test="query.pickState != null">
AND o.`pick_state` = #{query.pickState}
</if>
......@@ -1903,7 +1909,9 @@
</select>
<sql id="myOrderQuery">
<if test="query.hasConsignee != null ">
AND has_consignee = #{query.hasConsignee}
</if>
<if test="query.type != null and query.type != '' and query.type == 0 ">
AND (o.type is null or o.type = '' or o.type = '0')
</if>
......@@ -2704,6 +2712,9 @@
<if test="query.type == 2 ">
AND FIND_IN_SET(2, o.type)
</if>
<if test="query.hasConsignee != null ">
AND has_consignee = #{query.hasConsignee}
</if>
<if test="query.types != null and query.types.size()>0 ">
<if test=" query.types.size()>1 ">
AND (1 !=1
......@@ -3647,6 +3658,9 @@
<if test="query.type == 2 ">
AND FIND_IN_SET(2, o.type)
</if>
<if test="query.hasConsignee != null ">
AND has_consignee = #{query.hasConsignee}
</if>
<if test="query.types != null and query.types.size()>0 ">
<if test=" query.types.size()>1 ">
AND (1 !=1
......@@ -5220,6 +5234,9 @@
<if test="query.type == 2 ">
AND FIND_IN_SET(2, o.type)
</if>
<if test="query.hasConsignee != null ">
AND has_consignee = #{query.hasConsignee}
</if>
<if test="query.types != null and query.types.size()>0 ">
<if test=" query.types.size()>1 ">
AND (1 !=1
......@@ -7289,6 +7306,66 @@
</if>
<include refid="myOrderQuery"/>
</select>
<select id="statisticsOrder" resultType="cn.iocoder.yudao.module.order.vo.order.StatisticsOrderVO">
select
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, it.warehouse_in_info->>'$.cartonsNum'), 0)) as total_num,
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, it.warehouse_in_info->>'$.volume'), 0)) as total_volume,
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, it.warehouse_in_info->>'$.weight'), 0)) as total_weight,
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, it.warehouse_in_info->>'$.quantityAll'), 0)) as order_quantity,
SUM(IFNULL(it.w_volume,0)) as total_w_volume,
SUM(IFNULL(it.v_weight,0)) as total_v_weight,
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, IF(it.charge_weight > it.min_metering_weight ,it.charge_weight,it.min_metering_weight)), 0)) as total_charge_weight,
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, IF(it.charge_volume > it.min_metering_volume,it.charge_volume,it.min_metering_volume)), 0)) as total_charge_volume,
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, IF(it.charge_quantity > it.min_metering_quantity,it.charge_quantity,it.min_metering_quantity)), 0)) as total_charge_quantity
from ecw_order_item it
left join ecw_order o
ON it.order_id = o.order_id and it.deleted = 0
left join ecw_order_departure de on de.order_id = o.order_id
left join ecw_order_objective ob on ob.order_id = o.order_id
left join ecw_order_consignor nor on nor.order_id = o.order_id
left join ecw_order_consignee nee on nee.order_id = o.order_id
left join ecw_channel channel on channel.channel_id = o.channel_id
where o.deleted = 0 and o.in_warehouse_state != 211 and o.in_warehouse_state != 208 and o.status != 10
<if test = "query.deptId != null ">
AND o.dept_id = #{query.deptId}
</if>
<if test = "query.deptIdList != null and query.deptIdList.size() > 0">
AND (o.dept_id IN
<foreach item='deptId' collection='query.deptIdList' open='(' close=')' separator=','> #{deptId} </foreach>
or
(SELECT u.dept_id FROM system_user u WHERE u.id = o.creator) IN
<foreach item='deptId' collection='query.deptIdList' open='(' close=')' separator=','> #{deptId} </foreach>)
</if>
<include refid="orderQuery"/>
</select>
<select id="statisticsWarehouseIn" resultType="cn.iocoder.yudao.module.order.vo.order.StatisticsOrderVO">
select
SUM(IFNULL(wi.cartons_num, 0)) as total_num,
SUM(IFNULL(wi.volume, 0)) as total_volume,
SUM(IFNULL(wi.weight, 0)) as total_weight,
SUM(IFNULL(wi.quantity_all, 0)) as order_quantity
from ecw_order_warehouse_in wi
left join ecw_order o
ON wi.order_id = o.order_id
left join ecw_order_departure de on de.order_id = o.order_id
left join ecw_order_objective ob on ob.order_id = o.order_id
left join ecw_order_consignor nor on nor.order_id = o.order_id
left join ecw_order_consignee nee on nee.order_id = o.order_id
left join ecw_channel channel on channel.channel_id = o.channel_id
where o.deleted = 0 and o.in_warehouse_state != 211 and o.in_warehouse_state != 208 and o.status != 10 and
wi.deleted = 0
<if test="query.deptId != null ">
AND o.dept_id = #{query.deptId}
</if>
<if test="query.deptIdList != null and query.deptIdList.size() > 0">
AND (o.dept_id IN
<foreach item='deptId' collection='query.deptIdList' open='(' close=')' separator=','>#{deptId}</foreach>
or
(SELECT u.dept_id FROM system_user u WHERE u.id = o.creator) IN
<foreach item='deptId' collection='query.deptIdList' open='(' close=')' separator=','>#{deptId}</foreach>)
</if>
<include refid="orderQuery"/>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment