diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionDeliveryListController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionDeliveryListController.java index c2b453bd1..8a31df23e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionDeliveryListController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionDeliveryListController.java @@ -531,17 +531,22 @@ public class DistributionDeliveryListController extends BladeController { } + @PostMapping("/cancelZeroPackage") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "PC取消零担计划") + public R cancelZeroPackage(@Valid @RequestBody DistrilbutionAppsignforDTO distrilbutionloadingscanDTO) { + R r = distributionSignforService.cancelZeroPackage(distrilbutionloadingscanDTO); + return r; + } + + @PostMapping("/cancelDelivery") @ApiOperationSupport(order = 2) @ApiOperation(value = "PC取消配送任务") public R cancelDelivery(@Valid @RequestBody DistrilbutionAppsignforDTO distrilbutionloadingscanDTO) { R r = distributionDeliveryListService.cancelDelivery(distrilbutionloadingscanDTO.getDeliveryId()); -// if (r.isSuccess()){ - //取消成功,维护配送单状态和数量 -// distributionDeliveryListService.maintenanceDeliveryNum(distrilbutionloadingscanDTO.getDeliveryId()); -// distributionDeliveryListService.maintenanceDeliveryInfo(distrilbutionloadingscanDTO.getDeliveryId()); -// } + return r; } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java index 84515a59a..9b84521e2 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java @@ -321,4 +321,12 @@ public interface IDistributionSignforService extends BaseService exportDistributionSignforOrderList(Long signforId); + + /** + * 取消零担配送计划 + * @param distrilbutionloadingscanDTO + * @return + */ + R cancelZeroPackage(DistrilbutionAppsignforDTO distrilbutionloadingscanDTO); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index 793e26f63..c3c8ca886 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -1323,6 +1323,82 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl list = Func.toLongList(distrilbutionloadingscanDTO.getZeroPackageIds()); + //查询是否进行装车或者签收 + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() + .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) + .eq(DistributionLoadscanEntity::getDriverId, distrilbutionloadingscanDTO.getDeliveryId()) + .in(DistributionLoadscanEntity::getPackageId, list) + .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) + ); + if (Func.isNotEmpty(loadscanEntityList)){ + List orderIds = loadscanEntityList.stream().map(DistributionLoadscanEntity::getOrderId).distinct().collect(Collectors.toList()); + List distributionStockArticleEntities = distributionStockArticleService.listByIds(orderIds); + String orderCodes = distributionStockArticleEntities.stream().map(DistributionStockArticleEntity::getOrderCode).collect(Collectors.joining(",")); + log.error(method+"取消零担失败,已进行装车或签收orderCodes:{}",orderCodes); + return R.fail(orderCodes+"已进行装车或签收"); + } + //剩下的满足取消条件,进行计划内的资源释放即可 + List planZeroPackageEntities = distributionReservationZeroPackageService.list(Wrappers.query().lambda() + .eq(DistributionReservationZeroPackageEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) + .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) + ); + Map> planMap; + if (Func.isNotEmpty(planZeroPackageEntities)){ + planMap = planZeroPackageEntities.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getStockArticleId)); + } else { + planMap = null; + } + + List reservationZeroPackageEntities = distributionReservationZeroPackageService.list(Wrappers.query().lambda() + .eq(DistributionReservationZeroPackageEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) + .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) + .in(DistributionReservationZeroPackageEntity::getParcelListId, list) + ); + if (Func.isNotEmpty(planMap)){ + Map> cancelMap = reservationZeroPackageEntities.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getStockArticleId)); + cancelMap.forEach((k,v)->{ + if (!planMap.get(k).isEmpty()){ + List ids = v.stream().map(DistributionReservationZeroPackageEntity::getParcelListId).collect(Collectors.toList()); + distributionReservationZeroPackageService.recoverZeroPackage(distrilbutionloadingscanDTO.getReservationId(),ids); + if (planMap.get(k).size() == ids.size()){ + distributionReservationStockarticleService.update(new UpdateWrapper().lambda() + .eq(DistributionReservationStockarticleEntity::getReservationId,distrilbutionloadingscanDTO.getReservationId()) + .in(DistributionReservationStockarticleEntity::getStockArticleId,k) + .ne(DistributionReservationStockarticleEntity::getStockArticleStatus,ReservationOrderStatusConstant.quxiao.getValue()) + .set(DistributionReservationStockarticleEntity::getStockArticleStatus,ReservationOrderStatusConstant.quxiao.getValue()) + ); + } + } + }); + }else { + log.error(method+"查询原计划零担信息错误reservationId:{},ids:{}",distrilbutionloadingscanDTO.getReservationId(),list); + return R.fail("计划查询错误"); + } + return R.success("操作成功"); + } + private List handleStockUp(DistributionStockupEntity distributionStockupEntity) { List nodeVos = new ArrayList<>(); try { diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java index ab809fe37..c903395f8 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java @@ -286,7 +286,6 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl list = distributionDeliveryChargeService.list(Wrappers.query().lambda() .eq(DistributionDeliveryChargeEntity::getBillLading, distrilbutionBillLading.getId()) ); - if (!list.isEmpty()) { - list.forEach(i -> { - String s = distrilbutionBillLading.getFei().get(i.getCost()); - if (StringUtils.isNotBlank(s)) { - //修改 - DistributionDeliveryChargeEntity distributionDeliveryCharge = new DistributionDeliveryChargeEntity(); - distributionDeliveryCharge.setId(i.getId()); - distributionDeliveryCharge.setMoney(new BigDecimal(s)); - distributionDeliveryChargeService.updateById(distributionDeliveryCharge); - distrilbutionBillLading.getFei().remove(i.getCost()); - } else { - //删除 - distributionDeliveryChargeService.removeById(i.getId()); - } - }); - } +// List deliveryChargeEntities = new ArrayList<>(); +// if (!list.isEmpty()) { +// list.forEach(i -> { +// String s = distrilbutionBillLading.getFei().get(i.getCost()); +// if (StringUtils.isNotBlank(s)) { +// //修改 +// DistributionDeliveryChargeEntity distributionDeliveryCharge = new DistributionDeliveryChargeEntity(); +// distributionDeliveryCharge.setId(i.getId()); +// distributionDeliveryCharge.setMoney(new BigDecimal(s)); +// distributionDeliveryCharge.setCost(i.getCost()); +// deliveryChargeEntities.add(distributionDeliveryCharge); +//// distributionDeliveryChargeService.updateById(distributionDeliveryCharge); +// distrilbutionBillLading.getFei().remove(i.getCost()); +// } else { +// //删除 +// distributionDeliveryChargeService.removeById(i.getId()); +// } +// }); +// } +// if (!deliveryChargeEntities.isEmpty()){ +// distributionDeliveryChargeService.updateBatchById(deliveryChargeEntities); +// } //修改订单数据 if (!distrilbutionBillLading.getStockArticleList().isEmpty()) { boolean flag = handleOrder(distrilbutionBillLading); // boolean order = getOrder(distrilbutionBillLading.getStockArticleList(), distrilbutionBillLading.getId()); + String orderIds = distrilbutionBillLading.getStockArticleList().stream().map(DistributionStockArticleEntity::getId).map(String::valueOf).collect(Collectors.joining(",")); + distrilbutionBillLading.setStockArticleId(orderIds); + this.updateById(distrilbutionBillLading); + if (!flag) { throw new ServiceException("修改失败!!"); } @@ -453,6 +462,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImplupdate().lambda() + .eq(DistributionDeliveryChargeEntity::getBillLading,distrilbutionBillLading.getId()) + .set(DistributionDeliveryChargeEntity::getIsDeleted,1) + ); List listEntity = new ArrayList<>(); distrilbutionBillLading.getFei().forEach((k, v) -> { DistributionDeliveryChargeEntity distributionDeliveryCharge = new DistributionDeliveryChargeEntity(); @@ -1557,9 +1572,13 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl