feat(qms): 扩展质检员绑定物料查询功能
- 支持按物料类别层级结构查询,使用LIKE匹配前缀实现子类别检索 - 新增UNION ALL查询机制,合并直接绑定物料和通过物料类别绑定的物料 - 集成qms_qc_material_category表的ltree层次关系,支持类别树形结构展开 - 完善物料类别绑定逻辑,通过parent_tree <@匹配获取子孙类别下的所有物料 - 优化查询排序字段,统一使用material_id进行排序 - 更新SQL注释文档,详细说明两路数据源合并逻辑和类别层级匹配机制
This commit is contained in:
parent
5c8b2a01b8
commit
e8f4e98629
|
|
@ -105,10 +105,17 @@
|
|||
ORDER BY imi.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询绑定物料列表(支持物料编号/类别/描述过滤) -->
|
||||
<!--
|
||||
按 userId 查询绑定物料列表(支持物料编号/类别/描述过滤),合并两个来源:
|
||||
1) qms_inspector_material_item:直接绑定的物料
|
||||
2) qms_inspector_material_category_item:绑定的物料类别及其所有子孙类别下展开的物料
|
||||
(类别项存 material_category_id;经 ltree 的后代匹配 descendant.parent_tree <@ mc.parent_tree
|
||||
取出该类别自身及全部子孙类别,再用 category_code 匹配
|
||||
qms_qc_material.material_category_code 展开为物料)
|
||||
-->
|
||||
<select id="getMaterialsByUserIdWithFilter" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||
SELECT
|
||||
imi.id,
|
||||
m.id,
|
||||
imi.material_id,
|
||||
m.material_no,
|
||||
m.drawing_no,
|
||||
|
|
@ -128,12 +135,41 @@
|
|||
AND m.material_no = #{materialNo}
|
||||
</if>
|
||||
<if test="materialCategoryCode != null and materialCategoryCode != ''">
|
||||
AND m.material_category_code = #{materialCategoryCode}
|
||||
AND m.material_category_code LIKE CONCAT(#{materialCategoryCode}, '%')
|
||||
</if>
|
||||
<if test="materialDesc != null and materialDesc != ''">
|
||||
AND m.material_desc LIKE CONCAT('%', #{materialDesc}, '%')
|
||||
</if>
|
||||
ORDER BY imi.id ASC
|
||||
UNION ALL
|
||||
SELECT
|
||||
m.id,
|
||||
m.id AS material_id,
|
||||
m.material_no,
|
||||
m.drawing_no,
|
||||
m.drawing_no_ver,
|
||||
m.material_category_code,
|
||||
m.material_category_code_path_name AS material_category_name,
|
||||
m.material_desc AS material_name,
|
||||
m.material_specifications,
|
||||
m.material_texture,
|
||||
m.is_standard_maintained AS material_status
|
||||
FROM qms_inspector_material_category_item imci
|
||||
JOIN qms_qc_material_category mc ON mc.id = imci.material_category_id
|
||||
JOIN qms_qc_material_category descendant ON descendant.parent_tree <@ mc.parent_tree
|
||||
JOIN qms_qc_material m ON m.material_category_code = descendant.category_code
|
||||
WHERE imci.inspector_id = (
|
||||
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||
)
|
||||
<if test="materialNo != null and materialNo != ''">
|
||||
AND m.material_no = #{materialNo}
|
||||
</if>
|
||||
<if test="materialCategoryCode != null and materialCategoryCode != ''">
|
||||
AND m.material_category_code LIKE CONCAT(#{materialCategoryCode}, '%')
|
||||
</if>
|
||||
<if test="materialDesc != null and materialDesc != ''">
|
||||
AND m.material_desc LIKE CONCAT('%', #{materialDesc}, '%')
|
||||
</if>
|
||||
ORDER BY material_id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询关联物料类别列表(JOIN qms_qc_material_category 取类别信息) -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue