|
|
|
@ -1323,6 +1323,82 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
|
|
|
|
|
return distributionSignforOrderExcels; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param distrilbutionloadingscanDTO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public R cancelZeroPackage(DistrilbutionAppsignforDTO distrilbutionloadingscanDTO) { |
|
|
|
|
String method = "####################DistributionSignforImpl.cancelZeroPackage"; |
|
|
|
|
if (Func.isNotEmpty(distrilbutionloadingscanDTO.getZeroPackageIds())){ |
|
|
|
|
log.error(method+"ZeroPackageIds参数缺失"); |
|
|
|
|
return R.fail("请联系管理员维护!!!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())){ |
|
|
|
|
log.error(method+"ReservationId参数缺失"); |
|
|
|
|
return R.fail("请联系管理员维护!!!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(distrilbutionloadingscanDTO.getDeliveryId())){ |
|
|
|
|
log.error(method+"DeliveryId参数缺失"); |
|
|
|
|
return R.fail("请联系管理员维护!!!"); |
|
|
|
|
} |
|
|
|
|
List<Long> list = Func.toLongList(distrilbutionloadingscanDTO.getZeroPackageIds()); |
|
|
|
|
//查询是否进行装车或者签收
|
|
|
|
|
List<DistributionLoadscanEntity> loadscanEntityList = distributionLoadscanService.list(Wrappers.<DistributionLoadscanEntity>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<Long> orderIds = loadscanEntityList.stream().map(DistributionLoadscanEntity::getOrderId).distinct().collect(Collectors.toList()); |
|
|
|
|
List<DistributionStockArticleEntity> distributionStockArticleEntities = distributionStockArticleService.listByIds(orderIds); |
|
|
|
|
String orderCodes = distributionStockArticleEntities.stream().map(DistributionStockArticleEntity::getOrderCode).collect(Collectors.joining(",")); |
|
|
|
|
log.error(method+"取消零担失败,已进行装车或签收orderCodes:{}",orderCodes); |
|
|
|
|
return R.fail(orderCodes+"已进行装车或签收"); |
|
|
|
|
} |
|
|
|
|
//剩下的满足取消条件,进行计划内的资源释放即可
|
|
|
|
|
List<DistributionReservationZeroPackageEntity> planZeroPackageEntities = distributionReservationZeroPackageService.list(Wrappers.<DistributionReservationZeroPackageEntity>query().lambda() |
|
|
|
|
.eq(DistributionReservationZeroPackageEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) |
|
|
|
|
.ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) |
|
|
|
|
); |
|
|
|
|
Map<Long, List<DistributionReservationZeroPackageEntity>> planMap; |
|
|
|
|
if (Func.isNotEmpty(planZeroPackageEntities)){ |
|
|
|
|
planMap = planZeroPackageEntities.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getStockArticleId)); |
|
|
|
|
} else { |
|
|
|
|
planMap = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<DistributionReservationZeroPackageEntity> reservationZeroPackageEntities = distributionReservationZeroPackageService.list(Wrappers.<DistributionReservationZeroPackageEntity>query().lambda() |
|
|
|
|
.eq(DistributionReservationZeroPackageEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) |
|
|
|
|
.ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) |
|
|
|
|
.in(DistributionReservationZeroPackageEntity::getParcelListId, list) |
|
|
|
|
); |
|
|
|
|
if (Func.isNotEmpty(planMap)){ |
|
|
|
|
Map<Long, List<DistributionReservationZeroPackageEntity>> cancelMap = reservationZeroPackageEntities.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getStockArticleId)); |
|
|
|
|
cancelMap.forEach((k,v)->{ |
|
|
|
|
if (!planMap.get(k).isEmpty()){ |
|
|
|
|
List<Long> 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<DistributionReservationStockarticleEntity>().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<DeliveryNodeVo> handleStockUp(DistributionStockupEntity distributionStockupEntity) { |
|
|
|
|
List<DeliveryNodeVo> nodeVos = new ArrayList<>(); |
|
|
|
|
try { |
|
|
|
|