|
|
|
@ -1347,4 +1347,189 @@ |
|
|
|
END, a.create_date desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<!-- 优化版本:使用OFFSET分页的IPQC导出查询 --> |
|
|
|
<select id="downloadIPQCRecordWithOffset" parameterType="com.xujie.sys.modules.pms.data.QcReportData" resultType="com.xujie.sys.modules.pms.data.QcReportIPQCData"> |
|
|
|
SELECT |
|
|
|
a.inspection_no, |
|
|
|
a.site, |
|
|
|
a.bu_no, |
|
|
|
dbo.get_bu_desc(a.site, a.bu_no) as buDesc, |
|
|
|
a.state, |
|
|
|
a.inspection_result, |
|
|
|
a.task_date, |
|
|
|
a.inspection_type_no, |
|
|
|
a.inspection_cycle, |
|
|
|
a.order_no, |
|
|
|
a.operation_desc, |
|
|
|
a.resource_id, |
|
|
|
r.resourceDesc, |
|
|
|
a.part_no, |
|
|
|
d.PartDescription as part_desc, |
|
|
|
d.spec, |
|
|
|
a.inspection_remark, |
|
|
|
a.roll_qty, |
|
|
|
a.sampling_qty, |
|
|
|
a.disposal_measures, |
|
|
|
a.disposal_remark, |
|
|
|
a.inspector_date, |
|
|
|
a.seq_no, |
|
|
|
a.batch_roll_no, |
|
|
|
a.special_requirements, |
|
|
|
a.work_center_no, |
|
|
|
wc.WorkCenterDesc as workCenterDesc, |
|
|
|
a.roll_no, |
|
|
|
a.um_id, |
|
|
|
um.UMName as umName, |
|
|
|
a.action_date, |
|
|
|
a.action_by, |
|
|
|
a.pass_qty, |
|
|
|
a.not_pass_qty, |
|
|
|
b.item_no, |
|
|
|
b.item_desc, |
|
|
|
b.default_value, |
|
|
|
b.max_value, |
|
|
|
b.min_value, |
|
|
|
b.sampling_qty as itemSamplingQty, |
|
|
|
b.unqualified_quantity, |
|
|
|
b.item_result, |
|
|
|
CASE WHEN b.item_result = 'Y' THEN '合格' |
|
|
|
WHEN b.item_result = 'N' THEN '不合格' |
|
|
|
END as itemResultDesc, |
|
|
|
CASE WHEN b.value_type_db = 'T' THEN b.text_value |
|
|
|
WHEN b.value_type_db = 'N' THEN CONVERT(varchar, b.number_value, 126) |
|
|
|
END as textValue, |
|
|
|
isnull(dbo.joint_name (a.site, a.bu_no, a.inspection_no, 'coordination'), '') AS operatorName, |
|
|
|
isnull(dbo.joint_id (a.site, a.bu_no, a.inspection_no, 'supplier'), '') AS responsiblePerson |
|
|
|
FROM qc_ipqc_record as a |
|
|
|
LEFT JOIN qc_ipqc_detailed_record b ON a.site = b.site AND a.bu_no = b.bu_no AND a.inspection_no = b.inspection_no |
|
|
|
left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceID |
|
|
|
left join part as d on a.site = d.site and a.part_no = d.PartNo |
|
|
|
left join UM as um on a.site = um.site and a.um_id = um.UMID |
|
|
|
left join WorkCenter as wc on a.site = wc.site and a.work_center_no = wc.WorkCenterNo |
|
|
|
<where> |
|
|
|
a.site in (select site from eam_access_site where username = #{query.userName}) |
|
|
|
and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) |
|
|
|
<if test="query.buDesc != null and query.buDesc != ''"> |
|
|
|
AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc} |
|
|
|
</if> |
|
|
|
<if test = "query.inspectionNo != null and query.inspectionNo != ''"> |
|
|
|
AND a.inspection_no LIKE #{query.inspectionNo} |
|
|
|
</if> |
|
|
|
<if test = "query.partNo != null and query.partNo != ''"> |
|
|
|
AND a.part_no LIKE #{query.partNo} |
|
|
|
</if> |
|
|
|
<if test = "query.partDesc != null and query.partDesc != ''"> |
|
|
|
AND d.PartDescription LIKE #{query.partDesc} |
|
|
|
</if> |
|
|
|
<if test = "query.states != null and query.states.size > 0"> |
|
|
|
AND a.state in |
|
|
|
<foreach item="item" collection="query.states" open="(" separator="," close=")"> |
|
|
|
#{item} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''"> |
|
|
|
AND a.inspection_type_no = #{query.inspectionTypeNo} |
|
|
|
</if> |
|
|
|
<if test = "query.inspectionResult != null and query.inspectionResult != ''"> |
|
|
|
AND a.inspection_result = #{query.inspectionResult} |
|
|
|
</if> |
|
|
|
<if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> |
|
|
|
AND a.disposal_measures = #{query.disposalMeasures} |
|
|
|
</if> |
|
|
|
<if test = "query.orderNo != null and query.orderNo != ''"> |
|
|
|
AND a.order_no LIKE #{query.orderNo} |
|
|
|
</if> |
|
|
|
<if test = "query.seqNo != null and query.seqNo != ''"> |
|
|
|
AND a.seq_no LIKE #{query.seqNo} |
|
|
|
</if> |
|
|
|
<if test = "query.operationDesc != null and query.operationDesc != ''"> |
|
|
|
AND a.operation_desc LIKE #{query.operationDesc} |
|
|
|
</if> |
|
|
|
<if test="query.startDate != null"> |
|
|
|
AND a.inspector_date >= #{query.startDate} |
|
|
|
</if> |
|
|
|
<if test="query.endDate != null"> |
|
|
|
AND #{query.endDate} >= a.inspector_date |
|
|
|
</if> |
|
|
|
<if test="query.startDate2 != null"> |
|
|
|
AND a.task_date >= #{query.startDate2} |
|
|
|
</if> |
|
|
|
<if test="query.endDate2 != null"> |
|
|
|
AND #{query.endDate2} >= a.task_date |
|
|
|
</if> |
|
|
|
<if test = "query.itemResult != null and query.itemResult != ''"> |
|
|
|
AND b.item_result = #{query.itemResult} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
ORDER BY |
|
|
|
CASE WHEN a.state = '待检验' THEN 1 |
|
|
|
WHEN a.state = '待审核' THEN 2 |
|
|
|
WHEN a.state = '已完成' THEN 3 |
|
|
|
END, a.task_date desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<!-- 优化版本:仅查询总数的IPQC统计查询 --> |
|
|
|
<select id="getIPQCReportCountOptimized" parameterType="com.xujie.sys.modules.pms.data.QcReportData" resultType="int"> |
|
|
|
SELECT |
|
|
|
count(1) |
|
|
|
from qc_ipqc_detailed_record as b |
|
|
|
Left JOIN qc_ipqc_record as a ON a.site = b.site AND a.bu_no = b.bu_no AND a.inspection_no = b.inspection_no |
|
|
|
left join part as d on a.site = d.site and a.part_no = d.PartNo |
|
|
|
<where> |
|
|
|
a.site in (select site from eam_access_site where username = #{query.userName}) |
|
|
|
and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) |
|
|
|
<if test="query.buDesc != null and query.buDesc != ''"> |
|
|
|
AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc} |
|
|
|
</if> |
|
|
|
<if test = "query.inspectionNo != null and query.inspectionNo != ''"> |
|
|
|
AND a.inspection_no LIKE #{query.inspectionNo} |
|
|
|
</if> |
|
|
|
<if test = "query.partNo != null and query.partNo != ''"> |
|
|
|
AND a.part_no LIKE #{query.partNo} |
|
|
|
</if> |
|
|
|
<if test = "query.partDesc != null and query.partDesc != ''"> |
|
|
|
AND d.PartDescription LIKE #{query.partDesc} |
|
|
|
</if> |
|
|
|
<if test = "query.states != null and query.states.size > 0"> |
|
|
|
AND a.state in |
|
|
|
<foreach item="item" collection="query.states" open="(" separator="," close=")"> |
|
|
|
#{item} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''"> |
|
|
|
AND a.inspection_type_no = #{query.inspectionTypeNo} |
|
|
|
</if> |
|
|
|
<if test = "query.inspectionResult != null and query.inspectionResult != ''"> |
|
|
|
AND a.inspection_result = #{query.inspectionResult} |
|
|
|
</if> |
|
|
|
<if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> |
|
|
|
AND a.disposal_measures = #{query.disposalMeasures} |
|
|
|
</if> |
|
|
|
<if test = "query.orderNo != null and query.orderNo != ''"> |
|
|
|
AND a.order_no LIKE #{query.orderNo} |
|
|
|
</if> |
|
|
|
<if test = "query.seqNo != null and query.seqNo != ''"> |
|
|
|
AND a.seq_no LIKE #{query.seqNo} |
|
|
|
</if> |
|
|
|
<if test = "query.operationDesc != null and query.operationDesc != ''"> |
|
|
|
AND a.operation_desc LIKE #{query.operationDesc} |
|
|
|
</if> |
|
|
|
<if test="query.startDate != null"> |
|
|
|
AND a.inspector_date >= #{query.startDate} |
|
|
|
</if> |
|
|
|
<if test="query.endDate != null"> |
|
|
|
AND #{query.endDate} >= a.inspector_date |
|
|
|
</if> |
|
|
|
<if test="query.startDate2 != null"> |
|
|
|
AND a.task_date >= #{query.startDate2} |
|
|
|
</if> |
|
|
|
<if test="query.endDate2 != null"> |
|
|
|
AND #{query.endDate2} >= a.task_date |
|
|
|
</if> |
|
|
|
<if test = "query.itemResult != null and query.itemResult != ''"> |
|
|
|
AND b.item_result = #{query.itemResult} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
</select> |
|
|
|
|
|
|
|
</mapper> |