|
|
@@ -3657,6 +3657,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
if (Objects.isNull(subtask)){
|
|
|
throw new BusinessException("子运单信息不存在");
|
|
|
}
|
|
|
+ KwtLogisticsOrder kwtLogistics= kwtLogisticsOrderRepository.queryByLogisticsOrderId(subtask.getLOrderId());
|
|
|
KwtWaybillOrder updateOrder = new KwtWaybillOrder();
|
|
|
updateOrder.setId(billOrder.getId());
|
|
|
KwtWaybillOrderSubtask updateSubtask = new KwtWaybillOrderSubtask();
|
|
|
@@ -3680,11 +3681,12 @@ public class KwtWaybillOrderV1Service {
|
|
|
updateSubtask.setUnloadUploadTime(DateUtils.parse(req.getUploadTime(), DateUtils.DATE_TIME_PATTERN));
|
|
|
}
|
|
|
boolean b = kwtWaybillOrderRepository.updateById(updateOrder) && kwtWaybillOrderSubtaskRepository.updateById(updateSubtask);
|
|
|
- //修改物流订单数据
|
|
|
- KwtLogisticsOrder kwtLogistics= kwtLogisticsOrderRepository.queryByLogisticsOrderId(subtask.getLOrderId());
|
|
|
//获取更新 订单状态
|
|
|
- KwtLogisticsOrder kwtLogisticsOrder = getKwtLogisticsOrder(kwtLogistics, subtask,status);
|
|
|
- boolean b1 = kwtLogisticsOrderRepository.updateById(kwtLogisticsOrder);
|
|
|
+ if (Objects.equals(status, CarWaybillV1Enum.COMPLETED.getCode())){
|
|
|
+ KwtLogisticsOrder kwtLogisticsOrder = getKwtLogisticsOrder(kwtLogistics, subtask,status);
|
|
|
+ kwtLogisticsOrderRepository.updateById(kwtLogisticsOrder);
|
|
|
+ }
|
|
|
+
|
|
|
//如果物流订单状态是已完成需要通知贸易订单完成
|
|
|
|
|
|
// 存储记录
|
|
|
@@ -3697,7 +3699,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
|
|
|
saveNode(billOrder, subtask, status,remark);
|
|
|
- if (!b || !b1){
|
|
|
+ if (!b ){
|
|
|
throw new BusinessException("审核运单失败");
|
|
|
}
|
|
|
//查询司机是否存在已绑定的车辆
|
|
|
@@ -3737,31 +3739,45 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
//如果审核的状态是 完成,那么就要去查询物流订单状态是完结中,并且所有物流订单下的运单全部是完成或者取消如果是则更新状态为已完成
|
|
|
//修改物流订单数据
|
|
|
- updateLogisticOrder(subtask);
|
|
|
+ KwtLogisticsOrder kwtLogisticsOrder = getKwtLogisticsOrder(kwtLogistics, subtask,status);
|
|
|
+ kwtLogisticsOrderRepository.updateById(kwtLogisticsOrder);
|
|
|
+ // updateLogisticOrder(subtask,kwtLogistics);
|
|
|
//查询司机是否存在已绑定的车辆
|
|
|
log.info("运单由审核驳回审核完成,解绑司机与车辆关系,运单id:{},企业id:{},司机id:{}", billOrder.getId(), billOrder.getEntId(), billOrder.getDriverId());
|
|
|
remoteFleetService.unbindTruck(billOrder.getEntId(), billOrder.getDriverId());
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
|
+ noticeTraderOrder(status, subtask,kwtLogistics);
|
|
|
//计算司机分值
|
|
|
calculateAutoDispatchScore(billOrder, status);
|
|
|
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
|
|
|
- private void updateLogisticOrder(KwtWaybillOrderSubtask subtask) {
|
|
|
- KwtLogisticsOrder kwtLogistics= kwtLogisticsOrderRepository.queryByLogisticsOrderId(subtask.getLOrderId());
|
|
|
+ private void updateLogisticOrder(KwtWaybillOrderSubtask subtask,KwtLogisticsOrder kwtLogistics) {
|
|
|
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()));
|
|
|
+ KwtLogisticsOrder logisticsOrder = new KwtLogisticsOrder();
|
|
|
+ logisticsOrder.setId(kwtLogistics.getId());
|
|
|
if (b2){
|
|
|
- KwtLogisticsOrder logisticsOrder = new KwtLogisticsOrder();
|
|
|
- logisticsOrder.setId(kwtLogistics.getId());
|
|
|
logisticsOrder.setStatus(LogisticsOrderV1Enum.COMPLETED.getCode());
|
|
|
log.info("运单状态由审核驳回变成审核完成,修改物流订单状态为已完成,物流订单id:{}", kwtLogistics.getId());
|
|
|
- kwtLogisticsOrderRepository.updateById(logisticsOrder);
|
|
|
+
|
|
|
}
|
|
|
+ BigDecimal unloadAmount = Objects.isNull(kwtLogistics.getUnloadAmount()) ? BigDecimal.ZERO: kwtLogistics.getUnloadAmount();
|
|
|
+ BigDecimal subUnloadAmount = Objects.isNull(subtask.getUnloadAmount()) ? BigDecimal.ZERO: subtask.getUnloadAmount();
|
|
|
+ BigDecimal entrustAmount = Objects.isNull(kwtLogistics.getEntrustAmount()) ? BigDecimal.ZERO: kwtLogistics.getEntrustAmount();
|
|
|
+ BigDecimal subEntrustAmount = Objects.isNull(subtask.getEntrustAmount()) ? BigDecimal.ZERO: subtask.getEntrustAmount();
|
|
|
+ KwtLogisticsOrder kwtLogisticsOrder = new KwtLogisticsOrder();
|
|
|
+ kwtLogisticsOrder.setId(kwtLogistics.getId());
|
|
|
+ BigDecimal subtractAmount = entrustAmount.subtract(subEntrustAmount);
|
|
|
+ BigDecimal entrust = subtractAmount.compareTo(BigDecimal.ZERO) >= 0
|
|
|
+ ? subtractAmount : new BigDecimal("0.00");
|
|
|
+ kwtLogisticsOrder.setEntrustAmount(entrust);
|
|
|
+ kwtLogisticsOrder.setTotalUnloadAmount(unloadAmount.add(subUnloadAmount));
|
|
|
+ kwtLogisticsOrderRepository.updateById(logisticsOrder);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -4154,34 +4170,14 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void noticeTraderOrder(KwtLogisticsOrder kwtLogisticsOrder, KwtLogisticsOrder kwtLogistics) {
|
|
|
-
|
|
|
- if (!Objects.equals(kwtLogisticsOrder.getStatus(),LogisticsOrderV1Enum.COMPLETED.getCode())){
|
|
|
+ private void noticeTraderOrder(Integer status, KwtWaybillOrderSubtask subtask,KwtLogisticsOrder kwtLogistics) {
|
|
|
+ if (!Objects.equals(status,CarWaybillV1Enum.COMPLETED.getCode())){
|
|
|
+ log.info("物流订单状态不是已完成,不通知贸易订单完结");
|
|
|
return;
|
|
|
}
|
|
|
- // 根据贸易订单id查询物理订单
|
|
|
- List<KwtLogisticsOrder> kwtLogisticsOrders = kwtLogisticsOrderRepository.queryByTradeOrderId(kwtLogisticsOrder.getTOrderId());
|
|
|
- if (org.apache.commons.collections4.CollectionUtils.isEmpty(kwtLogisticsOrders)){
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断所有的物流订单都都已经完成
|
|
|
- boolean b = kwtLogisticsOrders.stream()
|
|
|
- .allMatch(x -> Arrays.asList(LogisticsOrderV1Enum.COMPLETED.getCode(), LogisticsOrderV1Enum.REJECT_ORDER.getCode()).contains(x.getStatus()));
|
|
|
- if (!b){
|
|
|
- return;
|
|
|
- }
|
|
|
TradeOrderSettlePara tradeOrderSettlePara = new TradeOrderSettlePara();
|
|
|
tradeOrderSettlePara.setTOrderId(kwtLogistics.getTOrderId());
|
|
|
- BigDecimal loadAmount = kwtLogisticsOrders.stream()
|
|
|
- .map(KwtLogisticsOrder::getLoadAmount)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal unloadAmount = kwtLogisticsOrders.stream()
|
|
|
- .map(KwtLogisticsOrder::getUnloadAmount)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- tradeOrderSettlePara.setLoadAmount(loadAmount);
|
|
|
- tradeOrderSettlePara.setUnloadAmount(unloadAmount);
|
|
|
+ tradeOrderSettlePara.setUnloadAmount(subtask.getUnloadAmount());
|
|
|
log.info("运单审核通过修改贸易订单状态请求参数:{}",JSON.toJSONString(tradeOrderSettlePara));
|
|
|
tradeOrderInfoService.orderSettle(tradeOrderSettlePara);
|
|
|
}
|
|
|
@@ -4208,15 +4204,18 @@ public class KwtWaybillOrderV1Service {
|
|
|
throw new BusinessException("物流订单信息不存在");
|
|
|
}
|
|
|
//调物流订单完结订单
|
|
|
- BigDecimal loadAmount = Objects.isNull(kwtLogistics.getLoadAmount()) ? BigDecimal.ZERO: kwtLogistics.getLoadAmount();
|
|
|
- BigDecimal subLoadAmount = Objects.isNull(subtask.getLoadAmount()) ? BigDecimal.ZERO: subtask.getLoadAmount();
|
|
|
+ // 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();
|
|
|
BigDecimal subUnloadAmount = Objects.isNull(subtask.getUnloadAmount()) ? BigDecimal.ZERO: subtask.getUnloadAmount();
|
|
|
-
|
|
|
-
|
|
|
+ BigDecimal entrustAmount = Objects.isNull(kwtLogistics.getEntrustAmount()) ? BigDecimal.ZERO: kwtLogistics.getEntrustAmount();
|
|
|
+ BigDecimal subEntrustAmount = Objects.isNull(subtask.getEntrustAmount()) ? BigDecimal.ZERO: subtask.getEntrustAmount();
|
|
|
KwtLogisticsOrder kwtLogisticsOrder = new KwtLogisticsOrder();
|
|
|
kwtLogisticsOrder.setId(kwtLogistics.getId());
|
|
|
- kwtLogisticsOrder.setTotalLoadAmount(loadAmount.add(subLoadAmount));
|
|
|
+ BigDecimal subtractAmount = entrustAmount.subtract(subEntrustAmount);
|
|
|
+ BigDecimal entrust = subtractAmount.compareTo(BigDecimal.ZERO) >= 0
|
|
|
+ ? subtractAmount : new BigDecimal("0.00");
|
|
|
+ kwtLogisticsOrder.setEntrustAmount(entrust);
|
|
|
kwtLogisticsOrder.setTotalUnloadAmount(unloadAmount.add(subUnloadAmount));
|
|
|
|
|
|
//如果审核的状态是 完成,那么就要去查询物流订单状态是完结中,并且所有物流订单下的运单全部是完成或者取消如果是则更新状态为已完成
|
|
|
@@ -4327,6 +4326,9 @@ public class KwtWaybillOrderV1Service {
|
|
|
waybillOrderNodeVo.setTimelines(voList);
|
|
|
// 获取时间节点
|
|
|
List<WaybillOrderNodeVo.WaybillOrderNode> nodeList = getWaybillOrderNodes(voList);
|
|
|
+ nodeList = nodeList.stream()
|
|
|
+ .sorted(Comparator.comparing(WaybillOrderNodeVo.WaybillOrderNode::getOrderStatus))
|
|
|
+ .collect(Collectors.toList());
|
|
|
waybillOrderNodeVo.setWaybillOrderNodes(nodeList);
|
|
|
return waybillOrderNodeVo;
|
|
|
}
|