|
|
@@ -83,6 +83,8 @@ public class KwtWaybillOrderService {
|
|
|
@Autowired
|
|
|
KwtLogisticsOrderCirculateMapper logisticsOrderCirculateDao;
|
|
|
@Autowired
|
|
|
+ KwtLogisticsOrderAmountMapper logisticsOrderAmountDao;
|
|
|
+ @Autowired
|
|
|
KwtWaybillOrderTicketService waybillOrderTicketService;
|
|
|
@Autowired
|
|
|
KwtLogisticsOrderGoodsService kwtLogisticsOrderGoodsService;
|
|
|
@@ -448,6 +450,27 @@ public class KwtWaybillOrderService {
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param params
|
|
|
+ * @desc 派车-多装多卸
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/19
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult sendCarV1(SendCarDto2 params) {
|
|
|
+ /**校验**/
|
|
|
+ HttpResult result = checkWaybillOrderV1(params);
|
|
|
+ if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println(JSON.toJSONString(params));
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 派车请求参数
|
|
|
* @param logisticsOrder 物流订单
|
|
|
@@ -499,6 +522,88 @@ public class KwtWaybillOrderService {
|
|
|
return HttpResult.ok(ranksAmount);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param params 派车请求参数
|
|
|
+ * @param logisticsOrder 物流订单
|
|
|
+ * @desc 派车校验
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/19
|
|
|
+ **/
|
|
|
+ public HttpResult checkWaybillOrderV1(SendCarDto2 params) {
|
|
|
+ /**控制校验**/
|
|
|
+ if (CollectionUtils.isEmpty(params.getSends())) {
|
|
|
+ return HttpResult.error("请选择委派信息!");
|
|
|
+ } else {
|
|
|
+ for (SendCarInfoDto sendCar:params.getSends()) {
|
|
|
+ if (CollectionUtils.isEmpty(sendCar.getEntrusts())) {
|
|
|
+ return HttpResult.error("请选择委派信息!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //车辆司机信息
|
|
|
+ List<SendCarInfoDto> sends = params.getSends();
|
|
|
+ //物流订单ID
|
|
|
+ List<Long> lOrderIds = new ArrayList<>();
|
|
|
+ //物流订单装卸货地址委派量统计
|
|
|
+ Map<Long, BigDecimal> truckTotalEntrustAmount = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ for (SendCarInfoDto sendCar:sends) {
|
|
|
+ //运输委托信息
|
|
|
+ List<SendCarEntrustDto> entrusts = sendCar.getEntrusts();
|
|
|
+ /**数据组装**/
|
|
|
+ entrusts.forEach(e -> {
|
|
|
+ lOrderIds.add(e.getLOrderId());
|
|
|
+ //承运订单该车辆计划运输总量:核定载量 * 趟次
|
|
|
+ BigDecimal entrustAmount = new BigDecimal(e.getEntrustAmount() * sendCar.getCount());
|
|
|
+ if (truckTotalEntrustAmount.get(e.getAddressId()) != null) {
|
|
|
+ truckTotalEntrustAmount.put(e.getAddressId(), truckTotalEntrustAmount.get(e.getAddressId()).add(entrustAmount));
|
|
|
+ } else {
|
|
|
+ truckTotalEntrustAmount.put(e.getAddressId(), entrustAmount);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ List<Long> lOrderIdsList = lOrderIds.stream().distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ /**校验物流运单是否可以派车**/
|
|
|
+ for (Long lOrderId:lOrderIdsList) {
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ return HttpResult.error("订单"+lOrderId+"已不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态校验
|
|
|
+ if (logisticsOrder.getStatus() != LogisticsOrderEnum.WAIT_DELIVERY.getCode() && logisticsOrder.getStatus() != LogisticsOrderEnum.IN_TRANSIT.getCode()) {
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + LogisticsOrderEnum.getName(logisticsOrder.getStatus()) + "不能派车!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //剩余可运量校验
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getEntrustAmount();
|
|
|
+ BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getSubcontractAmount();
|
|
|
+ //历史下游司机委派量 + 分包量
|
|
|
+ BigDecimal entrustAmountTotal = entrustAmount.add(subcontractAmount);
|
|
|
+ if (entrustAmountTotal.compareTo(logisticsOrder.getAmount()) > 0) {
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + "剩余可运量已不能派车!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**校验是车辆委托量否超过物流订单剩余量-趟次**/
|
|
|
+ //物流订单地址委托量信息-装货信息
|
|
|
+ KwtLogisticsOrderAddress queryAmount = new KwtLogisticsOrderAddress();
|
|
|
+ queryAmount.setLOrderId(lOrderId);
|
|
|
+ queryAmount.setAddressType(AddressDefaultTypeEnum.SHIPMENT.getCode());
|
|
|
+ List<KwtLogisticsOrderAmount> logisticsOrderAmounts = logisticsOrderAmountDao.findByAddress(queryAmount);
|
|
|
+ for (KwtLogisticsOrderAmount orderAmount:logisticsOrderAmounts) {
|
|
|
+ BigDecimal truckEntrustAmount = truckTotalEntrustAmount.get(orderAmount.getAddressId());
|
|
|
+ //当前下游司机委派量 + 历史下游司机委派量 + 分包量
|
|
|
+ BigDecimal actualAmount = truckEntrustAmount.add(entrustAmountTotal);
|
|
|
+ if (actualAmount.doubleValue() > orderAmount.getAmount().doubleValue()) {
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + "累计派车量已大于剩余可运量!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return HttpResult.ok(truckTotalEntrustAmount);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 派车请求参数
|
|
|
* @param logisticsOrder 物流订单
|