feat(wms): 新增根据计划ID获取可选钢卷列表接口
- 在IWmsDeliveryPlanService中新增getSelectableCoilsByPlanId方法 - 在WmsDeliveryPlanController中新增/selectableCoils GET接口 - 实现获取计划绑定钢卷但未被使用的钢卷列表逻辑 - 通过关联查询排除已被运单明细占用的钢卷 - 支持按钢卷ID集合查询完整钢卷信息 - 添加必要的空值检查和参数校验
This commit is contained in:
@@ -128,4 +128,15 @@ public class WmsDeliveryPlanController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据计划ID获取可选钢卷列表:计划绑定钢卷 - 明细已绑定钢卷
|
||||
* @param planId 计划ID
|
||||
*/
|
||||
@GetMapping("/selectableCoils")
|
||||
public R<List<WmsMaterialCoilVo>> getSelectableCoils(@RequestParam @NotNull(message = "planId不能为空") Long planId) {
|
||||
List<WmsMaterialCoilVo> list = iWmsDeliveryPlanService.getSelectableCoilsByPlanId(planId);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -60,4 +60,7 @@ public interface IWmsDeliveryPlanService {
|
||||
* 获取发货报表统计信息(包含汇总和按类型统计)
|
||||
*/
|
||||
WmsDeliveryReportResultVo getDeliveryReport(Date startTime, Date endTime);
|
||||
|
||||
List<WmsMaterialCoilVo> getSelectableCoilsByPlanId(Long planId);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<WmsMaterialCoilVo> 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<Long> 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<WmsDeliveryWaybill> waybills = waybillMapper.selectList(
|
||||
Wrappers.<WmsDeliveryWaybill>lambdaQuery().eq(WmsDeliveryWaybill::getPlanId, planId)
|
||||
);
|
||||
if (waybills == null || waybills.isEmpty()) {
|
||||
return queryCoilsByIds(planCoilIds);
|
||||
}
|
||||
Set<Long> waybillIds = waybills.stream().map(WmsDeliveryWaybill::getWaybillId).collect(Collectors.toSet());
|
||||
if (waybillIds.isEmpty()) {
|
||||
return queryCoilsByIds(planCoilIds);
|
||||
}
|
||||
List<WmsDeliveryWaybillDetail> details = waybillDetailMapper.selectList(
|
||||
Wrappers.<WmsDeliveryWaybillDetail>lambdaQuery().in(WmsDeliveryWaybillDetail::getWaybillId, waybillIds)
|
||||
);
|
||||
Set<Long> 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<WmsMaterialCoilVo> queryCoilsByIds(Set<Long> coilIds) {
|
||||
if (coilIds == null || coilIds.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
QueryWrapper<WmsMaterialCoil> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(WmsMaterialCoil::getCoilId, coilIds);
|
||||
// 使用动态联查以返回更完整的钢卷信息
|
||||
return coilMapper.selectVoListWithDynamicJoin(qw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user