|
|
@@ -60,9 +60,6 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class KwtWaybillOrderV1Service {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- KwtWaybillOrderMapper waybillOrderDao;
|
|
|
@Autowired
|
|
|
KwtWaybillOrderV1Mapper waybillOrderV1Dao;
|
|
|
@Autowired
|
|
|
@@ -92,6 +89,8 @@ public class KwtWaybillOrderV1Service {
|
|
|
@Autowired
|
|
|
KwtLogisticsOrderGoodsService kwtLogisticsOrderGoodsService;
|
|
|
@Autowired
|
|
|
+ KwtWaybillOrderSubtaskService waybillOrderSubtaskService;
|
|
|
+ @Autowired
|
|
|
KwtCommonService commonService;
|
|
|
@Resource
|
|
|
private StreamBridge streamBridge;
|
|
|
@@ -156,16 +155,18 @@ public class KwtWaybillOrderV1Service {
|
|
|
//物流订单装卸货地址委派量统计
|
|
|
Map<Long, BigDecimal> truckTotalEntrustAmount = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
for (SendCarInfoDto sendCar:sends) {
|
|
|
+ //趟次(循环单默认趟次为1)
|
|
|
+ int count = params.getType() == Global.NUMERICAL_ONE ? sendCar.getCount() : Global.NUMERICAL_ONE;
|
|
|
//运输委托信息
|
|
|
List<SendCarEntrustDto> entrusts = sendCar.getEntrusts();
|
|
|
/*数据组装*/
|
|
|
- for (SendCarEntrustDto e : entrusts) {
|
|
|
- lOrderIds.add(e.getLOrderId());
|
|
|
+ for (SendCarEntrustDto sendCarEntrust : entrusts) {
|
|
|
+ lOrderIds.add(sendCarEntrust.getLOrderId());
|
|
|
//承运订单该车辆计划运输总量:核定载量 * 趟次
|
|
|
- BigDecimal entrustAmount = BigDecimal.valueOf(e.getEntrustAmount() * sendCar.getCount());
|
|
|
- BigDecimal totalEntrustAmount = truckTotalEntrustAmount.get(e.getAddressId()) != null
|
|
|
- ? truckTotalEntrustAmount.get(e.getAddressId()) : NumberConstant.ZERO_TWO;
|
|
|
- truckTotalEntrustAmount.put(e.getAddressId(), totalEntrustAmount.add(entrustAmount));
|
|
|
+ BigDecimal entrustAmount = BigDecimal.valueOf(sendCarEntrust.getEntrustAmount() * count);
|
|
|
+ BigDecimal totalEntrustAmount = truckTotalEntrustAmount.get(sendCarEntrust.getAddressId()) != null
|
|
|
+ ? truckTotalEntrustAmount.get(sendCarEntrust.getAddressId()) : NumberConstant.ZERO_TWO;
|
|
|
+ truckTotalEntrustAmount.put(sendCarEntrust.getAddressId(), totalEntrustAmount.add(entrustAmount));
|
|
|
}
|
|
|
}
|
|
|
List<Long> lOrderIdsList = lOrderIds.stream().distinct().toList();
|
|
|
@@ -203,7 +204,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
//当前下游司机委派量 + 历史下游司机委派量 + 分包量
|
|
|
BigDecimal actualAmount = truckEntrustAmount.add(entrustAmountTotal);
|
|
|
if (actualAmount.doubleValue() > orderAmount.getAmount().doubleValue()) {
|
|
|
- return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + "累计派车量已大于剩余可运量!");
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + "可运量小于累计派车量!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -272,7 +273,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
|
|
|
//新增运单子单信息
|
|
|
- KwtWaybillOrderSubtask subtasks = sendCarSubtask(waybillOrder, lOrderId, entrustAmount, loadTime, unloadTime);
|
|
|
+ KwtWaybillOrderSubtask subtasks = waybillOrderSubtaskService.sendCarSubtask(waybillOrder, lOrderId, entrustAmount, loadTime, unloadTime);
|
|
|
for (SendCarEntrustDto sendCarEntrust:sendCars) {
|
|
|
//新增地址信息
|
|
|
sendCarAddress(subtasks.getId(), sendCarEntrust, waybillOrder);
|
|
|
@@ -336,7 +337,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
|
|
|
//更新承运订单kwt_logistics_order委派量
|
|
|
for (Long lAddressId:aEntrustAmount.keySet()) {
|
|
|
- KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByAddressId(lAddressId);
|
|
|
+ KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByLAddressId(lAddressId);
|
|
|
BigDecimal entrustAmount = logisticsOrderAmount.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrderAmount.getEntrustAmount();
|
|
|
logisticsOrderAmount.setEntrustAmount(entrustAmount.add(aEntrustAmount.get(lAddressId)));
|
|
|
logisticsOrderAmountDao.updateById(logisticsOrderAmount);
|
|
|
@@ -408,34 +409,6 @@ public class KwtWaybillOrderV1Service {
|
|
|
return waybillOrder;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param waybillOrder 运单信息
|
|
|
- * @param lOrderId 物流运单ID
|
|
|
- * @param entrustAmount 运输委托信息
|
|
|
- * @param loadTime 装货时间
|
|
|
- * @param unloadTime 卸货时间
|
|
|
- * @desc 车辆运单-子运单信息
|
|
|
- * @author zk
|
|
|
- * @date 2024/3/4
|
|
|
- **/
|
|
|
- public KwtWaybillOrderSubtask sendCarSubtask(KwtWaybillOrderV1 waybillOrder, Long lOrderId, BigDecimal entrustAmount, List<Date> loadTime, List<Date> unloadTime) {
|
|
|
- loadTime.sort(Comparator.naturalOrder());
|
|
|
- unloadTime.sort(Comparator.reverseOrder());
|
|
|
- KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
|
|
|
- KwtWaybillOrderSubtask orderSubtask = new KwtWaybillOrderSubtask();
|
|
|
- orderSubtask.setEntId(waybillOrder.getEntId());
|
|
|
- orderSubtask.setLOrderId(lOrderId);
|
|
|
- orderSubtask.setWOrderId(waybillOrder.getId());
|
|
|
- orderSubtask.setWOrderNo(waybillOrder.getWOrderNo());
|
|
|
- orderSubtask.setUnit(logisticsOrder != null ? logisticsOrder.getUnit() : null);
|
|
|
- orderSubtask.setEntrustAmount(entrustAmount.doubleValue());
|
|
|
- orderSubtask.setLoadTime(loadTime.get(Global.NUMERICAL_ZERO));
|
|
|
- orderSubtask.setUnloadTime(unloadTime.get(Global.NUMERICAL_ZERO));
|
|
|
- orderSubtask.setStatus(waybillOrder.getStatus());
|
|
|
- waybillOrderSubtaskDao.insert(orderSubtask);
|
|
|
- return orderSubtask;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param wSubtaskId 运单-子订单ID
|
|
|
* @param sendCarEntrust 运输委托信息
|
|
|
@@ -474,12 +447,331 @@ public class KwtWaybillOrderV1Service {
|
|
|
public void setWaybillOrderTrack(Long wOrderId, Date operateTime, int status, String remark) {
|
|
|
KwtWaybillOrderTrack orderTrack = new KwtWaybillOrderTrack();
|
|
|
orderTrack.setWOrderId(wOrderId);
|
|
|
- orderTrack.setOperateTime(operateTime);
|
|
|
+ orderTrack.setOperateTime(operateTime == null ? new Date() : operateTime);
|
|
|
orderTrack.setStatus(status);
|
|
|
orderTrack.setRemark(remark);
|
|
|
waybillOrderTrackDao.insert(orderTrack);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param ids 车辆运单主键ID,多个已逗号隔开
|
|
|
+ * @desc 取消派车(趟次派车)
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/7
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult cancelSendCarV1(List<Long> ids) {
|
|
|
+ /*1、校验*/
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return HttpResult.error("请选择需要撤回的运单!");
|
|
|
+ }
|
|
|
+ for (Long wOrderId:ids) {
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.error("运单" + wOrderId + "不存在,请确认!");
|
|
|
+ }
|
|
|
+ //趟次运单才能撤回
|
|
|
+ if (waybillOrder.getType() != Global.NUMERICAL_ONE) {
|
|
|
+ return HttpResult.error("运单" + waybillOrder.getWOrderNo() + "为循环运单不能撤回!");
|
|
|
+ }
|
|
|
+ //待接单的车辆运单才能撤回
|
|
|
+ if (!waybillOrder.getStatus().equals(CarWaybillEnum.PENDING_ORDER.getCode())) {
|
|
|
+ return HttpResult.error("运单" + waybillOrder.getWOrderNo() + "当前状态已不能撤回!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*2、更新运单状态*/
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.REVOKED.getCode());
|
|
|
+ waybillOrderV1Dao.updateById(waybillOrder);
|
|
|
+
|
|
|
+ /*3、新增运单状态记录*/
|
|
|
+ setWaybillOrderTrack(waybillOrder.getId(), waybillOrder.getUpdateTime(), waybillOrder.getStatus(), null);
|
|
|
+
|
|
|
+ /*4、回退物流订单委托量*/
|
|
|
+ /*4.1、装货址委派量entrustAmount回退*/
|
|
|
+ //运单装货地址
|
|
|
+ List<KwtWaybillOrderAddress> orderAddresses = waybillOrderAddressDao.findByAddresses(wOrderId, AddressDefaultTypeEnum.SHIPMENT.getCode());
|
|
|
+ for (KwtWaybillOrderAddress address:orderAddresses) {
|
|
|
+ //物流订单-装卸货地址运量信息
|
|
|
+ KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByLAddressId(address.getLAddressId());
|
|
|
+ //承运订单地址已委派量=承运订单地址原委派量-当前车辆运单地址委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrderAmount.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderAmount.getEntrustAmount();
|
|
|
+ logisticsOrderAmount.setEntrustAmount(entrustAmount.subtract(address.getEntrustAmount()));
|
|
|
+ logisticsOrderAmountDao.updateById(logisticsOrderAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*4.2、物流订单委派量entrustAmount回退*/
|
|
|
+ //运单子订单
|
|
|
+ List<KwtWaybillOrderSubtask> orderSubtasks = waybillOrderSubtaskDao.findByWOrderId(wOrderId);
|
|
|
+ for (KwtWaybillOrderSubtask subtask:orderSubtasks) {
|
|
|
+ //物流订单
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(subtask.getLOrderId());
|
|
|
+ //承运订单已委派量=承运订单原委派量-当前车辆运单委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount();
|
|
|
+ logisticsOrder.setEntrustAmount(entrustAmount.subtract(BigDecimal.valueOf(subtask.getEntrustAmount())));
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params {}
|
|
|
+ * @desc 确认接单
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/7
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult confirmSendCarV1(OperateWaybillDto params) {
|
|
|
+ /*1、校验*/
|
|
|
+ Long wOrderId = params.getWOrderId();
|
|
|
+ //运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.error("运单" + wOrderId + "不存在,请确认!");
|
|
|
+ }
|
|
|
+ //待接单的车辆运单才能撤回
|
|
|
+ if (!waybillOrder.getStatus().equals(CarWaybillEnum.PENDING_ORDER.getCode())) {
|
|
|
+ return HttpResult.error("运单" + waybillOrder.getWOrderNo() + "当前状态已不能接单!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*2、更新运单状态*/
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.PENDING_VEHICLE.getCode());
|
|
|
+ waybillOrderV1Dao.updateById(waybillOrder);
|
|
|
+
|
|
|
+ /*3、新增运单状态记录*/
|
|
|
+ setWaybillOrderTrack(waybillOrder.getId(), params.getOperateTime(), waybillOrder.getStatus(), params.getRemark());
|
|
|
+
|
|
|
+ /*4、更新司机/车辆数据*/
|
|
|
+ //更新司机信息
|
|
|
+ editDriver(waybillOrder.getDriverId());
|
|
|
+ //更新车辆信息
|
|
|
+ editTruck(waybillOrder.getTruckId());
|
|
|
+ //趟次运单不对物流订单委托量变更
|
|
|
+ if (waybillOrder.getType() == Global.NUMERICAL_ONE) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*5、累加物流订单委托量(循环运单)*/
|
|
|
+ /*5.1、装货址委派量entrustAmount累加*/
|
|
|
+ //运单装货地址
|
|
|
+ List<KwtWaybillOrderAddress> orderAddresses = waybillOrderAddressDao.findByAddresses(wOrderId, AddressDefaultTypeEnum.SHIPMENT.getCode());
|
|
|
+ for (KwtWaybillOrderAddress address:orderAddresses) {
|
|
|
+ //物流订单-装卸货地址运量信息
|
|
|
+ KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByLAddressId(address.getLAddressId());
|
|
|
+ //承运订单地址已委派量=承运订单地址原委派量+当前车辆运单地址委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrderAmount.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderAmount.getEntrustAmount();
|
|
|
+ logisticsOrderAmount.setEntrustAmount(entrustAmount.add(address.getEntrustAmount()));
|
|
|
+ logisticsOrderAmountDao.updateById(logisticsOrderAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*5.2、物流订单委派量entrustAmount累加*/
|
|
|
+ //运单子订单
|
|
|
+ List<KwtWaybillOrderSubtask> orderSubtasks = waybillOrderSubtaskDao.findByWOrderId(wOrderId);
|
|
|
+ for (KwtWaybillOrderSubtask subtask:orderSubtasks) {
|
|
|
+ //物流订单
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(subtask.getLOrderId());
|
|
|
+ //承运订单已委派量=承运订单原委派量+当前车辆运单委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount();
|
|
|
+ logisticsOrder.setEntrustAmount(entrustAmount.add(BigDecimal.valueOf(subtask.getEntrustAmount())));
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);
|
|
|
+ }
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params {}
|
|
|
+ * @desc 拒绝接单
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/7
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult refuseSendCarV1(OperateWaybillDto params) {
|
|
|
+ /*1、校验*/
|
|
|
+ Long wOrderId = params.getWOrderId();
|
|
|
+ //运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.error("运单" + wOrderId + "不存在,请确认!");
|
|
|
+ }
|
|
|
+ //待接单的车辆运单才能撤回
|
|
|
+ if (!waybillOrder.getStatus().equals(CarWaybillEnum.PENDING_ORDER.getCode())) {
|
|
|
+ return HttpResult.error("运单" + waybillOrder.getWOrderNo() + "当前状态已不能拒绝接单!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*2、更新运单状态*/
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.REJECT_ORDER.getCode());
|
|
|
+ waybillOrderV1Dao.updateById(waybillOrder);
|
|
|
+
|
|
|
+ /*3、新增运单状态记录*/
|
|
|
+ setWaybillOrderTrack(waybillOrder.getId(), params.getOperateTime(), waybillOrder.getStatus(), params.getRemark());
|
|
|
+
|
|
|
+ //循环运单不对物流订单委托量变更
|
|
|
+ if (waybillOrder.getType() == Global.NUMERICAL_TWO) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*4、回退物流订单委托量(循环运单)*/
|
|
|
+ /*4.1、装货址委派量entrustAmount回退*/
|
|
|
+ //运单装货地址
|
|
|
+ List<KwtWaybillOrderAddress> orderAddresses = waybillOrderAddressDao.findByAddresses(wOrderId, AddressDefaultTypeEnum.SHIPMENT.getCode());
|
|
|
+ for (KwtWaybillOrderAddress address:orderAddresses) {
|
|
|
+ //物流订单-装卸货地址运量信息
|
|
|
+ KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByLAddressId(address.getLAddressId());
|
|
|
+ //承运订单地址已委派量=承运订单地址原委派量-+当前车辆运单地址委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrderAmount.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderAmount.getEntrustAmount();
|
|
|
+ logisticsOrderAmount.setEntrustAmount(entrustAmount.subtract(address.getEntrustAmount()));
|
|
|
+ logisticsOrderAmountDao.updateById(logisticsOrderAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*4.2、物流订单委派量entrustAmount回退*/
|
|
|
+ //运单子订单
|
|
|
+ List<KwtWaybillOrderSubtask> orderSubtasks = waybillOrderSubtaskDao.findByWOrderId(wOrderId);
|
|
|
+ for (KwtWaybillOrderSubtask subtask:orderSubtasks) {
|
|
|
+ //物流订单
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(subtask.getLOrderId());
|
|
|
+ //承运订单已委派量=承运订单原委派量-当前车辆运单委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount();
|
|
|
+ logisticsOrder.setEntrustAmount(entrustAmount.subtract(BigDecimal.valueOf(subtask.getEntrustAmount())));
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);
|
|
|
+ }
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params {}
|
|
|
+ * @desc 确认出车
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/7
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult confirmDepartureV1(OperateWaybillDto params) {
|
|
|
+ /*1、校验*/
|
|
|
+ Long wOrderId = params.getWOrderId();
|
|
|
+ //运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.error("运单" + wOrderId + "不存在,请确认!");
|
|
|
+ }
|
|
|
+ //待出车的车辆运单才能撤回
|
|
|
+ if (!waybillOrder.getStatus().equals(CarWaybillEnum.PENDING_VEHICLE.getCode())) {
|
|
|
+ return HttpResult.error("运单" + waybillOrder.getWOrderNo() + "当前状态不能出车!");
|
|
|
+ }
|
|
|
+ //车辆任务中校验
|
|
|
+ WaybillCountVo countVo = waybillOrderV1Dao.findCountByDriverOrTruck(null, waybillOrder.getTruckId());
|
|
|
+ if (countVo.getTotalExecute() > 0) {
|
|
|
+ return HttpResult.error("车辆"+waybillOrder.getTruckNo()+"正在任务中,暂不能出车!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*2、更新运单状态*/
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.EXIT_COMPLETED.getCode());
|
|
|
+ waybillOrderV1Dao.updateById(waybillOrder);
|
|
|
+
|
|
|
+ /*3、新增运单状态记录*/
|
|
|
+ setWaybillOrderTrack(waybillOrder.getId(), params.getOperateTime(), waybillOrder.getStatus(), params.getRemark());
|
|
|
+
|
|
|
+ /*4、更新司机/车辆数据*/
|
|
|
+ //更新司机信息
|
|
|
+ editDriver(waybillOrder.getDriverId());
|
|
|
+ //更新车辆信息
|
|
|
+ editTruck(waybillOrder.getTruckId());
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params {}
|
|
|
+ * @desc 拒绝出车
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/7
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult refuseDepartureV1(OperateWaybillDto params) {
|
|
|
+ /*1、校验*/
|
|
|
+ Long wOrderId = params.getWOrderId();
|
|
|
+ //运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.error("运单" + wOrderId + "不存在,请确认!");
|
|
|
+ }
|
|
|
+ //待出车的车辆运单才能撤回
|
|
|
+ if (!waybillOrder.getStatus().equals(CarWaybillEnum.PENDING_VEHICLE.getCode())) {
|
|
|
+ return HttpResult.error("运单" + waybillOrder.getWOrderNo() + "当前状态不能拒绝出车!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*2、更新运单状态*/
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
|
|
|
+ waybillOrderV1Dao.updateById(waybillOrder);
|
|
|
+
|
|
|
+ /*3、新增运单状态记录*/
|
|
|
+ setWaybillOrderTrack(waybillOrder.getId(), params.getOperateTime(), waybillOrder.getStatus(), params.getRemark());
|
|
|
+
|
|
|
+ /*4、回退物流订单委托量*/
|
|
|
+ /*4.1、装货址委派量entrustAmount回退*/
|
|
|
+ //运单装货地址
|
|
|
+ List<KwtWaybillOrderAddress> orderAddresses = waybillOrderAddressDao.findByAddresses(wOrderId, AddressDefaultTypeEnum.SHIPMENT.getCode());
|
|
|
+ for (KwtWaybillOrderAddress address:orderAddresses) {
|
|
|
+ //物流订单-装卸货地址运量信息
|
|
|
+ KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByLAddressId(address.getLAddressId());
|
|
|
+ //承运订单地址已委派量=承运订单地址原委派量-当前车辆运单地址委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrderAmount.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderAmount.getEntrustAmount();
|
|
|
+ logisticsOrderAmount.setEntrustAmount(entrustAmount.subtract(address.getEntrustAmount()));
|
|
|
+ logisticsOrderAmountDao.updateById(logisticsOrderAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*4.2、物流订单委派量entrustAmount回退*/
|
|
|
+ //运单子订单
|
|
|
+ List<KwtWaybillOrderSubtask> orderSubtasks = waybillOrderSubtaskDao.findByWOrderId(wOrderId);
|
|
|
+ for (KwtWaybillOrderSubtask subtask:orderSubtasks) {
|
|
|
+ //物流订单
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(subtask.getLOrderId());
|
|
|
+ //承运订单已委派量=承运订单原委派量-当前车辆运单委派量
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount();
|
|
|
+ logisticsOrder.setEntrustAmount(entrustAmount.subtract(BigDecimal.valueOf(subtask.getEntrustAmount())));
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);
|
|
|
+ }
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param driverId 司机档案ID
|
|
|
+ * @desc 更新司机信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/8/3
|
|
|
+ **/
|
|
|
+ public void editDriver(Long driverId) {
|
|
|
+ //数据统计
|
|
|
+ WaybillCountVo countVo = waybillOrderV1Dao.findCountByDriverOrTruck(driverId, null);
|
|
|
+ WaybillCountVo amountVo = waybillOrderV1Dao.findAmountByDriverOrTruck(driverId, null);
|
|
|
+ RDriverVo driver = new RDriverVo();
|
|
|
+ driver.setId(driverId);
|
|
|
+ driver.setTotalComplete(countVo.getTotalComplete());
|
|
|
+ driver.setTotalTake(countVo.getTotalTake());
|
|
|
+ driver.setTotalWeight(amountVo.getLoadAmount());
|
|
|
+ driver.setBusinessStatus(countVo.getTotalExecute() > 0 ? 1 : 0);
|
|
|
+ remoteFleetService.updateById(driver);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param truckId 车辆档案ID
|
|
|
+ * @desc 更新车辆信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/8/3
|
|
|
+ **/
|
|
|
+ public void editTruck(Long truckId) {
|
|
|
+ //数据统计
|
|
|
+ WaybillCountVo countVo = waybillOrderV1Dao.findCountByDriverOrTruck(null, truckId);
|
|
|
+ WaybillCountVo amountVo = waybillOrderV1Dao.findAmountByDriverOrTruck(null, truckId);
|
|
|
+ RTruckVo truck = new RTruckVo();
|
|
|
+ truck.setId(truckId);
|
|
|
+ truck.setTotalComplete(countVo.getTotalComplete());
|
|
|
+ truck.setTotalTake(countVo.getTotalTake());
|
|
|
+ truck.setTotalWeight(amountVo.getLoadAmount());
|
|
|
+ truck.setBusinessStatus(countVo.getTotalExecute() > 0 ? 1 : 0);
|
|
|
+ remoteFleetService.updateById(truck);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param type 字典类型
|
|
|
* @param value 字典值
|