feat(wms): 添加物料规格筛选功能
- 在WmsMaterialCoilBo中新增itemSpecification字段 - 修改筛选逻辑以支持按规格筛选 - 实现规格字段的模糊匹配及多规格查询支持 - 更新查询构造器以兼容新字段的条件拼接 - 支持逗号分隔的多个规格同时查询 - 优化查询逻辑确保规格筛选与其他字段协同工作
This commit is contained in:
@@ -179,6 +179,9 @@ public class WmsMaterialCoilBo extends BaseEntity {
|
||||
// 锌层厚度(两表通用字段名:zinc_layer)
|
||||
private String itemZincLayer;
|
||||
|
||||
//规格
|
||||
private String itemSpecification;
|
||||
|
||||
private Boolean onlyUnshippedAndUnplanned;
|
||||
|
||||
}
|
||||
|
||||
@@ -338,14 +338,15 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
qw.eq(bo.getActualWarehouseId() != null, "mc.actual_warehouse_id", bo.getActualWarehouseId());
|
||||
qw.eq(StringUtils.isNotBlank(bo.getItemType()), "mc.item_type", bo.getItemType());
|
||||
|
||||
// 按 itemType + 细粒度字段筛选(若对应字段非空则拼接条件;为空则不拼)
|
||||
// 按 selectType + 细粒度字段筛选(若对应字段非空则拼接条件;为空则不拼)
|
||||
if (StringUtils.isNotBlank(bo.getSelectType())) {
|
||||
List<Long> matchedItemIds = new ArrayList<>();
|
||||
boolean hasAnyItemFilter = StringUtils.isNotBlank(bo.getItemMaterial())
|
||||
|| StringUtils.isNotBlank(bo.getItemManufacturer())
|
||||
|| StringUtils.isNotBlank(bo.getItemSurfaceTreatmentDesc())
|
||||
|| StringUtils.isNotBlank(bo.getItemZincLayer())
|
||||
|| StringUtils.isNotBlank(bo.getItemName()); // 兼容性关键字
|
||||
|| StringUtils.isNotBlank(bo.getItemName()) // 兼容性关键字
|
||||
|| StringUtils.isNotBlank(bo.getItemSpecification()); // 添加规格筛选条件
|
||||
|
||||
if (hasAnyItemFilter) {
|
||||
try {
|
||||
@@ -367,6 +368,23 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
if (StringUtils.isNotBlank(bo.getItemZincLayer())) {
|
||||
pq.like("zinc_layer", bo.getItemZincLayer());
|
||||
}
|
||||
// 添加规格筛选条件,支持逗号分隔的多个规格
|
||||
if (StringUtils.isNotBlank(bo.getItemSpecification())) {
|
||||
String[] specs = bo.getItemSpecification().split(",");
|
||||
if (specs.length == 1) {
|
||||
pq.like("specification", specs[0].trim());
|
||||
} else {
|
||||
pq.and(wrapper -> {
|
||||
for (int i = 0; i < specs.length; i++) {
|
||||
if (i == 0) {
|
||||
wrapper.like("specification", specs[i].trim());
|
||||
} else {
|
||||
wrapper.or().like("specification", specs[i].trim());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// MyBatis selectList默认返回空列表,无需判null,直接流式提取ID
|
||||
matchedItemIds = productMapper.selectList(pq).stream()
|
||||
.map(WmsProduct::getProductId)
|
||||
@@ -390,6 +408,23 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
if (StringUtils.isNotBlank(bo.getItemZincLayer())) {
|
||||
rq.like("zinc_layer", bo.getItemZincLayer());
|
||||
}
|
||||
// 添加规格筛选条件,支持逗号分隔的多个规格
|
||||
if (StringUtils.isNotBlank(bo.getItemSpecification())) {
|
||||
String[] specs = bo.getItemSpecification().split(",");
|
||||
if (specs.length == 1) {
|
||||
rq.like("specification", specs[0].trim());
|
||||
} else {
|
||||
rq.and(wrapper -> {
|
||||
for (int i = 0; i < specs.length; i++) {
|
||||
if (i == 0) {
|
||||
wrapper.like("specification", specs[i].trim());
|
||||
} else {
|
||||
wrapper.or().like("specification", specs[i].trim());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// 流式提取rawMaterialId,过滤null
|
||||
matchedItemIds = rawMaterialMapper.selectList(rq).stream()
|
||||
.map(WmsRawMaterial::getRawMaterialId)
|
||||
|
||||
Reference in New Issue
Block a user