From f86c339a21e36802b2886fb54db644adf3f51d23 Mon Sep 17 00:00:00 2001 From: Joshi <3040996759@qq.com> Date: Tue, 9 Dec 2025 14:15:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(wms):=20=E6=96=B0=E5=A2=9E=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=AE=A1=E5=88=92ID=E8=8E=B7=E5=8F=96=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E9=92=A2=E5=8D=B7=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在IWmsDeliveryPlanService中新增getSelectableCoilsByPlanId方法 - 在WmsDeliveryPlanController中新增/selectableCoils GET接口 - 实现获取计划绑定钢卷但未被使用的钢卷列表逻辑 - 通过关联查询排除已被运单明细占用的钢卷 - 支持按钢卷ID集合查询完整钢卷信息 - 添加必要的空值检查和参数校验 --- .../controller/WmsDeliveryPlanController.java | 11 ++++ .../klp/service/IWmsDeliveryPlanService.java | 3 + .../impl/WmsDeliveryPlanServiceImpl.java | 63 +++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/klp-wms/src/main/java/com/klp/controller/WmsDeliveryPlanController.java b/klp-wms/src/main/java/com/klp/controller/WmsDeliveryPlanController.java index 04d71303..8196f9e1 100644 --- a/klp-wms/src/main/java/com/klp/controller/WmsDeliveryPlanController.java +++ b/klp-wms/src/main/java/com/klp/controller/WmsDeliveryPlanController.java @@ -128,4 +128,15 @@ public class WmsDeliveryPlanController extends BaseController { } + /** + * 根据计划ID获取可选钢卷列表:计划绑定钢卷 - 明细已绑定钢卷 + * @param planId 计划ID + */ + @GetMapping("/selectableCoils") + public R> getSelectableCoils(@RequestParam @NotNull(message = "planId不能为空") Long planId) { + List list = iWmsDeliveryPlanService.getSelectableCoilsByPlanId(planId); + return R.ok(list); + } + + } diff --git a/klp-wms/src/main/java/com/klp/service/IWmsDeliveryPlanService.java b/klp-wms/src/main/java/com/klp/service/IWmsDeliveryPlanService.java index 8fe1752b..362c7125 100644 --- a/klp-wms/src/main/java/com/klp/service/IWmsDeliveryPlanService.java +++ b/klp-wms/src/main/java/com/klp/service/IWmsDeliveryPlanService.java @@ -60,4 +60,7 @@ public interface IWmsDeliveryPlanService { * 获取发货报表统计信息(包含汇总和按类型统计) */ WmsDeliveryReportResultVo getDeliveryReport(Date startTime, Date endTime); + + List getSelectableCoilsByPlanId(Long planId); + } diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsDeliveryPlanServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsDeliveryPlanServiceImpl.java index 1680e119..4ec47e0b 100644 --- a/klp-wms/src/main/java/com/klp/service/impl/WmsDeliveryPlanServiceImpl.java +++ b/klp-wms/src/main/java/com/klp/service/impl/WmsDeliveryPlanServiceImpl.java @@ -5,12 +5,17 @@ import com.klp.common.core.domain.entity.SysUser; import com.klp.common.core.page.TableDataInfo; import com.klp.common.core.domain.PageQuery; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.klp.common.utils.StringUtils; import com.klp.domain.WmsMaterialCoil; +import com.klp.domain.WmsDeliveryWaybill; +import com.klp.domain.WmsDeliveryWaybillDetail; import com.klp.domain.vo.*; import com.klp.mapper.WmsMaterialCoilMapper; +import com.klp.mapper.WmsDeliveryWaybillMapper; +import com.klp.mapper.WmsDeliveryWaybillDetailMapper; import com.klp.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -38,6 +43,10 @@ public class WmsDeliveryPlanServiceImpl implements IWmsDeliveryPlanService { private final WmsMaterialCoilMapper coilMapper; + private final WmsDeliveryWaybillMapper waybillMapper; + + private final WmsDeliveryWaybillDetailMapper waybillDetailMapper; + /** * 查询发货计划 */ @@ -169,4 +178,58 @@ public class WmsDeliveryPlanServiceImpl implements IWmsDeliveryPlanService { return result; } + @Override + public List getSelectableCoilsByPlanId(Long planId) { + if (planId == null) { + return Collections.emptyList(); + } + WmsDeliveryPlanVo planVo = baseMapper.selectVoById(planId); + if (planVo == null || StringUtils.isBlank(planVo.getCoil())) { + return Collections.emptyList(); + } + Set planCoilIds = Arrays.stream(planVo.getCoil().split(",")) + .map(String::trim) + .filter(StringUtils::isNotBlank) + .map(Long::valueOf) + .collect(Collectors.toSet()); + + if (planCoilIds.isEmpty()) { + return Collections.emptyList(); + } + + List waybills = waybillMapper.selectList( + Wrappers.lambdaQuery().eq(WmsDeliveryWaybill::getPlanId, planId) + ); + if (waybills == null || waybills.isEmpty()) { + return queryCoilsByIds(planCoilIds); + } + Set waybillIds = waybills.stream().map(WmsDeliveryWaybill::getWaybillId).collect(Collectors.toSet()); + if (waybillIds.isEmpty()) { + return queryCoilsByIds(planCoilIds); + } + List details = waybillDetailMapper.selectList( + Wrappers.lambdaQuery().in(WmsDeliveryWaybillDetail::getWaybillId, waybillIds) + ); + Set usedCoilIds = details == null ? Collections.emptySet() : details.stream() + .map(WmsDeliveryWaybillDetail::getCoilId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + planCoilIds.removeAll(usedCoilIds); + if (planCoilIds.isEmpty()) { + return Collections.emptyList(); + } + return queryCoilsByIds(planCoilIds); + } + + private List queryCoilsByIds(Set coilIds) { + if (coilIds == null || coilIds.isEmpty()) { + return Collections.emptyList(); + } + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().in(WmsMaterialCoil::getCoilId, coilIds); + // 使用动态联查以返回更完整的钢卷信息 + return coilMapper.selectVoListWithDynamicJoin(qw); + } + }