Bläddra i källkod

1、调整辅助单位统计逻辑;

zk 2 år sedan
förälder
incheckning
4968d8b73e

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtWaybillOrderMapper.java

@@ -121,7 +121,7 @@ public interface KwtWaybillOrderMapper extends BaseMapper<KwtWaybillOrder> {
      * @date 2023/7/31
      * @return 统计数据
      **/
-    WaybillCountVo findWaybillOrderTicketCount(Map<String, Object> params);
+    Double findWaybillOrderTicketCount(Map<String, Object> params);
 
     /**
      * 统计司机任务数(待接单/出车/执行/完结)

+ 21 - 8
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsOrderGoodsService.java

@@ -167,14 +167,20 @@ public class KwtLogisticsOrderGoodsService {
         if (CollectionUtils.isNotEmpty(assistUnit)) {
             assistUnit.forEach(e -> {
                 //车辆运单统计(运输中的物流订单+车辆运单审核通过)
-                WaybillCountVo waybillCount = waybillOrderMapper.findWaybillOrderTicketCount(new HashMap() {{
+                Map<String, Object> params = new HashMap<>(NumberConstant.SIXTEEN){{
                     put("unit", e.getUnit());
+                    put("type", NumberConstant.ONE);
                     put("lOrderId", lOrderId);
                     put("passStatus", Global.NUMERICAL_ONE);
-                }});
+                }};
+                //装货量
+                Double loadAmount = waybillOrderMapper.findWaybillOrderTicketCount(params);
+                //卸货量
+                params.put("type", NumberConstant.TWO);
+                Double unloadAmount = waybillOrderMapper.findWaybillOrderTicketCount(params);
                 //更新物流订单商品辅助单位-装卸货量
-                e.setLoadAmount(waybillCount.getLoadAmount());
-                e.setUnloadAmount(waybillCount.getUnloadAmount());
+                e.setLoadAmount(BigDecimal.valueOf(loadAmount));
+                e.setUnloadAmount(BigDecimal.valueOf(unloadAmount));
                 goodsUnitMapper.updateById(e);
             });
         }
@@ -193,20 +199,27 @@ public class KwtLogisticsOrderGoodsService {
         if (CollectionUtils.isNotEmpty(assistUnit)) {
             assistUnit.forEach(e -> {
                 //车辆运单统计(运输中的物流订单+车辆运单审核通过)
-                WaybillCountVo waybillCount = waybillOrderMapper.findWaybillOrderTicketCount(new HashMap() {{
+                Map<String, Object> params = new HashMap<>(NumberConstant.SIXTEEN){{
                     put("unit", e.getUnit());
+                    put("type", NumberConstant.ONE);
                     put("upperlOrderId", lOrderId);
                     put("passStatus", Global.NUMERICAL_ONE);
                     put("logisticsStatus", LogisticsOrderEnum.IN_TRANSIT.getCode());
-                }});
+                }};
+                //装货量
+                Double loadAmount = waybillOrderMapper.findWaybillOrderTicketCount(params);
+                //卸货量
+                params.put("type", NumberConstant.TWO);
+                Double unloadAmount = waybillOrderMapper.findWaybillOrderTicketCount(params);
+
                 //物流订单统计(运输完成后的物流订单)
                 LogisticsCountVo LogisticsCount = logisticsOrderMapper.findLogisticsOrderCount(new HashMap() {{
                     put("upperlOrderId", lOrderId);
                     put("finishedStatus", Global.NUMERICAL_ONE);
                 }});
                 //更新物流订单商品辅助单位-总装卸货量
-                e.setTotalLoadAmount(waybillCount.getLoadAmount().add(LogisticsCount.getLoadAmount()));
-                e.setTotalUnloadAmount(waybillCount.getUnloadAmount().add(LogisticsCount.getUnloadAmount()));
+                e.setTotalLoadAmount(BigDecimal.valueOf(loadAmount).add(LogisticsCount.getLoadAmount()));
+                e.setTotalUnloadAmount(BigDecimal.valueOf(unloadAmount).add(LogisticsCount.getUnloadAmount()));
                 goodsUnitMapper.updateById(e);
             });
         }

+ 11 - 13
sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.xml

@@ -161,8 +161,8 @@
         IFNULL(SUM(wo.unload_amount), 0.0) unloadAmount, IFNULL(SUM(wo.deficit_amount), 0.0) deficitAmount,
         MIN(wot1.operate_time) loadTime, MAX(wot2.operate_time) unloadTime
         from kwt_waybill_order wo
-        left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and wo.unit = wot1.unit and wot1.del_flag = 0
-        left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and wo.unit = wot2.unit and wot2.del_flag = 0
+        left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and wo.unit = wot1.unit and wot1.type = 1 and wot1.del_flag = 0
+        left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and wo.unit = wot2.unit and wot1.type = 2  and wot2.del_flag = 0
         left join kwt_logistics_order lo on lo.id = wo.l_order_id
         where wo.del_flag = 0 and lo.del_flag = 0
         <if test="driverId != null and driverId != ''">
@@ -200,17 +200,12 @@
         </if>
     </select>
 
-    <select id="findWaybillOrderTicketCount" resultType="com.sckw.transport.model.vo.WaybillCountVo"
-            parameterType="java.util.Map">
-        SELECT
-        IFNULL(SUM(wo.load_amount), 0.0) loadAmount,
-        IFNULL(SUM(wo.unload_amount), 0.0) unloadAmount
-        from kwt_waybill_order wo
-        left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and wot1.del_flag = 0
-        left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and wot2.del_flag = 0
+    <select id="findWaybillOrderTicketCount" parameterType="java.util.Map">
+        SELECT IFNULL(SUM(wot.amount), 0.0) amount from
+        kwt_waybill_order_ticket wot
+        left join kwt_waybill_order wo on wot.w_order_id = wo.id
         left join kwt_logistics_order lo on lo.id = wo.l_order_id
-        where wo.del_flag = 0 and lo.del_flag = 0
-<!--        and wot1.unit = 0 and wot2.unit = 0-->
+        where wot.del_flag = 0 and wo.del_flag = 0 and lo.del_flag = 0
         <if test="driverId != null and driverId != ''">
             and wo.driver_id = #{driverId, jdbcType=BIGINT}
         </if>
@@ -227,7 +222,10 @@
             and wo.status in (7, 8, 12, 13)
         </if>
         <if test="unit != null and unit != ''">
-            and wot1.unit = #{unit, jdbcType=VARCHAR} and wot2.unit = #{unit, jdbcType=VARCHAR}
+            and wot.unit = #{unit, jdbcType=VARCHAR}
+        </if>
+        <if test="type != null and type != ''">
+            and wot.type = #{type, jdbcType=VARCHAR}
         </if>
         <if test="tOrderId != null and tOrderId != ''">
             and lo.t_order_id = #{tOrderId, jdbcType=BIGINT}