Commit 72a95862 authored by zhengyi's avatar zhengyi

订单提货记录时间统计业务修正

parent 811de315
......@@ -3366,4 +3366,6 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
*/
@Update("update ecw_order set customer_id=#{customerId},salesman_id=#{salesmanId} where order_id = #{orderId}")
void updateOrderCustomerAndSalesmanId(@Param("customerId")Long customerId,@Param("salesmanId") Long salesmanId,@Param("orderId") Long orderId);
StatisticsOrderVO statisticsPickUp(@Param("query") OrderQueryVO query);
}
......@@ -1705,15 +1705,15 @@ public class OrderQueryServiceImpl implements OrderQueryService {
// vo.setOrderQuantity(0);
// }
// }
// if (Objects.nonNull(query.getBeginPickUpTime()) && Objects.nonNull(query.getEndPickUpTime())) {
// // 入仓记录统计时,实测入仓数据替换为入仓记录中的和值
// StatisticsOrderVO pickUpVO = orderMapper.statisticsPickUp(query);
// if (Objects.nonNull(pickUpVO)) {
// vo.setTotalNum(pickUpVO.getTotalNum());
// } else {
// vo.setTotalNum(0);
// }
// }
if (Objects.nonNull(query.getBeginPickUpTime()) && Objects.nonNull(query.getEndPickUpTime())) {
// 入仓记录统计时,实测入仓数据替换为入仓记录中的和值
StatisticsOrderVO pickUpVO = orderMapper.statisticsPickUp(query);
if (Objects.nonNull(pickUpVO)) {
vo.setTotalNum(pickUpVO.getTotalNum());
} else {
vo.setTotalNum(0);
}
}
return vo;
}
......@@ -1760,16 +1760,16 @@ public class OrderQueryServiceImpl implements OrderQueryService {
// vo.setOrderQuantity(0);
// }
// }
// if (Objects.nonNull(query.getBeginPickUpTime()) &&
// Objects.nonNull(query.getEndPickUpTime())) {
// // 提货记录统计时,实测入仓数据替换为提货记录中的和值
// StatisticsOrderVO pickUpVO = orderMapper.statisticsMyPickUp(query);
// if (Objects.nonNull(pickUpVO)) {
// vo.setTotalNum(pickUpVO.getTotalNum());
// } else {
// vo.setTotalNum(0);
// }
// }
if (Objects.nonNull(query.getBeginPickUpTime()) &&
Objects.nonNull(query.getEndPickUpTime())) {
// 提货记录统计时,实测入仓数据替换为提货记录中的和值
StatisticsOrderVO pickUpVO = orderMapper.statisticsPickUp(query);
if (Objects.nonNull(pickUpVO)) {
vo.setTotalNum(pickUpVO.getTotalNum());
} else {
vo.setTotalNum(0);
}
}
return vo;
}
......
......@@ -7366,26 +7366,19 @@
select
<choose>
<when test="query.beginWarehouseInTime != null and query.endWarehouseInTime != null">
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,
SUM(IFNULL( win.total_num, 0 )) AS total_num,
SUM(IFNULL( win.total_volume, 0 )) AS total_volume,
SUM(IFNULL( win.total_weight, 0 )) AS total_weight,
SUM(IFNULL( win.order_quantity, 0 )) AS order_quantity,
</when>
<when test="query.beginRucangTime != null and query.endRucangTime != null">
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,
SUM(IFNULL( win.total_num, 0 )) AS total_num,
SUM(IFNULL( win.total_volume, 0 )) AS total_volume,
SUM(IFNULL( win.total_weight, 0 )) AS total_weight,
SUM(IFNULL( win.order_quantity, 0 )) AS order_quantity,
</when>
<otherwise>
<choose>
<when test="query.beginPickUpTime != null and query.endPickUpTime != null">
SUM(IFNULL(select SUM(IFNULL(op.pick_num, 0)) from ecw_order_pickup op where op.order_id = o.order_no and op.deleted = 0, 0)) as total_num,
</when>
<otherwise>
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, it.warehouse_in_info->>'$.cartonsNum'), 0)) as total_num,
</otherwise>
</choose>
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,
......@@ -7396,8 +7389,8 @@
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
from ecw_order o
left join ecw_order_item it
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
......@@ -7405,11 +7398,41 @@
left join ecw_order_consignee nee on nee.order_id = o.order_id and nee.deleted = 0
left join ecw_channel channel on channel.channel_id = o.channel_id
<if test="query.beginWarehouseInTime != null and query.endWarehouseInTime != null ">
left join ecw_order_warehouse_in wi ON wi.order_item_id = it.order_item_id and wi.deleted = 0
</if>
<if test="query.beginRucangTime != null and query.endRucangTime != null ">
left join ecw_order_warehouse_in wi ON wi.order_item_id = it.order_item_id and wi.deleted = 0
</if>
left join (
SELECT
wi.order_item_id,
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
WHERE wi.deleted = 0
AND wi.`update_time` BETWEEN #{query.beginWarehouseInTime} and #{query.endWarehouseInTime}
GROUP BY wi.order_item_id
) win ON win.order_item_id = it.order_item_id
</if>
<if test="query.beginRucangTime != null and query.endRucangTime != null ">
left join (
SELECT
wi.order_item_id,
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
WHERE wi.deleted = 0
AND wi.`in_time` BETWEEN #{query.beginRucangTime} and #{query.endRucangTime}
GROUP BY wi.order_item_id
) win ON win.order_item_id = it.order_item_id
</if>
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}
......@@ -7427,26 +7450,19 @@
select
<choose>
<when test="query.beginWarehouseInTime != null and query.endWarehouseInTime != null">
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,
SUM(IFNULL( win.total_num, 0 )) AS total_num,
SUM(IFNULL( win.total_volume, 0 )) AS total_volume,
SUM(IFNULL( win.total_weight, 0 )) AS total_weight,
SUM(IFNULL( win.order_quantity, 0 )) AS order_quantity,
</when>
<when test="query.beginRucangTime != null and query.endRucangTime != null">
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,
SUM(IFNULL( win.total_num, 0 )) AS total_num,
SUM(IFNULL( win.total_volume, 0 )) AS total_volume,
SUM(IFNULL( win.total_weight, 0 )) AS total_weight,
SUM(IFNULL( win.order_quantity, 0 )) AS order_quantity,
</when>
<otherwise>
<choose>
<when test="query.beginPickUpTime != null and query.endPickUpTime != null">
SUM(IFNULL(select SUM(IFNULL(op.pick_num, 0)) from ecw_order_pickup op where op.order_id = o.order_no and op.deleted = 0, 0)) as total_num,
</when>
<otherwise>
SUM(IFNULL(IF(it.warehouse_in_info is null, 0, it.warehouse_in_info->>'$.cartonsNum'), 0)) as total_num,
</otherwise>
</choose>
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,
......@@ -7457,8 +7473,8 @@
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
from ecw_order o
left join ecw_order_item it
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
......@@ -7466,10 +7482,40 @@
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
<if test="query.beginWarehouseInTime != null and query.endWarehouseInTime != null ">
left join ecw_order_warehouse_in wi ON wi.order_item_id = it.order_item_id and wi.deleted = 0
left join (
SELECT
wi.order_item_id,
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
WHERE wi.deleted = 0
AND wi.`update_time` BETWEEN #{query.beginWarehouseInTime} and #{query.endWarehouseInTime}
GROUP BY wi.order_item_id
) win ON win.order_item_id = it.order_item_id
</if>
<if test="query.beginRucangTime != null and query.endRucangTime != null ">
left join ecw_order_warehouse_in wi ON wi.order_item_id = it.order_item_id and wi.deleted = 0
left join (
SELECT
wi.order_item_id,
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
WHERE wi.deleted = 0
AND wi.`in_time` BETWEEN #{query.beginRucangTime} and #{query.endRucangTime}
GROUP BY wi.order_item_id
) win ON win.order_item_id = it.order_item_id
</if>
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 ">
......@@ -7512,6 +7558,30 @@
</if>
<include refid="orderQuery"/>
</select>
<select id="statisticsPickUp" resultType="cn.iocoder.yudao.module.order.vo.order.StatisticsOrderVO">
select
SUM(IFNULL(op.pick_num, 0)) as total_num
from ecw_order_pickup op
left join ecw_order o
ON op.order_id = o.order_no and op.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 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