CCL_QMS检验
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

6120 lines
268 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gaotao.modules.pms.mapper.QcMapper">
<!-- ================================================= FAI检验维护 ================================================= -->
<!-- 查询FAI基础数据 -->
<select id="selectFAIBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
top 1
a.orderno as orderNo,
j.partNo,
j.PartDescription as part_desc,
c.operationDesc,
b.approve_qty as rollQty,
a.s_resourceid as resourceId,
DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
a.itemno as itemNo,
a.id as ssrId
FROM soscheduledrouting as a
inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
LEFT JOIN sfdc as b
ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
select min(sfdc.id)
from sfdc
group by sfdc.assjob_seq_no, site
)
LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
LEFT JOIN part j ON so.site = j.site and so.PartNo = j.partNo
WHERE a.itemno = '10'
AND a.id not in (select ssr_id from qc_fai_record)
AND b.approve_qty is not null
ORDER BY a.id desc
</select>
<!-- 获取该物料属性下维护的iqc -->
<select id="selectPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
qat.site,
qat.bu_no,
qat.attribute_no,
qat.template_id,
qat.sampling_level_no,
qsil.sampling_level_desc,
qat.inspection_cycle,
qat.sampling_programme_no,
qsip.sampling_programme_desc,
qat.AQL,
qat.AC,
qat.RE,
qt.default_sampling_quantity,
qt.default_sampling_proportion
FROM qc_attribute_template as qat
LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
WHERE qat.site = #{site} and qat.bu_no = #{buNo}
AND qat.attribute_no = #{partNo}
AND qat.attribute_type = #{attributeType}
AND qt.inspection_type_no = #{inspectionTypeNo}
AND qat.manufacturer_id = #{supplierNo}
</select>
<!-- 获取该物料属性下维护的ipqc -->
<select id="selectPartAttributeByOperationAndResource" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
qat.site,
qat.bu_no,
qat.attribute_no,
qat.template_id,
qat.sampling_level_no,
qsil.sampling_level_desc,
qat.inspection_cycle,
qat.sampling_programme_no,
qsip.sampling_programme_desc,
qat.AQL,
qat.AC,
qat.RE,
qt.default_sampling_quantity,
qt.default_sampling_proportion
FROM qc_attribute_template as qat
LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
WHERE qat.site = #{site} and qat.bu_no = #{buNo}
AND qat.attribute_no = #{partNo}
AND qat.attribute_type = #{attributeType1}
AND qt.inspection_type_no = #{inspectionTypeNo}
AND qat.operation = #{operationDesc}
AND qat.resource_id = #{resourceId}
</select>
<!-- 获取模板详情 -->
<select id="selectTemplate" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
qt.site,
qt.bu_no,
qt.template_id,
qt.sampling_level_no,
qsil.sampling_level_desc,
qt.inspection_cycle,
qt.sampling_programme_no,
qsip.sampling_programme_desc,
qt.AQL,
qt.AC,
qt.RE,
qt.default_sampling_quantity,
qt.default_sampling_proportion
FROM qc_template as qt
LEFT JOIN qc_sampling_inspection_level as qsil ON qt.sampling_level_no = qsil.sampling_level_no and qt.site = qsil.site and qt.bu_no = qsil.bu_no
LEFT JOIN qc_sampling_inspection_programme as qsip ON qt.sampling_programme_no = qsip.sampling_programme_no and qt.site = qsip.site and qt.bu_no = qsip.bu_no
WHERE qt.site = #{site} and qt.template_id = #{templateId} and qt.bu_no = #{buNo}
</select>
<!-- 新增FAI主记录信息 -->
<insert id="saveFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_fai_record (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id, part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
VALUES(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId}, #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
</insert>
<insert id="saveFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_fai_detailed_record
(inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
VALUES
(#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
#{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
#{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
</insert>
<!-- 新增FAI明细记录信息 -->
<insert id="saveFAIDetailedRecords">
INSERT INTO qc_fai_detailed_record
(inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
#{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
#{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
</foreach>
</insert>
<!-- 查询FAI主记录信息 -->
<select id="qcFAIInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
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,
dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
a.inspection_cycle,
a.order_no,
a.operation_desc,
a.resource_id,
r.resourceDesc,
a.part_no,
d.PartDescription as part_desc,
d.cinv_source_code as cinvSourceCode,
d.sku as sku,
d.PartType as invdefinetype,
a.inspection_remark,
a.roll_qty,
a.sampling_qty,
a.disposal_measures,
a.disposal_remark,
a.inspector_date as inspectorDate,
a.inspector_no,
u.user_display as inspectorName,
a.ssr_id,
a.unqualified_qty,
a.submit_flag,
a.seq_no,
a.batch_roll_no,
a.special_requirements,
a.work_center_no,
a.roll_no,
a.um_id,
um.UMName as umName,
a.action_date,
a.action_by,
isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
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, 'responsible'), '') as responsiblePerson,
isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
a.pass_qty,
a.not_pass_qty,
a.batch_qualified_qty
FROM qc_fai_record as a
inner join part as d on a.site = d.site and a.part_no = d.partNo
left join sys_user as u on a.inspector_no = u.username
left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
left join UM as um on a.site = um.site and a.um_id = um.UMID
<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})
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</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.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.disposalMeasures != null and query.disposalMeasures != ''">
AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
</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.inspectionResult != null and query.inspectionResult != ''">
AND a.inspection_result = #{query.inspectionResult}
</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>
</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>
<!-- 获取物料的类别编码 -->
<select id="selectFamilyIdByPartNo" parameterType="string" resultType="string">
SELECT FamilyID
FROM part
WHERE partNo = #{partNo} AND site = #{site}
</select>
<!-- FAI明细记录查询 -->
<select id="faiDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.bu_no,
a.inspection_no,
a.order_no,
a.template_id,
a.sampling_level_no,
a.sampling_level_desc,
a.sampling_programme_no,
a.sampling_programme_desc,
a.AQL,
a.AC,
a.RE,
a.item_no,
a.item_desc,
a.object_id,
a.object_desc,
a.default_value,
a.min_value,
a.max_value,
a.text_value,
a.number_value,
a.value_type_db,
a.value_type,
case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
a.is_submit,
isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
a.sampling_qty,
dbo.qc_get_fai_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
c.method_no,
c.method_name,
c.method_remark,
sw.color_code as qcSpecWarningColorCode,
sw.threshold_value as qcSpecWarningThresholdValue
FROM qc_fai_detailed_record as a
LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
order by a.order_id
</select>
<!-- 修改FAI主记录信息 -->
<update id="updateFAIMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_record
SET disposal_measures = #{disposalMeasures},
disposal_remark = #{disposalRemark},
inspection_result = #{inspectionResult},
inspector_no = #{inspectorNo},
state = #{state},
inspection_remark = #{inspectionRemark},
inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
roll_qty = #{rollQty,jdbcType=DECIMAL},
unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
pass_qty = #{passQty,jdbcType=DECIMAL},
not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
</update>
<!-- 修改FAI明细记录信息 -->
<update id="updateFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_detailed_record
SET item_result = #{itemResult},
unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
text_value = #{textValue},
number_value = #{numberValue,jdbcType=DECIMAL}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改子明细提交标识 -->
<update id="updateSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo}
</update>
<!-- 删除FAI检验记录 -->
<delete id="deleteFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_fai_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除FAI明细记录信息 -->
<delete id="deleteFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_fai_detailed_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除FAI子明细记录信息 -->
<delete id="deleteFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_fai_sub_detail_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 修改FAI主记录标识为已提交 -->
<update id="updateFAIMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_record
SET submit_flag = 'Y',
state = '已完成',
submit_date = getDate()
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改FAI明细记录标识为已提交 -->
<update id="updateFAIDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_detailed_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改子明细记录标识为已提交 -->
<update id="updateFAISubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 查询FAI检验记录是否已提交 -->
<select id="checkFAIIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag
FROM qc_fai_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 查询FAI检验记录状态(用于保存前校验) -->
<select id="getFAIRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag, state
FROM qc_fai_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 删除子明细的老数据 -->
<delete id="delFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
DELETE FROM qc_fai_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 新增FAI子明细信息 -->
<insert id="saveFAISubDetailed">
INSERT INTO qc_fai_sub_detail_record
(inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
</foreach>
</insert>
<!-- 查询FAI的子明细 -->
<select id="selectFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
sub_detail_value,
sampling_location,
is_submit,
sampling_location_b,
num,
sub_detail_value_b,
sub_detail_value_c,
sub_detail_value_d,
sub_detail_value_e
FROM qc_fai_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND sub_detail_value ${collectionDataContent}
</if>
</select>
<!-- 获取该项目的子明细值 -->
<select id="selectFAISubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT sub_detail_value,
sampling_location,
is_submit
FROM qc_fai_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
</select>
<!-- ================================================= IPQC检验维护 ================================================= -->
<!-- 查询IPQC基础数据 -->
<select id="selectIPQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
top 1
a.orderno as orderNo,
j.partNo,
j.PartDescription as partDesc,
c.operationDesc,
b.approve_qty as rollQty,
a.s_resourceid as resourceId,
DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
a.itemno as itemNo,
a.id as ssrId
FROM soscheduledrouting as a
inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
LEFT JOIN sfdc as b
ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
select max(sfdc.id)
from sfdc
group by sfdc.assjob_seq_no, site
)
LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
ON a.id = temp.ssr_id
WHERE b.approve_qty is not null and temp.ssr_id is null
ORDER BY a.id desc
</select>
<select id="qcExec" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="string" statementType="CALLABLE">
{CALL
getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
}
</select>
<insert id="saveIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_ipqc_detailed_record
(inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
VALUES
(#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
#{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
#{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
</insert>
<!-- 新增IPQC明细记录信息 -->
<insert id="saveIPQCDetailedRecords">
INSERT INTO qc_ipqc_detailed_record
(inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
#{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
#{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId}, #{item.custom1}, #{item.custom2}, #{item.custom3})
</foreach>
</insert>
<!-- 新增IPQC主记录信息 -->
<insert id="saveIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_ipqc_record
(inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, create_by, inspector_by)
VALUES
(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
#{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
#{createBy}, #{inspectorBy})
</insert>
<!-- 查询IPQC主记录信息 -->
<select id="qcIPQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
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.create_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.cinv_source_code as cinvSourceCode,
d.sku as sku,
d.PartType as invdefinetype,
d.spec,
a.inspection_remark,
a.roll_qty,
a.sampling_qty,
a.disposal_measures,
a.disposal_remark,
a.inspector_date as inspectorDate,
a.submit_date,
isnull(sub.user_display, a.submit_by) as submitBy,
a.inspector_no,
u.user_display as inspectorName,
a.ssr_id,
a.unqualified_qty,
a.submit_flag,
a.seq_no,
a.batch_roll_no,
a.special_requirements,
a.work_center_no,
a.roll_no,
a.um_id,
um.UMName as umName,
a.action_date,
isnull(ab.user_display, a.action_by) as actionBy,
isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
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, 'responsible'), '') as responsiblePerson,
isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
a.pass_qty,
a.not_pass_qty,
a.batch_qualified_qty,
w.WorkCenterDesc,
a.release_no as releaseNo,
a.line_no,
isnull(a.inspector_by, a.create_by) as inspectorBy,
isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
FROM qc_ipqc_record as a
inner join part as d on a.site = d.site and a.part_no = d.partNo
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 WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
left join UM as um on a.um_id = um.UMID
<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})
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</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.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.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.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
AND a.inspection_type_no in
<foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
#{item}
</foreach>
</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 LIKE '%' + #{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.resourceId != null and query.resourceId != ''">
AND a.resource_id = #{query.resourceId}
</if>
<if test = "query.workCenterNo != null and query.workCenterNo != ''">
AND a.work_center_no = #{query.workCenterNo}
</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.spec != null and query.spec != ''">
AND d.spec LIKE '%' + #{query.spec} + '%'
</if>
</where>
ORDER BY a.inspection_no desc,
CASE WHEN a.state = '未开始' THEN 1
WHEN a.state = '待检验' THEN 2
END, a.action_date,a.task_date,a.inspector_date desc
</select>
<!-- IPQC明细记录查询 -->
<select id="ipqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.bu_no,
a.inspection_no,
a.order_no,
a.template_id,
a.sampling_level_no,
a.sampling_level_desc,
a.sampling_programme_no,
a.sampling_programme_desc,
a.AQL,
a.AC,
a.RE,
a.item_no,
a.item_desc,
a.object_id,
a.object_desc,
a.default_value,
a.min_value,
a.max_value,
a.text_value,
a.number_value,
a.value_type_db,
a.value_type,
case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
a.item_remark as itemRemark,
a.custom1,
a.custom2,
a.custom3,
a.is_submit,
isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
a.sampling_qty,
dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
c.method_no,
c.method_name,
c.method_remark,
sw.color_code as qcSpecWarningColorCode,
sw.threshold_value as qcSpecWarningThresholdValue,
(SELECT TOP 1 epi.collection_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS collectionFlag,
(SELECT TOP 1 epi.image_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS imageFlag,
(SELECT TOP 1 epi.data_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS dataFlag
FROM qc_ipqc_detailed_record as a
LEFT JOIN qc_ipqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
OUTER APPLY (
SELECT TOP 1
w.color_code,
w.threshold_value
FROM qc_spec_warning w
WHERE w.site = a.site
AND w.bu_no = a.bu_no
AND w.part_no = r.part_no
AND w.item_no = a.item_no
AND w.inspection_type_no = r.inspection_type_no
ORDER BY w.threshold_value
) sw
LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
order by a.order_id
</select>
<!-- 删除IPQC检验记录 -->
<delete id="deleteIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_ipqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除IPQC明细记录信息 -->
<delete id="deleteIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_ipqc_detailed_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除IPQC子明细记录信息 -->
<delete id="deleteIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_ipqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 任务重载:修改IPQC检验记录 -->
<update id="updateIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_record
SET inspection_type_no = #{inspectionTypeNo},
sampling_qty = #{samplingQty},
inspection_cycle = #{inspectionCycle},
state = '未开始',
inspection_result = null,
disposal_measures = null,
disposal_remark = null,
inspection_remark = null,
inspector_no = null,
inspector_date = null,
submit_flag = 'N',
action_date = null,
action_by = null,
pass_qty = null,
not_pass_qty = null,
unqualified_qty = null,
batch_qualified_qty = null
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改IPQC主记录信息 -->
<update id="updateIPQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_record
SET disposal_measures = #{disposalMeasures},
disposal_remark = #{disposalRemark},
inspection_result = #{inspectionResult},
inspector_no = #{inspectorNo},
state = #{state},
inspection_remark = #{inspectionRemark},
inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
roll_qty = #{rollQty,jdbcType=DECIMAL},
unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
pass_qty = #{passQty,jdbcType=DECIMAL},
not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
</update>
<!-- 修改IPQC明细记录信息 -->
<update id="updateIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_detailed_record
SET item_result = #{itemResult},
unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
text_value = #{textValue},
number_value = #{numberValue,jdbcType=DECIMAL},
default_value = #{defaultValue},
min_value = #{minValue,jdbcType=DECIMAL},
max_value = #{maxValue,jdbcType=DECIMAL},
item_remark = #{itemRemark},
custom1 = #{custom1},
custom2 = #{custom2},
custom3 = #{custom3}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="patchIPQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_detailed_record
<set>
<if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
<if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
<if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
<if test="textValue != null">text_value = #{textValue},</if>
</set>
WHERE inspection_no = #{inspectionNo}
and RTRIM(item_no) = RTRIM(#{itemNo})
and site = #{site}
and bu_no = #{buNo}
</update>
<!-- 修改IPQC主记录标识为已提交 -->
<update id="updateIPQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_record
SET submit_flag = 'Y',
state = '已完成',
submit_date = getDate(),
submit_by = #{updateBy}
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改IPQC明细记录标识为已提交 -->
<update id="updateIPQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_detailed_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改IPQC子明细记录标识为已提交 -->
<update id="updateIPQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 删除IPQC子明细的老数据 -->
<delete id="delIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
DELETE FROM qc_ipqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 新增IPQC子明细信息 -->
<insert id="saveIPQCSubDetailed">
INSERT INTO qc_ipqc_sub_detail_record
(inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
</foreach>
</insert>
<!-- 查询IPQC的子明细 -->
<select id="selectIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
sub_detail_value,
sampling_location,
is_submit,
sampling_location_b,
num,
sub_detail_value_b,
sub_detail_value_c,
sub_detail_value_d,
sub_detail_value_e,
file_name,
is_transfer,
is_qualified,
defect_qty,
roll_no,
CONVERT(VARCHAR(19), create_time, 120) AS createTime
FROM qc_ipqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND sub_detail_value ${collectionDataContent}
</if>
</select>
<!-- 查询IPQC检验记录是否已提交 -->
<select id="checkIPQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag
FROM qc_ipqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 查询IPQC检验记录状态(用于保存前校验) -->
<select id="getIPQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag, state
FROM qc_ipqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 获取该项目的子明细值 -->
<select id="selectIPQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT sub_detail_value,
sampling_location,
is_submit
FROM qc_ipqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
</select>
<!-- ================================================= SQC库存复检 ================================================= -->
<select id="selectSQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
FROM qc_sqc_record
WHERE site = #{site} and bu_no = #{buNo}
</select>
<insert id="saveSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_sqc_detailed_record
(inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
VALUES
(#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
#{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
#{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo}, #{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
</insert>
<insert id="saveSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_sqc_record
(inspection_no, site, bu_no, state, create_date, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
part_no, part_desc, roll_qty, sampling_qty, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id,
batch_no, receipt_no, receipt_item_no, [po_orderNo], po_itemNo, supplier_no, create_by, inspector_by)
VALUES
(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
#{partNo}, #{partDesc}, #{rollQty,jdbcType=DECIMAL}, #{samplingQty,jdbcType=DECIMAL}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
#{batchNo}, #{receiptNo}, #{receiptItemNo}, #{poOrderNo}, #{poItemNo}, #{supplierNo}, #{createBy}, #{inspectorBy})
</insert>
<sql id="qcSQCInspectionSearchWhere">
<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})
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</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} + '%' OR 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.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.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
AND a.inspection_type_no in
<foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
#{item}
</foreach>
</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 LIKE '%' + #{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.batchNo != null and query.batchNo != ''">
AND a.batch_no LIKE '%' + #{query.batchNo} + '%'
</if>
<if test = "query.receiptNo != null and query.receiptNo != ''">
AND a.receipt_no LIKE '%' + #{query.receiptNo} + '%'
</if>
<if test = "query.operationDesc != null and query.operationDesc != ''">
AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
</if>
<if test = "query.resourceId != null and query.resourceId != ''">
AND a.resource_id = #{query.resourceId}
</if>
<if test = "query.workCenterNo != null and query.workCenterNo != ''">
AND a.work_center_no = #{query.workCenterNo}
</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.spec != null and query.spec != ''">
AND d.spec LIKE '%' + #{query.spec} + '%'
</if>
</where>
</sql>
<select id="qcSQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
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.create_date,
a.inspection_type_no,
a.inspection_cycle,
a.order_no,
a.operation_desc,
a.resource_id,
r.resourceDesc,
a.part_no,
COALESCE(d.PartDescription, a.part_desc) as part_desc,
d.cinv_source_code as cinvSourceCode,
d.sku as sku,
d.PartType as invdefinetype,
d.spec,
a.inspection_remark,
a.roll_qty,
a.sampling_qty,
a.disposal_measures,
a.disposal_remark,
a.inspector_date as inspectorDate,
a.submit_date,
isnull(sub.user_display, a.submit_by) as submitBy,
a.inspector_no,
u.user_display as inspectorName,
a.unqualified_qty,
a.submit_flag,
a.seq_no,
a.batch_roll_no,
a.special_requirements,
a.work_center_no,
a.roll_no,
a.um_id,
um.UMName as umName,
a.action_date,
isnull(ab.user_display, a.action_by) as actionBy,
isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
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, 'responsible'), '') as responsiblePerson,
isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
a.pass_qty,
a.not_pass_qty,
a.batch_qualified_qty,
w.WorkCenterDesc,
a.batch_no,
a.receipt_no,
a.receipt_item_no,
a.[po_orderNo] as poOrderNo,
a.po_itemNo as poItemNo,
a.release_no as releaseNo,
a.line_no,
isnull(a.inspector_by, a.create_by) as inspectorBy,
isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
FROM qc_sqc_record as a
inner join part as d on a.site = d.site and a.part_no = d.partNo
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 WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
left join UM as um on a.site = um.site and a.um_id = um.UMID
<include refid="qcSQCInspectionSearchWhere"/>
ORDER BY a.inspection_no desc,
CASE WHEN a.state = '未开始' THEN 1
WHEN a.state = '待检验' THEN 2
END, a.action_date,a.task_date,a.inspector_date desc
</select>
<select id="qcSQCInspectionSearchCount" resultType="java.lang.Long">
SELECT COUNT(1)
FROM qc_sqc_record as a
inner join part as d on a.site = d.site and a.part_no = d.partNo
<include refid="qcSQCInspectionSearchWhere"/>
</select>
<select id="sqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.bu_no,
a.inspection_no,
a.template_id,
a.sampling_level_no,
a.sampling_level_desc,
a.sampling_programme_no,
a.sampling_programme_desc,
a.AQL,
a.AC,
a.RE,
a.item_no,
a.item_desc,
a.object_id,
a.object_desc,
a.default_value,
a.min_value,
a.max_value,
a.text_value,
a.number_value,
a.value_type_db,
a.value_type,
case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
a.item_remark as itemRemark,
a.custom1,
a.custom2,
a.custom3,
a.is_submit,
isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
a.sampling_qty,
(SELECT COUNT(1) FROM qc_sqc_sub_detail_record s WHERE s.site = a.site AND s.bu_no = a.bu_no AND s.inspection_no = a.inspection_no AND s.item_no = a.item_no) as subDetailRecordNum,
dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
c.method_no,
c.method_name,
c.method_remark,
sw.color_code as qcSpecWarningColorCode,
sw.threshold_value as qcSpecWarningThresholdValue,
(SELECT TOP 1 epi.collection_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS collectionFlag,
(SELECT TOP 1 epi.image_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS imageFlag,
(SELECT TOP 1 epi.data_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS dataFlag
FROM qc_sqc_detailed_record as a
LEFT JOIN qc_sqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
OUTER APPLY (
SELECT TOP 1
w.color_code,
w.threshold_value
FROM qc_spec_warning w
WHERE w.site = a.site
AND w.bu_no = a.bu_no
AND w.part_no = r.part_no
AND w.item_no = a.item_no
AND w.inspection_type_no = r.inspection_type_no
ORDER BY w.threshold_value
) sw
LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
order by a.order_id
</select>
<delete id="deleteSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_sqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<delete id="deleteSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_sqc_detailed_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<delete id="deleteSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_sqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 任务重载:修改SQC检验记录 -->
<update id="updateSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_record
SET inspection_type_no = #{inspectionTypeNo},
sampling_qty = #{samplingQty},
inspection_cycle = #{inspectionCycle},
part_desc = #{partDesc},
state = '未开始',
inspection_result = null,
disposal_measures = null,
disposal_remark = null,
inspection_remark = null,
inspector_no = null,
inspector_date = null,
submit_flag = 'N',
action_date = null,
action_by = null,
pass_qty = null,
not_pass_qty = null,
unqualified_qty = null,
batch_qualified_qty = null
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateSQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_record
SET disposal_measures = #{disposalMeasures},
disposal_remark = #{disposalRemark},
inspection_result = #{inspectionResult},
inspector_no = #{inspectorNo},
state = #{state},
inspection_remark = #{inspectionRemark},
inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
roll_qty = #{rollQty,jdbcType=DECIMAL},
unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
pass_qty = #{passQty,jdbcType=DECIMAL},
not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
</update>
<update id="updateSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_detailed_record
SET item_result = #{itemResult},
unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
text_value = #{textValue},
number_value = #{numberValue,jdbcType=DECIMAL},
default_value = #{defaultValue},
min_value = #{minValue,jdbcType=DECIMAL},
max_value = #{maxValue,jdbcType=DECIMAL},
item_remark = #{itemRemark},
custom1 = #{custom1},
custom2 = #{custom2},
custom3 = #{custom3}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="patchSQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_detailed_record
<set>
<if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
<if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
<if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
<if test="textValue != null">text_value = #{textValue},</if>
</set>
WHERE inspection_no = #{inspectionNo}
and RTRIM(item_no) = RTRIM(#{itemNo})
and site = #{site}
and bu_no = #{buNo}
</update>
<update id="updateSQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_record
SET submit_flag = 'Y',
state = '已完成',
submit_date = getDate(),
submit_by = #{updateBy}
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateSQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_detailed_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateSQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<delete id="delSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
DELETE FROM qc_sqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</delete>
<insert id="saveSQCSubDetailed">
INSERT INTO qc_sqc_sub_detail_record
(inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
</foreach>
</insert>
<select id="selectSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
sub_detail_value,
sampling_location,
is_submit,
sampling_location_b,
num,
sub_detail_value_b,
sub_detail_value_c,
sub_detail_value_d,
sub_detail_value_e,
file_name,
is_transfer,
is_qualified,
defect_qty,
roll_no,
CONVERT(VARCHAR(19), create_time, 120) AS createTime
FROM qc_sqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND sub_detail_value ${collectionDataContent}
</if>
</select>
<select id="checkSQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag
FROM qc_sqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<select id="getSQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag, state
FROM qc_sqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<select id="selectSQCSubDetailValue" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT sub_detail_value,
sampling_location,
is_submit
FROM qc_sqc_sub_detail_record
WHERE inspection_no = #{param1} and item_no = #{param2} and site = #{param3}
</select>
<update id="actionSQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
update qc_sqc_record
set action_date = getDate(),
action_by = #{actionBy},
state = #{state}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<select id="getSQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
select
a.site,
a.bu_no,
a.inspection_no,
a.item_no,
a.item_desc,
b.collection_source,
b.collection_method,
b.equipment_classification
from qc_sqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="getSQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
ItemNo as itemNo,
ItemDesc as itemDesc,
DefaultValue as defaultValue,
MaxValue as maxValue,
MinValue as minValue,
ValueType as valueType,
ValueType_DB as valueTypeDb
FROM eam_properties_item
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_type_no = #{inspectionTypeNo}
<if test="itemNo != null and itemNo != ''">
AND ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
AND ItemNo NOT IN (
SELECT item_no
FROM qc_sqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
)
ORDER BY ItemNo
</select>
<select id="getSQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
d.item_no as itemNo,
d.item_desc as itemDesc
FROM qc_sqc_detailed_record d
WHERE d.site = #{site}
AND d.bu_no = #{buNo}
AND d.inspection_no = #{inspectionNo}
ORDER BY d.item_no
</select>
<select id="getExistingSQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT TOP 1
template_id as templateId,
item_no as itemNo,
item_desc as itemDesc
FROM qc_sqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
ORDER BY item_no
</select>
<insert id="insertSQCItemDetail" parameterType="java.util.Map">
INSERT INTO qc_sqc_detailed_record (
inspection_no,
template_id,
item_no,
item_desc,
default_value,
min_value,
max_value,
value_type_db,
value_type,
site,
bu_no,
order_id
) VALUES (
#{inspectionNo},
#{templateId},
#{itemNo},
#{itemDesc},
#{defaultValue},
#{minValue},
#{maxValue},
#{valueTypeDb},
#{valueType},
#{site},
#{buNo},
#{orderId}
)
</insert>
<select id="getMaxOrderIdForSQC" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT ISNULL(MAX(order_id), 0)
FROM qc_sqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<delete id="deleteSQCItemDetail" parameterType="java.util.Map">
DELETE FROM qc_sqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<delete id="deleteSQCSubDetailByItem" parameterType="java.util.Map">
DELETE FROM qc_sqc_sub_detail_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<select id="getSQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
SELECT
t.template_id as templateId,
t.template_name as templateName,
t.template_remark as remark,
(SELECT COUNT(*) FROM qc_template_detailed d
WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
FROM qc_template t
WHERE t.site = #{site}
AND t.bu_no = #{buNo}
AND t.inspection_type_no = #{inspectionTypeNo}
<if test="templateId != null and templateId != ''">
AND t.template_id LIKE '%' + #{templateId} + '%'
</if>
<if test="templateDesc != null and templateDesc != ''">
AND t.template_name LIKE '%' + #{templateDesc} + '%'
</if>
ORDER BY t.template_id
</select>
<select id="getExistingSQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
SELECT item_no
FROM qc_sqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<select id="getSQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select
a.site,
a.bu_no,
b.collection_condition as equipmentNo,
#{inspectionNo} as inspectionNo,
a.item_no,
b.collection_source,
#{actionBy} as actionBy,
b.collection_method
from qc_sqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
order by a.order_id
</select>
<!-- 查询工序列表 -->
<select id="getOperationList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT DISTINCT
operation_description as operationDesc
FROM View_IFS_Shop_Order_Operation
WHERE site = #{site}
AND order_no = #{orderNo}
AND release_no = #{releaseNo}
AND sequence_no = #{lineNo}
<!--<choose>
<when test="orderNo != null and orderNo != '' and releaseNo != null and releaseNo != '' and lineNo != null and lineNo != ''">
SELECT DISTINCT
operation_description as operationDesc
FROM View_IFS_Shop_Order_Operation
WHERE site = #{site}
AND order_no = #{orderNo}
AND release_no = #{releaseNo}
AND sequence_no = #{lineNo}
</when>
<otherwise>
SELECT
DISTINCT
a.seqno as seqNo,
a.orderno as orderNo,
j.partNo,
j.PartDescription as partDesc,
j.PartType as invdefinetype,
j.sku,
c.operationDesc as operationDesc,
a.itemno as operationNo,
a.s_resourceid as resourceId,
DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
c.WorkCenterNo
FROM soscheduledrouting as a
inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
WHERE a.site = #{site} and a.seqno = #{seqNo}
</otherwise>
</choose>-->
</select>
<!-- 根据工单号和工序号查出所有数据 -->
<select id="getResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.s_resourceid as resourceId,
DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
c.workCenterNo
FROM soscheduledrouting as a
LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
<!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
ORDER BY a.id desc
</select>
<!-- 查询机台名称 -->
<select id="selectResourceDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT distinct
resourceDesc
FROM WorkCenterResource
WHERE site = #{site} and resourceId = #{resourceId}
</select>
<!-- 查询物料名称 -->
<select id="selectPartDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT distinct
PartDescription as part_desc
FROM part
WHERE site = #{site} and partNo = #{partNo}
</select>
<!-- ================================================= IQC检验维护 ================================================= -->
<!-- 查询IQC基础数据 -->
<select id="selectIQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
qir.inspection_no,
qir.state,
qir.defect_tracking_flag as defectTrackingFlag,
qir.create_date as taskDate,
qir.roll_no,
qir.part_no,
p.PartDescription as part_desc,
p.cinv_source_code,
p.sku as sku,
qir.roll_qty,
qir.print_flag,
qir.inspector_by,
qir.supplier_no,
qir.site,
qir.bu_no,
qir.po_orderNo,
qir.po_itemNo,
qir.roll_count,
qir.document_no
FROM qc_iqc_record as qir
LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
WHERE qir.site in (select site from AccessSite where userID = #{userName})
and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
and qir.detail_flag = 'N'
</select>
<!-- 新增IQC明细记录信息 -->
<insert id="saveIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_iqc_detailed_record (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value, max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
VALUES(#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
</insert>
<!-- 生成IQC检验单号:格式 IQC + YYYYMMDD + 3位流水(与 GetAutogenerateinspectiontasks 一致) -->
<select id="selectIQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
CONVERT(VARCHAR(8), GETDATE(), 112)
+ RIGHT('000' + CONVERT(VARCHAR(3), ISNULL(MAX(CONVERT(INT, RIGHT(inspection_no, 3))), 0) + 1), 3)
FROM qc_iqc_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no LIKE 'IQC' + CONVERT(VARCHAR(8), GETDATE(), 112) + '%'
AND LEN(inspection_no) >= 14
</select>
<!-- 新增IQC主记录信息(刀模新增等直接保存场景) -->
<insert id="saveIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_iqc_record
(inspection_no, site, bu_no, state, create_date, inspection_type_no, part_no, part_desc,
roll_qty, roll_count, roll_no, supplier_no, create_by, inspector_by, detail_flag, submission_type,
tool_instance_id, qualified_supplier_flag, supplier_avl_no, die_mold_type, special_requirements)
VALUES
(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{partNo}, #{partDesc,jdbcType=VARCHAR},
#{rollQty,jdbcType=DECIMAL}, #{rollCount,jdbcType=DECIMAL}, #{rollNo,jdbcType=VARCHAR}, #{supplierNo,jdbcType=VARCHAR}, #{createBy}, #{inspectorBy},
'N', #{taskSource,jdbcType=VARCHAR},
#{toolInstanceId,jdbcType=VARCHAR}, #{qualifiedSupplierFlag,jdbcType=CHAR}, #{supplierAvlNo,jdbcType=VARCHAR}, #{dieMoldType,jdbcType=NVARCHAR}, #{specialRequirements,jdbcType=VARCHAR})
</insert>
<!-- 修改IQC检验记录 -->
<update id="updateIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET inspection_type_no = #{inspectionTypeNo},
sampling_qty = #{samplingQty},
inspection_cycle = #{inspectionCycle},
part_desc = #{partDesc},
detail_flag = 'Y',
state = '未开始',
action_date = null,
action_by = null
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 新增IQC记录后更新送检卷数 -->
<update id="updateIQCRecordRollCountOnAdd" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET roll_count = #{rollCount,jdbcType=DECIMAL}
WHERE site = #{site}
AND bu_no = #{buNo}
AND po_orderNo = #{poOrderNo}
AND po_itemNo = #{poItemNo}
AND part_no = #{partNo}
AND inspection_no = (
SELECT TOP 1 inspection_no
FROM qc_iqc_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND po_orderNo = #{poOrderNo}
AND po_itemNo = #{poItemNo}
AND part_no = #{partNo}
ORDER BY create_date DESC
)
</update>
<!-- 刀模新增后更新扩展字段 -->
<update id="updateIQCRecordDieMoldOnAdd" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET roll_count = #{rollCount,jdbcType=DECIMAL},
roll_qty = #{rollQty,jdbcType=DECIMAL},
supplier_no = #{supplierNo,jdbcType=VARCHAR},
tool_instance_id = #{toolInstanceId,jdbcType=VARCHAR},
qualified_supplier_flag = #{qualifiedSupplierFlag,jdbcType=CHAR},
supplier_avl_no = #{supplierAvlNo,jdbcType=VARCHAR},
die_mold_type = #{dieMoldType,jdbcType=NVARCHAR}
WHERE site = #{site}
AND bu_no = #{buNo}
AND part_no = #{partNo}
AND inspection_no = (
SELECT TOP 1 inspection_no
FROM qc_iqc_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND part_no = #{partNo}
ORDER BY create_date DESC
)
</update>
<!-- 新增检验记录后更新下达号、行号 -->
<update id="updateRecordReleaseNoLineNoOnAdd">
UPDATE
<choose>
<when test="recordType == 'IQC'">qc_iqc_record</when>
<when test="recordType == 'IPQC'">qc_ipqc_record</when>
<when test="recordType == 'FQC'">qc_fqc_record</when>
<when test="recordType == 'OQC'">qc_oqc_record</when>
<when test="recordType == 'SQC'">qc_sqc_record</when>
</choose>
SET release_no = #{data.releaseNo,jdbcType=VARCHAR},
line_no = #{data.lineNo,jdbcType=VARCHAR}
WHERE site = #{data.site}
AND bu_no = #{data.buNo}
<choose>
<when test="data.inspectionNo != null and data.inspectionNo != ''">
AND inspection_no = #{data.inspectionNo}
</when>
<when test="recordType == 'IQC'">
AND po_orderNo = #{data.poOrderNo}
AND po_itemNo = #{data.poItemNo}
AND part_no = #{data.partNo}
AND inspection_no = (
SELECT TOP 1 inspection_no
FROM qc_iqc_record
WHERE site = #{data.site}
AND bu_no = #{data.buNo}
AND po_orderNo = #{data.poOrderNo}
AND po_itemNo = #{data.poItemNo}
AND part_no = #{data.partNo}
ORDER BY create_date DESC
)
</when>
<when test="recordType == 'OQC'">
AND part_no = #{data.partNo}
AND inspector_by = #{data.inspectorBy}
AND inspection_no = (
SELECT TOP 1 inspection_no
FROM qc_oqc_record
WHERE site = #{data.site}
AND bu_no = #{data.buNo}
AND part_no = #{data.partNo}
AND inspector_by = #{data.inspectorBy}
ORDER BY create_date DESC
)
</when>
<otherwise>
AND order_no = #{data.orderNo}
AND seq_no = #{data.seqNo}
AND part_no = #{data.partNo}
AND inspection_no = (
SELECT TOP 1 inspection_no
FROM
<choose>
<when test="recordType == 'IPQC'">qc_ipqc_record</when>
<when test="recordType == 'FQC'">qc_fqc_record</when>
<when test="recordType == 'SQC'">qc_sqc_record</when>
</choose>
WHERE site = #{data.site}
AND bu_no = #{data.buNo}
AND order_no = #{data.orderNo}
AND seq_no = #{data.seqNo}
AND part_no = #{data.partNo}
ORDER BY create_date DESC
)
</otherwise>
</choose>
</update>
<!-- 查询IQC主记录信息 -->
<select id="qcIQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.inspection_no,
a.site,
a.bu_no,
dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
a.state,
a.defect_tracking_flag as defectTrackingFlag,
a.inspection_result,
a.create_date as taskDate,
a.create_date,
a.inspection_type_no,
a.inspection_cycle,
a.part_no,
d.PartDescription as partDesc,
d.cinv_source_code as cinvSourceCode,
d.sku,
d.umid as umId,
um.UMName as umName,
d.PartType as invdefinetype,
d.spec,
a.inspection_remark,
a.roll_qty,
a.sampling_qty,
a.disposal_measures,
a.disposal_remark,
a.inspector_date as inspectorDate,
a.submit_date,
isnull(sub.user_display, a.submit_by) as submitBy,
a.inspector_no,
u.user_display as inspectorName,
a.unqualified_quantity,
a.submit_flag,
a.roll_no,
a.supplier_no,
s.SupplierName as supplierDesc,
a.po_orderNo,
a.po_itemNo,
a.roll_count,
a.roll_count as dhjs,
dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) as orderType,
a.action_date,
isnull(ab.user_display, a.action_by) as actionBy,
isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
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, 'responsible'), '') as responsiblePerson,
isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
a.submission_remark,
a.submission_type as submissionType,
a.tool_instance_id as toolInstanceId,
a.qualified_supplier_flag as qualifiedSupplierFlag,
a.supplier_avl_no as supplierAvlNo,
a.die_mold_type as dieMoldType,
a.batch_no,
a.production_date,
a.expiration_warning_date,
a.expiration_date,
a.pass_qty,
a.not_pass_qty,
a.batch_qualified_qty,
a.release_no as releaseNo,
a.line_no,
a.document_no,
isnull(a.inspector_by, a.create_by) as inspectorBy,
isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
FROM qc_iqc_record as a
inner join part as d on a.site = d.site and a.part_no = d.partNo
left join view_Supplier as s on a.site = s.site and 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
<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})
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</if>
<if test = "query.inspectionNo != null and query.inspectionNo != ''">
AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
</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.inspectionResult != null and query.inspectionResult != ''">
AND a.inspection_result = #{query.inspectionResult}
</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 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>
<if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
</if>
<if test = "query.inspectorName != null and query.inspectorName != ''">
u.user_display LIKE '%' + #{query.inspectorName} + '%'
</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.create_date >= #{query.startDate2}
</if>
<if test="query.endDate2 != null">
AND #{query.endDate2} >= a.create_date
</if>
<if test = "query.poOrderNo != null and query.poOrderNo != ''">
AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
</if>
<if test = "query.poItemNo != null and query.poItemNo != ''">
AND a.po_itemNo LIKE '%' + #{query.poItemNo} + '%'
</if>
<if test = "query.orderType != null and query.orderType != ''">
AND dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) = #{query.orderType}
</if>
<if test = "query.submissionType != null and query.submissionType != ''">
AND a.submission_type = #{query.submissionType}
</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
</select>
<!-- IQC明细记录查询 -->
<select id="iqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.bu_no,
a.inspection_no,
a.template_id,
a.sampling_level_no,
a.sampling_level_desc,
a.sampling_programme_no,
a.sampling_programme_desc,
a.AQL,
a.AC,
a.RE,
a.item_no,
a.item_desc,
a.object_id,
a.object_desc,
a.default_value,
a.min_value,
a.max_value,
a.text_value,
a.number_value,
a.value_type_db,
a.value_type,
case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
a.item_remark as itemRemark,
a.custom1,
a.custom2,
a.custom3,
a.is_submit,
isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
c.method_no,
c.method_name,
c.method_remark,
sw.color_code as qcSpecWarningColorCode,
sw.threshold_value as qcSpecWarningThresholdValue,
a.sampling_qty,
(SELECT TOP 1 epi.collection_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS collectionFlag,
(SELECT TOP 1 epi.image_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS imageFlag,
(SELECT TOP 1 epi.data_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS dataFlag
FROM qc_iqc_detailed_record as a
LEFT JOIN qc_iqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
OUTER APPLY (
SELECT TOP 1
w.color_code,
w.threshold_value
FROM qc_spec_warning w
WHERE w.site = a.site
AND w.bu_no = a.bu_no
AND w.part_no = r.part_no
AND w.item_no = a.item_no
AND w.inspection_type_no = r.inspection_type_no
ORDER BY w.threshold_value
) sw
LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
order by a.order_id
</select>
<!-- 查询IQC的子明细 -->
<select id="selectIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
sub_detail_value,
sampling_location,
is_submit,
sampling_location_b,
num,
sub_detail_value_b,
sub_detail_value_c,
sub_detail_value_d,
sub_detail_value_e,
file_name,
is_transfer,
is_qualified,
defect_qty,
roll_no,
CONVERT(VARCHAR(19), create_time, 120) AS createTime
FROM qc_iqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND sub_detail_value ${collectionDataContent}
</if>
</select>
<!-- 获取该项目的子明细值 -->
<select id="selectIQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT sub_detail_value,
sampling_location,
is_submit
FROM qc_iqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
</select>
<!-- 修改IQC主记录信息 -->
<update id="updateIQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET disposal_measures = #{disposalMeasures},
disposal_remark = #{disposalRemark},
inspection_result = #{inspectionResult},
inspector_no = #{inspectorNo},
state = #{state},
inspection_remark = #{inspectionRemark},
inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
roll_count = #{rollCount,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
pass_qty = #{passQty,jdbcType=DECIMAL},
not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<!-- 修改IQC明细记录信息 -->
<update id="updateIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_detailed_record
SET item_result = #{itemResult},
unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
text_value = #{textValue},
number_value = #{numberValue,jdbcType=DECIMAL},
default_value = #{defaultValue},
min_value = #{minValue,jdbcType=DECIMAL},
max_value = #{maxValue,jdbcType=DECIMAL},
item_remark = #{itemRemark},
custom1 = #{custom1},
custom2 = #{custom2},
custom3 = #{custom3}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 部分更新IQC明细(实测值/结论即时落库,避免 null 覆盖其他字段) -->
<update id="patchIQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_detailed_record
<set>
<if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
<if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
<if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
<if test="textValue != null">text_value = #{textValue},</if>
</set>
WHERE inspection_no = #{inspectionNo}
and RTRIM(item_no) = RTRIM(#{itemNo})
and site = #{site}
and bu_no = #{buNo}
</update>
<!-- 查询该记录明细是否已存在 -->
<select id="checkIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT inspection_no,
template_id
FROM qc_iqc_detailed_record
WHERE inspection_no = #{inspectionNo} and site = #{site}
</select>
<!-- 查询IQC检验记录是否已提交 -->
<select id="checkIQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag
FROM qc_iqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site}
</select>
<!-- 查询IQC检验记录状态(用于保存前校验) -->
<select id="getIQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag, state
FROM qc_iqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 删除IQC子明细的老数据 -->
<delete id="delIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
DELETE FROM qc_iqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 新增IQC子明细信息 -->
<insert id="saveIQCSubDetailed">
INSERT INTO qc_iqc_sub_detail_record
(inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
</foreach>
</insert>
<!-- 修改IQC主记录标识为已提交 -->
<update id="updateIQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET submit_flag = 'Y',
state = '已完成',
submit_date = getDate(),
submit_by = #{updateBy}
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改IQC明细记录标识为已提交 -->
<update id="updateIQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_detailed_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改IQC子明细记录标识为已提交 -->
<update id="updateIQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 删除IQC检验记录 -->
<delete id="deleteIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_iqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除IQC明细记录信息 -->
<delete id="deleteIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_iqc_detailed_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除IQC子明细记录信息 -->
<delete id="deleteIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_iqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 查询文件ID -->
<select id="queryFileId" parameterType="com.gaotao.modules.oss.entity.SysOssEntity" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
SELECT id, file_name
FROM sys_oss
WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
</select>
<!-- 获取工序列表 -->
<select id="getOperationDescList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
SELECT distinct
operationDesc
FROM view_SO_Routing
<where>
<if test = "query.operationDesc != null and query.operationDesc != ''">
AND operationDesc LIKE '%' + #{query.operationDesc} + '%'
</if>
<if test="query.site != null and query.site != ''">
AND site = #{query.site}
</if>
</where>
</select>
<!-- 获取供应商列表 -->
<select id="getManufacturerList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
SELECT
supplierID as manufacturerID,
supplierName as manufacturerName
FROM view_Supplier
<where>
<if test = "query.manufacturerID != null and query.manufacturerID != ''">
AND supplierID LIKE '%' + #{query.manufacturerID} + '%'
</if>
<if test = "query.manufacturerName != null and query.manufacturerName != ''">
AND supplierName LIKE '%' + #{query.manufacturerName} + '%'
</if>
</where>
</select>
<!-- 获取机台列表 -->
<select id="getAllResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT distinct
resourceId,
resourceDesc
FROM WorkCenterResource
<where>
site = #{site}
<if test = "resourceId != null and resourceId != ''">
AND resourceId LIKE '%' + #{resourceId} + '%'
</if>
<if test = "resourceDesc != null and resourceDesc != ''">
AND resourceDesc LIKE '%' + #{resourceDesc} + '%'
</if>
</where>
</select>
<!-- 获取工单列表 -->
<select id="getOrderNoList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT DISTINCT
a.orderno as orderNo
FROM soscheduledrouting as a
LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
<!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
<where>
a.site = #{site}
AND b.approve_qty is not null
<if test = "orderNo != null and orderNo != ''">
AND a.orderno LIKE '%' + #{orderNo} + '%'
</if>
</where>
order by a.orderno DESC
</select>
<!-- 查询FQC主记录信息 -->
<select id="qcFQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
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.create_date,
a.inspection_type_no,
dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
a.inspection_cycle,
a.order_no,
a.operation_desc,
a.resource_id,
r.resourceDesc,
a.part_no,
d.PartDescription as part_desc,
d.cinv_source_code as cinvSourceCode,
d.sku as sku,
d.PartType as invdefinetype,
d.spec,
a.inspection_remark,
a.roll_qty,
a.sampling_qty,
a.disposal_measures,
a.disposal_remark,
a.inspector_date as inspectorDate,
a.submit_date,
isnull(su.user_display, a.submit_by) as submitBy,
a.inspector_no,
u.user_display as inspectorName,
a.ssr_id,
a.unqualified_qty,
a.submit_flag,
a.seq_no,
a.batch_roll_no,
a.special_requirements,
a.work_center_no,
a.roll_no,
a.um_id,
um.UMName as umName,
a.action_date,
isnull(ab.user_display, a.action_by) as actionBy,
isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
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, 'responsible'), '') as responsiblePerson,
isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
a.pass_qty,
a.not_pass_qty,
a.batch_qualified_qty,
a.document_no,
a.release_no as releaseNo,
a.line_no,
isnull(a.inspector_by, a.create_by) as inspectorBy,
isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
FROM qc_fqc_record as a
inner join part as d on a.site = d.site and a.part_no = d.partNo
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 su on a.submit_by = su.username
left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
left join UM as um on a.site = um.site and a.um_id = um.UMID
<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})
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</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.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.disposalMeasures != null and query.disposalMeasures != ''">
AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
</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.inspectionResult != null and query.inspectionResult != ''">
AND a.inspection_result = #{query.inspectionResult}
</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.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.task_date desc
</select>
<insert id="saveFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_fqc_detailed_record
(inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
VALUES
(#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
#{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
#{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
</insert>
<!-- 新增FQC明细记录信息 -->
<insert id="saveFQCDetailedRecords">
INSERT INTO qc_fqc_detailed_record
(inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
#{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
#{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId}, #{item.custom1}, #{item.custom2}, #{item.custom3})
</foreach>
</insert>
<!-- 新增FQC主记录信息 -->
<insert id="saveFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_fqc_record
(inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, create_by, inspector_by)
VALUES
(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
#{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
#{createBy}, #{inspectorBy})
</insert>
<!-- FQC明细记录查询 -->
<select id="fqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.bu_no,
a.inspection_no,
a.order_no,
a.template_id,
a.sampling_level_no,
a.sampling_level_desc,
a.sampling_programme_no,
a.sampling_programme_desc,
a.AQL,
a.AC,
a.RE,
a.item_no,
a.item_desc,
a.object_id,
a.object_desc,
a.default_value,
a.min_value,
a.max_value,
a.text_value,
a.number_value,
a.value_type_db,
a.value_type,
case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
a.item_remark as itemRemark,
a.custom1,
a.custom2,
a.custom3,
a.is_submit,
isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
a.sampling_qty,
dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
c.method_no,
c.method_name,
c.method_remark,
sw.color_code as qcSpecWarningColorCode,
sw.threshold_value as qcSpecWarningThresholdValue,
(SELECT TOP 1 epi.collection_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS collectionFlag,
(SELECT TOP 1 epi.image_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS imageFlag,
(SELECT TOP 1 epi.data_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS dataFlag
FROM qc_fqc_detailed_record as a
LEFT JOIN qc_fqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
OUTER APPLY (
SELECT TOP 1
w.color_code,
w.threshold_value
FROM qc_spec_warning w
WHERE w.site = a.site
AND w.bu_no = a.bu_no
AND w.part_no = r.part_no
AND w.item_no = a.item_no
AND w.inspection_type_no = r.inspection_type_no
ORDER BY w.threshold_value
) sw
LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
order by a.order_id
</select>
<!-- 删除FQC检验记录 -->
<delete id="deleteFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_fqc_record
WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</delete>
<!-- 删除FQC明细记录信息 -->
<delete id="deleteFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_fqc_detailed_record
WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</delete>
<!-- 删除FQC子明细记录信息 -->
<delete id="deleteFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_fqc_sub_detail_record
WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</delete>
<!-- 任务重载:修改FQC检验记录 -->
<update id="updateFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_record
SET inspection_type_no = #{inspectionTypeNo},
sampling_qty = #{samplingQty},
inspection_cycle = #{inspectionCycle},
state = '未开始',
inspection_result = null,
disposal_measures = null,
disposal_remark = null,
inspection_remark = null,
inspector_no = null,
inspector_date = null,
submit_flag = 'N',
action_date = null,
action_by = null,
pass_qty = null,
not_pass_qty = null,
unqualified_qty = null,
batch_qualified_qty = null
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改FQC主记录信息 -->
<update id="updateFQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_record
SET disposal_measures = #{disposalMeasures},
disposal_remark = #{disposalRemark},
inspection_result = #{inspectionResult},
inspector_no = #{inspectorNo},
state = #{state},
inspection_remark = #{inspectionRemark},
inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
roll_qty = #{rollQty,jdbcType=DECIMAL},
unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
pass_qty = #{passQty,jdbcType=DECIMAL},
not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
</update>
<!-- 修改FQC明细记录信息 -->
<update id="updateFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_detailed_record
SET item_result = #{itemResult},
unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
text_value = #{textValue},
number_value = #{numberValue,jdbcType=DECIMAL},
default_value = #{defaultValue},
min_value = #{minValue,jdbcType=DECIMAL},
max_value = #{maxValue,jdbcType=DECIMAL},
item_remark = #{itemRemark},
custom1 = #{custom1},
custom2 = #{custom2},
custom3 = #{custom3}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="patchFQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_detailed_record
<set>
<if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
<if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
<if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
<if test="textValue != null">text_value = #{textValue},</if>
</set>
WHERE inspection_no = #{inspectionNo}
and RTRIM(item_no) = RTRIM(#{itemNo})
and site = #{site}
and bu_no = #{buNo}
</update>
<!-- 修改FQC主记录标识为已提交 -->
<update id="updateFQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_record
SET submit_flag = 'Y',
state = '已完成',
submit_date = getDate(),
submit_by = #{updateBy}
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改FAI明细记录标识为已提交 -->
<update id="updateFQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_detailed_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改子明细记录标识为已提交 -->
<update id="updateFQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 删除子明细的老数据 -->
<delete id="delFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
DELETE FROM qc_fqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 新增子明细信息 -->
<insert id="saveFQCSubDetailed">
INSERT INTO qc_fqc_sub_detail_record
(inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
</foreach>
</insert>
<!-- 查询FQC的子明细 -->
<select id="selectFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
sub_detail_value,
sampling_location,
is_submit,
sampling_location_b,
num,
sub_detail_value_b,
sub_detail_value_c,
sub_detail_value_d,
sub_detail_value_e,
file_name,
is_transfer,
is_qualified,
defect_qty,
roll_no,
CONVERT(VARCHAR(19), create_time, 120) AS createTime
FROM qc_fqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND sub_detail_value ${collectionDataContent}
</if>
</select>
<!-- 查询FQC检验记录是否已提交 -->
<select id="checkFQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag
FROM qc_fqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 查询FQC检验记录状态(用于保存前校验) -->
<select id="getFQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag, state
FROM qc_fqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<!-- 获取该项目的子明细值 -->
<select id="selectFQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT sub_detail_value,
sampling_location,
is_submit
FROM qc_fqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
</select>
<!-- 生成FQC检验单号 -->
<select id="selectFQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
FROM qc_fqc_record
WHERE site = #{site} and bu_no = #{buNo}
</select>
<!-- 生成IPQC检验单号 -->
<select id="selectIPQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
FROM qc_ipqc_record
WHERE site = #{site} and bu_no = #{buNo}
</select>
<!-- 生成FAI检验单号 -->
<select id="selectFAIInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
FROM qc_fai_record
WHERE site = #{site} and bu_no = #{buNo}
</select>
<!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
<select id="queryDataFromViewPoOrder" resultType="com.gaotao.modules.pms.data.PoOrderData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
site,
order_no,
item_no,
part_no,
part_desc,
spec,
supplier_id,
supplier_name,
order_qty,
created_date,
status,
citem_code,
citem_class,
sendto_address,
order_type
FROM view_po_order
WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
</select>
<!-- 向收货任务表里添加数据 -->
<insert id="saveReceivingTask" parameterType="com.gaotao.modules.pms.data.PoOrderData">
INSERT INTO receiving_task (site, order_no, item_no, part_no, part_desc, spec, supplier_id, supplier_name, order_qty, created_date, status, citem_code, citem_class, sendto_address, order_type, inspection_no, batch_no, production_date, expiration_warning_date, expiration_date)
VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}, #{batchNo}, #{productionDate}, #{expirationWarningDate}, #{expirationDate})
</insert>
<!-- 检查动控是否开启 -->
<select id="queryController" parameterType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity" resultType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity">
SELECT
type,
base_data,
base_desc,
status,
remark,
third_type,
second_type,
page_control,
control_style
FROM sys_scene_dynamic_control_model
where site = #{site} and control_no = #{controlNo}
</select>
<!-- 查询检验模板列表 -->
<select id="queryTemplateList" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
SELECT
site,
bu_no,
template_id as templateId,
template_name as templateName,
dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
FROM qc_template
<where>
site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
<if test = "templateId != null and templateId != ''">
AND template_id LIKE '%' + #{templateId}+'%'
</if>
<if test = "templateName != null and templateName != ''">
AND template_name LIKE '%' + #{templateName}+'%'
</if>
<if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
AND inspection_type_no = #{inspectionTypeNo}
</if>
</where>
</select>
<!-- 查询检验模板列表 -->
<select id="getPartInformation" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
select
partNo,
PartDescription as partDesc,
spec,
sku,
DefaultWarehouseID as defaultWarehouseId
from part
where site = #{site} and partNo = #{partNo}
</select>
<!-- 获取特殊工序列表 -->
<select id="getSpecialOperationList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
select
site,
operation_no,
operation_desc
from qc_special_task_operation
where site = #{site}
</select>
<!-- 获取处置措施列表 -->
<select id="disposalMeasuresSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
id,
disposal_measures
FROM qc_disposal_measures
<where>
<if test = "inspectionTypeNo != '101'">
inspection_type != 'IPQC'
</if>
</where>
</select>
<!-- 查询文件路径 -->
<select id="searchItemFileUrl" resultType="com.gaotao.modules.oss.entity.SysOssEntity" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
id,
url,
file_name
FROM sys_oss
WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
</select>
<!-- 删除图片-->
<delete id="imageDelete" parameterType="com.gaotao.modules.oss.entity.SysOssEntity">
DELETE FROM sys_oss
WHERE id = #{id}
</delete>
<!-- 模糊查询标签号 -->
<select id="getRollNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT DISTINCT top 3
a.seqno,
a.orderno,
b.RollNo
FROM soscheduledrouting AS a
LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
WHERE a.site = #{site} and b.RollNo like '%' + #{rollNo} + '%'
</select>
<!-- 标签号回车事件 -->
<select id="rollNoEnter" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.seqno as seqNo,
a.orderno as orderNo,
b.RollNo,
#{inspectionTypeNo} as inspectionTypeNo
FROM soscheduledrouting AS a
LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
WHERE a.site = #{site} and b.RollNo = #{rollNo}
</select>
<!-- 查询物料列表 -->
<select id="queryPartList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
site,
partNo,
PartDescription as partDesc,
PartType as invdefinetype,
sku,
spec,
cinv_source_code as cinvSourceCode
FROM part
<where>
site = #{site}
<if test = "partNo != null and partNo != ''">
AND partNo LIKE '%' + #{partNo} + '%'
</if>
<if test = "partDesc != null and partDesc != ''">
AND PartDescription LIKE '%' + #{partDesc} + '%'
</if>
<if test = "sku != null and sku != ''">
AND sku LIKE '%' + #{sku} + '%'
</if>
<if test = "cinvSourceCode != null and cinvSourceCode != ''">
AND cinv_source_code LIKE '%' + #{cinvSourceCode} + '%'
</if>
</where>
order by partNo
</select>
<!-- 查询物料列表(分页) -->
<select id="queryPartListPage" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
site,
partNo,
PartDescription as partDesc,
PartType as invdefinetype,
sku,
spec,
cinv_source_code as cinvSourceCode
FROM part
<where>
site = #{query.site}
<if test = "query.partNo != null and query.partNo != ''">
AND partNo LIKE '%' + #{query.partNo} + '%'
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND PartDescription LIKE '%' + #{query.partDesc} + '%'
</if>
<if test = "query.sku != null and query.sku != ''">
AND sku LIKE '%' + #{query.sku} + '%'
</if>
<if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
</if>
</where>
order by partNo
</select>
<!-- 查询单位列表 -->
<select id="umSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
site,
UMID as umId,
UMName as umName
FROM UM
WHERE active = #{active}
</select>
<!-- 查询单位列表 -->
<select id="checkItem" resultType="com.gaotao.modules.pms.data.SubDetailValues" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
inspection_no,
item_no,
value_type_db,
min_value,
max_value
FROM
<choose>
<when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
<when test="flag == 'sqc'">qc_sqc_detailed_record</when>
<when test="flag == 'fqc'">qc_fqc_detailed_record</when>
<when test="flag == 'fai'">qc_fai_detailed_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
<when test="flag == 'pqc'">qc_pqc_detailed_record</when>
<otherwise>qc_iqc_detailed_record</otherwise>
</choose>
WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
order by order_id
</select>
<!-- 修改detailFlag字段为N -->
<update id="updateIQCDetailFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET detail_flag = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<select id="searchSeqInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.order_no as orderNo,
a.release_no as releaseNo,
a.sequence_no as [lineNo],
a.part_no as partNo,
a.part_description as partDesc,
a.lot_size as lotsize,
a.planner,
a.status
FROM View_IFS_Shop_Order a
WHERE a.site = #{query.site}
<if test="query.userName != null and query.userName != ''">
AND a.site in (Select Site from AccessSite where upper(UserID) = #{query.userName})
</if>
<if test="query.status != null and query.status != ''">
AND a.status = #{query.status}
</if>
<if test="query.orderNo != null and query.orderNo != ''">
AND a.order_no LIKE '%' + #{query.orderNo} + '%'
</if>
<if test="query.releaseNo != null and query.releaseNo != ''">
AND a.release_no LIKE '%' + #{query.releaseNo} + '%'
</if>
<if test="query.lineNo != null and query.lineNo != ''">
AND a.sequence_no LIKE '%' + #{query.lineNo} + '%'
</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 a.part_description LIKE '%' + #{query.partDesc} + '%'
</if>
</select>
<!-- 查询采购订单信息(IQC新增) -->
<select id="searchPoOrderInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
v.site,
v.poOrderNo,
v.poOrderItemNo as poItemNo,
CAST(v.poOrderLineNo AS VARCHAR(20)) as releaseNo,
CAST(v.receiptNo AS VARCHAR(20)) as receiptItemNo,
CAST(v.receiptNo AS VARCHAR(20)) as receiptNo,
v.partNo,
p.PartDescription as partDesc,
p.spec,
v.supplierNo,
s.SupplierName as supplierDesc,
v.orderQty as lotsize,
p.PartType as invdefinetype,
v.receivedQty as currentArrivalQty,
ISNULL(v.qtyInspected, 0) as allowInQty,
ISNULL(v.qtyToInspected, 0) as pendingInspectQty,
ISNULL(v.qtyInspected, 0) as inspectedQty,
v.umId,
um.UMName as umName
FROM View_Purchase_Order_List v
LEFT JOIN part p ON v.site = p.site AND v.partNo = p.PartNo
LEFT JOIN Supplier s ON v.supplierNo = s.SupplierID
LEFT JOIN UM um ON v.site = um.site AND v.umId = um.UMID
WHERE v.site = #{query.site}
AND CAST(v.poOrderNo AS VARCHAR(50)) LIKE '%' + #{query.poOrderNo} + '%'
<if test="query.poItemNo != null and query.poItemNo != ''">
AND CAST(v.poOrderItemNo AS VARCHAR(20)) LIKE '%' + #{query.poItemNo} + '%'
</if>
<if test="query.releaseNo != null and query.releaseNo != ''">
AND CAST(v.poOrderLineNo AS VARCHAR(20)) LIKE '%' + #{query.releaseNo} + '%'
</if>
<if test="query.receiptNo != null and query.receiptNo != ''">
AND CAST(v.receiptNo AS VARCHAR(20)) LIKE '%' + #{query.receiptNo} + '%'
</if>
<if test="query.partNo != null and query.partNo != ''">
AND v.partNo LIKE '%' + #{query.partNo} + '%'
</if>
<if test="query.partDesc != null and query.partDesc != ''">
AND p.PartDescription LIKE '%' + #{query.partDesc} + '%'
</if>
<if test="query.supplierNo != null and query.supplierNo != ''">
AND v.supplierNo LIKE '%' + #{query.supplierNo} + '%'
</if>
<if test="query.supplierDesc != null and query.supplierDesc != ''">
AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
</if>
</select>
<!--
IQC批量新增:采购接收单查询(可不填PO;支持供应商、接收日期)
依赖 View_Purchase_Order_List 提供:receivedDate(接收日期)、batchNo(供应商批次)
若视图暂无这两列,请先执行 db/view_purchase_order_list_batch_fields.sql 说明让 Mingo 补齐
-->
<select id="searchPoOrderInfoForBatch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
v.site,
v.poOrderNo,
v.poOrderItemNo as poItemNo,
CAST(v.poOrderLineNo AS VARCHAR(20)) as releaseNo,
CAST(v.receiptNo AS VARCHAR(20)) as receiptItemNo,
CAST(v.receiptNo AS VARCHAR(20)) as receiptNo,
v.partNo,
p.PartDescription as partDesc,
p.spec,
v.supplierNo,
s.SupplierName as supplierDesc,
v.orderQty as lotsize,
p.PartType as invdefinetype,
v.receivedQty as currentArrivalQty,
ISNULL(v.qtyInspected, 0) as allowInQty,
ISNULL(v.qtyToInspected, 0) as pendingInspectQty,
ISNULL(v.qtyInspected, 0) as inspectedQty,
v.umId,
um.UMName as umName<!--,
v.batchNo as batchNo,
v.receivedDate as arrivalDate-->
FROM View_Purchase_Order_List v
LEFT JOIN part p ON v.site = p.site AND v.partNo = p.PartNo
LEFT JOIN Supplier s ON v.supplierNo = s.SupplierID
LEFT JOIN UM um ON v.site = um.site AND v.umId = um.UMID
WHERE v.site = #{query.site}
<if test="query.poOrderNo != null and query.poOrderNo != ''">
AND CAST(v.poOrderNo AS VARCHAR(50)) LIKE '%' + #{query.poOrderNo} + '%'
</if>
<if test="query.poItemNo != null and query.poItemNo != ''">
AND CAST(v.poOrderItemNo AS VARCHAR(20)) LIKE '%' + #{query.poItemNo} + '%'
</if>
<if test="query.releaseNo != null and query.releaseNo != ''">
AND CAST(v.poOrderLineNo AS VARCHAR(20)) LIKE '%' + #{query.releaseNo} + '%'
</if>
<if test="query.receiptNo != null and query.receiptNo != ''">
AND CAST(v.receiptNo AS VARCHAR(20)) LIKE '%' + #{query.receiptNo} + '%'
</if>
<if test="query.partNo != null and query.partNo != ''">
AND v.partNo LIKE '%' + #{query.partNo} + '%'
</if>
<if test="query.partDesc != null and query.partDesc != ''">
AND p.PartDescription LIKE '%' + #{query.partDesc} + '%'
</if>
<if test="query.supplierNo != null and query.supplierNo != ''">
AND v.supplierNo LIKE '%' + #{query.supplierNo} + '%'
</if>
<if test="query.supplierDesc != null and query.supplierDesc != ''">
AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
</if>
<if test="query.startDate != null">
AND v.receivedDate &gt;= #{query.startDate}
</if>
<if test="query.endDate != null">
AND v.receivedDate &lt;= #{query.endDate}
</if>
ORDER BY v.poOrderNo, v.poOrderItemNo
</select>
<select id="searchPartInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
select
partNo,
PartDescription as partDesc,
PartType as invdefinetype,
sku,
bu_no
from
part
where
bu_no = #{query.buNo}
<if test="query.site != null and query.site != ''">
AND site = #{query.site}
</if>
<if test="query.type != null and query.type != ''">
AND PartType = #{query.type}
</if>
<if test="query.handle != null and query.handle != ''">
AND handle = #{query.handle}
</if>
<if test="query.partNo != null and query.partNo != ''">
AND partNo LIKE '%' + #{query.partNo} + '%'
</if>
<if test="query.partDesc != null and query.partDesc != ''">
AND PartDescription LIKE '%' + #{query.partDesc} + '%'
</if>
<if test="query.sku != null and query.sku != ''">
AND sku LIKE '%' + #{query.sku} + '%'
</if>
<if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
</if>
order by partNo
</select>
<select id="getInterfaceTimeData" parameterType="String" resultType="com.gaotao.modules.pms.data.InterfaceTimeData">
SELECT
id,
start_time,
end_time,
del_flag
FROM interface_time
WHERE del_flag = 'N' and site = #{site}
</select>
<update id="updateInterfaceTimeData" parameterType="com.gaotao.modules.pms.data.InterfaceTimeData">
UPDATE interface_time
set
updated_by = #{updatedBy},
updated_date = #{updatedDate},
del_flag = #{delFlag}
</update>
<select id="getInterfaceRdStyleData" parameterType="String" resultType="com.gaotao.modules.pms.data.RdStyleData">
SELECT
crdcode,
crdname,
iRdGrade,
rdtype,
brdend
FROM view_custdev_mes_rdstyle
WHERE crdname = #{crdName}
</select>
<insert id="insertHardtagPurchaseInStorageData" parameterType="com.gaotao.modules.pms.data.HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
INSERT INTO purchase_in_storage_count
(site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
#{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
</insert>
<insert id="batchSaveHrdtagTransHeader" parameterType="com.gaotao.modules.pms.data.HardtagTransHeaderData">
insert into TransHeader
(TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
#{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
#{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
</insert>
<insert id="batchSaveHardtagTransDetail" parameterType="com.gaotao.modules.pms.data.HardtagTransDetailData">
INSERT INTO TransDetail
(TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
values
(#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
</insert>
<select id="getSendMailAddress" parameterType="String" resultType="com.gaotao.modules.pms.data.MailAddressData">
SELECT
id,
site,
bu_no,
mail_address,
send_type,
del_flag,
created_by,
created_date,
orderref1
FROM mailAddress
WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
<if test="buNo != null and buNo != ''">
AND bu_no = #{buNo}
</if>
</select>
<select id="getSendMailFromAddress" resultType="com.gaotao.modules.pms.data.MailSendAddressData">
SELECT
port,
host,
username,
password,
emailForm,
timeout,
personal,
id
FROM mailSendAddress
where delFlag = 'N'
</select>
<!-- 新增发送邮件记录 -->
<insert id="saveSendMailRecord" parameterType="com.gaotao.modules.pms.data.SendMailRecord">
insert into send_mail_record
(site, bu_no, document_no, sender, recipient, send_date, type)
values
(#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate(), #{type})
</insert>
<select id="orderTypeSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT distinct
order_type
FROM view_po_order
</select>
<update id="actionIQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
update qc_iqc_record
set action_date = getDate(),
action_by = #{actionBy},
state = #{state}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<update id="actionFAIInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
update qc_fai_record
set action_date = getDate(),
action_by = #{actionBy},
state = #{state}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<update id="actionIPQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
update qc_ipqc_record
set action_date = getDate(),
action_by = #{actionBy},
state = #{state}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<update id="actionFQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
update qc_fqc_record
set action_date = getDate(),
action_by = #{actionBy},
state = #{state}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<insert id="addEquipmentDataAcquisition">
insert into Equipment_data_acquisition
(site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
values
<foreach collection="list" item="item" separator=",">
(#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
</foreach>
</insert>
<!-- 新增人员信息 -->
<insert id="saveOperator" >
INSERT INTO eam_actual_operator
(site, order_no, function_type, operator, bu_no)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
</foreach>
</insert>
<!-- 删除之前的人员-->
<delete id="delOperator" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM eam_actual_operator
WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
</delete>
<select id="getInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select distinct
site,
bu_no,
equipment_no,
inspection_no,
item_no,
collection_source,
collection_method,
batch_no,
accumulate_collect,
delete_after_collect
from Equipment_data_acquisition
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<select id="getInspectionNoByItem" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select distinct
site,
bu_no,
equipment_no,
inspection_no,
item_no,
collection_source,
collection_method,
batch_no,
accumulate_collect,
delete_after_collect
from Equipment_data_acquisition
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
</select>
<select id="dataAcquisition" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
select
id,
site,
bu_no,
#{inspectionNo} as inspectionNo,
#{itemNo} as itemNo,
<if test='subDetailValueType == 0'>
${collectionSource} as subDetailValue,
</if>
<if test='subDetailValueType == 1'>
${collectionSource} as subDetailValueB,
</if>
<if test='subDetailValueType == 2'>
${collectionSource} as subDetailValueC,
</if>
<if test='subDetailValueType == 3'>
${collectionSource} as subDetailValueD,
</if>
<if test='subDetailValueType == 4'>
${collectionSource} as subDetailValueE,
</if>
num,
#{collectionSource} as collectionSource,
#{collectionMethod} as collectionMethod
from Equipment_data_detail
where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
<if test='collectionMethod == "plc"'>
AND inspection_no = #{inspectionNo}
</if>
<if test='collectionMethod == "RS232"'>
AND (inspection_no is null or inspection_no = '')
</if>
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND ${collectionSource} ${collectionDataContent}
</if>
<if test='standardMode != null and standardMode'>
AND source_column_no IS NULL
AND (serial_no IS NULL OR serial_no = '')
</if>
and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
</select>
<select id="dataAcquisitionB" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
select
id,
site,
bu_no,
#{inspectionNo} as inspectionNo,
#{itemNo} as itemNo,
${collectionSource} as subDetailValueB,
num,
#{collectionSource} as collectionSource
from Equipment_data_detail
where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
<if test='collectionMethod == "plc"'>
AND inspection_no = #{inspectionNo}
</if>
<if test='collectionMethod == "RS232"'>
AND (inspection_no is null or inspection_no = '')
</if>
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND ${collectionSource} ${collectionDataContent}
</if>
and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
</select>
<select id="dataAcquisition2" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
select
site as orderRef1,
bu_no as orderRef4,
#{inspectionNo} as orderRef2,
#{itemNo} as orderRef3,
${collectionSource} as url
from Equipment_data_detail
where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
<if test = "collectionDataContent != null and collectionDataContent != ''">
AND ${collectionSource} ${collectionDataContent}
</if>
and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
</select>
<select id="getIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select
a.site,
a.bu_no,
b.collection_condition as equipmentNo,
#{inspectionNo} as inspectionNo,
a.item_no,
b.collection_source,
#{actionBy} as actionBy,
b.collection_method
from qc_iqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="getFAIDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select
a.site,
a.bu_no,
b.collection_condition as equipmentNo,
#{inspectionNo} as inspectionNo,
a.item_no,
b.collection_source,
#{actionBy} as actionBy,
b.collection_method
from qc_fai_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
order by order_id
</select>
<select id="getIPQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select
a.site,
a.bu_no,
b.collection_condition as equipmentNo,
#{inspectionNo} as inspectionNo,
a.item_no,
b.collection_source,
#{actionBy} as actionBy,
b.collection_method
from qc_ipqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="getFQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
select
a.site,
a.bu_no,
b.collection_condition as equipmentNo,
#{inspectionNo} as inspectionNo,
a.item_no,
b.collection_source,
#{actionBy} as actionBy,
b.collection_method
from qc_fqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="querySubDetails" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
select
b.site,
b.bu_no,
b.inspection_no,
b.item_no,
b.default_value,
b.min_value,
b.max_value,
b.value_type_db,
a.sub_detail_value
<if test="flag == 'iqc'">
from qc_iqc_sub_detail_record as a
left join qc_iqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
</if>
<if test="flag == 'ipqc'">
from qc_ipqc_sub_detail_record as a
left join qc_ipqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
</if>
<if test="flag == 'sqc'">
from qc_sqc_sub_detail_record as a
left join qc_sqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
</if>
<if test="flag == 'fqc'">
from qc_fqc_sub_detail_record as a
left join qc_fqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
</if>
<if test="flag == 'fai'">
from qc_fai_sub_detail_record as a
left join qc_fai_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
</if>
<if test="flag == 'fqas' or flag == 'oqc'">
from qc_oqc_sub_detail_record as a
left join qc_oqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
</if>
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
order by b.order_id
</select>
<insert id="saveFileList">
INSERT INTO sys_oss
(url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
</foreach>
</insert>
<select id="getEquipmentNoList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
select
equipment_no
from Equipment_folder_location
where site = #{site} and bu_no = #{buNo}
</select>
<select id="getEquipmentClassificationList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
select distinct
equipment_classification
from Equipment_folder_location
where site = #{site} and bu_no = #{buNo}
and equipment_classification is not null
and equipment_classification != ''
order by equipment_classification
</select>
<!-- 获取责任人员列表 -->
<select id="getResponsibleOperatorList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
SELECT
DISTINCT
OperatorID as adminID,
OperatorName as adminName
FROM operator
<where>
site in (select site from AccessSite where userID = #{userName})
<if test = "adminID != null and adminID != ''">
AND OperatorID LIKE '%' + #{adminID} + '%'
</if>
<if test = "adminName != null and adminName != ''">
AND OperatorName LIKE '%' + #{adminName} + '%'
</if>
</where>
</select>
<select id="getDataContentList" parameterType="com.gaotao.modules.pms.data.QcCollectionDataContentData" resultType="com.gaotao.modules.pms.data.QcCollectionDataContentData">
select
content_desc
from qc_collection_data_content
where site = #{site} and bu_no = #{buNo} and active = 'Y'
</select>
<select id="getItemCollectionDataContent" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="string">
select
collection_data_content
from eam_properties_item
where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
</select>
<!-- 获取当前项目不包含的设备 -->
<select id="getObjectList1" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
SELECT
a.site,
a.bu_no,
a.equipment_no as ObjectID,
a.equipment_desc as ObjectDesc
FROM Equipment_folder_location as a
left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.equipment_no = b.ObjectID and b.ItemNo = #{itemNo}
where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null
</select>
<!-- 获取当前项目所包含的设备 -->
<select id="getObjectList2" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
SELECT
a.site,
a.bu_no,
a.ObjectID,
b.equipment_desc as ObjectDesc,
a.default_flag
FROM qc_item_object a
LEFT JOIN Equipment_folder_location b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.equipment_no
WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
</select>
<!-- 获取当前项目不包含的设备 -->
<select id="getObjectListBy" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
SELECT
a.site,
a.bu_no,
a.equipment_no as ObjectID,
a.equipment_desc as ObjectDesc
FROM Equipment_folder_location as a
left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.equipment_no = b.ObjectID and b.ItemNo = #{itemNo}
<where>
a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null
<if test = "objectID != null and objectID != ''">
AND a.equipment_no LIKE '%' + #{objectID} + '%'
</if>
<if test = "objectDesc != null and objectDesc != ''">
AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
</if>
</where>
order by a.equipment_no
</select>
<!-- 新增项目设备 -->
<insert id="addItemObject">
INSERT INTO qc_item_object
(site, bu_no, ItemNo, ObjectID, default_flag)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
</foreach>
</insert>
<delete id="deleteItemObject">
DELETE FROM qc_item_object
WHERE
<foreach collection="list" item="item" separator=" or " index="index">
(site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
</foreach>
</delete>
<update id="updateItemObject">
UPDATE qc_item_object
SET default_flag = #{defaultFlag}
WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
</update>
<select id="getIQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
select
a.site,
a.bu_no,
a.inspection_no,
a.item_no,
a.item_desc,
b.collection_source,
b.collection_method,
b.equipment_classification
from qc_iqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="getFAIInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
select
a.site,
a.bu_no,
a.inspection_no,
a.item_no,
a.item_desc,
b.collection_source,
b.collection_method,
b.equipment_classification
from qc_fai_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="getFQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
select
a.site,
a.bu_no,
a.inspection_no,
a.item_no,
a.item_desc,
b.collection_source,
b.collection_method,
b.equipment_classification
from qc_fqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
order by a.order_id
</select>
<select id="getIPQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
select
a.site,
a.bu_no,
a.inspection_no,
a.item_no,
a.item_desc,
b.collection_source,
b.collection_method,
b.equipment_classification
from qc_ipqc_detailed_record as a
left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
order by a.order_id
</select>
<delete id="deleteEquipmentDataAcquisition" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
delete from Equipment_data_acquisition
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</delete>
<!-- IPQC检验项目操作相关SQL -->
<!-- 查询可选的IPQC检验项目(未添加到当前检验单的) -->
<select id="getIPQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
ItemNo as itemNo,
ItemDesc as itemDesc,
DefaultValue as defaultValue,
MaxValue as maxValue,
MinValue as minValue,
ValueType as valueType,
ValueType_DB as valueTypeDb
FROM eam_properties_item
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_type_no = '101'
<if test="itemNo != null and itemNo != ''">
AND ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
AND ItemNo NOT IN (
SELECT item_no
FROM qc_ipqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
)
ORDER BY ItemNo
</select>
<!-- 查询已有的IPQC检验项目(当前检验单已添加的) -->
<select id="getIPQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
d.item_no as itemNo,
d.item_desc as itemDesc
FROM qc_ipqc_detailed_record d
WHERE d.site = #{site}
AND d.bu_no = #{buNo}
AND d.inspection_no = #{inspectionNo}
ORDER BY d.item_no
</select>
<!-- 查询当前检验单已有的项目(用于获取template_id) -->
<select id="getExistingIPQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT TOP 1
template_id as templateId,
item_no as itemNo,
item_desc as itemDesc
FROM qc_ipqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
ORDER BY item_no
</select>
<!-- 插入IPQC检验项目明细 -->
<insert id="insertIPQCItemDetail" parameterType="java.util.Map">
INSERT INTO qc_ipqc_detailed_record (
inspection_no,
order_no,
template_id,
item_no,
item_desc,
default_value,
min_value,
max_value,
value_type_db,
value_type,
site,
bu_no,
foreign_flag,
order_id
) VALUES (
#{inspectionNo},
#{orderNo},
#{templateId},
#{itemNo},
#{itemDesc},
#{defaultValue},
#{minValue},
#{maxValue},
#{valueTypeDb},
#{valueType},
#{site},
#{buNo},
#{foreignFlag},
#{orderId}
)
</insert>
<!-- 获取检验单中最大的order_id -->
<select id="getMaxOrderIdForIPQC" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT ISNULL(MAX(order_id), 0)
FROM qc_ipqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 删除IPQC检验项目明细 -->
<delete id="deleteIPQCItemDetail" parameterType="java.util.Map">
DELETE FROM qc_ipqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 删除IPQC检验项目的子明细 -->
<delete id="deleteIPQCSubDetailByItem" parameterType="java.util.Map">
DELETE FROM qc_ipqc_sub_detail_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- IPQC模板导入相关SQL -->
<!-- 查询IPQC模板列表 -->
<select id="getIPQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
SELECT
t.template_id as templateId,
t.template_name as templateName,
t.template_remark as remark,
(SELECT COUNT(*) FROM qc_template_detailed d
WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
FROM qc_template t
WHERE t.site = #{site}
AND t.bu_no = #{buNo}
AND t.inspection_type_no = '101'
<if test="templateId != null and templateId != ''">
AND t.template_id LIKE '%' + #{templateId} + '%'
</if>
<if test="templateDesc != null and templateDesc != ''">
AND t.template_name LIKE '%' + #{templateDesc} + '%'
</if>
ORDER BY t.template_id
</select>
<!-- 查询模板的所有检验项目(按order_id排序) -->
<select id="getTemplateItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
d.ItemNo as itemNo,
p.ItemDesc as itemDesc,
d.default_value as defaultValue,
d.max_value as maxValue,
d.min_value as minValue,
p.ValueType as valueType,
p.ValueType_DB as valueTypeDb,
d.order_id as orderId
FROM qc_template_detailed d
LEFT JOIN eam_properties_item p
ON d.site = p.site
AND d.bu_no = p.bu_no
AND d.ItemNo = p.ItemNo
WHERE d.site = #{site}
AND d.bu_no = #{buNo}
AND d.template_id = #{templateId}
ORDER BY COALESCE(d.order_id, 99999) ASC, d.ItemNo ASC
</select>
<!-- 查询检验单已有的项目编码列表 -->
<select id="getExistingItemNos" parameterType="java.util.Map" resultType="java.lang.String">
SELECT item_no
FROM qc_ipqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- ======================== IQC检验项目操作和模板导入 ======================== -->
<!-- 查询IQC可选的检验项目 -->
<select id="getIQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
ItemNo as itemNo,
ItemDesc as itemDesc,
DefaultValue as defaultValue,
MaxValue as maxValue,
MinValue as minValue,
ValueType as valueType,
ValueType_DB as valueTypeDb
FROM eam_properties_item
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_type_no = '105'
<if test="itemNo != null and itemNo != ''">
AND ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
AND ItemNo NOT IN (
SELECT item_no
FROM qc_iqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
)
ORDER BY ItemNo
</select>
<!-- 查询IQC已选的检验项目 -->
<select id="getIQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
d.item_no as itemNo,
d.item_desc as itemDesc
FROM qc_iqc_detailed_record d
WHERE d.site = #{site}
AND d.bu_no = #{buNo}
AND d.inspection_no = #{inspectionNo}
ORDER BY d.item_no
</select>
<!-- 查询当前IQC检验单已有的项目 -->
<select id="getExistingIQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT TOP 1
template_id as templateId,
item_no as itemNo,
foreign_flag as foreignFlag
FROM qc_iqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 插入IQC检验项目 -->
<insert id="insertIQCItemDetail" parameterType="java.util.Map">
INSERT INTO qc_iqc_detailed_record (
inspection_no,
template_id,
item_no,
item_desc,
default_value,
min_value,
max_value,
value_type_db,
value_type,
site,
bu_no,
foreign_flag,
order_id
) VALUES (
#{inspectionNo},
#{templateId},
#{itemNo},
#{itemDesc},
#{defaultValue},
#{minValue},
#{maxValue},
#{valueTypeDb},
#{valueType},
#{site},
#{buNo},
#{foreignFlag},
#{orderId}
)
</insert>
<!-- 获取IQC检验单中最大的order_id -->
<select id="getMaxOrderIdForIQC" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT ISNULL(MAX(order_id), 0)
FROM qc_iqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 删除IQC检验项目 -->
<delete id="deleteIQCItemDetail" parameterType="java.util.Map">
DELETE FROM qc_iqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 删除IQC检验项目的子明细 -->
<delete id="deleteIQCSubDetailByItem" parameterType="java.util.Map">
DELETE FROM qc_iqc_sub_detail_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 查询IQC模板列表 -->
<select id="getIQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
SELECT
t.template_id as templateId,
t.template_name as templateName,
t.template_remark as remark,
(SELECT COUNT(*) FROM qc_template_detailed d
WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
FROM qc_template t
WHERE t.site = #{site}
AND t.bu_no = #{buNo}
AND t.inspection_type_no = '105'
<if test="templateId != null and templateId != ''">
AND t.template_id LIKE '%' + #{templateId} + '%'
</if>
<if test="templateDesc != null and templateDesc != ''">
AND t.template_name LIKE '%' + #{templateDesc} + '%'
</if>
ORDER BY t.template_id
</select>
<!-- 查询IQC检验单已有的项目编码 -->
<select id="getExistingIQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
SELECT item_no
FROM qc_iqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- ======================== FQC检验项目操作和模板导入 ======================== -->
<!-- 查询FQC可选的检验项目 -->
<select id="getFQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
ItemNo as itemNo,
ItemDesc as itemDesc,
DefaultValue as defaultValue,
MaxValue as maxValue,
MinValue as minValue,
ValueType as valueType,
ValueType_DB as valueTypeDb
FROM eam_properties_item
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_type_no = '107'
<if test="itemNo != null and itemNo != ''">
AND ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
AND ItemNo NOT IN (
SELECT item_no
FROM qc_fqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
)
ORDER BY ItemNo
</select>
<!-- 查询FQC已选的检验项目 -->
<select id="getFQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
d.item_no as itemNo,
d.item_desc as itemDesc
FROM qc_fqc_detailed_record d
WHERE d.site = #{site}
AND d.bu_no = #{buNo}
AND d.inspection_no = #{inspectionNo}
ORDER BY d.item_no
</select>
<!-- 查询当前FQC检验单已有的项目 -->
<select id="getExistingFQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT TOP 1
template_id as templateId,
item_no as itemNo,
foreign_flag as foreignFlag
FROM qc_fqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 插入FQC检验项目 -->
<insert id="insertFQCItemDetail" parameterType="java.util.Map">
INSERT INTO qc_fqc_detailed_record (
inspection_no,
template_id,
item_no,
item_desc,
default_value,
min_value,
max_value,
value_type_db,
value_type,
site,
bu_no,
foreign_flag,
order_id
) VALUES (
#{inspectionNo},
#{templateId},
#{itemNo},
(SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
#{site},
#{buNo},
#{foreignFlag},
#{orderId}
)
</insert>
<!-- 获取FQC检验单中最大的order_id -->
<select id="getMaxOrderIdForFQC" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT ISNULL(MAX(order_id), 0)
FROM qc_fqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 删除FQC检验项目 -->
<delete id="deleteFQCItemDetail" parameterType="java.util.Map">
DELETE FROM qc_fqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 删除FQC检验项目的子明细 -->
<delete id="deleteFQCSubDetailByItem" parameterType="java.util.Map">
DELETE FROM qc_fqc_sub_detail_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 查询FQC模板列表 -->
<select id="getFQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
SELECT
t.template_id as templateId,
t.template_name as templateName,
t.template_remark as remark,
(SELECT COUNT(*) FROM qc_template_detailed d
WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
FROM qc_template t
WHERE t.site = #{site}
AND t.bu_no = #{buNo}
AND t.inspection_type_no = '107'
<if test="templateId != null and templateId != ''">
AND t.template_id LIKE '%' + #{templateId} + '%'
</if>
<if test="templateDesc != null and templateDesc != ''">
AND t.template_name LIKE '%' + #{templateDesc} + '%'
</if>
ORDER BY t.template_id
</select>
<!-- 查询FQC检验单已有的项目编码 -->
<select id="getExistingFQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
SELECT item_no
FROM qc_fqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- ======================== OQC检验项目操作和模板导入 ======================== -->
<!-- 查询OQC可选的检验项目 -->
<select id="getOQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
ItemNo as itemNo,
ItemDesc as itemDesc,
DefaultValue as defaultValue,
MaxValue as maxValue,
MinValue as minValue,
ValueType as valueType,
ValueType_DB as valueTypeDb
FROM eam_properties_item
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_type_no = '109'
<if test="itemNo != null and itemNo != ''">
AND ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
AND ItemNo NOT IN (
SELECT item_no
FROM qc_oqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
)
ORDER BY ItemNo
</select>
<!-- 查询OQC已选的检验项目 -->
<select id="getOQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT
d.item_no as itemNo,
d.item_desc as itemDesc
FROM qc_oqc_detailed_record d
WHERE d.site = #{site}
AND d.bu_no = #{buNo}
AND d.inspection_no = #{inspectionNo}
ORDER BY d.item_no
</select>
<!-- 查询当前OQC检验单已有的项目 -->
<select id="getExistingOQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
SELECT TOP 1
template_id as templateId,
item_no as itemNo,
foreign_flag as foreignFlag
FROM qc_oqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 插入OQC检验项目 -->
<insert id="insertOQCItemDetail" parameterType="java.util.Map">
INSERT INTO qc_oqc_detailed_record (
inspection_no,
template_id,
item_no,
item_desc,
default_value,
min_value,
max_value,
value_type_db,
value_type,
site,
bu_no,
foreign_flag,
order_id
) VALUES (
#{inspectionNo},
#{templateId},
#{itemNo},
(SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
(SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
#{site},
#{buNo},
#{foreignFlag},
#{orderId}
)
</insert>
<!-- 获取OQC检验单中最大的order_id -->
<select id="getMaxOrderIdForOQC" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT ISNULL(MAX(order_id), 0)
FROM qc_oqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<!-- 删除OQC检验项目 -->
<delete id="deleteOQCItemDetail" parameterType="java.util.Map">
DELETE FROM qc_oqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 删除OQC检验项目的子明细 -->
<delete id="deleteOQCSubDetailByItem" parameterType="java.util.Map">
DELETE FROM qc_oqc_sub_detail_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</delete>
<!-- 查询OQC模板列表 -->
<select id="getOQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
SELECT
t.template_id as templateId,
t.template_name as templateName,
t.template_remark as remark,
(SELECT COUNT(*) FROM qc_template_detailed d
WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
FROM qc_template t
WHERE t.site = #{site}
AND t.bu_no = #{buNo}
AND t.inspection_type_no = '109'
<if test="templateId != null and templateId != ''">
AND t.template_id LIKE '%' + #{templateId} + '%'
</if>
<if test="templateDesc != null and templateDesc != ''">
AND t.template_name LIKE '%' + #{templateDesc} + '%'
</if>
ORDER BY t.template_id
</select>
<!-- 查询OQC检验单已有的项目编码 -->
<select id="getExistingOQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
SELECT item_no
FROM qc_oqc_detailed_record
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
</select>
<select id="getInspectionStandards" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
select
site,
bu_no,
template_id,
item_no,
default_value,
min_value,
max_value,
condition,
collection_source,
seq_no
from qc_inspection_standards
where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
</select>
<delete id="deleteInspectionStandard" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData">
delete from qc_inspection_standards
where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
</delete>
<insert id="saveInspectionStandard">
INSERT INTO qc_inspection_standards
(site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
</foreach>
</insert>
<select id="getInspectionTemplateDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
select
site,
bu_no,
template_id,
item_no
<if test="flag == 'iqc'">
from qc_iqc_detailed_record
</if>
<if test="flag == 'ipqc'">
from qc_ipqc_detailed_record
</if>
<if test="flag == 'sqc'">
from qc_sqc_detailed_record
</if>
<if test="flag == 'fqc'">
from qc_fqc_detailed_record
</if>
<if test="flag == 'fai'">
from qc_fai_detailed_record
</if>
<if test="flag == 'fqas' or flag == 'oqc'">
from qc_oqc_detailed_record
</if>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
order by order_id
</select>
<update id="updateEquipmentDataDetailInspectionNo" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
update Equipment_data_detail
set inspection_no = #{inspectionNo}
where id = #{id}
</update>
<delete id="deleteInspectionFiles" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
delete sys_oss
where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo}
</delete>
<select id="getUpItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
select
top 1
site,
bu_no,
template_id,
ItemNo,
order_id
from qc_template_detailed
where #{orderId} > order_id
and site = #{site}
and bu_no= #{buNo}
and template_id = #{templateId}
order by order_id desc
</select>
<select id="getDownItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
select
top 1
site,
bu_no,
template_id,
ItemNo,
order_id
from qc_template_detailed
where order_id > #{orderId}
and site = #{site}
and bu_no= #{buNo}
and template_id = #{templateId}
order by order_id
</select>
<update id="updateQcItemOrder">
update qc_template_detailed
set order_id=#{orderId}
where site = #{site}
and bu_no= #{buNo}
and template_id = #{templateId}
and ItemNo = #{itemNo}
</update>
<select id="selectInfoByInspectionNo" resultType="com.gaotao.modules.pms.data.PoOrderRollNoData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
select
site,
bu_no,
inspection_no
from po_order_roll_no
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<update id="updateIQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET submit_flag = 'N',
state = '待检验',
cancel_check_by = #{updateBy},
cancel_check_date = getDate(),
submit_by = NULL
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateIQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_detailed_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateIQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_sub_detail_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updatePartDefectTracking" statementType="CALLABLE">
{CALL UspUpdatePartDefectTracking(
#{site,mode=IN,jdbcType=VARCHAR},
#{buNo,mode=IN,jdbcType=VARCHAR},
#{partNo,mode=IN,jdbcType=VARCHAR},
#{supplierId,mode=IN,jdbcType=VARCHAR},
#{passFlag,mode=IN,jdbcType=BIT}
)}
</update>
<update id="updateFAIMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_record
SET submit_flag = 'N',
state = '待检验',
cancel_check_by = #{updateBy},
cancel_check_date = getDate()
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFAIDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_detailed_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFAISubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fai_sub_detail_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateIPQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_record
SET submit_flag = 'N',
state = '待检验',
cancel_check_by = #{updateBy},
cancel_check_date = getDate(),
submit_by = NULL
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateIPQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_detailed_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateIPQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_sub_detail_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateSQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_record
SET submit_flag = 'N',
state = '待检验',
cancel_check_by = #{updateBy},
cancel_check_date = getDate(),
submit_by = NULL
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateSQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_detailed_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateSQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_sub_detail_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_record
SET submit_flag = 'N',
state = '待检验',
cancel_check_by = #{updateBy},
cancel_check_date = getDate(),
submit_by = NULL
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_detailed_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_sub_detail_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFQASMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_record
SET submit_flag = 'N',
state = '待检验',
cancel_check_by = #{updateBy},
cancel_check_date = getDate(),
submit_by = NULL
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFQASDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_detailed_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="updateFQASSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_sub_detail_record
SET is_submit = 'N'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<delete id="deleteReceivingTaskByInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
delete receiving_task
where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
</delete>
<delete id="deleteObjectFile">
delete from sys_oss where id = #{id}
</delete>
<!-- 获取用户角色列表 -->
<select id="getUserRoleList" resultType="com.gaotao.modules.sys.entity.SysRoleEntity">
SELECT
role_id,
role_name
FROM sys_role
</select>
<select id="getOperatorListByOrder" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
SELECT
a.user_id, a.username AS adminID, a.email, a.mobile AS phone, a.user_display AS adminName,
d.role_id, e.role_name, c.site, c.bu_no,
-- 获取计划工单数
dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) AS planOrderCount,
-- 获取实际工单数
dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) AS actualOrderCount,
-- 负荷率(%)
CASE
WHEN dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) = 0 THEN 0
ELSE
CAST(
dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) * 100.0 /
dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username)
AS DECIMAL(5,2))
END AS load_rate
FROM
sys_user AS a
LEFT JOIN AccessSite AS b ON a.username = b.userID
LEFT JOIN AccessBu AS c ON b.userID = c.username AND b.site = c.site
LEFT JOIN sys_user_role AS d ON a.user_id = d.user_id
LEFT JOIN sys_role AS e ON d.role_id = e.role_id
<where>
b.site = #{site} and c.bu_no = #{buNo}
<if test = "adminID != null and adminID != ''">
AND a.username LIKE '%' + #{adminID} + '%'
</if>
<if test = "adminName != null and adminName != ''">
AND a.user_display LIKE '%' + #{adminName} + '%'
</if>
<if test = "roleId != null and roleId != ''">
AND d.role_id = #{roleId}
</if>
<if test = "date != null and classesCode != null and classesCode != ''">
AND a.username IN (
SELECT tpm_scheduling_record.admin_id
FROM tpm_scheduling
join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
)
</if>
<if test = "date != null and (classesCode == null or classesCode == '')">
AND a.username IN (
SELECT tpm_scheduling_record.admin_id
FROM tpm_scheduling
join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling_record.isHoliday = 'N'
)
</if>
<if test = "classesCode != null and classesCode != '' and date == null">
AND a.username IN (
SELECT tpm_scheduling_record.admin_id
FROM tpm_scheduling
join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
)
</if>
</where>
order by load_rate desc
</select>
<!-- 查询OQC基础数据 -->
<select id="selectOQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
qir.inspection_no,
qir.state,
qir.create_date as taskDate,
qir.roll_no,
qir.part_no,
dbo.Get_Part_DescSpec(qir.site, qir.part_no) as part_desc,
qir.roll_qty,
qir.print_flag,
qir.inspector_by,
qir.site,
qir.bu_no,
qir.roll_count
FROM qc_oqc_record as qir
LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
WHERE qir.site in (select site from AccessSite where userID = #{userName})
and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
and qir.detail_flag = 'N'
</select>
<select id="selectFQASPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
qat.site,
qat.bu_no,
qat.attribute_no,
qat.template_id,
qat.sampling_level_no,
qsil.sampling_level_desc,
qat.inspection_cycle,
qat.sampling_programme_no,
qsip.sampling_programme_desc,
qat.AQL,
qat.AC,
qat.RE,
qt.default_sampling_quantity,
qt.default_sampling_proportion
FROM qc_attribute_template as qat
LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
WHERE qat.site = #{site} and qat.bu_no = #{buNo}
AND qat.attribute_no = #{partNo}
AND qat.attribute_type = #{attributeType}
AND qt.inspection_type_no = #{inspectionTypeNo}
</select>
<!-- 新增OQC明细记录信息 -->
<insert id="saveFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
INSERT INTO qc_oqc_detailed_record
(inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE,
item_no, item_desc, object_id, object_desc, default_value, min_value, max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
VALUES
(#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL},
#{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo}, #{orderId}, #{custom1}, #{custom2}, #{custom3})
</insert>
<!-- 修改OQC检验记录 -->
<update id="updateFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_record
SET inspection_type_no = #{inspectionTypeNo},
sampling_qty = #{samplingQty},
inspection_cycle = #{inspectionCycle},
part_desc = #{partDesc},
detail_flag = 'Y',
pass_qty = #{samplingQty},
not_pass_qty = 0
<if test="inspectorBy != null and inspectorBy != ''">
, inspector_by = #{inspectorBy}
</if>
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 查询OQC主记录信息 -->
<select id="qcOQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
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.create_date as taskDate,
a.create_date,
a.inspection_type_no,
a.inspection_cycle,
a.part_no,
d.PartDescription as partDesc,
d.umid as umId,
um.UMName as umName,
d.spec,
a.inspection_remark,
a.roll_qty,
a.sampling_qty,
a.disposal_measures,
a.disposal_remark,
a.inspector_date as inspectorDate,
a.submit_date,
isnull(sub.user_display, a.submit_by) as submitBy,
a.inspector_no,
u.user_display as inspectorName,
a.submit_flag,
a.roll_no,
a.roll_count,
a.action_date,
isnull(ab.user_display, a.action_by) as actionBy,
isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
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, 'responsible'), '') as responsiblePerson,
isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
a.pass_qty,
a.not_pass_qty,
a.batch_qualified_qty,
a.create_by as createBy,
isnull(u2.user_display, a.create_by) as createByName,
a.customer_no,
dbo.Get_CustomerDesc(a.site, a.customer_no) as customerName,
a.po_orderNo,
a.po_itemNo,
a.document_no,
a.release_no as releaseNo,
a.line_no,
a.operation_desc,
isnull(a.inspector_by, a.create_by) as inspectorBy,
isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
FROM qc_oqc_record as a
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
inner join part as d on a.site = d.site and a.part_no = d.partNo
left join um as um on d.umid = um.UMID
left join sys_user as u2 on a.create_by = u2.username
left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
<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})
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</if>
<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.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.inspectionResult != null and query.inspectionResult != ''">
AND a.inspection_result = #{query.inspectionResult}
</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 a.part_desc LIKE '%' + #{query.partDesc} + '%'
</if>
<if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
</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.create_date >= #{query.startDate2}
</if>
<if test="query.endDate2 != null">
AND #{query.endDate2} >= a.create_date
</if>
<if test = "query.customerNo != null and query.customerNo != ''">
AND a.customer_no LIKE '%' + #{query.customerNo} + '%'
</if>
<if test = "query.customerName != null and query.customerName != ''">
AND dbo.Get_CustomerDesc(a.site, a.customer_no) LIKE '%' + #{query.customerName} + '%'
</if>
<if test = "query.poOrderNo != null and query.poOrderNo != ''">
AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
</if>
<if test = "query.spec != null and query.spec != ''">
AND d.spec LIKE '%' + #{query.spec} + '%'
</if>
<if test = "query.operationDesc != null and query.operationDesc != ''">
AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
</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
</select>
<!-- IQC明细记录查询 -->
<select id="fqasDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
a.site,
a.bu_no,
a.inspection_no,
a.template_id,
a.sampling_level_no,
a.sampling_level_desc,
a.sampling_programme_no,
a.sampling_programme_desc,
a.AQL,
a.AC,
a.RE,
a.item_no,
a.item_desc,
a.object_id,
a.object_desc,
a.default_value,
a.min_value,
a.max_value,
a.text_value,
a.number_value,
a.value_type_db,
a.value_type,
case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
a.item_remark as itemRemark,
a.custom1,
a.custom2,
a.custom3,
a.is_submit,
a.unqualified_quantity,
dbo.qc_get_fqas_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
c.method_no,
c.method_name,
c.method_remark,
sw.color_code as qcSpecWarningColorCode,
sw.threshold_value as qcSpecWarningThresholdValue,
a.sampling_qty,
(SELECT TOP 1 epi.collection_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS collectionFlag,
(SELECT TOP 1 epi.image_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS imageFlag,
(SELECT TOP 1 epi.data_flag
FROM eam_properties_item epi
WHERE epi.site = a.site
AND epi.bu_no = a.bu_no
AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
epi.inspection_type_no) AS dataFlag
FROM qc_oqc_detailed_record as a
LEFT JOIN qc_oqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
OUTER APPLY (
SELECT TOP 1
w.color_code,
w.threshold_value
FROM qc_spec_warning w
WHERE w.site = a.site
AND w.bu_no = a.bu_no
AND w.part_no = r.part_no
AND w.item_no = a.item_no
AND w.inspection_type_no = r.inspection_type_no
ORDER BY w.threshold_value
) sw
LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
ORDER BY COALESCE(a.order_id, 99999) ASC
</select>
<!-- 查询FQAS的子明细 -->
<select id="selectFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
SELECT
site,
bu_no,
sub_detail_value,
sampling_location,
is_submit,
sampling_location_b,
num,
sub_detail_value_b,
sub_detail_value_c,
sub_detail_value_d,
sub_detail_value_e,
file_name,
is_transfer,
is_qualified,
defect_qty,
roll_no,
CONVERT(VARCHAR(19), create_time, 120) AS createTime
FROM qc_oqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</select>
<select id="getSupplier" parameterType="java.lang.String" resultType="com.gaotao.modules.base.entity.SupplierData">
SELECT
site,
SupplierID,
SupplierName
FROM Supplier
WHERE site = #{site} and SupplierID = #{supplierID} and Active = #{active}
</select>
<!-- 修改FQAS主记录信息 -->
<update id="updateFQASMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_record
SET disposal_measures = #{disposalMeasures},
disposal_remark = #{disposalRemark},
inspection_result = #{inspectionResult},
inspector_no = #{inspectorNo},
state = #{state},
inspection_remark = #{inspectionRemark},
inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
roll_count = #{rollCount,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
pass_qty = #{passQty,jdbcType=DECIMAL},
not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
</update>
<!-- 修改FQAS明细记录信息 -->
<update id="updateFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_detailed_record
SET item_result = #{itemResult},
unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
sampling_qty = #{samplingQty,jdbcType=DECIMAL},
text_value = #{textValue},
number_value = #{numberValue,jdbcType=DECIMAL},
default_value = #{defaultValue},
min_value = #{minValue,jdbcType=DECIMAL},
max_value = #{maxValue,jdbcType=DECIMAL},
item_remark = #{itemRemark},
custom1 = #{custom1},
custom2 = #{custom2},
custom3 = #{custom3}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="patchFQASDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_detailed_record
<set>
<if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
<if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
<if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
<if test="textValue != null">text_value = #{textValue},</if>
</set>
WHERE inspection_no = #{inspectionNo}
and RTRIM(item_no) = RTRIM(#{itemNo})
and site = #{site}
and bu_no = #{buNo}
</update>
<!-- 查询FQAS主记录信息 -->
<select id="getFQASInspectionRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT
site,
bu_no,
inspection_no,
not_pass_qty,
roll_count,
inspection_result,
disposal_measures,
part_no
FROM qc_oqc_record
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<!-- 修改FQAS主记录标识为已提交 -->
<update id="updateFQASMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_record
SET submit_flag = 'Y',
state = '已完成',
submit_date = getDate(),
submit_by = #{updateBy}
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改FQAS明细记录标识为已提交 -->
<update id="updateFQASDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_detailed_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 修改FQAS子明细记录标识为已提交 -->
<update id="updateFQASSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_sub_detail_record
SET is_submit = 'Y'
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</update>
<!-- 查询FQAS检验记录是否已提交 -->
<select id="checkFQASIsSubmit" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag
FROM qc_oqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site}
</select>
<!-- 删除FQAS子明细的老数据 -->
<delete id="delFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
DELETE FROM qc_oqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 新增FQAS子明细信息 -->
<insert id="saveFQASSubDetailed">
INSERT INTO qc_oqc_sub_detail_record
(inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
</foreach>
</insert>
<!-- 删除FQAS检验记录 -->
<delete id="deleteFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_oqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除FQAS明细记录信息 -->
<delete id="deleteFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_oqc_detailed_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 删除FQAS子明细记录信息 -->
<delete id="deleteFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
DELETE FROM qc_oqc_sub_detail_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</delete>
<!-- 查询FQAS(OQC)检验单当前状态 -->
<select id="getFQASRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
SELECT submit_flag, state
FROM qc_oqc_record
WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
</select>
<update id="actionFQASInspection" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
update qc_oqc_record
set action_date = getDate(),
action_by = #{actionBy},
state = #{state}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<update id="updateSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
update
<if test = "inspectionTypeNo == '105'">
qc_iqc_record
</if>
<if test = "inspectionTypeNo == '108'">
qc_oqc_record
</if>
set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<update id="updateDetailSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
update
<if test = "inspectionTypeNo == '105'">
qc_iqc_detailed_record
</if>
<if test = "inspectionTypeNo == '108'">
qc_oqc_detailed_record
</if>
set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</update>
<!-- 获取审核人员列表 -->
<select id="getCheckerList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
SELECT
a.user_id,
a.username as adminID,
a.email,
a.mobile as phone,
a.user_display as adminName,
dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
d.role_id,
e.role_name
FROM sys_user as a
LEFT JOIN AccessSite as b on a.username = b.userID
LEFT JOIN AccessBu as c on b.userID = c.username and b.site = c.site
LEFT JOIN sys_user_role as d on a.user_id = d.user_id
LEFT JOIN sys_role as e on d.role_id = e.role_id
<where>
b.site = #{site} and c.bu_no = #{buNo}
<if test = "adminID != null and adminID != ''">
AND a.username LIKE '%' + #{adminID}+'%'
</if>
<if test = "adminName != null and adminName != ''">
AND a.user_display LIKE '%' + #{adminName}+'%'
</if>
<if test = "buDesc != null and buDesc != ''">
AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
</if>
<if test = "roleId != null and roleId != ''">
AND d.role_id = #{roleId}
</if>
</where>
</select>
<!-- ================================================= SOP清单相关SQL ================================================= -->
<!-- SOP清单查询 -->
<select id="sopListSearch" resultType="map">
<!-- SELECT-->
<!-- ps.site,-->
<!-- ps.bu_no as buNo,-->
<!-- ps.part_no as partNo,-->
<!-- ps.sop_no as sopNo,-->
<!-- ps.sop_name as sopName,-->
<!-- ps.sop_url as sopUrl,-->
<!-- ps.version,-->
<!-- ps.sop_status as sopStatus,-->
<!-- ps.phase_in_date as phaseInDate,-->
<!-- ps.phase_out_date as phaseOutDate,-->
<!-- ps.created_by as createdBy,-->
<!-- ps.creation_date as creationDate,-->
<!-- ps.sop_type as sopType,-->
<!-- ps.operation_desc as operationDesc-->
<!-- FROM part_sop ps-->
<!-- <where>-->
<!-- <if test="params.site != null and params.site != ''">-->
<!-- AND ps.site = #{params.site}-->
<!-- </if>-->
<!-- <if test="params.partNo != null and params.partNo != ''">-->
<!-- AND ps.part_no = #{params.partNo}-->
<!-- </if>-->
<!-- </where>-->
<!-- ORDER BY ps.creation_date DESC-->
SELECT DISTINCT
site,
buNo,
partNo,
sopNo,
sopName,
sopUrl,
[version],
sopStatus,
phaseInDate,
phaseOutDate,
createdBy,
creationDate,
sopType,
operationDesc
FROM (
-- 来源1: part_sop(零件SOP)
SELECT
ps.site,
ps.bu_no AS buNo,
ps.part_no AS partNo,
ps.sop_no AS sopNo,
ps.sop_name AS sopName,
ps.sop_url AS sopUrl,
ps.[version ] AS [version],
ps.sop_status AS sopStatus,
ps.phase_in_date AS phaseInDate,
ps.phase_out_date AS phaseOutDate,
ps.created_by AS createdBy,
ps.creation_date AS creationDate,
ps.sop_type AS sopType,
ps.operation_desc AS operationDesc
FROM part_sop ps
WHERE ps.site = #{params.site}
AND ps.part_no = #{params.partNo}
UNION ALL
-- 来源2: file_management(公共生产文件 或 订单关联文件)
SELECT
fm.site,
fm.bu_no AS buNo,
'' AS partNo,
fm.file_no AS sopNo,
fm.file_name AS sopName,
fm.url_add_ress AS sopUrl,
fm.sop_rev_no AS [version],
fm.status AS sopStatus,
fm.phase_in_date AS phaseInDate,
fm.phase_out_date AS phaseOutDate,
fm.created_by AS createdBy,
fm.create_date AS creationDate,
fm.file_type AS sopType,
fm.item_no AS operationDesc
FROM file_management fm
WHERE fm.site = #{params.site}
AND fm.file_type = '生产'
AND (
ISNULL(fm.public_flag, 'N') = 'Y'
OR fm.order_no = #{params.orderNo}
)
) AS CombinedResults
</select>
<!-- 查询检验页面的SOP文件列表(从file_management表) -->
<select id="searchQcSopFileList" resultType="map">
<!-- SELECT DISTINCT-->
<!-- fm.ID AS id,-->
<!-- fm.url_add_ress AS sopUrl,-->
<!-- fm.create_date AS creationDate,-->
<!-- fm.file_name AS sopName,-->
<!-- fm.new_file_name AS newFileName,-->
<!-- fm.created_by AS createdBy,-->
<!-- fm.file_type AS fileType,&#45;&#45;-->
<!-- fm.file_suffix AS fileSuffix,-->
<!-- fm.sop_rev_no AS version,-->
<!-- fm.phase_in_date AS phaseInDate,-->
<!-- fm.phase_out_date AS phaseOutDate-->
<!-- FROM file_management fm-->
SELECT DISTINCT
site,
buNo,
partNo,
sopNo,
sopName,
sopUrl,
[version],
sopStatus,
phaseInDate,
phaseOutDate,
createdBy,
creationDate,
sopType as fileType,
operationDesc
FROM (
-- 来源1: part_sop(零件SOP)
SELECT
ps.site,
ps.bu_no AS buNo,
ps.part_no AS partNo,
ps.sop_no AS sopNo,
ps.sop_name AS sopName,
ps.sop_url AS sopUrl,
ps.[version ] AS [version],
ps.sop_status AS sopStatus,
ps.phase_in_date AS phaseInDate,
ps.phase_out_date AS phaseOutDate,
ps.created_by AS createdBy,
ps.creation_date AS creationDate,
ps.sop_type AS sopType,
ps.operation_desc AS operationDesc
FROM part_sop ps
WHERE ps.site = #{params.site}
AND ps.part_no = #{params.partNo}
UNION ALL
-- 来源2: file_management(公共生产文件 或 订单关联文件)
SELECT
fm.site,
fm.bu_no AS buNo,
'' AS partNo,
fm.file_no AS sopNo,
fm.file_name AS sopName,
fm.url_add_ress AS sopUrl,
fm.sop_rev_no AS [version],
fm.status AS sopStatus,
fm.phase_in_date AS phaseInDate,
fm.phase_out_date AS phaseOutDate,
fm.created_by AS createdBy,
fm.create_date AS creationDate,
fm.file_type AS sopType,
fm.item_no AS operationDesc
FROM file_management fm
WHERE fm.site = #{params.site}
AND fm.file_type = '质量'
AND (
ISNULL(fm.public_flag, 'N') = 'Y'
OR fm.order_no = #{params.orderNo}
)
) AS CombinedResults
</select>
<!-- 查询可用的SOP文件 -->
<select id="sopAvailableFiles" resultType="map">
SELECT
A.site,
A.bu_no as buNo,
A.file_no as fileNo,
A.file_name as fileName,
A.file_type as fileType,
A.file_suffix as fileSuffix,
A.sop_rev_no as sopRevNo,
A.url_add_ress as sopUrl,
A.sop_type as sopType,
A.source_system as sourceSystem
FROM file_management A
LEFT JOIN part_sop B ON A.SITE = B.SITE AND A.BU_NO = B.BU_NO AND A.FILE_NO = B.sop_no and b.part_no = #{params.partNo}
<where>
B.SITE IS NULL
AND A.status_tb = 0
and ISNULL(public_flag,'N') = 'N'
<if test="params.site != null and params.site != ''">
AND A.site = #{params.site}
</if>
<if test="params.fileNo != null and params.fileNo != ''">
AND A.file_no LIKE '%' + #{params.fileNo} + '%'
</if>
<if test="params.fileName != null and params.fileName != ''">
AND A.file_name LIKE '%' + #{params.fileName} + '%'
</if>
<if test="params.fileType != null and params.fileType != ''">
AND A.file_type LIKE '%' + #{params.fileType} + '%'
</if>
<if test="params.sopRevNo != null and params.sopRevNo != ''">
AND A.sop_rev_no LIKE '%' + #{params.sopRevNo} + '%'
</if>
</where>
ORDER BY A.file_no
</select>
<!-- 插入SOP记录 -->
<insert id="insertSopRecord">
INSERT INTO part_sop (
site,
bu_no,
part_no,
sop_no,
sop_name,
sop_url,
sop_type,
version,
sop_status,
phase_in_date,
phase_out_date,
created_by,
creation_date,
operation_desc
) VALUES (
#{data.site},
#{data.buNo},
#{data.partNo},
#{data.sopNo},
#{data.sopName},
#{data.sopUrl},
#{data.sopType},
#{data.version},
#{data.sopStatus},
<choose>
<when test="data.phaseInDate != null and data.phaseInDate != ''">
CONVERT(DATE, #{data.phaseInDate})
</when>
<otherwise>
NULL
</otherwise>
</choose>,
<choose>
<when test="data.phaseOutDate != null and data.phaseOutDate != ''">
CONVERT(DATE, #{data.phaseOutDate})
</when>
<otherwise>
NULL
</otherwise>
</choose>,
#{data.createdBy},
<choose>
<when test="data.creationDate != null and data.creationDate != ''">
CONVERT(DATE, #{data.creationDate})
</when>
<otherwise>
GETDATE()
</otherwise>
</choose>,
#{data.operationDesc}
)
</insert>
<!-- 删除SOP记录 -->
<delete id="deleteSopRecord">
DELETE FROM part_sop
<where>
<if test="params.site != null and params.site != ''">
AND site = #{params.site}
</if>
<if test="params.buNo != null and params.buNo != ''">
AND bu_no = #{params.buNo}
</if>
<if test="params.partNo != null and params.partNo != ''">
AND part_no = #{params.partNo}
</if>
<if test="params.sopNo != null and params.sopNo != ''">
AND sop_no = #{params.sopNo}
</if>
</where>
</delete>
<!-- ================================================= BOM清单相关SQL ================================================= -->
<!-- BOM清单查询 -->
<select id="bomListSearch" resultType="com.gaotao.modules.pms.data.BomListData">
SELECT
bh.site,
bh.bu_no as buNo,
bh.revno,
bh.bomtype,
bh.status,
bh.phaseindate,
bh.phaseoutdate
FROM BOMHeader bh
<where>
<if test="query.site != null and query.site != ''">
AND bh.site = #{query.site}
</if>
<if test="query.buNo != null and query.buNo != ''">
AND bh.bu_no = #{query.buNo}
</if>
<if test="query.partNo != null and query.partNo != ''">
AND bh.bu_no = #{query.partNo}
</if>
</where>
ORDER BY bh.phaseindate DESC
</select>
<!-- ================================================= Routing清单相关SQL ================================================= -->
<!-- Routing清单查询 -->
<select id="routingListSearch" resultType="com.gaotao.modules.pms.data.RoutingListData">
SELECT
rh.site,
rh.bu_no as buNo,
rh.revno,
rh.routingtype,
rh.status,
rh.phaseindate,
rh.phaseoutdate
FROM RoutingHeader rh
<where>
<if test="query.site != null and query.site != ''">
AND rh.site = #{query.site}
</if>
<if test="query.buNo != null and query.buNo != ''">
AND rh.bu_no = #{query.buNo}
</if>
<if test="query.partNo != null and query.partNo != ''">
AND rh.bu_no = #{query.partNo}
</if>
</where>
ORDER BY rh.phaseindate DESC
</select>
<update id="updateInboundNotificationStatus">
update inbound_notification_head
set order_status = #{status}
<if test="inspectionFlag != null and inspectionFlag != ''">
, inspection_flag = #{inspectionFlag}
</if>
where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
</update>
<!-- 查询过程检验待检验记录数量(只统计首件检和自检类型) -->
<select id="checkProcessInspectionPendingCount" resultType="int">
SELECT COUNT(1)
FROM qc_ipqc_record
WHERE site = #{site}
AND order_no = #{orderNo}
AND state IN ('未开始', '待检验')
AND seq_no = #{seqNo}
AND inspection_type_no IN ('首件检', '自检', '末件检')
</select>
<select id="queryResourceList3" resultType="com.gaotao.modules.pms.data.ResourceData">
select DISTINCT ResourceId,ResourceDesc from WorkCenterResource
</select>
<update id="updateSaleBoxManageStatus">
update outbound_notification_head
set order_status = #{status}
where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
</update>
<update id="updateSaleBoxManageInspectionFlag">
update outbound_notification_detail
set inspection_flag = #{inspectionFlag}
where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
</update>
<select id="queryEquipmentFolderLocationList"
resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
select efl.*,
dbo.get_bu_desc(efl.site, efl.bu_no) as buDesc
from Equipment_folder_location efl
<where>
<if test="params.site != null and params.site != ''">
and efl.site = #{params.site}
</if>
<if test="params.buNo != null and params.buNo != ''">
and efl.bu_no = #{params.buNo}
</if>
<if test="params.equipmentNo != null and params.equipmentNo != ''">
and efl.equipment_no like '%'+ #{params.equipmentNo} +'%'
</if>
<if test="params.equipmentDesc != null and params.equipmentDesc != ''">
and efl.equipment_desc like '%'+ #{params.equipmentDesc} +'%'
</if>
<if test="params.IP != null and params.IP != ''">
and efl.IP like '%'+ #{params.IP} +'%'
</if>
<if test="params.suffix != null and params.suffix != ''">
and efl.suffix like '%'+ #{params.suffix} +'%'
</if>
</where>
order by equipment_no
</select>
<insert id="saveEquipmentFolderLocationList">
insert into Equipment_folder_location
(folder_path,equipment_no,site,bu_no,file_no,backup_folder_path,IP,suffix,equipment_desc,backup_photo_path,batch_date,port,register_address,
register_num,register_num_columntype,register_address_inspection,register_num_inspection,register_num_inspection_columntype,unit_id,
excel_compare_fields_x,excel_compare_fields_y,initial_line,data_row,data_column,skip_line,cutting_symbol,transparent_flag,Formula_calculation,
Formula,Group_calculation,regexp,data_storage_mode,serial_no,repair_type,buzzer,equipment_classification)
values (#{folderPath}, #{equipmentNo}, #{site}, #{buNo}, #{fileNo}, #{backupFolderPath}, #{IP}, #{suffix}, #{equipmentDesc}, #{backupPhotoPath}, #{batchDate}, #{port}, #{registerAddress},
#{registerNum}, #{registerNumColumntype}, #{registerAddressInspection}, #{registerNumInspection}, #{registerNumInspectionColumntype}, #{unitId},
#{excelCompareFieldsX}, #{excelCompareFieldsY}, #{initialLine}, #{dataRow}, #{dataColumn}, #{skipLine}, #{cuttingSymbol}, #{transparentFlag}, #{formulaCalculation},
#{formula}, #{groupCalculation}, #{regexp}, #{dataStorageMode}, #{serialNo}, #{repairType}, #{buzzer}, #{equipmentClassification})
</insert>
<update id="updateEquipmentFolderLocation">
UPDATE Equipment_folder_location
SET
folder_path = #{folderPath},
equipment_no = #{equipmentNo},
bu_no = #{buNo},
file_no = #{fileNo},
backup_folder_path = #{backupFolderPath},
IP = #{IP},
suffix = #{suffix},
equipment_desc = #{equipmentDesc},
backup_photo_path = #{backupPhotoPath},
batch_date = #{batchDate},
port = #{port},
register_address = #{registerAddress},
register_num = #{registerNum},
register_num_columntype = #{registerNumColumntype},
register_address_inspection = #{registerAddressInspection},
register_num_inspection = #{registerNumInspection},
register_num_inspection_columntype = #{registerNumInspectionColumntype},
unit_id = #{unitId},
excel_compare_fields_x = #{excelCompareFieldsX},
excel_compare_fields_y = #{excelCompareFieldsY},
initial_line = #{initialLine},
data_row = #{dataRow},
data_column = #{dataColumn},
skip_line = #{skipLine},
cutting_symbol = #{cuttingSymbol},
transparent_flag = #{transparentFlag},
Formula_calculation = #{formulaCalculation},
Formula = #{formula},
Group_calculation = #{groupCalculation},
regexp = #{regexp},
data_storage_mode = #{dataStorageMode},
serial_no = #{serialNo},
repair_type = #{repairType},
buzzer = #{buzzer},
equipment_classification = #{equipmentClassification},
update_by = #{updateBy},
update_time = getDate()
WHERE id = #{id}
</update>
<delete id="deleteEquipmentFolderLocationList">
delete from Equipment_folder_location
where id = #{id}
</delete>
<select id="checkEquipmentFolderLocation" resultType="java.lang.Integer">
select count(1)
from Equipment_folder_location
where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
</select>
<select id="getSuffixList" resultType="java.lang.String">
select distinct suffix from Equipment_folder_location
</select>
<!-- 获取检验单物料编码 -->
<select id="getInspectionPartNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
select part_no from
<choose>
<when test="flag == 'ipqc'">qc_ipqc_record</when>
<when test="flag == 'sqc'">qc_sqc_record</when>
<when test="flag == 'fqc'">qc_fqc_record</when>
<when test="flag == 'fai'">qc_fai_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
<otherwise>qc_iqc_record</otherwise>
</choose>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<!-- 获取检验单工序(仅 IPQC/FQC/OQC 主表维护 operation_desc) -->
<select id="getInspectionOperationDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
<choose>
<when test="flag == 'ipqc'">
select operation_desc from qc_ipqc_record
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</when>
<when test="flag == 'fqc'">
select operation_desc from qc_fqc_record
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</when>
<when test="flag == 'fqas' or flag == 'oqc'">
select operation_desc from qc_oqc_record
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</when>
<otherwise>
select null
</otherwise>
</choose>
</select>
<!-- 获取检验单检验类型 -->
<select id="getInspectionTypeNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
select inspection_type_no from
<choose>
<when test="flag == 'ipqc'">qc_ipqc_record</when>
<when test="flag == 'sqc'">qc_sqc_record</when>
<when test="flag == 'fqc'">qc_fqc_record</when>
<when test="flag == 'fai'">qc_fai_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
<otherwise>qc_iqc_record</otherwise>
</choose>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<!-- 获取检验单全部子明细实测值 -->
<select id="listInspectionSubDetailValues" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
select
item_no as itemNo,
sub_detail_value as subDetailValue,
sub_detail_value_b as subDetailValueB,
sub_detail_value_c as subDetailValueC,
sub_detail_value_d as subDetailValueD,
sub_detail_value_e as subDetailValueE,
sampling_location as samplingLocation,
sampling_location_b as samplingLocationB,
num,
file_name as fileName,
is_transfer as isTransfer,
is_qualified as isQualified,
defect_qty as defectQty,
roll_no as rollNo
from
<choose>
<when test="flag == 'ipqc'">qc_ipqc_sub_detail_record</when>
<when test="flag == 'sqc'">qc_sqc_sub_detail_record</when>
<when test="flag == 'fqc'">qc_fqc_sub_detail_record</when>
<when test="flag == 'fai'">qc_fai_sub_detail_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_sub_detail_record</when>
<otherwise>qc_iqc_sub_detail_record</otherwise>
</choose>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
order by item_no, num
</select>
<!-- 获取检验单明细项目编码 -->
<select id="listInspectionItemNos" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
select item_no from
<choose>
<when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
<when test="flag == 'sqc'">qc_sqc_detailed_record</when>
<when test="flag == 'fqc'">qc_fqc_detailed_record</when>
<when test="flag == 'fai'">qc_fai_detailed_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
<otherwise>qc_iqc_detailed_record</otherwise>
</choose>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<!-- 获取检验单明细行实测值(含规格,用于复制与合格判定) -->
<select id="listInspectionDetailMeasuredValues" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
select
item_no as itemNo,
number_value as numberValue,
text_value as textValue,
value_type_db as valueTypeDb,
min_value as minValue,
max_value as maxValue,
item_result as itemResult,
unqualified_quantity as unqualifiedQuantity
from
<choose>
<when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
<when test="flag == 'sqc'">qc_sqc_detailed_record</when>
<when test="flag == 'fqc'">qc_fqc_detailed_record</when>
<when test="flag == 'fai'">qc_fai_detailed_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
<otherwise>qc_iqc_detailed_record</otherwise>
</choose>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<!-- 更新明细行实测值(数值/文本) -->
<update id="updateInspectionDetailMeasuredValue" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
update
<choose>
<when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
<when test="flag == 'sqc'">qc_sqc_detailed_record</when>
<when test="flag == 'fqc'">qc_fqc_detailed_record</when>
<when test="flag == 'fai'">qc_fai_detailed_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
<otherwise>qc_iqc_detailed_record</otherwise>
</choose>
set
number_value = #{numberValue,jdbcType=DECIMAL},
text_value = #{textValue}
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
</update>
<!-- 查询检验单提交标识 -->
<select id="getInspectionSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
select submit_flag from
<choose>
<when test="flag == 'ipqc'">qc_ipqc_record</when>
<when test="flag == 'sqc'">qc_sqc_record</when>
<when test="flag == 'fqc'">qc_fqc_record</when>
<when test="flag == 'fai'">qc_fai_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
<otherwise>qc_iqc_record</otherwise>
</choose>
where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
</select>
<!-- 按物料+设备查询文件列映射 -->
<select id="listPartFileCollectByPartAndEquipment" resultType="com.gaotao.modules.pms.data.QcPartFileCollectData">
SELECT
file_column_no AS fileColumnNo,
item_no AS itemNo,
item_desc AS itemDesc,
operation
FROM qc_part_file_collect
WHERE site = #{site}
AND bu_no = #{buNo}
AND part_no = #{partNo}
AND equipment_no = #{equipmentNo}
ORDER BY file_column_no, id
</select>
<!-- 按物料查询已配置的设备编码 -->
<select id="listEquipmentNoByPartFileCollect" resultType="java.lang.String">
SELECT DISTINCT equipment_no
FROM qc_part_file_collect
WHERE site = #{site}
AND bu_no = #{buNo}
AND part_no = #{partNo}
AND equipment_no IS NOT NULL
AND equipment_no <![CDATA[<>]]> ''
ORDER BY equipment_no
</select>
<!-- 获取项目默认关联设备(优先 default_flag=Y) -->
<select id="getDefaultItemObjectId" resultType="java.lang.String">
SELECT TOP 1 ObjectID
FROM qc_item_object
WHERE site = #{site}
AND bu_no = #{buNo}
AND ItemNo = #{itemNo}
ORDER BY CASE WHEN default_flag = 'Y' THEN 0 ELSE 1 END, ObjectID
</select>
<!-- 校验项目是否关联指定设备 -->
<select id="countItemObject" resultType="int">
SELECT COUNT(1)
FROM qc_item_object
WHERE site = #{site}
AND bu_no = #{buNo}
AND ItemNo = #{itemNo}
AND ObjectID = #{objectId}
</select>
<!-- 按设备编码查询文件夹配置 -->
<select id="getEquipmentFolderLocationByEquipmentNo"
resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
SELECT TOP 1
equipment_no AS equipmentNo,
equipment_desc AS equipmentDesc,
data_storage_mode AS dataStorageMode
FROM Equipment_folder_location
WHERE site = #{site}
AND bu_no = #{buNo}
AND equipment_no = #{equipmentNo}
</select>
<!-- 查询项目采集配置 -->
<select id="getItemCollectionConfig" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
SELECT
ItemNo AS itemNo,
ItemDesc AS itemDesc,
collection_source AS collectionSource,
collection_method AS collectionMethod,
collection_data_content AS collectionDataContent
FROM eam_properties_item
WHERE site = #{site}
AND bu_no = #{buNo}
AND ItemNo = #{itemNo}
</select>
<!-- 查询设备最新批次解析数据(含列号元数据) -->
<select id="listLatestEquipmentDataDetail" resultType="com.gaotao.modules.reader.entity.EquipmentDataDetail">
SELECT
id,
site,
bu_no AS buNo,
equipment_no AS equipmentNo,
value0,
source_column_no AS sourceColumnNo,
num,
serial_no AS serialNo,
batch_no AS batchNo,
file_name AS fileName
FROM Equipment_data_detail
WHERE site = #{site}
AND bu_no = #{buNo}
AND equipment_no = #{equipmentNo}
AND batch_no = (
SELECT MAX(batch_no)
FROM Equipment_data_detail
WHERE site = #{site} AND bu_no = #{buNo} AND equipment_no = #{equipmentNo}
)
AND source_column_no IS NOT NULL
AND source_column_no != -1
ORDER BY source_column_no, num
</select>
<!-- 按列号查询设备最新批次解析数据;collectionDataContent 非空时作为 value0 的 SQL 过滤条件 -->
<select id="listLatestEquipmentDataDetailByColumn" resultType="com.gaotao.modules.reader.entity.EquipmentDataDetail">
SELECT
id,
site,
bu_no AS buNo,
equipment_no AS equipmentNo,
value0,
source_column_no AS sourceColumnNo,
num,
serial_no AS serialNo,
batch_no AS batchNo,
file_name AS fileName
FROM Equipment_data_detail
WHERE site = #{site}
AND bu_no = #{buNo}
AND equipment_no = #{equipmentNo}
<choose>
<when test="matchBySerialNo == true">
AND LTRIM(RTRIM(CONVERT(VARCHAR(50), serial_no))) = CONVERT(VARCHAR(50), #{fileColumnNo})
</when>
<otherwise>
AND source_column_no = #{fileColumnNo}
</otherwise>
</choose>
AND batch_no = (
SELECT MAX(batch_no)
FROM Equipment_data_detail
WHERE site = #{site} AND bu_no = #{buNo} AND equipment_no = #{equipmentNo}
)
<if test="collectionDataContent != null and collectionDataContent != ''">
AND value0 ${collectionDataContent}
</if>
ORDER BY num
</select>
<!-- 数据采集后更新明细不合格数量与项目检验结果 -->
<update id="updateIQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_detailed_record
SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
item_result = #{itemResult}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="refreshIQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_iqc_record
SET unqualified_qty = (
SELECT COUNT(*) FROM qc_iqc_detailed_record
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
)
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
</update>
<update id="updateIPQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_detailed_record
SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
item_result = #{itemResult}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="refreshIPQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_ipqc_record
SET unqualified_qty = (
SELECT COUNT(*) FROM qc_ipqc_detailed_record
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
)
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
</update>
<update id="updateSQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_detailed_record
SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
item_result = #{itemResult}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="refreshSQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_sqc_record
SET unqualified_qty = (
SELECT COUNT(*) FROM qc_sqc_detailed_record
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
)
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
</update>
<update id="updateFQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_detailed_record
SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
item_result = #{itemResult}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="refreshFQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_fqc_record
SET unqualified_qty = (
SELECT COUNT(*) FROM qc_fqc_detailed_record
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
)
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
</update>
<update id="updateFQASDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_detailed_record
SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
item_result = #{itemResult}
WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
</update>
<update id="refreshFQASMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
UPDATE qc_oqc_record
SET unqualified_qty = (
SELECT COUNT(*) FROM qc_oqc_detailed_record
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
)
WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
</update>
<select id="getLatestEquipmentDetailBatchNo" resultType="java.lang.Integer">
SELECT MAX(batch_no)
FROM Equipment_data_detail
WHERE site = #{site}
AND bu_no = #{buNo}
AND equipment_no = #{equipmentNo}
</select>
<update id="updateEquipmentDataAcquisitionBatchNo">
UPDATE Equipment_data_acquisition
SET batch_no = #{batchNo}
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND equipment_no = #{equipmentNo}
</update>
<update id="updateEquipmentDataAcquisitionCollectMode">
UPDATE Equipment_data_acquisition
SET accumulate_collect = #{accumulateCollect},
delete_after_collect = #{deleteAfterCollect}
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND equipment_no = #{equipmentNo}
</update>
<!-- 累计采集时用于续号 -->
<select id="getSubDetailMaxNum" resultType="java.lang.Integer">
SELECT ISNULL(MAX(num), 0)
FROM
<choose>
<when test="flag == 'ipqc'">qc_ipqc_sub_detail_record</when>
<when test="flag == 'sqc'">qc_sqc_sub_detail_record</when>
<when test="flag == 'fqc'">qc_fqc_sub_detail_record</when>
<when test="flag == 'fai'">qc_fai_sub_detail_record</when>
<when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_sub_detail_record</when>
<otherwise>qc_iqc_sub_detail_record</otherwise>
</choose>
WHERE site = #{site}
AND bu_no = #{buNo}
AND inspection_no = #{inspectionNo}
AND item_no = #{itemNo}
</select>
<!-- 检验单弹框:最近设备解析时间 -->
<select id="getLatestEquipmentParseTime" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
SELECT TOP 1
N'最近解析时间:' + a.equipment_no + N' - ' + ISNULL(b.equipment_desc, N'') + N' - '
+ CONVERT(varchar(19), c.create_date, 120)
FROM Equipment_data_acquisition A
INNER JOIN Equipment_folder_location B
ON A.site = B.site AND A.bu_no = B.bu_no AND A.equipment_no = B.equipment_no
INNER JOIN Equipment_folder_sort C
ON B.site = C.site AND B.bu_no = C.bu_no AND B.file_no = C.file_no
WHERE A.site = #{site}
AND A.bu_no = #{buNo}
AND A.inspection_no = #{inspectionNo}
ORDER BY C.create_date DESC
</select>
</mapper>