feat(wms): 添加钢卷重复数据分组查询功能
- 在 IWmsMaterialCoilService 中新增 getDuplicateCoilGroups 方法定义 - 在 WmsMaterialCoilController 中添加 /duplicateGroups 接口 - 在 WmsMaterialCoilServiceImpl 中实现重复钢卷分组逻辑 - 支持按入场钢卷号和当前钢卷号分别进行重复分组 - 返回结构包含 enterGroups 和 currentGroups 两个分组数组 - 自动过滤 data_type=1 且未删除的数据记录 - 批量填充关联对象信息以提高查询效率
This commit is contained in:
@@ -288,5 +288,16 @@ public class WmsMaterialCoilController extends BaseController {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询data_type=1的重复钢卷分组
|
||||
* - 入场钢卷号重复分组
|
||||
* - 当前钢卷号重复分组
|
||||
*/
|
||||
@GetMapping("/duplicateGroups")
|
||||
public R<Map<String, Object>> getDuplicateCoilGroups() {
|
||||
Map<String, Object> result = iWmsMaterialCoilService.getDuplicateCoilGroups();
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -137,5 +137,16 @@ public interface IWmsMaterialCoilService {
|
||||
* - prefix: 前缀值
|
||||
*/
|
||||
Map<String, Object> getMaxEnterCoilNoByPrefix(String enterCoilNoPrefix);
|
||||
|
||||
/**
|
||||
* 查询data_type=1时的重复钢卷分组
|
||||
* 将入场钢卷号重复的分为一组,将当前钢卷号重复的分为一组
|
||||
* 返回结构:
|
||||
* {
|
||||
* enterGroups: [ { enterCoilNo: "xxx", coils: [WmsMaterialCoilVo...] }, ...],
|
||||
* currentGroups: [ { currentCoilNo: "yyy", coils: [WmsMaterialCoilVo...] }, ...]
|
||||
* }
|
||||
*/
|
||||
Map<String, Object> getDuplicateCoilGroups();
|
||||
}
|
||||
|
||||
|
||||
@@ -540,6 +540,72 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
return qw;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
Map<String, List<WmsMaterialCoil>> enterGrouped = all.stream()
|
||||
.filter(e -> StringUtils.isNotBlank(e.getEnterCoilNo()))
|
||||
.collect(Collectors.groupingBy(WmsMaterialCoil::getEnterCoilNo));
|
||||
Map<String, List<WmsMaterialCoil>> currentGrouped = all.stream()
|
||||
.filter(e -> StringUtils.isNotBlank(e.getCurrentCoilNo()))
|
||||
.collect(Collectors.groupingBy(WmsMaterialCoil::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;
|
||||
})
|
||||
.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;
|
||||
})
|
||||
.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。
|
||||
* 例如:column = "p.product_name", values = "A,B" -> 返回 "(p.product_name LIKE {0} OR p.product_name LIKE {1})"
|
||||
|
||||
Reference in New Issue
Block a user