|
|
|
@ -1176,7 +1176,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
//推翻原有的
|
|
|
|
|
Long id = distributionReservationDTO.getId(); |
|
|
|
|
//这里需要查询出这个预约原来的订单、包件信息
|
|
|
|
|
List<DistributionReservationStockarticleEntity> distributionReservationStockarticleEntities = distributionReservationStockarticleService.getBaseMapper().selectList(Wrappers.<DistributionReservationStockarticleEntity>query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, id).ne(DistributionReservationStockarticleEntity::getStockArticleStatus,ReservationOrderStatusConstant.quxiao.getValue())); |
|
|
|
|
List<DistributionReservationStockarticleEntity> distributionReservationStockarticleEntities = distributionReservationStockarticleService.getBaseMapper().selectList(Wrappers.<DistributionReservationStockarticleEntity>query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, id).ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); |
|
|
|
|
Map<Long, List<DistributionReservationStockarticleEntity>> oldStockArticle = distributionReservationStockarticleEntities.stream().collect(Collectors.groupingBy(DistributionReservationStockarticleEntity::getStockArticleId)); |
|
|
|
|
List<DistributionStockArticleDTO> dtoStockArticleList = distributionReservationDTO.getStockArticleList(); |
|
|
|
|
Map<Long, List<DistributionStockArticleDTO>> newStockArticle = dtoStockArticleList.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getId)); |
|
|
|
@ -1192,7 +1192,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
AtomicInteger packageNum = new AtomicInteger(); |
|
|
|
|
DistributionStockArticleDTO distributionStockArticleDTO = v.get(0); |
|
|
|
|
if (distributionStockArticleDTO.getIsZero().equals(IsOrNoConstant.no.getValue())) { |
|
|
|
|
if (Func.isNotEmpty(distributionStockArticleDTO.getPackageListInfo())){ |
|
|
|
|
if (Func.isNotEmpty(distributionStockArticleDTO.getPackageListInfo())) { |
|
|
|
|
List<DistributionParcelListDTO> packageListInfo = distributionStockArticleDTO.getPackageListInfo(); |
|
|
|
|
packageListInfo.forEach(p -> { |
|
|
|
|
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); |
|
|
|
@ -1208,7 +1208,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
distributionParcelListService.updateById(parcelListEntity); |
|
|
|
|
distributionAsyncService.checkStockArticleReservationStatus(p); |
|
|
|
|
}); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
//添加此订单可用所有包件数量
|
|
|
|
|
//添加订单下的所有在库订单的包件
|
|
|
|
|
List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda().eq(DistributionParcelListEntity::getStockArticleId, distributionStockArticleDTO.getId()) |
|
|
|
@ -1321,16 +1321,18 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
} else { |
|
|
|
|
//查询出这个订单原来在这个预约中的勾选情况
|
|
|
|
|
DistributionStockArticleDTO distributionStockArticleDTO = v.get(0); |
|
|
|
|
AtomicInteger packageNum = new AtomicInteger(); |
|
|
|
|
if (distributionStockArticleDTO.getIsZero().equals(IsOrNoConstant.no.getValue())) { |
|
|
|
|
if (Func.isEmpty(distributionStockArticleDTO.getPackageListInfo())) { |
|
|
|
|
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle.get(k).get(0); |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(distributionStockArticleDTO.getPackageListInfo())) { |
|
|
|
|
List<DistributionReservationPackageEntity> packageEntityList = distributionReservationPackageMapper.selectPackageByReservationAndStockArticleId(id, k); |
|
|
|
|
Map<Long, List<DistributionReservationPackageEntity>> oldPackage = packageEntityList.stream().collect(Collectors.groupingBy(DistributionReservationPackageEntity::getParceListId)); |
|
|
|
|
Map<Long, List<DistributionParcelListEntity>> newPackage = distributionStockArticleDTO.getPackageListInfo().stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getId)); |
|
|
|
|
AtomicInteger packageNum = new AtomicInteger(); |
|
|
|
|
AtomicInteger reduceNum = new AtomicInteger(); |
|
|
|
|
// AtomicInteger reduceNum = new AtomicInteger();
|
|
|
|
|
newPackage.forEach((m, n) -> { |
|
|
|
|
if (Func.isEmpty(oldPackage.get(m))) { |
|
|
|
|
DistributionParcelListEntity distributionParcelListEntity = n.get(0); |
|
|
|
|
if (Func.isEmpty(oldPackage.get(m))) { |
|
|
|
|
//新增
|
|
|
|
|
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); |
|
|
|
|
reservationPackageEntity.setStockArticleId(distributionStockArticleDTO.getId()); |
|
|
|
@ -1345,7 +1347,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
distributionParcelListService.updateById(parcelListEntity); |
|
|
|
|
} else { |
|
|
|
|
//数量维护
|
|
|
|
|
packageNum.getAndAdd(oldStockArticle.get(k).get(0).getReservationNum()); |
|
|
|
|
packageNum.getAndAdd(distributionParcelListEntity.getQuantity()); |
|
|
|
|
//移除
|
|
|
|
|
oldPackage.remove(m); |
|
|
|
|
} |
|
|
|
@ -1356,23 +1358,24 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
reservationPackageEntity.setPacketBarStatus(ReservationPackageStatusConstant.quxiao.getValue()); |
|
|
|
|
distributionReservationPackageService.updateById(reservationPackageEntity); |
|
|
|
|
//统计减少包件数量
|
|
|
|
|
reduceNum.getAndAdd(distributionParcelListService.getById(reservationPackageEntity.getParceListId()).getQuantity()); |
|
|
|
|
// reduceNum.getAndAdd(distributionParcelListService.getById(reservationPackageEntity.getParceListId()).getQuantity());
|
|
|
|
|
DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(reservationPackageEntity.getParceListId()); |
|
|
|
|
parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue()); |
|
|
|
|
distributionParcelListService.updateById(parcelListEntity); |
|
|
|
|
}); |
|
|
|
|
//对存在订单进行维护
|
|
|
|
|
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle.get(k).get(0); |
|
|
|
|
Integer reservationNum = reservationStockarticleEntity.getReservationNum(); |
|
|
|
|
reservationStockarticleEntity.setReservationNum(reservationNum + packageNum.get() - reduceNum.get()); |
|
|
|
|
reservationStockarticleEntity.setReservationNum(packageNum.get()); |
|
|
|
|
distributionReservationStockarticleService.updateById(reservationStockarticleEntity); |
|
|
|
|
packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); |
|
|
|
|
oldStockArticle.remove(k); |
|
|
|
|
distributionAsyncService.changeOrderReservationStatus(distributionStockArticleDTO); |
|
|
|
|
}else { |
|
|
|
|
oldStockArticle.remove(k); |
|
|
|
|
} else { |
|
|
|
|
//没有包件 保持原装
|
|
|
|
|
packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); |
|
|
|
|
oldStockArticle.remove(k); |
|
|
|
|
} |
|
|
|
|
//对存在订单进行维护
|
|
|
|
|
// Integer reservationNum = reservationStockarticleEntity.getReservationNum();
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//零担订单出现编辑操作,这里对于零担订单发生编辑操作一定会存在有录入数量的操作
|
|
|
|
|
List<DistributionParcelNumberVO> parcelNumberVOS = distributionStockArticleDTO.getParcelNumberVOS(); |
|
|
|
@ -1456,7 +1459,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
if (Func.isNotEmpty(oldStockArticle)){ |
|
|
|
|
if (Func.isNotEmpty(oldStockArticle)) { |
|
|
|
|
oldStockArticle.forEach((i, j) -> { |
|
|
|
|
//这里就是需要进行取消的订单信息
|
|
|
|
|
DistributionReservationStockarticleEntity reservationStockarticleEntity = j.get(0); |
|
|
|
@ -1827,7 +1830,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
AtomicInteger reservationOrderNum = new AtomicInteger(); |
|
|
|
|
if (s.getIsZero().equals(IsOrNoConstant.no.getValue())) { |
|
|
|
|
//存在勾选包件的操作
|
|
|
|
|
if (Func.isNotEmpty(s.getPackageListInfo())){ |
|
|
|
|
if (Func.isNotEmpty(s.getPackageListInfo())) { |
|
|
|
|
List<DistributionParcelListDTO> packageListInfo = s.getPackageListInfo(); |
|
|
|
|
packageListInfo.forEach(p -> { |
|
|
|
|
reservationOrderNum.getAndAdd(p.getQuantity()); |
|
|
|
@ -1843,7 +1846,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
//这里根据包件进行订单状态的改变
|
|
|
|
|
distributionAsyncService.checkStockArticleReservationStatus(p); |
|
|
|
|
}); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
//没有进行包件选择 默认添加可配送的所有包件
|
|
|
|
|
//添加订单下的所有在库订单的包件
|
|
|
|
|
List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda() |
|
|
|
@ -1851,9 +1854,9 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
.ne(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.yizhuangche.getValue()) |
|
|
|
|
.ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue()) |
|
|
|
|
.notIn(DistributionParcelListEntity::getOrderPackageStatus, new String[]{OrderPackageStatusConstant.yichuku.getValue(), OrderPackageStatusConstant.yiqianshou.getValue()})); |
|
|
|
|
if (Func.isEmpty(distributionParcelListEntities)){ |
|
|
|
|
log.error("#########################此订单下包件列表查询为空:{}",s.getOrderCode()); |
|
|
|
|
throw new RuntimeException(s.getOrderCode()+"无可用包件信息..."); |
|
|
|
|
if (Func.isEmpty(distributionParcelListEntities)) { |
|
|
|
|
log.error("#########################此订单下包件列表查询为空:{}", s.getOrderCode()); |
|
|
|
|
throw new RuntimeException(s.getOrderCode() + "无可用包件信息..."); |
|
|
|
|
} |
|
|
|
|
distributionParcelListEntities.forEach(dp -> { |
|
|
|
|
if (!dp.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { |
|
|
|
@ -1888,7 +1891,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
if (Func.isNotEmpty(parcelNumberVOS)) { |
|
|
|
|
//进行了零担订单
|
|
|
|
|
parcelNumberVOS.forEach(p -> { |
|
|
|
|
if (Func.isNotEmpty(p.getReservationNum()) && p.getReservationNum() > 0){ |
|
|
|
|
if (Func.isNotEmpty(p.getReservationNum()) && p.getReservationNum() > 0) { |
|
|
|
|
DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = new DistributionReservationZeroPackageEntity(); |
|
|
|
|
distributionReservationZeroPackageEntity.setZeroPackageStatus(ReservationOrderStatusConstant.zhengchang.getValue()); |
|
|
|
|
distributionReservationZeroPackageEntity.setQuantity(p.getReservationNum()); |
|
|
|
@ -1904,17 +1907,17 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
p.setDeliveryQuantity(deliveryQuantity.add(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberService.updateById(p); |
|
|
|
|
reservationOrderNum.getAndAdd(distributionReservationZeroPackageEntity.getQuantity()); |
|
|
|
|
distributionAsyncService.checkZeroStockArticleReservationStatus(Func.copy(p,DistributionParcelNumberEntity.class)); |
|
|
|
|
distributionAsyncService.checkZeroStockArticleReservationStatus(Func.copy(p, DistributionParcelNumberEntity.class)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
List<DistributionParcelNumberVO> list = distributionStockArticleService.getZeroOrderDetail(s.getId()); |
|
|
|
|
int zeroPackageNum = list.stream().mapToInt(DistributionParcelNumberVO::getHandQuantity).sum(); |
|
|
|
|
|
|
|
|
|
//判断是否存在可用零担数量
|
|
|
|
|
if (Func.isNotEmpty(list)) { |
|
|
|
|
if (zeroPackageNum > 0){ |
|
|
|
|
if (zeroPackageNum > 0) { |
|
|
|
|
list.forEach(l -> { |
|
|
|
|
if (l.getHandQuantity() > 0){ |
|
|
|
|
if (l.getHandQuantity() > 0) { |
|
|
|
|
DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = new DistributionReservationZeroPackageEntity(); |
|
|
|
|
distributionReservationZeroPackageEntity.setZeroPackageStatus(ReservationOrderStatusConstant.zhengchang.getValue()); |
|
|
|
|
distributionReservationZeroPackageEntity.setQuantity(l.getHandQuantity() - l.getDeliveryQuantity() - l.getOutboundQuantity()); |
|
|
|
@ -1930,12 +1933,12 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
l.setDeliveryQuantity(deliveryQuantity.add(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberService.updateById(l); |
|
|
|
|
reservationOrderNum.getAndAdd(distributionReservationZeroPackageEntity.getQuantity()); |
|
|
|
|
distributionAsyncService.checkZeroStockArticleReservationStatus(Func.copy(l,DistributionParcelNumberEntity.class)); |
|
|
|
|
distributionAsyncService.checkZeroStockArticleReservationStatus(Func.copy(l, DistributionParcelNumberEntity.class)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}else { |
|
|
|
|
log.error("########################此零担订单无可用数量:{}",s.getOrderCode()); |
|
|
|
|
throw new RuntimeException(s.getOrderCode()+"无可用包件数量"); |
|
|
|
|
} else { |
|
|
|
|
log.error("########################此零担订单无可用数量:{}", s.getOrderCode()); |
|
|
|
|
throw new RuntimeException(s.getOrderCode() + "无可用包件数量"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.error("###########################零担订单查询品类错误,订单ID:{}", s.getId()); |
|
|
|
@ -2047,10 +2050,10 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
}); |
|
|
|
|
distributionDeliveryListEntity.setDistributionCompany("汇通"); |
|
|
|
|
distributionDeliveryListEntity.setKind(ServiceConstant.DELIVERLIST_KIND_SELF); |
|
|
|
|
if (Func.isEmpty(driverNames)){ |
|
|
|
|
if (Func.isEmpty(driverNames)) { |
|
|
|
|
throw new RuntimeException("请选择配送人员信息!!!"); |
|
|
|
|
} |
|
|
|
|
if (Func.isEmpty(vehicleNubs)){ |
|
|
|
|
if (Func.isEmpty(vehicleNubs)) { |
|
|
|
|
throw new RuntimeException("请选择配送人员信息!!!"); |
|
|
|
|
} |
|
|
|
|
distributionDeliveryListEntity.setDriverName(driverNames.deleteCharAt(driverNames.length() - 1).toString()); |
|
|
|
@ -2754,9 +2757,9 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
.ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue()) |
|
|
|
|
.eq(DistributionParcelListEntity::getConditions, 1) |
|
|
|
|
.notIn(DistributionParcelListEntity::getOrderPackageStatus, new String[]{OrderPackageStatusConstant.yichuku.getValue(), OrderPackageStatusConstant.yiqianshou.getValue()})); |
|
|
|
|
if (Func.isEmpty(distributionParcelListEntities)){ |
|
|
|
|
log.error("#########################无可用包件,订单ID为‘;:{}",s.getId()); |
|
|
|
|
throw new RuntimeException(s.getOrderCode()+"无可用包件!!!"); |
|
|
|
|
if (Func.isEmpty(distributionParcelListEntities)) { |
|
|
|
|
log.error("#########################无可用包件,订单ID为‘;:{}", s.getId()); |
|
|
|
|
throw new RuntimeException(s.getOrderCode() + "无可用包件!!!"); |
|
|
|
|
} |
|
|
|
|
distributionParcelListEntities.forEach(dp -> { |
|
|
|
|
if (!dp.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { |
|
|
|
@ -3064,7 +3067,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
.eq(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.daiyuyue.getValue()) |
|
|
|
|
.notIn(DistributionParcelListEntity::getOrderPackageStatus, OrderPackageStatusConstant.yiqianshou.getValue(), OrderPackageStatusConstant.yichuku.getValue())); |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(reservationPackageEntityList)){ |
|
|
|
|
if (Func.isNotEmpty(reservationPackageEntityList)) { |
|
|
|
|
List<Long> packageIds = reservationPackageEntityList.stream().map(DistributionReservationPackageEntity::getParceListId).collect(Collectors.toList()); |
|
|
|
|
List<DistributionParcelListEntity> reservationPackageList = distributionParcelListService.listByIds(packageIds); |
|
|
|
|
String packageListIds = reservationPackageEntityList.stream().map(DistributionReservationPackageEntity::getParceListId).map(String::valueOf).collect(Collectors.joining(",")); |
|
|
|
@ -3073,7 +3076,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
|
|
|
|
|
reservationOrderPackageVO.setReservationPackageList(parcelListVOS); |
|
|
|
|
reservationOrderPackageVO.setPackageListIds(packageListIds); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(parcelListEntities)){ |
|
|
|
|
if (Func.isNotEmpty(parcelListEntities)) { |
|
|
|
|
allPackageList.addAll(DistributionParcelListWrapper.build().listVO(parcelListEntities)); |
|
|
|
|
} |
|
|
|
|
if (Func.isEmpty(allPackageList)) { |
|
|
|
|