From ee83b5e16fe2eeb29bc3384b3026d12d552c397d Mon Sep 17 00:00:00 2001 From: kilo Date: Mon, 30 Oct 2023 18:12:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=82=E9=85=8D=E7=BC=96=E8=BE=91=E3=80=81?= =?UTF-8?q?=E5=A2=9E=E5=80=BC=E6=9C=8D=E5=8A=A1=E7=BC=96=E8=BE=91=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/DistributionSignforMapper.xml | 8 +- .../impl/DistributionAddvalueServiceImpl.java | 48 ++- .../DistributionDeliveryListServiceImpl.java | 51 +++- .../DistributionReservationServiceImpl.java | 289 +++++++++--------- .../impl/DistributionSignforServiceImpl.java | 59 ++-- .../impl/WarehouseUpdownTypeServiceImpl.java | 2 + 6 files changed, 284 insertions(+), 173 deletions(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml index cdb4c0e6e..426c06a1c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.xml @@ -543,7 +543,8 @@ SELECT ldr.id id, ldr.consignee consignee, - ldr.reservation_num reservationNum, + ldr.reservation_num, + ldr.reservation_stock_list_num, lds.driver_signing driverSigning, lds.Signing_status SigningStatus, lds.loaded_number loadingNub, @@ -552,8 +553,9 @@ ldr.is_urgent isUrgent, ldr.remarks, CASE WHEN lds.positioning IS NOT NULL THEN true ELSE false END AS positioning, - (SELECT COALESCE(COUNT(*), 0) from logpm_distribution_reservation_stockarticle ldrs WHERE ldrs.reservation_id =ldr.id ) ordNub, - COALESCE(lds.received_quantity + lds.receivedin_quantity, 0) signNub + (SELECT COALESCE(COUNT(*), 0) from logpm_distribution_reservation_stockarticle ldrs WHERE ldrs.reservation_id =ldr.id ) ordNub, + COALESCE(lds.received_quantity + lds.receivedin_quantity, 0) signNub, + COALESCE(ldr.reservation_num + ldr.reservation_stock_list_num, 0) reservationNum FROM logpm_distribution_signfor lds JOIN logpm_distribution_reservation ldr ON ldr.id = lds.reservation_id diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAddvalueServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAddvalueServiceImpl.java index 3805dce5b..716cc075b 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAddvalueServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAddvalueServiceImpl.java @@ -389,7 +389,7 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl> oldPackageList = distributionAddvaluePackageEntities.stream().collect(Collectors.groupingBy(DistributionAddvaluePackageEntity::getPackageId)); - Map> newPackageList = packageEntityList.stream().collect(Collectors.groupingBy(DistributionAddvaluePackageEntity::getPackageId)); + Map> newPackageList = packageEntityList.stream().collect(Collectors.groupingBy(DistributionAddvaluePackageEntity::getPackageId)); newPackageList.forEach((k, v) -> { + DistributionAddvaluePackageDTO distributionAddvaluePackageEntity = v.get(0); if (Func.isEmpty(oldPackageList.get(k))) { //从老的包件中无法进行获取,这里进行包件的新增 - DistributionAddvaluePackageEntity distributionAddvaluePackageEntity = v.get(0); - distributionAddvaluePackageEntity.setAddvalueDetailId(distributionAddvaluePackageEntities.get(0).getAddvalueDetailId()); - distributionAddvaluePackageService.save(distributionAddvaluePackageEntity); + DistributionAddvaluePackageEntity addvaluePackageEntity = new DistributionAddvaluePackageEntity(); + addvaluePackageEntity.setQuantity(distributionAddvaluePackageEntity.getZeroQuantity()); + addvaluePackageEntity.setAddvalueDetailId(distributionAddvaluePackageEntity.getAddvalueDetailId()); + addvaluePackageEntity.setStockArticleId(distributionAddvaluePackageEntity.getStockArticleId()); + addvaluePackageEntity.setMaterialName(distributionAddvaluePackageEntity.getMaterialName()); + addvaluePackageEntity.setPackageId(distributionAddvaluePackageEntity.getPackageId()); + addvaluePackageEntity.setReservationId(distributionAddvaluePackageEntity.getReservationId()); + if (distributionAddvaluePackageEntity.getConditions() == 3){ + addvaluePackageEntity.setConditions(3); + addvaluePackageEntity.setRecordType("3"); + distributionAddvaluePackageService.save(addvaluePackageEntity); + }else if (distributionAddvaluePackageEntity.getConditions() == 1){ + //新增订制品 + addvaluePackageEntity.setOrderPackageCode(distributionAddvaluePackageEntity.getOrderPackageCode()); + addvaluePackageEntity.setRecordType("1"); + addvaluePackageEntity.setConditions(1); + }else { + //新增库存品 + addvaluePackageEntity.setOrderPackageCode(distributionAddvaluePackageEntity.getOrderPackageCode()); + addvaluePackageEntity.setRecordType("2"); + addvaluePackageEntity.setConditions(2); + } +// distributionAddvaluePackageEntity.setAddvalueDetailId(distributionAddvaluePackageEntities.get(0).getAddvalueDetailId()); + distributionAddvaluePackageService.save(addvaluePackageEntity); } else { + if (distributionAddvaluePackageEntity.getConditions() == 3){ + if (distributionAddvaluePackageEntity.getZeroQuantity() != 0){ + if (distributionAddvaluePackageEntity.getZeroQuantity() > 0){ + distributionAddvaluePackageEntity.setQuantity(distributionAddvaluePackageEntity.getZeroQuantity()); + distributionAddvaluePackageService.updateById(distributionAddvaluePackageEntity); + }else { + log.error("###############零担品类录入数量有误:{}",distributionAddvaluePackageEntity.getZeroQuantity()); + } + }else { + //删除对应的包件信息 + distributionAddvaluePackageMapper.deleteAddvaluePackage(distributionAddvaluePackageEntity.getReservationId(),distributionAddvaluePackageEntity.getPackageId()); + } + } + //存在零担需要进行比对是否发生变化 //存在不进行维护 oldPackageList.remove(k); } @@ -415,7 +451,6 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl r.getDeliveryType().equals(DistributionTypeConstant.shangpei.getValue())); if (shangpeiFlag) { - List reservationEntities = reservationEntityList.stream().filter(r -> Func.isNotEmpty(r) && r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); + List reservationEntities = reservationEntityList.stream().filter(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); + //查询是否满足商配异常装车 + boolean flag = reservationEntityList.stream().anyMatch(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())); if (reservationEntities.size() == 1) { return R.fail(5000, "异常装车"); } else { @@ -3861,6 +3864,23 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl collect = list.stream().filter(l -> !l.getScanStatus().equals(LoadingStatusConstant.quxiao.getValue())).map(DistributionLoadscaninvnEntity::getScanUser).collect(Collectors.toList()); + rs.setLoadedinNumber(list.stream().mapToInt(DistributionLoadscaninvnEntity::getLoadedNub).sum()); HashSet strings = new HashSet<>(); strings.addAll(collect); rs.setScanUser(String.join(",", strings)); @@ -4394,7 +4433,17 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl loadscanEntities = distributionLoadscanService.list(Wrappers.query().lambda() + .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) + .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) + .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) + .eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); + if (Func.isNotEmpty(loadscanEntities)) { + //存在装车数据了 + log.error("配送计划null:{}", loadscanEntities); + return Resp.scanFail("重复扫描", "重复异常装车"); + } DistributionDeliveryListEntity deliveryListEntity = distributionDeliveryListMapper.selectById(distrilbutionloadingscanDTO.getDeliveryId()); if (Func.isEmpty(deliveryListEntity)) { log.error("配送计划null:{}", deliveryListEntity); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java index 41de3cd62..10953e25f 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java @@ -1176,7 +1176,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl distributionReservationStockarticleEntities = distributionReservationStockarticleService.getBaseMapper().selectList(Wrappers.query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, id).ne(DistributionReservationStockarticleEntity::getStockArticleStatus,ReservationOrderStatusConstant.quxiao.getValue())); + List distributionReservationStockarticleEntities = distributionReservationStockarticleService.getBaseMapper().selectList(Wrappers.query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, id).ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); Map> oldStockArticle = distributionReservationStockarticleEntities.stream().collect(Collectors.groupingBy(DistributionReservationStockarticleEntity::getStockArticleId)); List dtoStockArticleList = distributionReservationDTO.getStockArticleList(); Map> newStockArticle = dtoStockArticleList.stream().collect(Collectors.groupingBy(DistributionStockArticleDTO::getId)); @@ -1192,7 +1192,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl packageListInfo = distributionStockArticleDTO.getPackageListInfo(); packageListInfo.forEach(p -> { DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); @@ -1208,7 +1208,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl distributionParcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, distributionStockArticleDTO.getId()) @@ -1321,133 +1321,136 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl packageEntityList = distributionReservationPackageMapper.selectPackageByReservationAndStockArticleId(id, k); - Map> oldPackage = packageEntityList.stream().collect(Collectors.groupingBy(DistributionReservationPackageEntity::getParceListId)); - Map> newPackage = distributionStockArticleDTO.getPackageListInfo().stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getId)); - AtomicInteger packageNum = new AtomicInteger(); - AtomicInteger reduceNum = new AtomicInteger(); - newPackage.forEach((m, n) -> { - if (Func.isEmpty(oldPackage.get(m))) { - DistributionParcelListEntity distributionParcelListEntity = n.get(0); - //新增 - DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); - reservationPackageEntity.setStockArticleId(distributionStockArticleDTO.getId()); - reservationPackageEntity.setPacketBarStatus(ReservationPackageStatusConstant.xinzeng.getValue()); - reservationPackageEntity.setPacketBarCode(distributionParcelListEntity.getOrderPackageCode()); - reservationPackageEntity.setParceListId(distributionParcelListEntity.getId()); - reservationPackageEntity.setReservationId(id); - distributionReservationPackageService.save(reservationPackageEntity); - packageNum.getAndAdd(distributionParcelListEntity.getQuantity()); - DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(distributionParcelListEntity.getId()); - parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); - distributionParcelListService.updateById(parcelListEntity); - } else { - //数量维护 - packageNum.getAndAdd(oldStockArticle.get(k).get(0).getReservationNum()); - //移除 - oldPackage.remove(m); - } - }); - //移除包件进行取消 - oldPackage.forEach((o, p) -> { - DistributionReservationPackageEntity reservationPackageEntity = p.get(0); - reservationPackageEntity.setPacketBarStatus(ReservationPackageStatusConstant.quxiao.getValue()); - distributionReservationPackageService.updateById(reservationPackageEntity); - //统计减少包件数量 - reduceNum.getAndAdd(distributionParcelListService.getById(reservationPackageEntity.getParceListId()).getQuantity()); - DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(reservationPackageEntity.getParceListId()); - parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue()); + AtomicInteger packageNum = new AtomicInteger(); + if (distributionStockArticleDTO.getIsZero().equals(IsOrNoConstant.no.getValue())) { + DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle.get(k).get(0); + + if (Func.isNotEmpty(distributionStockArticleDTO.getPackageListInfo())) { + List packageEntityList = distributionReservationPackageMapper.selectPackageByReservationAndStockArticleId(id, k); + Map> oldPackage = packageEntityList.stream().collect(Collectors.groupingBy(DistributionReservationPackageEntity::getParceListId)); + Map> newPackage = distributionStockArticleDTO.getPackageListInfo().stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getId)); +// AtomicInteger reduceNum = new AtomicInteger(); + newPackage.forEach((m, n) -> { + DistributionParcelListEntity distributionParcelListEntity = n.get(0); + if (Func.isEmpty(oldPackage.get(m))) { + //新增 + DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity(); + reservationPackageEntity.setStockArticleId(distributionStockArticleDTO.getId()); + reservationPackageEntity.setPacketBarStatus(ReservationPackageStatusConstant.xinzeng.getValue()); + reservationPackageEntity.setPacketBarCode(distributionParcelListEntity.getOrderPackageCode()); + reservationPackageEntity.setParceListId(distributionParcelListEntity.getId()); + reservationPackageEntity.setReservationId(id); + distributionReservationPackageService.save(reservationPackageEntity); + packageNum.getAndAdd(distributionParcelListEntity.getQuantity()); + DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(distributionParcelListEntity.getId()); + parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); distributionParcelListService.updateById(parcelListEntity); - }); - //对存在订单进行维护 - DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle.get(k).get(0); - Integer reservationNum = reservationStockarticleEntity.getReservationNum(); - reservationStockarticleEntity.setReservationNum(reservationNum + packageNum.get() - reduceNum.get()); - distributionReservationStockarticleService.updateById(reservationStockarticleEntity); - packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); - oldStockArticle.remove(k); - distributionAsyncService.changeOrderReservationStatus(distributionStockArticleDTO); - }else { - //没有包件 保持原装 - oldStockArticle.remove(k); - } - } else { - //零担订单出现编辑操作,这里对于零担订单发生编辑操作一定会存在有录入数量的操作 - List parcelNumberVOS = distributionStockArticleDTO.getParcelNumberVOS(); - List reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda() - .eq(DistributionReservationZeroPackageEntity::getReservationId, id) - .eq(DistributionReservationZeroPackageEntity::getStockArticleId, distributionStockArticleDTO.getId()) - .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, "2")); - Map> oldZeroPackage = reservationZeroPackageEntityList.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getParcelListId)); - if (Func.isEmpty(reservationZeroPackageEntityList)) { - log.error("#############零担订单预约信息数据错误:{}", distributionStockArticleDTO); - } - AtomicInteger zeroPrderNum = new AtomicInteger(); - parcelNumberVOS.forEach(p -> { - List distributionReservationZeroPackageEntities = oldZeroPackage.get(p.getParcelListId()); - if (Func.isNotEmpty(distributionReservationZeroPackageEntities)) { - DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = distributionReservationZeroPackageEntities.get(0); - Integer quantity = distributionReservationZeroPackageEntity.getQuantity(); - if (p.getReservationNum() == 0) { - distributionReservationZeroPackageEntity.setQuantity(0); - distributionReservationZeroPackageEntity.setZeroPackageStatus(ReservationOrderStatusConstant.quxiao.getValue()); - distributionReservationZeroPackageService.updateById(distributionReservationZeroPackageEntity); - DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() - .eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId())); - parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - quantity); - distributionParcelNumberService.updateById(parcelNumberEntity); - } else if (p.getReservationNum() != quantity) { - distributionReservationZeroPackageEntity.setQuantity(p.getReservationNum()); - distributionReservationZeroPackageService.updateById(distributionReservationZeroPackageEntity); - //进行修改操作 - DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() - .eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId())); - parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - quantity + p.getReservationNum()); - distributionParcelNumberService.updateById(parcelNumberEntity); - } - zeroPrderNum.getAndAdd(distributionReservationZeroPackageEntity.getQuantity()); } else { - //这里就是新增 - DistributionReservationZeroPackageEntity zeroPackageEntity = new DistributionReservationZeroPackageEntity(); - zeroPackageEntity.setParcelListId(p.getParcelListId()); - zeroPackageEntity.setCategoryName(p.getFirsts()); - zeroPackageEntity.setQuantity(p.getReservationNum()); - zeroPackageEntity.setZeroPackageStatus(ReservationOrderStatusConstant.zengjia.getValue()); - zeroPackageEntity.setType(DistributionTypeConstant.shipie.getValue()); - zeroPackageEntity.setReservationId(id); - zeroPackageEntity.setStockArticleId(distributionStockArticleDTO.getId()); - distributionReservationZeroPackageService.save(zeroPackageEntity); - DistributionReservationStockarticleEntity reservationStockarticleEntity = distributionReservationStockarticleService.getOne(Wrappers.query().lambda() - .eq(DistributionReservationStockarticleEntity::getReservationId, id) - .eq(DistributionReservationStockarticleEntity::getStockArticleId, distributionStockArticleDTO.getId()) - .ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); - reservationStockarticleEntity.setReservationNum(reservationStockarticleEntity.getReservationNum() + zeroPackageEntity.getQuantity()); - distributionReservationStockarticleService.updateById(reservationStockarticleEntity); - //维护具体的零担订单品类数量 - DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() - .eq(DistributionParcelNumberEntity::getParcelListId, p.getParcelListId())); - parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() + zeroPackageEntity.getQuantity()); - distributionParcelNumberService.updateById(parcelNumberEntity); - zeroPrderNum.getAndAdd(zeroPackageEntity.getQuantity()); - + //数量维护 + packageNum.getAndAdd(distributionParcelListEntity.getQuantity()); + //移除 + oldPackage.remove(m); } - //考虑情况:1、数量发生修改 2、数量修改为0表示取消该零担订单对应的品类 3、该零担订单新增品类 - //该零担订单原有的品类信息 }); - DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle.get(k).get(0); - reservationStockarticleEntity.setReservationNum(zeroPrderNum.get()); + //移除包件进行取消 + oldPackage.forEach((o, p) -> { + DistributionReservationPackageEntity reservationPackageEntity = p.get(0); + reservationPackageEntity.setPacketBarStatus(ReservationPackageStatusConstant.quxiao.getValue()); + distributionReservationPackageService.updateById(reservationPackageEntity); + //统计减少包件数量 +// reduceNum.getAndAdd(distributionParcelListService.getById(reservationPackageEntity.getParceListId()).getQuantity()); + DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(reservationPackageEntity.getParceListId()); + parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue()); + distributionParcelListService.updateById(parcelListEntity); + }); + reservationStockarticleEntity.setReservationNum(packageNum.get()); distributionReservationStockarticleService.updateById(reservationStockarticleEntity); packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); -// oldStockArticle.remove(k); distributionAsyncService.changeOrderReservationStatus(distributionStockArticleDTO); oldStockArticle.remove(k); + } else { + //没有包件 保持原装 + packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); + oldStockArticle.remove(k); } - warehouseNames.add(distributionStockArticleDTO.getWarehouse()); - mallName.add(distributionStockArticleDTO.getMallName()); - storeName.add(distributionStockArticleDTO.getStoreName()); - receivingUnit.add(distributionStockArticleDTO.getConsigneeUnit()); + //对存在订单进行维护 +// Integer reservationNum = reservationStockarticleEntity.getReservationNum(); + + } else { + //零担订单出现编辑操作,这里对于零担订单发生编辑操作一定会存在有录入数量的操作 + List parcelNumberVOS = distributionStockArticleDTO.getParcelNumberVOS(); + List reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda() + .eq(DistributionReservationZeroPackageEntity::getReservationId, id) + .eq(DistributionReservationZeroPackageEntity::getStockArticleId, distributionStockArticleDTO.getId()) + .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, "2")); + Map> oldZeroPackage = reservationZeroPackageEntityList.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getParcelListId)); + if (Func.isEmpty(reservationZeroPackageEntityList)) { + log.error("#############零担订单预约信息数据错误:{}", distributionStockArticleDTO); + } + AtomicInteger zeroPrderNum = new AtomicInteger(); + parcelNumberVOS.forEach(p -> { + List distributionReservationZeroPackageEntities = oldZeroPackage.get(p.getParcelListId()); + if (Func.isNotEmpty(distributionReservationZeroPackageEntities)) { + DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = distributionReservationZeroPackageEntities.get(0); + Integer quantity = distributionReservationZeroPackageEntity.getQuantity(); + if (p.getReservationNum() == 0) { + distributionReservationZeroPackageEntity.setQuantity(0); + distributionReservationZeroPackageEntity.setZeroPackageStatus(ReservationOrderStatusConstant.quxiao.getValue()); + distributionReservationZeroPackageService.updateById(distributionReservationZeroPackageEntity); + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() + .eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId())); + parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - quantity); + distributionParcelNumberService.updateById(parcelNumberEntity); + } else if (p.getReservationNum() != quantity) { + distributionReservationZeroPackageEntity.setQuantity(p.getReservationNum()); + distributionReservationZeroPackageService.updateById(distributionReservationZeroPackageEntity); + //进行修改操作 + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() + .eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId())); + parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - quantity + p.getReservationNum()); + distributionParcelNumberService.updateById(parcelNumberEntity); + } + zeroPrderNum.getAndAdd(distributionReservationZeroPackageEntity.getQuantity()); + } else { + //这里就是新增 + DistributionReservationZeroPackageEntity zeroPackageEntity = new DistributionReservationZeroPackageEntity(); + zeroPackageEntity.setParcelListId(p.getParcelListId()); + zeroPackageEntity.setCategoryName(p.getFirsts()); + zeroPackageEntity.setQuantity(p.getReservationNum()); + zeroPackageEntity.setZeroPackageStatus(ReservationOrderStatusConstant.zengjia.getValue()); + zeroPackageEntity.setType(DistributionTypeConstant.shipie.getValue()); + zeroPackageEntity.setReservationId(id); + zeroPackageEntity.setStockArticleId(distributionStockArticleDTO.getId()); + distributionReservationZeroPackageService.save(zeroPackageEntity); + DistributionReservationStockarticleEntity reservationStockarticleEntity = distributionReservationStockarticleService.getOne(Wrappers.query().lambda() + .eq(DistributionReservationStockarticleEntity::getReservationId, id) + .eq(DistributionReservationStockarticleEntity::getStockArticleId, distributionStockArticleDTO.getId()) + .ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); + reservationStockarticleEntity.setReservationNum(reservationStockarticleEntity.getReservationNum() + zeroPackageEntity.getQuantity()); + distributionReservationStockarticleService.updateById(reservationStockarticleEntity); + //维护具体的零担订单品类数量 + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() + .eq(DistributionParcelNumberEntity::getParcelListId, p.getParcelListId())); + parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() + zeroPackageEntity.getQuantity()); + distributionParcelNumberService.updateById(parcelNumberEntity); + zeroPrderNum.getAndAdd(zeroPackageEntity.getQuantity()); + + } + //考虑情况:1、数量发生修改 2、数量修改为0表示取消该零担订单对应的品类 3、该零担订单新增品类 + //该零担订单原有的品类信息 + }); + DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle.get(k).get(0); + reservationStockarticleEntity.setReservationNum(zeroPrderNum.get()); + distributionReservationStockarticleService.updateById(reservationStockarticleEntity); + packTotal.getAndAdd(reservationStockarticleEntity.getReservationNum()); +// oldStockArticle.remove(k); + distributionAsyncService.changeOrderReservationStatus(distributionStockArticleDTO); + oldStockArticle.remove(k); + } + warehouseNames.add(distributionStockArticleDTO.getWarehouse()); + mallName.add(distributionStockArticleDTO.getMallName()); + storeName.add(distributionStockArticleDTO.getStoreName()); + receivingUnit.add(distributionStockArticleDTO.getConsigneeUnit()); // DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionStockArticleDTO.getId()); // stockArticleEntity.setReservationStatus(status); @@ -1456,7 +1459,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl { //这里就是需要进行取消的订单信息 DistributionReservationStockarticleEntity reservationStockarticleEntity = j.get(0); @@ -1827,7 +1830,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl packageListInfo = s.getPackageListInfo(); packageListInfo.forEach(p -> { reservationOrderNum.getAndAdd(p.getQuantity()); @@ -1843,7 +1846,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl distributionParcelListEntities = distributionParcelListService.list(Wrappers.query().lambda() @@ -1851,9 +1854,9 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl { if (!dp.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { @@ -1888,7 +1891,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl { - 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 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 { if (!dp.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { @@ -3064,7 +3067,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl packageIds = reservationPackageEntityList.stream().map(DistributionReservationPackageEntity::getParceListId).collect(Collectors.toList()); List 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 Func.equals(f.getIsSignfor(), LoadScanSigningStatusConstant.yiqianshou.getValue())).mapToInt(DistributionLoadscanEntity::getReceivedQuantity).sum(); + int signforNub = orderMap.get(stockArticleEntity.getId()).stream().filter(f -> Func.equals(f.getSignforState(), LoadScanSigningStatusConstant.yiqianshou.getValue())).mapToInt(DistributionLoadscanEntity::getReceivedQuantity).sum(); distributionAppStockArticleVO.setLoadingNub(loadingNum); distributionAppStockArticleVO.setSignforNub(signforNub); } @@ -1075,17 +1075,39 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl().lambda() + List loadscanEntities = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() .eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) .eq(DistributionLoadscanEntity::getSignforState, 2) - ).stream().mapToInt(DistributionLoadscanEntity::getReceivedQuantity).sum(); + ); + AtomicInteger signNum = new AtomicInteger(); + AtomicInteger loadNum = new AtomicInteger(); + if (Func.isNotEmpty(loadscanEntities)){ + //统计库存品配送数和签收数 + loadNum.getAndAdd(loadscanEntities.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum()); + signNum.getAndAdd(loadscanEntities.stream().mapToInt(DistributionLoadscanEntity::getReceivedQuantity).sum()); + } +// int lad = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() +// .eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) +// .eq(DistributionLoadscanEntity::getSignforState, 2) +// ).stream().mapToInt(DistributionLoadscanEntity::getReceivedQuantity).sum(); //查询库存品签收件数 - Integer nad = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() + List distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() .eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) .eq(DistributionLoadscaninvnEntity::getSignforState, 2) - ).stream().mapToInt(DistributionLoadscaninvnEntity::getReceivedQuantity).sum(); - distributionAppDeliveryListVO.setSignNub(lad + nad); + ); + if (Func.isNotEmpty(distributionLoadscaninvnEntities)){ + //统计库存品配送数和签收数 + loadNum.getAndAdd(distributionLoadscaninvnEntities.stream().mapToInt(DistributionLoadscaninvnEntity::getLoadedNub).sum()); + signNum.getAndAdd(distributionLoadscaninvnEntities.stream().mapToInt(DistributionLoadscaninvnEntity::getReceivedQuantity).sum()); + } +// Integer nad = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() +// .eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) +// .eq(DistributionLoadscaninvnEntity::getSignforState, 2) +// ).stream().mapToInt(DistributionLoadscaninvnEntity::getReceivedQuantity).sum(); + + distributionAppDeliveryListVO.setSignNub(signNum.get()); + distributionAppDeliveryListVO.setDeliveryNumber(loadNum.get()); //查询完成客户数 Integer cusCount = distributionDeliveryListMapper.selectCompletecusInCount(distributionAppDeliveryListVO.getId()); //查询完成订单数 @@ -2279,26 +2301,25 @@ public class DistributionSignforServiceImpl extends BaseServiceImplquery().lambda().eq(DistributionSignforEntity::getDeliveryId, loadscanEntityList.getDeliveryId()).eq(DistributionSignforEntity::getReservationId, loadscanEntityList.getReservationId())); + BigDecimal loadedNumber = new BigDecimal(signforEntity.getLoadedNumber()); + BigDecimal signingNumber = new BigDecimal(signforEntity.getReceivedQuantity()); if (loadscanEntityList.getLoadedNub() < p.getSigningNum()){ //这里需要同时维护装车和签收数量 - loadscanEntityList.setLoadedNub(p.getSigningNum()); - loadscanEntityList.setPackageNub(p.getSigningNum()); - loadscanEntityList.setLoadedNub(p.getSigningNum()); - loadscanEntityList.setPackageNub(p.getSigningNum()); +// loadscanEntityList.setLoadedNub(p.getSigningNum()); +// loadscanEntityList.setPackageNub(p.getSigningNum()); +// loadscanEntityList.setLoadedNub(p.getSigningNum()); +// loadscanEntityList.setPackageNub(p.getSigningNum()); loadscanEntityList.setMsg("签收数量大于装车数"); parcelNumberEntity.setDeliveryQuantity(newDeliveryQuantity); parcelNumberEntity.setOutboundQuantity(newOunBoundQuantity); parcelNumberEntity.setHandQuantity(newHandQuantity); + signforEntity.setLoadedNumber(loadedNumber.subtract(loadedNub).add(signingNum).intValue()); } if (p.getSigningNum() == 0) { //签收状态 loadscanEntityList.setSignforState(LoadScanSigningStatusConstant.weiqianshou.getValue()); } - DistributionSignforEntity signforEntity = distributionSignforMapper.selectOne(Wrappers.query().lambda().eq(DistributionSignforEntity::getDeliveryId, loadscanEntityList.getDeliveryId()).eq(DistributionSignforEntity::getReservationId, loadscanEntityList.getReservationId())); - BigDecimal loadedNumber = new BigDecimal(signforEntity.getLoadedNumber()); - BigDecimal signingNumber = new BigDecimal(signforEntity.getReceivedQuantity()); - signforEntity.setLoadedNumber(loadedNumber.subtract(loadedNub).add(signingNum).intValue()); signforEntity.setReceivedQuantity(signingNumber.subtract(receivedQuantity).add(signingNum).intValue()); distributionSignforMapper.updateById(signforEntity); distributionLoadscanService.updateById(loadscanEntityList); diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java index 5cdb6b24d..a26a5cbb9 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java @@ -1008,6 +1008,8 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl