From a037c5612246d8a7bac01a6482f3e7e620f78e4c Mon Sep 17 00:00:00 2001 From: Joshi <3040996759@qq.com> Date: Sun, 14 Jun 2026 12:19:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(wms):=20=E5=AE=8C=E5=96=84=E9=80=80?= =?UTF-8?q?=E7=81=AB=E8=AE=A1=E5=88=92=E9=92=A2=E5=8D=B7=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=92=8C=E8=A7=A3=E7=BB=91=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加钢卷映射缓存以提高查询效率 - 增加钢卷排他状态检查防止并发操作冲突 - 实现绑定计划时自动释放实际库区锁定功能 - 优化解绑操作增加数据验证和异常处理 - 修复解绑后钢卷状态更新确保一致性 - 移除冗余的批量释放库区操作提升性能 --- .../impl/WmsFurnacePlanServiceImpl.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsFurnacePlanServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsFurnacePlanServiceImpl.java index 2d73acc4..99fab0d6 100644 --- a/klp-wms/src/main/java/com/klp/service/impl/WmsFurnacePlanServiceImpl.java +++ b/klp-wms/src/main/java/com/klp/service/impl/WmsFurnacePlanServiceImpl.java @@ -267,6 +267,8 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService { // 校验钢卷必须为现存钢卷(dataType=1),历史钢卷不能被加工 List coils = materialCoilMapper.selectBatchIds(coilIds); Set existingIds = coils.stream().map(WmsMaterialCoil::getCoilId).collect(Collectors.toSet()); + java.util.Map coilMap = coils.stream() + .collect(Collectors.toMap(WmsMaterialCoil::getCoilId, c -> c, (a, b) -> a)); for (Long coilId : coilIds) { if (!existingIds.contains(coilId)) { throw new ServiceException("钢卷被删除无法执行退火"); @@ -284,12 +286,20 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService { .eq(WmsFurnacePlanCoil::getCoilId, coilId)) > 0) { continue; } + // 检查钢卷是否已被其他操作锁定(exclusiveStatus != 0) + // exclusiveStatus=1: 分卷中, exclusiveStatus=2: 已在其他计划中 + WmsMaterialCoil coil = coilMap.get(coilId); + if (coil != null && coil.getExclusiveStatus() != null && coil.getExclusiveStatus() != 0) { + throw new ServiceException("钢卷" + coil.getEnterCoilNo() + "正在进行其他操作,无法绑定"); + } WmsFurnacePlanCoil entity = new WmsFurnacePlanCoil(); entity.setPlanId(bo.getPlanId()); entity.setCoilId(coilId); entity.setLogicWarehouseId(bo.getLogicWarehouseId()); entity.setFurnaceLevel(bo.getFurnaceLevel()); planCoilMapper.insert(entity); + // 绑定计划时立即释放实际库区(锁卷) + releaseActualWarehouse(coilId); } return true; } @@ -300,9 +310,17 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService { if (bo.getPlanId() == null || bo.getCoilId() == null) { throw new ServiceException("计划ID和钢卷ID不能为空"); } - return planCoilMapper.delete(Wrappers.lambdaQuery() + int deleted = planCoilMapper.delete(Wrappers.lambdaQuery() .eq(WmsFurnacePlanCoil::getPlanId, bo.getPlanId()) - .eq(WmsFurnacePlanCoil::getCoilId, bo.getCoilId())) > 0; + .eq(WmsFurnacePlanCoil::getCoilId, bo.getCoilId())); + if (deleted <= 0) { + throw new ServiceException("该钢卷未绑定到此计划,无需解绑"); + } + // 解绑后解锁钢卷 + materialCoilMapper.update(null, Wrappers.lambdaUpdate() + .eq(WmsMaterialCoil::getCoilId, bo.getCoilId()) + .set(WmsMaterialCoil::getExclusiveStatus, 0)); + return true; } @Override @@ -330,10 +348,6 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService { updateFurnaceBusy(plan.getTargetFurnaceId(), 1); - List coils = queryPlanCoils(planId); - for (WmsFurnacePlanCoilVo coil : coils) { - releaseActualWarehouse(coil.getCoilId()); - } return true; }