|
|
|
@ -1895,14 +1895,36 @@ |
|
|
|
a.upper_system_flag as upperSystemFlag |
|
|
|
|
|
|
|
FROM qc_iqc_record as a |
|
|
|
<include refid="iqcInspectionPartJoins"/> |
|
|
|
<include refid="iqcInspectionRecordJoins"/> |
|
|
|
<include refid="iqcInspectionRecordWhere"/> |
|
|
|
<include refid="iqcInspectionPartFilters"/> |
|
|
|
ORDER BY a.inspection_no desc, |
|
|
|
CASE WHEN a.state = '待检验' THEN 1 |
|
|
|
WHEN a.state = '待审核' THEN 2 |
|
|
|
WHEN a.state = '已完成' THEN 3 |
|
|
|
END, a.create_date desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<sql id="iqcInspectionPartJoins"> |
|
|
|
<include refid="iqcInspectionPartJoin"/> |
|
|
|
left join um as um on d.umid = um.UMID |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="iqcInspectionPartJoin"> |
|
|
|
inner join part as d on a.site = d.site and a.part_no = d.partNo |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="iqcInspectionRecordJoins"> |
|
|
|
left join view_Supplier as s on a.supplier_no = s.SupplierID |
|
|
|
left join sys_user as u on a.inspector_no = u.username |
|
|
|
left join sys_user as ab on a.action_by = ab.username |
|
|
|
left join sys_user as sub on a.submit_by = sub.username |
|
|
|
left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username |
|
|
|
left join um as um on d.umid = um.UMID |
|
|
|
left join um as inspectionUm on a.inspection_um_id = inspectionUm.UMID |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="iqcInspectionRecordWhere"> |
|
|
|
<where> |
|
|
|
a.site in (select site from AccessSite where userID = #{query.userName}) |
|
|
|
and a.bu_no in (select bu_no from AccessBu where username = #{query.userName}) |
|
|
|
@ -1930,12 +1952,6 @@ |
|
|
|
<if test = "query.partDesc != null and query.partDesc != ''"> |
|
|
|
AND a.part_desc LIKE '%' + #{query.partDesc} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''"> |
|
|
|
AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.sku != null and query.sku != ''"> |
|
|
|
AND d.sku LIKE '%' + #{query.sku} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.supplierDesc != null and query.supplierDesc != ''"> |
|
|
|
AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%' |
|
|
|
</if> |
|
|
|
@ -1943,7 +1959,7 @@ |
|
|
|
AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.inspectorName != null and query.inspectorName != ''"> |
|
|
|
u.user_display LIKE '%' + #{query.inspectorName} + '%' |
|
|
|
AND u.user_display LIKE '%' + #{query.inspectorName} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.startDate != null"> |
|
|
|
AND a.inspector_date >= #{query.startDate} |
|
|
|
@ -1969,21 +1985,69 @@ |
|
|
|
<if test = "query.submissionType != null and query.submissionType != ''"> |
|
|
|
AND a.submission_type = #{query.submissionType} |
|
|
|
</if> |
|
|
|
<if test = "query.documentNo != null and query.documentNo != ''"> |
|
|
|
AND a.document_no LIKE '%' + #{query.documentNo} + '%' |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="iqcInspectionPartFilters"> |
|
|
|
<if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''"> |
|
|
|
AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.sku != null and query.sku != ''"> |
|
|
|
AND d.sku LIKE '%' + #{query.sku} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.invdefinetype != null and query.invdefinetype != ''"> |
|
|
|
AND d.PartType LIKE '%' + #{query.invdefinetype} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.spec != null and query.spec != ''"> |
|
|
|
AND d.spec LIKE '%' + #{query.spec} + '%' |
|
|
|
</if> |
|
|
|
<if test = "query.documentNo != null and query.documentNo != ''"> |
|
|
|
AND a.document_no LIKE '%' + #{query.documentNo} + '%' |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
ORDER BY a.inspection_no desc, |
|
|
|
CASE WHEN a.state = '待检验' THEN 1 |
|
|
|
WHEN a.state = '待审核' THEN 2 |
|
|
|
WHEN a.state = '已完成' THEN 3 |
|
|
|
END, a.create_date desc |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="iqcInspectionCountWithLookups"> |
|
|
|
SELECT COALESCE(SUM(a.record_count), 0) |
|
|
|
FROM ( |
|
|
|
SELECT a.site, a.part_no, COUNT_BIG(*) AS record_count |
|
|
|
FROM qc_iqc_record as a |
|
|
|
<include refid="iqcInspectionRecordJoins"/> |
|
|
|
<include refid="iqcInspectionRecordWhere"/> |
|
|
|
GROUP BY a.site, a.part_no |
|
|
|
) as a |
|
|
|
<include refid="iqcInspectionPartJoins"/> |
|
|
|
<where><include refid="iqcInspectionPartFilters"/></where> |
|
|
|
</sql> |
|
|
|
|
|
|
|
<select id="qcIQCInspectionSearchCount" resultType="java.lang.Long"> |
|
|
|
<choose> |
|
|
|
<when test="(query.supplierDesc != null and query.supplierDesc != '') or (query.inspectorName != null and query.inspectorName != '')"> |
|
|
|
<include refid="iqcInspectionCountWithLookups"/> |
|
|
|
</when> |
|
|
|
<otherwise> |
|
|
|
<!-- 展示表的关联键有重复时,列表的一条检验记录可能对应多行。 --> |
|
|
|
SELECT CASE WHEN |
|
|
|
EXISTS (SELECT 1 FROM view_Supplier WHERE SupplierID IS NOT NULL |
|
|
|
GROUP BY SupplierID HAVING COUNT_BIG(*) > 1) |
|
|
|
OR EXISTS (SELECT 1 FROM sys_user WHERE username IS NOT NULL |
|
|
|
GROUP BY username HAVING COUNT_BIG(*) > 1) |
|
|
|
OR EXISTS (SELECT 1 FROM um WHERE UMID IS NOT NULL |
|
|
|
GROUP BY UMID HAVING COUNT_BIG(*) > 1) |
|
|
|
THEN ( |
|
|
|
<include refid="iqcInspectionCountWithLookups"/> |
|
|
|
) ELSE ( |
|
|
|
SELECT COALESCE(SUM(a.record_count), 0) |
|
|
|
FROM ( |
|
|
|
SELECT a.site, a.part_no, COUNT_BIG(*) AS record_count |
|
|
|
FROM qc_iqc_record as a |
|
|
|
<include refid="iqcInspectionRecordWhere"/> |
|
|
|
GROUP BY a.site, a.part_no |
|
|
|
) as a |
|
|
|
<include refid="iqcInspectionPartJoin"/> |
|
|
|
<where><include refid="iqcInspectionPartFilters"/></where> |
|
|
|
) END |
|
|
|
</otherwise> |
|
|
|
</choose> |
|
|
|
</select> |
|
|
|
|
|
|
|
<!-- IQC明细记录查询 --> |
|
|
|
|