瀏覽代碼

提交修改商品名称

chenxiaofei 5 月之前
父節點
當前提交
d5df5cf7b0

+ 30 - 17
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderV1Service.java

@@ -3672,7 +3672,6 @@ public class KwtWaybillOrderV1Service {
             KwtLogisticsOrder kwtLogisticsOrder = getKwtLogisticsOrder(kwtLogistics, subtask);
             boolean b1 = kwtLogisticsOrderRepository.updateById(kwtLogisticsOrder);
             //如果物流订单状态是已完成需要通知贸易订单完成
-           // noticeTraderOrder(kwtLogisticsOrder, kwtLogistics);
 
             // 存储记录
             String remark = null;
@@ -3713,10 +3712,6 @@ public class KwtWaybillOrderV1Service {
                 updateSubtask.setUnloadUploadTime(DateUtils.parse(req.getUploadTime(), DateUtils.DATE_TIME_PATTERN));
             }
             boolean b = kwtWaybillOrderRepository.updateById(updateOrder) && kwtWaybillOrderSubtaskRepository.updateById(updateSubtask);
-//            kwtWaybillOrderTicket.setWOrderId(waybillId);
-//            kwtWaybillOrderTicket.setUrls(req.getAddressUrl());
-//            kwtWaybillOrderTicket.setUploadingTime(new Date());
-//            Boolean b1 = kwtWaybillOrderTicketRepository.updateByBillOrderIdAndType(kwtWaybillOrderTicket, 2);
             // 存储记录
             Long currentRoleId = LoginUserHolder.getCurrentRoleId();
             KwsRoleDto kwsRoleDto = remoteSystemService.queryByRoleIdAndEntId(currentRoleId);
@@ -3726,6 +3721,9 @@ public class KwtWaybillOrderV1Service {
             if (!b ){
                throw new BusinessException("完善单证失败");
             }
+            //如果审核的状态是 完成,那么就要去查询物流订单状态是完结中,并且所有物流订单下的运单全部是完成或者取消如果是则更新状态为已完成
+            //修改物流订单数据
+            updateLogisticOrder(subtask);
             //查询司机是否存在已绑定的车辆
             log.info("运单由审核驳回审核完成,解绑司机与车辆关系,运单id:{},企业id:{},司机id:{}", billOrder.getId(), billOrder.getEntId(), billOrder.getDriverId());
             remoteFleetService.unbindTruck(billOrder.getEntId(), billOrder.getDriverId());
@@ -3737,6 +3735,22 @@ public class KwtWaybillOrderV1Service {
         return Boolean.FALSE;
     }
 
+    private void updateLogisticOrder(KwtWaybillOrderSubtask subtask) {
+        KwtLogisticsOrder kwtLogistics= kwtLogisticsOrderRepository.queryByLogisticsOrderId(subtask.getLOrderId());
+        if (Objects.nonNull(kwtLogistics) && Objects.equals(kwtLogistics.getStatus(), LogisticsOrderV1Enum.NEARING_COMPLETION.getCode())){
+            List<KwtWaybillOrderSubtask> waybillOrderSubtasks = kwtWaybillOrderSubtaskRepository.queryByLogId(subtask.getLOrderId());
+            boolean b2 = waybillOrderSubtasks.stream()
+                    .allMatch(x -> Arrays.asList(CarWaybillV1Enum.COMPLETED.getCode(), CarWaybillV1Enum.CANCELLED.getCode()).contains(x.getStatus()));
+            if (b2){
+                KwtLogisticsOrder logisticsOrder = new KwtLogisticsOrder();
+                logisticsOrder.setId(kwtLogistics.getId());
+                logisticsOrder.setStatus(LogisticsOrderV1Enum.COMPLETED.getCode());
+                log.info("运单状态由审核驳回变成审核完成,修改物流订单状态为已完成,物流订单id:{}", kwtLogistics.getId());
+                kwtLogisticsOrderRepository.updateById(logisticsOrder);
+            }
+        }
+    }
+
     /**
      * 自动派单计算司机分值
      * @param billOrder
@@ -4185,13 +4199,6 @@ public class KwtWaybillOrderV1Service {
             throw new BusinessException("物流订单信息不存在");
         }
         //调物流订单完结订单
-//        List<KwtWaybillOrderSubtask> waybillOrderSubtasks = kwtWaybillOrderSubtaskRepository.queryByLogId(subtask.getLOrderId());
-//        boolean b2 = waybillOrderSubtasks.stream()
-//                .allMatch(x -> Arrays.asList(CarWaybillV1Enum.WAIT_UNLOADING.getCode(), CarWaybillV1Enum.APPROVAL_TREAT.getCode()).contains(x.getStatus()));
-        // KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderRepository.queryByLogisticsOrderId(subtask.getLOrderId());
-
-//        BigDecimal entrustAmount  = Objects.isNull(kwtLogistics.getEntrustAmount())  ? BigDecimal.ZERO: kwtLogistics.getEntrustAmount();
-//        BigDecimal subEntrustAmount = Objects.isNull(subtask.getEntrustAmount()) ? BigDecimal.ZERO: subtask.getEntrustAmount();
         BigDecimal loadAmount  = Objects.isNull(kwtLogistics.getLoadAmount())  ? BigDecimal.ZERO: kwtLogistics.getLoadAmount();
         BigDecimal subLoadAmount = Objects.isNull(subtask.getLoadAmount()) ? BigDecimal.ZERO: subtask.getLoadAmount();
         BigDecimal unloadAmount  = Objects.isNull(kwtLogistics.getUnloadAmount())  ? BigDecimal.ZERO: kwtLogistics.getUnloadAmount();
@@ -4200,13 +4207,19 @@ public class KwtWaybillOrderV1Service {
 
         KwtLogisticsOrder kwtLogisticsOrder = new KwtLogisticsOrder();
         kwtLogisticsOrder.setId(kwtLogistics.getId());
-       // kwtLogisticsOrder.setEntrustAmount(entrustAmount.add(subEntrustAmount));
         kwtLogisticsOrder.setLoadAmount(loadAmount.add(subLoadAmount));
         kwtLogisticsOrder.setUnloadAmount(unloadAmount.add(subUnloadAmount));
-//        if (b2){
-//            //调物流订单完结订单
-//            kwtLogisticsOrder.setStatus(LogisticsOrderV1Enum.HAVE_RECONCILED.getCode());
-//        }
+
+        //如果审核的状态是 完成,那么就要去查询物流订单状态是完结中,并且所有物流订单下的运单全部是完成或者取消如果是则更新状态为已完成
+        if (Objects.equals(kwtLogistics.getStatus(), LogisticsOrderV1Enum.NEARING_COMPLETION.getCode())){
+            List<KwtWaybillOrderSubtask> waybillOrderSubtasks = kwtWaybillOrderSubtaskRepository.queryByLogId(subtask.getLOrderId());
+            boolean b2 = waybillOrderSubtasks.stream()
+               .allMatch(x -> Arrays.asList(CarWaybillV1Enum.COMPLETED.getCode(), CarWaybillV1Enum.CANCELLED.getCode()).contains(x.getStatus()));
+            if (b2){
+                log.info("物流订单状态修改为已完成");
+                kwtLogisticsOrder.setStatus(LogisticsOrderV1Enum.COMPLETED.getCode());
+            }
+        }
         return kwtLogisticsOrder;
     }