From 8f29c7189fbcba1408090d2951d0de82230e5b85 Mon Sep 17 00:00:00 2001 From: PigBaoBei <2739175034@qq.com> Date: Fri, 19 Jul 2024 13:48:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=8F=90=E8=AE=A2=E5=8D=95=E5=B7=B2?= =?UTF-8?q?=E7=AD=BE=E8=AE=A2=E5=8D=95=E7=A7=BB=E9=99=A4BUG=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DistrilbutionBillLadingServiceImpl.java | 50 +++++++++++-- .../DistrilbutionBillStockServiceImpl.java | 72 ++++++++++++++++--- 2 files changed, 107 insertions(+), 15 deletions(-) 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 5807c3e76..4cb6b21ae 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 @@ -1109,6 +1109,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl list = Func.toLongList(distrilbutionBillLading.getPackageIds()); List distributionParcelListEntities = distributionParcelListService.listByIds(list); @@ -1354,7 +1355,12 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl handleSignPackage(Map> packageMap, Long id, BasicdataWarehouseEntity myCurrentWarehouse) { String method = "###################DistributionBillLadingServiceImpl.handleSignPackage"; List ladingScanEntities = new ArrayList<>(); + //查询自提信息 + DistrilbutionBillLadingEntity billLadingEntity = this.getById(id); + List orderCodes = new ArrayList<>(); + List packageLockIds = new ArrayList<>(); + packageMap.forEach((k, v) -> { switch (k) { case 1: @@ -1390,6 +1396,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl a = redis.get("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:"); + if (Func.isNotEmpty(a)) { + boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any)); + if (flag) { + //正在操作,请稍后重试 + throw new RuntimeException("该包件正在被操作,请稍后再试!!!"); + } else { + packageLockIds.addAll(a); + redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L); + } + } else { + redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L); + } + } if (!orderCodes.isEmpty()) { String collect = orderCodes.stream().distinct().collect(Collectors.joining(",")); log.info(method + "维护订单,orderCodes:{}", collect); @@ -3130,6 +3153,10 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl list4 = distributionParcelListService.list(Wrappers.query() .lambda() @@ -3172,7 +3199,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl packageLockIds = new ArrayList<>(); AtomicBoolean n = new AtomicBoolean(false); // 获取订单的ID List ls = list.stream() // 转换为Stream @@ -3266,7 +3293,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl a = redis.get("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:"); + if (Func.isNotEmpty(a)) { + boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any)); + if (flag) { + //正在操作,请稍后重试 + throw new RuntimeException("该包件正在被操作,请稍后再试!!!"); + } else { + packageLockIds.addAll(a); + redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L); + } + } else { + redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L); + } + } return Resp.scanSuccess("签收成功", "签收成功"); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillStockServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillStockServiceImpl.java index c69291758..8060e7de2 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillStockServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillStockServiceImpl.java @@ -27,26 +27,26 @@ import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.distribution.dto.DistrilbutionBillStockDTO; import com.logpm.distribution.dto.app.StockupDTO; -import com.logpm.distribution.entity.DistributionBillLadingScanEntity; -import com.logpm.distribution.entity.DistrilbutionBillPackageEntity; -import com.logpm.distribution.entity.DistrilbutionBillStockEntity; +import com.logpm.distribution.entity.*; import com.logpm.distribution.excel.DistributionBillOrderExcel; import com.logpm.distribution.excel.DistributionBillOrderPackExcel; import com.logpm.distribution.excel.DistrilbutionBillStockExcel; import com.logpm.distribution.mapper.DistrilbutionBillStockMapper; -import com.logpm.distribution.service.IDistributionBillLadingScanService; -import com.logpm.distribution.service.IDistrilbutionBillPackageService; -import com.logpm.distribution.service.IDistrilbutionBillStockService; +import com.logpm.distribution.service.*; import com.logpm.distribution.vo.*; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.DictBizConstant; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.system.cache.DictBizCache; import org.springblade.system.entity.User; import org.springblade.system.feign.IUserClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,14 +62,30 @@ import java.util.stream.Collectors; * @since 2023-07-25 */ @Service -@AllArgsConstructor +@Slf4j public class DistrilbutionBillStockServiceImpl extends BaseServiceImpl implements IDistrilbutionBillStockService { - private final IUserClient userClient; + @Autowired + private IUserClient userClient; - private final IDistrilbutionBillPackageService distrilbutionBillPackageService; + @Autowired + private BladeRedis redis; - private final IDistributionBillLadingScanService distributionBillLadingScanService; + @Autowired + private IBasicdataWarehouseClient warehouseClient; + @Autowired + private IDistrilbutionBillPackageService distrilbutionBillPackageService; + @Autowired + @Lazy + private IDistributionBillLadingScanService distributionBillLadingScanService; + + @Autowired + @Lazy + private IDistrilbutionBillLadingService distrilbutionBillLadingService; + + @Autowired + @Lazy + private IDistributionStockArticleService distributionStockArticleService; @@ -266,11 +282,47 @@ public class DistrilbutionBillStockServiceImpl extends BaseServiceImpl ladingScanEntities = distributionBillLadingScanService.list(Wrappers.query().lambda() .eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId) .eq(DistributionBillLadingScanEntity::getStockArticleId, orderId) ); + if (!ladingScanEntities.isEmpty()) { + //判断是否存在别人在进行签收操作 + List a = redis.get("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:"); + List packageIds = ladingScanEntities.stream().map(DistributionBillLadingScanEntity::getParcelListId).collect(Collectors.toList()); + if (!packageIds.isEmpty() && !a.isEmpty()) { + boolean flag = a.stream().anyMatch(any -> packageIds.contains(any)); + if (flag){ + List ids = a.stream().filter(f -> packageIds.contains(f)).collect(Collectors.toList()); + List orderIds = ladingScanEntities.stream().filter(f -> ids.contains(f.getParcelListId())).map(DistributionBillLadingScanEntity::getStockArticleId).distinct().collect(Collectors.toList()); + List distributionStockArticleEntities = distributionStockArticleService.listByIds(orderIds); + if (!distributionStockArticleEntities.isEmpty()) { + String orderCodes = distributionStockArticleEntities.stream().map(DistributionStockArticleEntity::getOrderCode).collect(Collectors.joining(",")); + log.error("these orderCodes is operated on by now:{}",orderCodes); + throw new RuntimeException(orderCodes+"订单正在进行操作,请稍后再试!!!"); + } + + } + } + } + return ladingScanEntities.isEmpty(); }