|
|
|
@ -1732,6 +1732,181 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl<Distrib
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public synchronized void maintenanceOrderInfoByIds(List<Long> ids) { |
|
|
|
|
String method = "###############方法:maintenanceOrderInfo,"; |
|
|
|
|
if (Func.isEmpty(ids)) { |
|
|
|
|
log.error(method + "参数缺失ids:{}", ids); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
for (Long s : ids) { |
|
|
|
|
//查询订单
|
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = this.getById(s); |
|
|
|
|
if (Func.isEmpty(stockArticleEntity)) { |
|
|
|
|
log.error(method + "订单不存在orderCode:{}", s); |
|
|
|
|
throw new RuntimeException("订单不存在"); |
|
|
|
|
} |
|
|
|
|
if (IsOrNoConstant.no.getValue().equals(stockArticleEntity.getIsZero())) { |
|
|
|
|
//查询包件列表
|
|
|
|
|
List<DistributionParcelListEntity> parcelListEntities = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda() |
|
|
|
|
.eq(DistributionParcelListEntity::getOrderCode, s) |
|
|
|
|
.eq(DistributionParcelListEntity::getConditions, 1) |
|
|
|
|
.eq(DistributionParcelListEntity::getStockArticleId, stockArticleEntity.getId()) |
|
|
|
|
); |
|
|
|
|
if (Func.isEmpty(parcelListEntities)) { |
|
|
|
|
log.error(method + "查询包件列表空orderCode:{}", s); |
|
|
|
|
throw new RuntimeException("包件列表为空"); |
|
|
|
|
} |
|
|
|
|
//在库数量
|
|
|
|
|
int inWarehouseQuantity = 0; |
|
|
|
|
//装车数量
|
|
|
|
|
int loadingQuantity = 0; |
|
|
|
|
//配送件数
|
|
|
|
|
int deliveryQuantity = 0; |
|
|
|
|
//签收件数
|
|
|
|
|
int signingQuantity = 0; |
|
|
|
|
//订单总件数
|
|
|
|
|
int totalNumber = stockArticleEntity.getTotalNumber().intValue(); |
|
|
|
|
for (DistributionParcelListEntity parcelListEntity : parcelListEntities) { |
|
|
|
|
//统计订单相关的状态节点数量
|
|
|
|
|
if (parcelListEntity.getOrderPackageReservationStatus().equals(OrderPackageReservationStatusConstant.yiyueyue.getValue())) { |
|
|
|
|
deliveryQuantity += parcelListEntity.getQuantity(); |
|
|
|
|
} |
|
|
|
|
if (parcelListEntity.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())) { |
|
|
|
|
loadingQuantity += parcelListEntity.getQuantity(); |
|
|
|
|
} |
|
|
|
|
if (parcelListEntity.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { |
|
|
|
|
signingQuantity += parcelListEntity.getQuantity(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// int sum = parcelListEntities.stream().filter(f -> !OrderPackageStatusConstant.yiqianshou.getValue().equals(f.getOrderPackageStatus())
|
|
|
|
|
// || OrderPackageLoadingStatusConstant.weizhuancghe.getValue().equals(f.getOrderPackageLoadingStatus())
|
|
|
|
|
// || OrderPackageReservationStatusConstant.daiyuyue.getValue().equals(f.getOrderPackageReservationStatus())
|
|
|
|
|
// ).mapToInt(DistributionParcelListEntity::getQuantity).sum();
|
|
|
|
|
int a = parcelListEntities.stream().filter(f -> !OrderPackageStatusConstant.yiqianshou.getValue().equals(f.getOrderPackageStatus()) && OrderPackageLoadingStatusConstant.weizhuancghe.getValue().equals(f.getOrderPackageLoadingStatus())) |
|
|
|
|
.mapToInt(DistributionParcelListEntity::getQuantity).sum(); |
|
|
|
|
inWarehouseQuantity = a; |
|
|
|
|
|
|
|
|
|
stockArticleEntity.setHandQuantity(inWarehouseQuantity); |
|
|
|
|
stockArticleEntity.setDeliveryQuantity(deliveryQuantity); |
|
|
|
|
stockArticleEntity.setSigninQuantity(signingQuantity); |
|
|
|
|
if (totalNumber != 0) { |
|
|
|
|
|
|
|
|
|
if (totalNumber == deliveryQuantity) { |
|
|
|
|
stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); |
|
|
|
|
} else { |
|
|
|
|
stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue()); |
|
|
|
|
} |
|
|
|
|
if (deliveryQuantity == 0) { |
|
|
|
|
stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//未签收的情况下分析订单的装车状态,此时该订单未有包件进行其拿手
|
|
|
|
|
if (signingQuantity == 0) { |
|
|
|
|
if (totalNumber == loadingQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); |
|
|
|
|
} else { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); |
|
|
|
|
} |
|
|
|
|
if (loadingQuantity == 0) { |
|
|
|
|
if (totalNumber == inWarehouseQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue()); |
|
|
|
|
} else { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenruku.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
//订单存在签收数据了,此时就需要进行签收状态的判断
|
|
|
|
|
if (totalNumber == signingQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.qianshou.getValue()); |
|
|
|
|
} else { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenqianshou.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (inWarehouseQuantity > 0) { |
|
|
|
|
stockArticleEntity.setGenre(1); |
|
|
|
|
} |
|
|
|
|
this.updateById(stockArticleEntity); |
|
|
|
|
} |
|
|
|
|
} else if (IsOrNoConstant.yes.getValue().equals(stockArticleEntity.getIsZero())) { |
|
|
|
|
//零担订单维护
|
|
|
|
|
List<DistributionParcelNumberEntity> parcelNumberEntities = distributionParcelNumberMapper.selectList(Wrappers.<DistributionParcelNumberEntity>query().lambda() |
|
|
|
|
.eq(DistributionParcelNumberEntity::getStockArticleId,s) |
|
|
|
|
); |
|
|
|
|
//在库数量
|
|
|
|
|
int inWarehouseQuantity = 0; |
|
|
|
|
//装车数量
|
|
|
|
|
int loadingQuantity = 0; |
|
|
|
|
//配送件数
|
|
|
|
|
int deliveryQuantity = 0; |
|
|
|
|
//签收件数
|
|
|
|
|
int signingQuantity = 0; |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(parcelNumberEntities)) { |
|
|
|
|
//在库数量
|
|
|
|
|
inWarehouseQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getHandQuantity).sum(); |
|
|
|
|
deliveryQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getDeliveryQuantity).sum(); |
|
|
|
|
loadingQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getOutboundQuantity).sum(); |
|
|
|
|
signingQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getSigninQuantity).sum(); |
|
|
|
|
log.info("############维护零担数量deliveryQuantity:{}", deliveryQuantity); |
|
|
|
|
log.info("############维护零担数量loadingQuantity:{}", loadingQuantity); |
|
|
|
|
log.info("############维护零担数量inWarehouseQuantity:{}", inWarehouseQuantity); |
|
|
|
|
log.info("############维护零担数量signingQuantity:{}", signingQuantity); |
|
|
|
|
log.info("############维护零担数量TotalNumber:{}", stockArticleEntity.getTotalNumber()); |
|
|
|
|
if (stockArticleEntity.getTotalNumber() == loadingQuantity) { |
|
|
|
|
//此时的出库和总数一致,该零担此时全部进行出库
|
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); |
|
|
|
|
} else if (stockArticleEntity.getTotalNumber() > loadingQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); |
|
|
|
|
} else { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue()); |
|
|
|
|
} |
|
|
|
|
if ((loadingQuantity + deliveryQuantity) == 0) { |
|
|
|
|
if (stockArticleEntity.getTotalNumber() == inWarehouseQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue()); |
|
|
|
|
stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue()); |
|
|
|
|
} else if (inWarehouseQuantity > 0) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenruku.getValue()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ((loadingQuantity + deliveryQuantity) == stockArticleEntity.getTotalNumber()) { |
|
|
|
|
//无在库数量则无法进行预约
|
|
|
|
|
stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); |
|
|
|
|
} else if ((loadingQuantity + deliveryQuantity) > 0) { |
|
|
|
|
stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (signingQuantity == 0) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue()); |
|
|
|
|
} else { |
|
|
|
|
if (stockArticleEntity.getTotalNumber() == signingQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.qianshou.getValue()); |
|
|
|
|
} else if (stockArticleEntity.getTotalNumber() > signingQuantity) { |
|
|
|
|
stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenqianshou.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//维护订单的在库件数
|
|
|
|
|
stockArticleEntity.setHandQuantity(inWarehouseQuantity); |
|
|
|
|
//维护订单的配送件数
|
|
|
|
|
// deliveryQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getDeliveryQuantity).sum() + parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getSigninQuantity).sum() + parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getOutboundQuantity).sum();
|
|
|
|
|
stockArticleEntity.setDeliveryQuantity(loadingQuantity); |
|
|
|
|
stockArticleEntity.setSigninQuantity(signingQuantity); |
|
|
|
|
// stockArticleEntity.setDeliveryQuantity(deliveryQuantity);
|
|
|
|
|
if (inWarehouseQuantity > 0) { |
|
|
|
|
stockArticleEntity.setGenre(1); |
|
|
|
|
} |
|
|
|
|
this.updateById(stockArticleEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param orderCode |
|
|
|
|
* @param warehouseId |
|
|
|
|