|
|
|
|
@ -153,16 +153,42 @@ |
|
|
|
|
ROW_NUMBER() OVER (PARTITION BY p.PART_CODE ORDER BY v.PART_VERSION DESC) AS rn |
|
|
|
|
FROM DS_PART p |
|
|
|
|
LEFT JOIN DS_PART_VERSION v ON p.ID = v.PART_ID AND v.IS_DELETED = 0 |
|
|
|
|
WHERE NOT EXISTS ( |
|
|
|
|
SELECT 1 |
|
|
|
|
FROM DS_PART_RELATION r |
|
|
|
|
WHERE r.CHILD_PART_ID = p.ID |
|
|
|
|
AND r.IS_DELETED = 0 |
|
|
|
|
) |
|
|
|
|
AND p.IS_DELETED = 0 |
|
|
|
|
WHERE p.IS_DELETED = 0 |
|
|
|
|
|
|
|
|
|
<!-- 动态判断是否查询子件 --> |
|
|
|
|
<choose> |
|
|
|
|
<!-- 当零件号或零件名称不为空时,支持查询子件 --> |
|
|
|
|
<when test="(dsPart.partCode != null and dsPart.partCode != '') or (dsPart.partName != null and dsPart.partName != '')"> |
|
|
|
|
AND ( |
|
|
|
|
<!-- 原部件查询条件 --> |
|
|
|
|
NOT EXISTS ( |
|
|
|
|
SELECT 1 |
|
|
|
|
FROM DS_PART_RELATION r |
|
|
|
|
WHERE r.CHILD_PART_ID = p.ID |
|
|
|
|
AND r.IS_DELETED = 0 |
|
|
|
|
) |
|
|
|
|
OR |
|
|
|
|
EXISTS ( |
|
|
|
|
SELECT 1 |
|
|
|
|
FROM DS_PART_RELATION r |
|
|
|
|
WHERE r.CHILD_PART_ID = p.ID |
|
|
|
|
AND r.IS_DELETED = 0 |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
</when> |
|
|
|
|
<!-- 只查询部件 --> |
|
|
|
|
<otherwise> |
|
|
|
|
AND NOT EXISTS ( |
|
|
|
|
SELECT 1 |
|
|
|
|
FROM DS_PART_RELATION r |
|
|
|
|
WHERE r.CHILD_PART_ID = p.ID |
|
|
|
|
AND r.IS_DELETED = 0 |
|
|
|
|
) |
|
|
|
|
</otherwise> |
|
|
|
|
</choose> |
|
|
|
|
|
|
|
|
|
<if test="dsPart.plate != null and dsPart.plate != ''"> |
|
|
|
|
AND p.PLATE LIKE '%' || #{dsPart.plate} || '%' |
|
|
|
|
AND p.PLATE LIKE '%' || #{dsPart.plate} || '%' |
|
|
|
|
</if> |
|
|
|
|
<if test="dsPart.partCode != null and dsPart.partCode != ''"> |
|
|
|
|
AND p.PART_CODE LIKE '%' || #{dsPart.partCode} || '%' |
|
|
|
|
@ -174,7 +200,7 @@ |
|
|
|
|
AND p.SIN_TER_TYPE = #{dsPart.sinTerType} |
|
|
|
|
</if> |
|
|
|
|
<if test="dsPart.material != null and dsPart.material != ''"> |
|
|
|
|
AND p.MATERIAL LIKE '%' || #{dsPart.material} || '%' |
|
|
|
|
AND p.MATERIAL LIKE '%' || #{dsPart.material} || '%' |
|
|
|
|
</if> |
|
|
|
|
<if test="dsPart.powderWeight != null"> |
|
|
|
|
AND p.POWDER_WEIGHT = #{dsPart.powderWeight} |
|
|
|
|
@ -183,10 +209,10 @@ |
|
|
|
|
AND p.FORMING_THICKNESS = #{dsPart.formingThickness} |
|
|
|
|
</if> |
|
|
|
|
<if test="dsPart.productType != null"> |
|
|
|
|
AND p.PRODUCT_TYPE LIKE '%' || #{dsPart.productType} || '%' |
|
|
|
|
AND p.PRODUCT_TYPE LIKE '%' || #{dsPart.productType} || '%' |
|
|
|
|
</if> |
|
|
|
|
<if test="dsPart.hardness != null"> |
|
|
|
|
AND p.HARDNESS LIKE '%' || #{dsPart.hardness} || '%' |
|
|
|
|
AND p.HARDNESS LIKE '%' || #{dsPart.hardness} || '%' |
|
|
|
|
</if> |
|
|
|
|
<if test="dsPart.startDate != null and dsPart.endDate != null"> |
|
|
|
|
AND p.NEXT_DUE BETWEEN TO_DATE(#{dsPart.startDate}, 'YYYY-MM-DD') |
|
|
|
|
|