feat(wms): 优化钢卷重复卷号查询速率
- 在WmsMaterialCoilMapper中新增selectDuplicateEnterCoilNoList和selectDuplicateCurrentCoilNoList方法 - 在WmsMaterialCoilMapper.xml中实现两个SQL查询,分别查找重复入场卷号和当前卷号的钢卷信息 - 优化WmsMaterialCoilServiceImpl中的getDuplicateCoilGroups方法,使用新的数据库查询替代原有流式处理 - 移除不再使用的toVoBasic私有方法和相关VO转换逻辑 - 直接返回完整的WmsMaterialCoilVo对象,减少数据转换步骤
This commit is contained in:
@@ -54,6 +54,20 @@ public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMap
|
||||
*/
|
||||
List<com.klp.domain.vo.WmsMaterialCoilExportVo> selectExportList(@Param("ew")QueryWrapper<WmsMaterialCoil> lqw);
|
||||
|
||||
/**
|
||||
* 查询重复入场卷号的钢卷信息
|
||||
*
|
||||
* @return 重复入场卷号的钢卷列表
|
||||
*/
|
||||
List<WmsMaterialCoilVo> selectDuplicateEnterCoilNoList();
|
||||
|
||||
/**
|
||||
* 查询重复当前卷号的钢卷信息
|
||||
*
|
||||
* @return 重复当前卷号的钢卷列表
|
||||
*/
|
||||
List<WmsMaterialCoilVo> selectDuplicateCurrentCoilNoList();
|
||||
|
||||
/**
|
||||
* 更新钢卷发货撤回:将发货时间置空,状态改为指定值
|
||||
*
|
||||
|
||||
@@ -618,69 +618,50 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDuplicateCoilGroups() {
|
||||
LambdaQueryWrapper<WmsMaterialCoil> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(WmsMaterialCoil::getDataType, 1);
|
||||
lqw.eq(WmsMaterialCoil::getDelFlag, 0);
|
||||
List<WmsMaterialCoil> all = baseMapper.selectList(lqw);
|
||||
// 使用优化的数据库查询方法,直接获取重复入场卷号的钢卷信息
|
||||
List<WmsMaterialCoilVo> enterDuplicates = baseMapper.selectDuplicateEnterCoilNoList();
|
||||
|
||||
Map<String, List<WmsMaterialCoil>> enterGrouped = all.stream()
|
||||
// 使用优化的数据库查询方法,直接获取重复当前卷号的钢卷信息
|
||||
List<WmsMaterialCoilVo> currentDuplicates = baseMapper.selectDuplicateCurrentCoilNoList();
|
||||
|
||||
// 按入场卷号分组重复项
|
||||
Map<String, List<WmsMaterialCoilVo>> enterGrouped = enterDuplicates.stream()
|
||||
.filter(e -> StringUtils.isNotBlank(e.getEnterCoilNo()))
|
||||
.collect(Collectors.groupingBy(WmsMaterialCoil::getEnterCoilNo));
|
||||
Map<String, List<WmsMaterialCoil>> currentGrouped = all.stream()
|
||||
.collect(Collectors.groupingBy(WmsMaterialCoilVo::getEnterCoilNo));
|
||||
|
||||
// 按当前卷号分组重复项
|
||||
Map<String, List<WmsMaterialCoilVo>> currentGrouped = currentDuplicates.stream()
|
||||
.filter(e -> StringUtils.isNotBlank(e.getCurrentCoilNo()))
|
||||
.collect(Collectors.groupingBy(WmsMaterialCoil::getCurrentCoilNo));
|
||||
.collect(Collectors.groupingBy(WmsMaterialCoilVo::getCurrentCoilNo));
|
||||
|
||||
// 构建入场卷号重复组
|
||||
List<Map<String, Object>> enterGroups = enterGrouped.entrySet().stream()
|
||||
.filter(en -> en.getValue() != null && en.getValue().size() > 1)
|
||||
.map(en -> {
|
||||
List<WmsMaterialCoilVo> vos = en.getValue().stream().map(this::toVoBasic).collect(Collectors.toList());
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("enterCoilNo", en.getKey());
|
||||
m.put("coils", vos);
|
||||
return m;
|
||||
.filter(entry -> entry.getValue() != null && entry.getValue().size() > 1)
|
||||
.map(entry -> {
|
||||
Map<String, Object> group = new HashMap<>();
|
||||
group.put("enterCoilNo", entry.getKey());
|
||||
group.put("coils", entry.getValue());
|
||||
return group;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建当前卷号重复组
|
||||
List<Map<String, Object>> currentGroups = currentGrouped.entrySet().stream()
|
||||
.filter(en -> en.getValue() != null && en.getValue().size() > 1)
|
||||
.map(en -> {
|
||||
List<WmsMaterialCoilVo> vos = en.getValue().stream().map(this::toVoBasic).collect(Collectors.toList());
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("currentCoilNo", en.getKey());
|
||||
m.put("coils", vos);
|
||||
return m;
|
||||
.filter(entry -> entry.getValue() != null && entry.getValue().size() > 1)
|
||||
.map(entry -> {
|
||||
Map<String, Object> group = new HashMap<>();
|
||||
group.put("currentCoilNo", entry.getKey());
|
||||
group.put("coils", entry.getValue());
|
||||
return group;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 可选:批量填充关联对象信息
|
||||
List<WmsMaterialCoilVo> allVos = new ArrayList<>();
|
||||
for (Map<String, Object> g : enterGroups) {
|
||||
Object list = g.get("coils");
|
||||
if (list instanceof List) {
|
||||
allVos.addAll((List<WmsMaterialCoilVo>) list);
|
||||
}
|
||||
}
|
||||
for (Map<String, Object> g : currentGroups) {
|
||||
Object list = g.get("coils");
|
||||
if (list instanceof List) {
|
||||
allVos.addAll((List<WmsMaterialCoilVo>) list);
|
||||
}
|
||||
}
|
||||
if (!allVos.isEmpty()) {
|
||||
fillRelatedObjectsBatch(allVos);
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("enterGroups", enterGroups);
|
||||
result.put("currentGroups", currentGroups);
|
||||
return result;
|
||||
}
|
||||
|
||||
private WmsMaterialCoilVo toVoBasic(WmsMaterialCoil e) {
|
||||
WmsMaterialCoilVo vo = new WmsMaterialCoilVo();
|
||||
BeanUtils.copyProperties(e, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 OR 连接的 LIKE 子句,使用 MyBatis-Plus apply 的 {index} 占位符并将参数加入 args。
|
||||
|
||||
Reference in New Issue
Block a user