|
|
<?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.xujie.sys.modules.pms.mapper.QcMapper">
<!-- ================================================= 检验方法 ================================================= -->
<!-- 条件查询检验方法 --> <select id="qcMethodSearch" parameterType="QcMethodData" resultType="QcMethodData"> SELECT qm.site, qm.bu_no, dbo.get_bu_desc(qm.site, qm.bu_no) as buDesc, qm.method_no, qm.method_name, qm.create_date, qm.create_by, qm.method_remark, qm.update_date, qm.update_by, qm.inspection_type_no, qit.inspection_type_name FROM qc_method as qm LEFT JOIN qc_inspection_type as qit on qm.site = qit.site and qm.inspection_type_no = qit.inspection_type_no <where> qm.site in (select site from eam_access_site where username = #{query.userName}) and (qm.site + '-' + qm.bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( qm.site, qm.bu_no ) = #{query.buDesc} </if> <if test="query.methodNo != null and query.methodNo != ''"> AND qm.method_no LIKE '%' + #{query.methodNo} +'%' </if> <if test="query.methodName != null and query.methodName != ''"> AND qm.method_name LIKE '%' + #{query.methodName} +'%' </if> <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''"> AND qm.inspection_type_no = #{query.inspectionTypeNo} </if> </where> </select>
<!-- 获得检验方法单号 --> <select id="getMethodNo" resultType="string" parameterType="QcMethodData"> SELECT Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(method_no,4))),0)+1),4) FROM qc_method WHERE site = #{site} AND inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo} </select>
<!-- 新增检验方法 --> <insert id="qcMethodSave" parameterType="QcMethodData"> INSERT INTO qc_method (site, bu_no, method_no, method_name, create_date, create_by, method_remark, update_date, update_by, inspection_type_no) VALUES (#{site}, #{buNo}, #{methodNo}, #{methodName}, GetDate(), #{createBy}, #{methodRemark}, getDate(), #{updateBy}, #{inspectionTypeNo}) </insert>
<!-- 修改检验方法 --> <update id="qcMethodUpdate" parameterType="QcMethodData"> UPDATE qc_method SET method_name = #{methodName}, method_remark = #{methodRemark}, update_date = getDate(), update_by = #{updateBy}, inspection_type_no = #{inspectionTypeNo} WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo} </update>
<!-- 检查方法是否在被项目使用 --> <select id="checkMethodIsUsed" parameterType="QcMethodData" resultType="EamPropertiesItemData"> SELECT ItemNo FROM qc_method_item WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo} </select>
<!-- 删除检验方法 --> <delete id="qcMethodDelete" parameterType="QcMethodData"> DELETE FROM qc_method WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo} </delete>
<!-- ================================================= 检验项目 ================================================= -->
<!-- 根据条件查询检验项目 --> <select id="qcItemSearch" parameterType="QcItemData" resultType="QcItemData"> SELECT epi.site, epi.bu_no, dbo.get_bu_desc(epi.site, epi.bu_no) as buDesc, epi.ItemNo, epi.ItemDesc, epi.DefaultValue, epi.ValueType, epi.ValueType_DB as valueTypeDb, epi.ValueChooseFlag, epi.CreatedDate, epi.CreatedBy, epi.MaxValue, epi.MinValue, epi.ItemRemark, epi.ItemType, epi.update_date, epi.update_by, qm.method_no, qm.method_name, qm.method_remark, epi.inspection_type_no, qit.inspection_type_name, epi.item_sampling_quantity, epi.sampling_programme_no, qsip.sampling_programme_desc, epi.sampling_level_no, qsil.sampling_level_desc, epi.default_sampling_proportion, epi.defect_level_code, dbo.get_defect_level_code_desc(epi.site, epi.bu_no, epi.defect_level_code) as defectLevelDescription, epi.type_no, qit2.type_desc FROM eam_properties_item as epi LEFT JOIN qc_method_item as qmi on epi.ItemNo = qmi.ItemNo and epi.site = qmi.site and epi.bu_no = qmi.bu_no LEFT JOIN qc_method as qm on qmi.method_no = qm.method_no and qmi.site = qm.site and qmi.bu_no = qm.bu_no LEFT JOIN qc_inspection_type as qit on qit.inspection_type_no = epi.inspection_type_no and qit.site = epi.site left join qc_sampling_inspection_programme as qsip on qsip.site = epi.site and qsip.sampling_programme_no = epi.sampling_programme_no and qsip.bu_no = epi.bu_no left join qc_sampling_inspection_level as qsil on qsil.site = epi.site and qsil.sampling_level_no = epi.sampling_level_no and qsil.bu_no = epi.bu_no left join qc_item_type as qit2 on epi.site = qit2.site and epi.bu_no = qit2.bu_no and epi.type_no = qit2.type_no <where> epi.site in (select site from eam_access_site where username = #{query.userName}) and (epi.site + '-' + epi.bu_no) in (select * from dbo.query_bu(#{query.userName})) and epi.ItemType = #{query.itemType} <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( epi.site, epi.bu_no ) = #{query.buDesc} </if> <if test="query.itemDesc != null and query.itemDesc != ''"> AND epi.ItemDesc LIKE '%' + #{query.itemDesc} +'%' </if> <if test="query.itemNo != null and query.itemNo != ''"> AND epi.ItemNo LIKE '%' + #{query.itemNo} +'%' </if> <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''"> AND epi.inspection_type_no = #{query.inspectionTypeNo} </if> <if test="query.typeNo != null and query.typeNo != ''"> AND epi.type_no = #{query.typeNo} </if> </where> </select>
<!-- 检测是否存在该项目 --> <select id="checkQcItem" parameterType="QcItemData" resultType="QcItemData"> SELECT ItemNo, ItemDesc FROM eam_properties_item WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} </select>
<!-- 获得检验项目单号 --> <select id="getItemNo" resultType="string" parameterType="QcItemData"> SELECT Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(ItemNo,4))),0)+1),4) FROM eam_properties_item WHERE site = #{site} and ItemType = 'D' and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo} </select>
<!-- 新增检验项目 --> <insert id="qcItemSave" parameterType="QcItemData"> INSERT INTO eam_properties_item (site, bu_no, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, CreatedDate, CreatedBy, MaxValue, MinValue, ItemRemark, ItemType, update_date, update_by, inspection_type_no, item_sampling_quantity, sampling_programme_no, sampling_level_no, default_sampling_proportion, defect_level_code, type_no) VALUES (#{site}, #{buNo}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag}, GetDate(), #{createdBy}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{itemRemark}, #{itemType}, getDate(), #{updateBy}, #{inspectionTypeNo}, #{itemSamplingQuantity}, #{samplingProgrammeNo}, #{samplingLevelNo}, #{defaultSamplingProportion}, #{defectLevelCode}, #{typeNo}) </insert>
<!-- 新增项目里的方法 --> <insert id="qcItemMethodSave" parameterType="QcItemData"> INSERT INTO qc_method_item (ItemNo, method_no, site, bu_no) VALUES (#{itemNo}, #{methodNo}, #{site}, #{buNo}) </insert>
<!-- 修改检验项目 --> <update id="qcItemUpdate" parameterType="QcItemData"> UPDATE eam_properties_item SET ItemDesc = #{itemDesc}, DefaultValue = #{defaultValue}, ValueType = #{valueType}, ValueType_DB = #{valueTypeDb}, ValueChooseFlag = #{valueChooseFlag}, MaxValue = #{maxValue,jdbcType=DECIMAL}, MinValue = #{minValue,jdbcType=DECIMAL}, ItemRemark = #{itemRemark}, update_date = getDate(), update_by = #{updateBy}, inspection_type_no = #{inspectionTypeNo}, item_sampling_quantity = #{itemSamplingQuantity}, sampling_programme_no = #{samplingProgrammeNo}, sampling_level_no = #{samplingLevelNo}, default_sampling_proportion = #{defaultSamplingProportion}, defect_level_code = #{defectLevelCode}, type_no = #{typeNo} WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo} </update>
<!-- 修改项目中的方法 --> <update id="qcItemMethodUpdate" parameterType="QcItemData"> UPDATE qc_method_item SET method_no = #{methodNo} WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo} </update>
<!-- 检查项目是否在被模板使用 --> <select id="checkItemIsUsed" parameterType="QcItemData" resultType="EamPropertiesModelDetailData"> SELECT template_id FROM qc_template_detailed WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo} </select>
<!-- 删除检验项目 --> <delete id="qcItemDelete" parameterType="QcItemData"> DELETE FROM eam_properties_item WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo} </delete>
<!-- 删除项目-方法中间表数据 --> <delete id="qcItemMethodDelete" parameterType="QcItemData"> DELETE FROM qc_method_item WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo} </delete>
<!-- ================================================= 质检员信息维护 ================================================= -->
<!-- 查询质检员信息列表 --> <select id="inspectorSearch" resultType="QcInspectorData"> SELECT inspector_no, inspector_name, inspector_phone, inspector_type, inspector_active FROM qc_inspector </select>
<!-- 检验是否已存在该质检员 --> <select id="checkInspector" resultType="QcInspectorData"> SELECT inspector_name FROM qc_inspector WHERE inspector_no = #{inspectorNo} </select>
<!-- 新增质检员 --> <insert id="inspectorSave" parameterType="QcInspectorData"> INSERT INTO qc_inspector (inspector_no, inspector_name, inspector_phone, inspector_type, inspector_active, create_time) VALUES (#{inspectorNo}, #{inspectorName}, #{inspectorPhone}, #{inspectorType}, #{inspectorActive}, getDate()) </insert>
<!-- 修改质检员 --> <update id="inspectorUpdate" parameterType="QcInspectorData"> UPDATE qc_inspector SET inspector_name = #{inspectorName}, inspector_phone = #{inspectorPhone}, inspector_type = #{inspectorType}, inspector_active = #{inspectorActive} WHERE inspector_no = #{inspectorNo} </update>
<!-- 删除质检员 --> <delete id="inspectorDelete" parameterType="QcInspectorData"> DELETE FROM qc_inspector WHERE inspector_no = #{inspectorNo} </delete>
<!-- ================================================= 抽样矩阵维护 ================================================= -->
<!-- 查询抽样矩阵 --> <select id="samplingInspectionPlanSearch" parameterType="QcSamplingInspectionPlanData" resultType="QcSamplingInspectionPlanData"> SELECT qsip.site, qsip.bu_no, dbo.get_bu_desc(qsip.site, qsip.bu_no) as buDesc, qsip.sampling_plan_no, qsip.sampling_plan_desc, qsip.sampling_qty_no, qsiq.sampling_qty, qsiq.sampling_qty_desc, qsip.sampling_qty_rank_no, qsiqr.sampling_qty_rank_desc, qsiqr.min_qty, qsiqr.max_qty, qsip.sampling_level_no, qsil.sampling_level_desc, qsip.sampling_plan_active, qsip.create_date, qsip.create_by, qsip.update_date, qsip.update_by FROM qc_sampling_inspection_plan as qsip LEFT JOIN qc_sampling_inspection_qty as qsiq ON qsip.sampling_qty_no = qsiq.sampling_qty_no and qsip.site = qsiq.site and qsip.bu_no = qsiq.bu_no LEFT JOIN qc_sampling_inspection_qty_rank as qsiqr ON qsip.sampling_qty_rank_no = qsiqr.sampling_qty_rank_no and qsip.site = qsiqr.site and qsip.bu_no = qsiqr.bu_no LEFT JOIN qc_sampling_inspection_level as qsil ON qsip.sampling_level_no = qsil.sampling_level_no and qsip.site = qsil.site and qsip.bu_no = qsil.bu_no <where> qsip.site in (select site from eam_access_site where username = #{query.userName}) and (qsip.site + '-' + qsip.bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( qsip.site, qsip.bu_no ) = #{query.buDesc} </if> <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''"> AND qsiq.sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc}+'%' </if> <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''"> AND qsil.sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%' </if> <if test="query.samplingPlanActive != null and query.samplingPlanActive != ''"> AND qsip.sampling_plan_active = #{query.samplingPlanActive} </if> </where> </select>
<!-- 根据三个编码查矩阵 --> <select id="selectSamplingPlanByNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionPlanData"> SELECT site, bu_no, sampling_plan_no, sampling_qty_no, sampling_qty_rank_no, sampling_level_no, sampling_plan_active FROM qc_sampling_inspection_plan WHERE sampling_qty_no = #{samplingQtyNo} AND sampling_qty_rank_no = #{samplingQtyRankNo} AND sampling_level_no = #{samplingLevelNo} AND site = #{site} and bu_no = #{buNo} </select>
<!-- 根据名称查矩阵 --> <select id="selectSamplingPlanByDesc" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionPlanData"> SELECT site, bu_no, sampling_plan_no, sampling_qty_no, sampling_qty_rank_no, sampling_level_no, sampling_plan_active FROM qc_sampling_inspection_plan WHERE sampling_plan_desc = #{samplingPlanDesc} AND site = #{site} and bu_no = #{buNo} </select>
<!-- 获取最大方矩阵编码 --> <select id="queryLastSamplingPlanNo" resultType="string" parameterType="QcSamplingInspectionPlanData"> SELECT top 1 sampling_plan_no FROM qc_sampling_inspection_plan where site = #{site} and bu_no = #{buNo} ORDER BY sampling_plan_no Desc </select>
<!-- 新增抽样矩阵 --> <insert id="samplingInspectionPlanSave" parameterType="QcSamplingInspectionPlanData"> INSERT INTO qc_sampling_inspection_plan (site, bu_no, sampling_plan_no, sampling_plan_desc, sampling_qty_rank_no, sampling_level_no, sampling_qty_no, sampling_plan_active, create_date, create_by, update_date, update_by) VALUES (#{site}, #{buNo}, #{samplingPlanNo}, #{samplingPlanDesc}, #{samplingQtyRankNo}, #{samplingLevelNo}, #{samplingQtyNo}, #{samplingPlanActive}, getDate(), #{createBy}, getDate(), #{updateBy}) </insert>
<!-- 修改抽样矩阵 --> <update id="samplingInspectionPlanUpdate" parameterType="QcSamplingInspectionPlanData"> UPDATE qc_sampling_inspection_plan SET sampling_qty_rank_no = #{samplingQtyRankNo}, sampling_level_no = #{samplingLevelNo}, sampling_qty_no = #{samplingQtyNo}, sampling_plan_active = #{samplingPlanActive}, update_date = getDate(), update_by = #{updateBy} WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo} </update>
<!-- 删除抽样矩阵 --> <delete id="samplingInspectionPlanDelete" parameterType="QcSamplingInspectionPlanData"> DELETE FROM qc_sampling_inspection_plan WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo} </delete>
<!-- ================================================= 检验模板维护 ================================================= -->
<!-- 查询模板 --> <select id="templateSearch" parameterType="QcTemplateData" resultType="QcTemplateData"> SELECT qt.site, qt.bu_no, dbo.get_bu_desc(qt.site, qt.bu_no) as buDesc, qt.template_id, qt.template_name, qt.template_remark, qt.template_type, qt.template_version, qt.sampling_programme_no, qsip.sampling_programme_Desc, qt.inspection_type_no, qit.inspection_type_name, qt.sampling_level_no, qsil.sampling_level_desc, qt.inspection_cycle, qt.create_time, qt.create_by, qt.update_date, qt.update_by, qt.AQL, qt.AC, qt.RE, qt.default_sampling_quantity, qt.default_sampling_proportion FROM qc_template as qt LEFT JOIN qc_inspection_type as qit on qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site 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 in (select site from eam_access_site where username = #{query.userName}) and (qt.site + '-' + qt.bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( qt.site, qt.bu_no ) = #{query.buDesc} </if> <if test = "query.templateId != null and query.templateId != ''"> AND qt.template_id LIKE '%' + #{query.templateId}+'%' </if> <if test = "query.templateName != null and query.templateName != ''"> AND qt.template_name LIKE '%' + #{query.templateName}+'%' </if> <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''"> AND qt.inspection_type_no = #{query.inspectionTypeNo} </if> </where> </select>
<!-- 获得检验模板单号 --> <select id="getTemplateNo" resultType="string" parameterType="QcTemplateData"> SELECT Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(template_id,3))),0)+1),3) FROM qc_template WHERE site = #{site} and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo} </select>
<!-- 新增模板 --> <insert id="templateSave" parameterType="QcTemplateData"> INSERT INTO qc_template (site, bu_no, template_id, template_name, template_version, template_remark, template_type, sampling_programme_no, inspection_type_no, create_time, create_by, sampling_level_no, inspection_cycle, AQL, AC, RE, default_sampling_quantity, default_sampling_proportion, update_date, update_by) VALUES (#{site}, #{buNo}, #{templateId}, #{templateName},#{templateVersion}, #{templateRemark}, #{templateType}, #{samplingProgrammeNo}, #{inspectionTypeNo}, getDate(), #{createBy}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{aql}, #{ac}, #{re}, #{defaultSamplingQuantity}, #{defaultSamplingProportion}, getDate(), #{updateBy}) </insert>
<!-- 修改模板 --> <update id="templateUpdate" parameterType="QcTemplateData"> UPDATE qc_template SET template_name = #{templateName}, template_version = #{templateVersion}, template_remark = #{templateRemark}, template_type = #{templateType}, sampling_programme_no = #{samplingProgrammeNo}, inspection_cycle = #{inspectionCycle}, inspection_type_no = #{inspectionTypeNo}, sampling_level_no = #{samplingLevelNo}, AQL = #{aql}, AC = #{ac}, RE = #{re}, default_sampling_quantity = #{defaultSamplingQuantity}, default_sampling_proportion = #{defaultSamplingProportion}, update_date = getDate(), update_by = #{updateBy} WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo} </update>
<!-- 查询模板里的项目详情 --> <select id="templateDetailsSearch" resultType="QcTemplateData"> SELECT a.site, a.bu_no, a.template_id, a.ItemNo, b.ItemDesc, a.default_value, b.ValueType, b.ValueType_DB, a.max_value, a.min_value, b.ItemRemark, b.ItemType, a.object_id, eo.objectDesc, b.item_sampling_quantity, b.sampling_programme_no, c.sampling_programme_desc, b.sampling_level_no, d.sampling_level_desc, b.default_sampling_proportion, a.serial_no FROM qc_template_detailed a LEFT JOIN eam_properties_item b ON a.ItemNo = b.ItemNo and a.site = b.site and a.bu_no = b.bu_no left join qc_sampling_inspection_programme as c on b.site = c.site and b.sampling_programme_no = c.sampling_programme_no and b.bu_no = c.bu_no left join qc_sampling_inspection_level as d on b.site = d.site and b.sampling_level_no = d.sampling_level_no and b.bu_no = d.bu_no LEFT JOIN eam_object eo ON a.object_id = eo.ObjectID and a.site = b.site and a.bu_no = b.bu_no WHERE a.template_id = #{templateId} AND b.ItemType = #{itemType} and a.site = #{site} and a.bu_no = #{buNo} ORDER BY COALESCE(a.serial_no, 99999) ASC </select>
<!-- 查询模板里是否已存在该项目 --> <select id="selectItemDetails" resultType="QcTemplateData"> SELECT template_id, ItemNo, default_value, max_value, min_value FROM qc_template_detailed WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 查询项目的最大最小值 --> <select id="selectDetail" resultType="QcTemplateData"> SELECT ItemNo, DefaultValue, MaxValue, MinValue FROM eam_properties_item WHERE ItemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo} </select>
<!-- 新增模板的检验项目 --> <insert id="addItemDetails" parameterType="QcTemplateData"> INSERT INTO qc_template_detailed (template_id, ItemNo, default_value, max_value, min_value, site, bu_no) VALUES (#{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{site}, #{buNo}) </insert>
<!-- 删除模板的检验项目 --> <delete id="delItemDetails" > DELETE FROM qc_template_detailed WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 获取当前模板不包含的项目 --> <select id="getItemList" resultType="QcTemplateData"> SELECT a.site, a.bu_no, a.itemNo, a.ItemDesc, a.DefaultValue, a.MaxValue, a.MinValue FROM eam_properties_item a LEFT JOIN qc_template_detailed b ON b.template_id = #{templateId} and b.ItemNo = a.ItemNo and a.site = b.site and a.bu_no = b.bu_no WHERE a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo} and dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) = #{inspectionTypeName} </select>
<!-- 查询项目 --> <select id="getItem" resultType="QcTemplateData"> SELECT a.site, a.bu_no, a.itemNo, a.ItemDesc, a.DefaultValue, a.MaxValue, a.MinValue FROM eam_properties_item a LEFT JOIN qc_template_detailed b ON b.template_id = #{templateId} and b.ItemNo = a.ItemNo and a.site = b.site and a.bu_no = b.bu_no <where> a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo} and dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) = #{inspectionTypeName} <if test = "itemNo != null and itemNo != ''"> AND a.ItemNo LIKE '%' + #{itemNo} + '%' </if> <if test = "itemDesc != null and itemDesc != ''"> AND a.ItemDesc LIKE '%' + #{itemDesc} + '%' </if> <if test = "inspectionTypeNo != null and inspectionTypeNo != ''"> AND a.inspection_type_no = #{inspectionTypeNo} </if> </where> </select>
<!-- 删除模板 --> <delete id="templateDelete" parameterType="QcTemplateData"> DELETE FROM qc_template WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除模板-项目中间表 --> <delete id="itemItemDelete" parameterType="QcTemplateData"> DELETE FROM qc_template_detailed WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 搜索所有检验类型 --> <select id="inspectionTypeSearch" resultType="QcInspectionTypeData" parameterType="QcInspectionTypeData"> SELECT inspection_type_no, inspection_type_name FROM qc_inspection_type WHERE site = #{site} </select>
<!-- 搜索所有检验项目类型 --> <select id="itemTypeSearch" resultType="QcItemTypeData" parameterType="QcItemTypeData"> SELECT site, bu_no, type_no, type_desc FROM qc_item_type WHERE site = #{site} and bu_no = #{buNo} and active = #{active} </select>
<!-- 搜索所有设备 --> <select id="objectSearch" resultType="EamObjectData"> SELECT ObjectID, ObjectDesc FROM eam_object WHERE Active = 'Y' and site = #{site} and bu_no = #{buNo} </select>
<!-- 导入文件检验 --> <select id="getItemByItemNo" resultType="EamPropertiesItemData" parameterType="QcItemData"> SELECT ItemDesc, ItemType FROM eam_properties_item WHERE ItemDesc = #{itemDesc} AND DefaultValue = #{defaultValue} AND MaxValue = #{maxValue} AND MinValue = #{minValue} AND ItemType = #{itemType} </select>
<!-- 新增检验项目 --> <insert id="insertItem" parameterType="EamPropertiesItemData"> INSERT INTO eam_properties_item (ItemNo, ItemDesc,DefaultValue,ValueType,ValueType_DB, CreatedDate,CreatedBy,MaxValue, MinValue, ItemRemark,ItemType) VALUES(#{itemNo},#{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, GetDate(), #{createdBy}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{itemRemark}, #{itemType}) </insert>
<!-- <!– 获取最大项目编码 –>--><!-- <select id="queryLastItemNo" resultType="string" parameterType="QcItemData">--><!-- SELECT top 1 ItemNo--><!-- FROM eam_properties_item--><!-- WHERE ItemType = #{itemType}--><!-- ORDER BY ItemNo Desc--><!-- </select>-->
<!-- 根据模板名称查询模板 --> <select id="selectTemplateByDesc" parameterType="QcTemplateData" resultType="QcTemplateData"> SELECT template_id, template_name, template_version FROM qc_template WHERE template_name = #{templateName} AND site = #{site} AND template_version = #{templateVersion} </select>
<!-- <!– 修改项目明细的最大最小值 –>--><!-- <update id="saveItemDetailed" parameterType="QcTemplateData">--><!-- UPDATE qc_template_detailed--><!-- SET default_value = #{defaultValue},--><!-- max_value = #{maxValue,jdbcType=DECIMAL},--><!-- min_value = #{minValue,jdbcType=DECIMAL},--><!-- object_id = #{objectID}--><!-- WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}--><!-- </update>-->
<!-- 查询项目明细 --> <select id="selectItem" resultType="QcTemplateData"> SELECT ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, MaxValue, MinValue, ItemRemark, ItemType FROM eam_properties_item WHERE ItemNo = #{itemNo} AND ItemType = #{itemType} </select>
<!-- ================================================= 样本量维护 ================================================= -->
<!-- 查询样本量 --> <select id="samplingQtySearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData"> SELECT site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, sampling_qty_no, sampling_qty_desc, sampling_qty, sampling_qty_remark, sampling_qty_active, create_date, create_by, update_date, update_by FROM qc_sampling_inspection_qty <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test="query.samplingQtyNo != null and query.samplingQtyNo != ''"> AND sampling_qty_no LIKE '%' + #{query.samplingQtyNo} + '%' </if> <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''"> AND sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc} + '%' </if> <if test="query.samplingQty != null"> AND sampling_qty = #{query.samplingQty,jdbcType=DECIMAL} </if> <if test="query.samplingQtyActive != null and query.samplingQtyActive != ''"> AND sampling_qty_active = #{query.samplingQtyActive} </if> </where> </select>
<!-- 新增样本量 --> <insert id="samplingQtySave" parameterType="QcSamplingInspectionQtyData"> INSERT INTO qc_sampling_inspection_qty (site, bu_no, sampling_qty_no, sampling_qty, sampling_qty_remark, sampling_qty_active, sampling_qty_desc, create_date, create_by, update_date, update_by) VALUES(#{site}, #{buNo}, #{samplingQtyNo}, #{samplingQty,jdbcType=DECIMAL}, #{samplingQtyRemark}, #{samplingQtyActive}, #{samplingQtyDesc}, getDate(), #{createBy}, getDate(), #{updateBy}) </insert>
<!-- 根据样本量字码查询样本量 --> <select id="selectSamplingQtyByDesc" parameterType="QcSamplingInspectionQtyData" resultType="QcSamplingInspectionQtyData"> SELECT site, bu_no, sampling_qty_no, sampling_qty_desc, sampling_qty, sampling_qty_remark, sampling_qty_active FROM qc_sampling_inspection_qty WHERE sampling_qty_desc = #{samplingQtyDesc} AND site = #{site} and bu_no = #{buNo} </select>
<!-- 获取最大样本量编码 --> <select id="queryLastSamplingQtyNo" resultType="string" parameterType="QcSamplingInspectionQtyData"> SELECT top 1 sampling_qty_no FROM qc_sampling_inspection_qty where site = #{site} and bu_no = #{buNo} ORDER BY sampling_qty_no Desc </select>
<!-- 修改样本量 --> <update id="samplingQtyUpdate" parameterType="QcSamplingInspectionQtyData"> UPDATE qc_sampling_inspection_qty SET sampling_qty = #{samplingQty,jdbcType=DECIMAL}, sampling_qty_desc = #{samplingQtyDesc}, sampling_qty_remark = #{samplingQtyRemark}, sampling_qty_active = #{samplingQtyActive}, update_date = getDate(), update_by = #{updateBy} WHERE sampling_qty_no = #{samplingQtyNo} AND site = #{site} and bu_no = #{buNo} </update>
<!-- 根据样本量编码查询矩阵 --> <select id="selectSamplingPlanBySamplingQtyNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionQtyData"> SELECT site, sampling_plan_no, sampling_qty_no, sampling_qty_rank_no, sampling_level_no, sampling_plan_active FROM qc_sampling_inspection_plan WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} and bu_no = #{buNo} </select>
<!-- 删除样本量 --> <delete id="samplingQtyDelete" parameterType="QcSamplingInspectionQtyData"> DELETE FROM qc_sampling_inspection_qty WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} AND sampling_qty_desc = #{samplingQtyDesc} and bu_no = #{buNo} </delete>
<!-- ================================================= 批量级次维护 ================================================= -->
<!-- 查询批量级次 --> <select id="samplingQtyRankSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData"> SELECT site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, sampling_qty_rank_no, sampling_qty_rank_desc, min_qty, max_qty, sampling_qty_rank_active, sampling_qty_rank_Remark, create_date, create_by, update_date, update_by FROM qc_sampling_inspection_qty_rank <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test="query.samplingQtyRankNo != null and query.samplingQtyRankNo != ''"> AND sampling_qty_rank_no LIKE '%' + #{query.samplingQtyRankNo}+'%' </if> <if test="query.samplingQtyRankDesc != null and query.samplingQtyRankDesc != ''"> AND sampling_qty_rank_desc LIKE '%' + #{query.samplingQtyRankDesc}+'%' </if> <if test="query.samplingQtyRankActive != null and query.samplingQtyRankActive != ''"> AND sampling_qty_rank_active = #{query.samplingQtyRankActive} </if> </where> </select>
<!-- 根据名称查询批量级次 --> <select id="selectSamplingQtyRankByDesc" parameterType="QcSamplingInspectionQtyRankData" resultType="QcSamplingInspectionQtyRankData"> SELECT site, bu_no, sampling_qty_rank_no, sampling_qty_rank_desc, min_qty, max_qty, sampling_qty_rank_active, sampling_qty_rank_Remark FROM qc_sampling_inspection_qty_rank WHERE sampling_qty_rank_desc = #{samplingQtyRankDesc} AND site = #{site} and bu_no = #{buNo} </select>
<!-- 获取最大批量级次编码 --> <select id="queryLastSamplingQtyRankNo" resultType="string" parameterType="QcSamplingInspectionQtyRankData"> SELECT top 1 sampling_qty_rank_no FROM qc_sampling_inspection_qty_rank where site = #{site} and bu_no = #{buNo} ORDER BY sampling_qty_rank_no Desc </select>
<!-- 新增批量级次 --> <insert id="samplingQtyRankSave" parameterType="QcSamplingInspectionQtyRankData"> INSERT INTO qc_sampling_inspection_qty_rank (site, bu_no, sampling_qty_rank_no, sampling_qty_rank_desc, min_qty, max_qty, sampling_qty_rank_Remark, sampling_qty_rank_active, create_date, create_by, update_date, update_by) VALUES(#{site}, #{buNo}, #{samplingQtyRankNo}, #{samplingQtyRankDesc}, #{minQty,jdbcType=DECIMAL}, #{maxQty,jdbcType=DECIMAL}, #{samplingQtyRankRemark}, #{samplingQtyRankActive}, getDate(), #{createBy}, getDate(), #{updateBy}) </insert>
<!-- 根据批量级次编码查询矩阵 --> <select id="selectSamplingPlanBySamplingQtyRankNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionQtyRankData"> SELECT site, bu_no, sampling_plan_no, sampling_qty_no, sampling_qty_rank_no, sampling_level_no, sampling_plan_active FROM qc_sampling_inspection_plan WHERE site = #{site} AND sampling_qty_rank_no = #{samplingQtyRankNo} and bu_no = #{buNo} </select>
<!-- 修改批量级次 --> <update id="samplingQtyRankUpdate" parameterType="QcSamplingInspectionQtyRankData"> UPDATE qc_sampling_inspection_qty_rank SET sampling_qty_rank_desc = #{samplingQtyRankDesc}, min_qty = #{minQty,jdbcType=DECIMAL}, max_qty = #{maxQty,jdbcType=DECIMAL}, sampling_qty_rank_Remark = #{samplingQtyRankRemark}, sampling_qty_rank_active = #{samplingQtyRankActive}, update_date = getDate(), update_by = #{updateBy} WHERE sampling_qty_rank_no = #{samplingQtyRankNo} AND site = #{site} and bu_no = #{buNo} </update>
<!-- 删除批量级次 --> <delete id="samplingQtyRankDelete" parameterType="QcSamplingInspectionQtyRankData"> DELETE FROM qc_sampling_inspection_qty_rank WHERE site = #{site} and bu_no = #{buNo} AND sampling_qty_rank_no = #{samplingQtyRankNo} AND sampling_qty_rank_desc = #{samplingQtyRankDesc} </delete>
<!-- ================================================= 检验等级维护 ================================================= -->
<!-- 查询检验等级 --> <select id="samplingLevelSearch" parameterType="QcSamplingInspectionLevelData" resultType="QcSamplingInspectionLevelData"> SELECT site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, sampling_level_no, sampling_level_desc, sampling_level_remark, sampling_level_active, create_date, create_by, update_date, update_by FROM qc_sampling_inspection_level <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test="query.samplingLevelNo != null and query.samplingLevelNo != ''"> AND sampling_level_no LIKE '%' + #{query.samplingLevelNo}+'%' </if> <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''"> AND sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%' </if> <if test="query.samplingLevelActive != null and query.samplingLevelActive != ''"> AND sampling_level_active = #{query.samplingLevelActive} </if> </where> </select>
<!-- 根据名称查询检验等级 --> <select id="selectSamplingLevelByDesc" parameterType="QcSamplingInspectionLevelData" resultType="QcSamplingInspectionLevelData"> SELECT site, bu_no, sampling_level_no, sampling_level_desc, sampling_level_remark, sampling_level_active FROM qc_sampling_inspection_level WHERE sampling_level_desc = #{samplingLevelDesc} AND site = #{site} and bu_no = #{buNo} </select>
<!-- 获取最大检验等级编码 --> <select id="queryLastSamplingLevelNo" resultType="string" parameterType="QcSamplingInspectionLevelData"> SELECT top 1 sampling_level_no FROM qc_sampling_inspection_level where site = #{site} and bu_no = #{buNo} ORDER BY sampling_level_no Desc </select>
<!-- 新增检验等级 --> <insert id="samplingLevelSave" parameterType="QcSamplingInspectionLevelData"> INSERT INTO qc_sampling_inspection_level (site, bu_no, sampling_level_no, sampling_level_desc, sampling_level_remark, sampling_level_active, create_date, create_by, update_date, update_by) VALUES (#{site}, #{buNo}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingLevelRemark}, #{samplingLevelActive}, getDate(), #{createBy}, getDate(), #{updateBy}) </insert>
<!-- 根据检验等级编码查询矩阵 --> <select id="selectSamplingPlanBySamplingLevelNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionLevelData"> SELECT site, bu_no, sampling_plan_no, sampling_qty_no, sampling_qty_rank_no, sampling_level_no, sampling_plan_active FROM qc_sampling_inspection_plan WHERE site = #{site} and bu_no = #{buNo} AND sampling_level_no = #{samplingLevelNo} </select>
<!-- 修改检验等级 --> <update id="samplingLevelUpdate" parameterType="QcSamplingInspectionLevelData"> UPDATE qc_sampling_inspection_level SET sampling_level_desc = #{samplingLevelDesc}, sampling_level_remark = #{samplingLevelRemark}, sampling_level_active = #{samplingLevelActive}, update_date = getDate(), update_by = #{updateBy} WHERE sampling_level_no = #{samplingLevelNo} AND site = #{site} and bu_no = #{buNo} </update>
<!-- 删除检验等级 --> <delete id="samplingLevelDelete" parameterType="QcSamplingInspectionLevelData"> DELETE FROM qc_sampling_inspection_level WHERE site = #{site} and bu_no = #{buNo} AND sampling_level_no = #{samplingLevelNo} AND sampling_level_desc = #{samplingLevelDesc} </delete>
<!-- ================================================= 物料属性设置维护 ================================================= --> <!-- 查询物料属性 --> <select id="qcPartAttributeSearch" parameterType="QcPartAttributeData" resultType="QcPartAttributeData"> SELECT qa.site, qa.bu_no, dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc, p.PartNo as partNo, dbo.Get_Part_DescSpec(qa.site, p.PartNo) as part_desc, p.FamilyID, p.spec as FamilyName, p.umid, qa.supplier_no, dbo.qc_get_supplier_name(qa.site, qa.supplier_no) as supplierDesc, qa.attribute_remark, qa.create_time, qa.create_by, qa.attribute_type, qa.update_date, qa.update_by, qa.exempt_inspection FROM qc_part_attribute qa LEFT JOIN part p on qa.attribute_no = p.partNo and qa.site = p.site <where> qa.site in (select site from eam_access_site where username = #{query.userName}) and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName})) and qa.attribute_type = #{query.attributeType} <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc} </if> <if test = "query.partNo != null and query.partNo != ''"> AND qa.attribute_no LIKE '%' + #{query.partNo}+'%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.Get_Part_DescSpec(qa.site, p.PartNo) LIKE '%' + #{query.partDesc}+'%' </if> <if test = "query.familyName != null and query.familyName != ''"> AND p.spec LIKE '%' + #{query.familyName}+'%' </if> </where> </select>
<select id="qcPartAttributeImportSearch" parameterType="QcPartAttributeData" resultType="QcPartAttributeData"> SELECT qa.site, qa.bu_no, dbo.get_bu_desc (qa.site, qa.bu_no) AS buDesc, p.PartNo AS partNo, dbo.Get_Part_DescSpec (qa.site, p.PartNo) AS part_desc, p.FamilyID, p.spec AS FamilyName, p.umid, qa.supplier_no, dbo.qc_get_supplier_name (qa.site, qa.supplier_no) AS supplierDesc, qa.attribute_remark, qa.create_time, qa.create_by, qa.attribute_type, qa.update_date, qa.update_by, qa.exempt_inspection, dbo.get_templateIds_by_partAttribute ( qa.attribute_no, qa.site, qa.bu_no ) AS templateIds FROM qc_part_attribute qa LEFT JOIN part p ON qa.attribute_no = p.partNo AND qa.site = p.site <where> qa.site in (select site from eam_access_site where username = #{query.userName}) and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName})) and qa.attribute_type = #{query.attributeType} <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc} </if> <if test = "query.partNo != null and query.partNo != ''"> AND qa.attribute_no LIKE '%' + #{query.partNo}+'%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.Get_Part_DescSpec(qa.site, p.PartNo) LIKE '%' + #{query.partDesc}+'%' </if> <if test = "query.familyName != null and query.familyName != ''"> AND p.spec LIKE '%' + #{query.familyName}+'%' </if> </where> </select>
<!-- 查询是否已有该物料属性 --> <select id="selectPartAttributeByNo" resultType="QcPartAttributeData" parameterType="QcPartAttributeData"> SELECT attribute_no, supplier_no, attribute_remark, attribute_type FROM qc_part_attribute WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo} </select>
<!-- 新增物料属性 --> <insert id="qcPartAttributeSave" parameterType="QcPartAttributeData"> INSERT INTO qc_part_attribute (attribute_no, supplier_no, attribute_remark, create_time, create_by, attribute_type, site, exempt_inspection, bu_no) VALUES(#{partNo}, #{supplierNo}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{exemptInspection}, #{buNo}) </insert>
<!-- 物料属性修改 --> <update id="qcPartAttributeEdit" parameterType="QcPartAttributeData"> UPDATE qc_part_attribute SET attribute_remark = #{attributeRemark}, exempt_inspection = #{exemptInspection}, update_date = getDate(), update_by = #{updateBy} WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo} </update>
<!-- 删除物料属性 --> <delete id="qcPartAttributeDelete" parameterType="QcPartAttributeData"> DELETE FROM qc_part_attribute WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} </delete>
<!-- 删除物料属性模板 --> <delete id="deletePartAttributeTemplate" parameterType="QcPartAttributeData"> DELETE FROM qc_attribute_template WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} </delete>
<!-- 查询类别模板 --> <select id="searchPartAttributeDetails" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT qat.site, qat.bu_no, qpa.attribute_no, qpa.attribute_type, qt.template_id, qt.template_name, qt.template_remark, qt.template_version, qat.sampling_programme_no, qsip.sampling_programme_desc, qat.AQL, qat.AC, qat.RE, qt.inspection_type_no, qit.inspection_type_name, qt.default_sampling_quantity, qt.default_sampling_proportion, qat.sampling_level_no, qsil.sampling_level_desc, qat.inspection_cycle, qat.operation, qat.manufacturer_id, dbo.qc_get_supplier_name(qat.site, qat.manufacturer_id) as manufacturerName, qat.resource_id, qat.customer_id as customerID, dbo.qc_get_customer_name(qat.site, qat.customer_id) as customerName FROM qc_attribute_template as qat LEFT JOIN qc_part_attribute as qpa ON qpa.attribute_no = qat.attribute_no and qat.site = qpa.site and qat.bu_no = qpa.bu_no 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_inspection_type as qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site 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 qpa.attribute_type = #{attributeType} and qpa.attribute_no = #{attributeNo} and qat.bu_no = #{buNo} </select>
<!-- 物料属性模板查重 --> <select id="searchPartRepeat" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT attribute_no, template_id FROM qc_attribute_template WHERE attribute_no = #{attributeNo} AND template_id = #{templateId} AND attribute_type = #{attributeType} AND special_field = #{specialField} </select>
<!-- 新增物料属性模板 --> <insert id="savePartAttributeDetails" parameterType="QcTemplateData"> INSERT INTO qc_attribute_template (attribute_no, template_id, sampling_level_no, inspection_cycle, sampling_programme_no, AQL, AC, RE, attribute_type, operation, manufacturer_id, resource_id, site, bu_no, customer_id) VALUES (#{attributeNo}, #{templateId}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{samplingProgrammeNo}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{attributeType}, #{operation}, #{manufacturerID}, #{resourceID}, #{site}, #{buNo}, #{customerID}) </insert>
<!-- <!– 可选模板 –>--><!-- <select id="getTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData">--><!-- SELECT--><!-- qt.template_id,--><!-- qt.template_name,--><!-- qit.inspection_type_name--><!-- FROM qc_template as qt--><!-- LEFT JOIN qc_attribute_template as qat ON qat.template_id = qt.template_id and qat.attribute_no = #{attributeNo}--><!-- LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site--><!-- <where>--><!-- qt.site = #{site} AND qat.attribute_no is null--><!-- <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">--><!-- AND qt.inspection_type_no = #{inspectionTypeNo}--><!-- </if>--><!-- <if test = "templateId != null and templateId != ''">--><!-- AND qt.template_id LIKE '%' + #{templateId}+'%'--><!-- </if>--><!-- <if test = "templateName != null and templateName != ''">--><!-- AND qt.template_name LIKE '%' + #{templateName}+'%'--><!-- </if>--><!-- </where>--><!-- </select>-->
<!-- 可选模板 --> <select id="getTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT qt.template_id, qt.template_name, qit.inspection_type_name FROM qc_template as qt LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site <where> qt.site = #{site} <if test = "inspectionTypeNo != null and inspectionTypeNo != ''"> AND qt.inspection_type_no = #{inspectionTypeNo} </if> <if test = "templateId != null and templateId != ''"> AND qt.template_id LIKE '%' + #{templateId}+'%' </if> <if test = "templateName != null and templateName != ''"> AND qt.template_name LIKE '%' + #{templateName}+'%' </if> </where> </select>
<!-- 已有模板 --> <select id="getPartTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT qt.template_id, qt.template_name, qit.inspection_type_name, qat.operation, qat.manufacturer_id, dbo.qc_get_supplier_name(qt.site, qat.manufacturer_id) as manufacturerName, qat.resource_id, qat.customer_id as customerID, dbo.qc_get_customer_name(qt.site, qat.customer_id) as customerName 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_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site WHERE qt.site = #{site} AND qat.attribute_no = #{attributeNo} and qt.bu_no = #{buNo} </select>
<!-- 物料可选模板 --> <select id="getTemplateListAll" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT qt.template_id, qt.template_name, qit.inspection_type_name FROM qc_template as qt LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site <where> qt.site = #{site} and qt.bu_no = #{buNo} <if test = "inspectionTypeNo != null and inspectionTypeNo != ''"> AND qt.inspection_type_no = #{inspectionTypeNo} </if> <if test = "templateId != null and templateId != ''"> AND qt.template_id LIKE '%' + #{templateId}+'%' </if> <if test = "templateName != null and templateName != ''"> AND qt.template_name LIKE '%' + #{templateName}+'%' </if> </where> </select>
<!-- 删除物料属性模板 --> <delete id="deletePartAttributeDetails" parameterType="QcTemplateData"> DELETE FROM qc_attribute_template <where> site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId} and attribute_type = #{attributeType} <if test = "operation != null and operation != ''"> and operation = #{operation} </if> <if test = "resourceID != null and resourceID != ''"> and resource_id = #{resourceID} </if> <if test = "manufacturerID != null and manufacturerID != ''"> and manufacturer_id = #{manufacturerID} </if> </where> </delete>
<!-- 查询模板的基础数据 --> <select id="selectTemplateData" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT template_id, template_name, sampling_programme_no, sampling_level_no, inspection_cycle, AQL, AC, RE FROM qc_template WHERE site = #{site} AND template_id = #{templateId} and bu_no = #{buNo} </select>
<!-- 新增物料属性模板详情 --> <update id="saveAttributeDetailed" parameterType="QcTemplateData"> UPDATE qc_attribute_template SET sampling_level_no = #{samplingLevelNo}, inspection_cycle = #{inspectionCycle,jdbcType=DECIMAL}, sampling_programme_no = #{samplingProgrammeNo}, AQL = #{aql,jdbcType=DECIMAL}, AC = #{ac,jdbcType=DECIMAL}, RE = #{re,jdbcType=DECIMAL} <where> site = #{site} and attribute_no = #{attributeNo} AND template_id = #{templateId} AND attribute_type = #{attributeType} and bu_no = #{buNo} <if test = "operation != null and operation != ''"> AND operation = #{operation} </if> <if test = "resourceID != null and resourceID != ''"> AND resource_id = #{resourceID} </if> <if test = "manufacturerID != null and manufacturerID != ''"> AND manufacturer_id = #{manufacturerID} </if> </where> </update>
<!-- 更新物料属性修改时间 --> <update id="updatePartAttributeTime" parameterType="QcTemplateData"> UPDATE qc_part_attribute SET update_date = getDate(), update_by = #{updateBy} WHERE site = #{site} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and bu_no = #{buNo} </update>
<!-- ================================================= 类别属性设置维护 ================================================= -->
<!-- 查询类别属性 --> <select id="qcFamilyAttributeSearch" parameterType="QcPartAttributeData" resultType="QcPartAttributeData"> SELECT qa.site, qa.bu_no, dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc, qa.attribute_no as familyID, pf.FamilyName, qa.supplier_no, qa.attribute_remark, qa.create_time, qa.create_by, qa.update_date, qa.update_by, qa.attribute_type FROM qc_part_attribute as qa LEFT JOIN PartFamily as pf on qa.attribute_no = pf.FamilyID and qa.site = pf.site <where> qa.site in (select site from eam_access_site where username = #{query.userName}) and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName})) and qa.attribute_type = #{query.attributeType} <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc} </if> <if test = "query.familyID != null and query.familyID != ''"> AND qa.attribute_no LIKE '%' + #{query.familyID}+'%' </if> <if test = "query.familyName != null and query.familyName != ''"> AND pf.FamilyName LIKE '%' + #{query.familyName}+'%' </if> </where> </select>
<!-- 新增类别属性 --> <insert id="qcFamilyAttributeSave" parameterType="QcPartAttributeData"> INSERT INTO qc_part_attribute (attribute_no, attribute_remark, create_time, create_by, attribute_type, site, bu_no) VALUES(#{familyID}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{buNo}) </insert>
<!-- 删除分类属性 --> <delete id="qcFamilyAttributeDelete" parameterType="QcPartAttributeData"> DELETE FROM qc_part_attribute WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo} </delete>
<!-- 删除分类属性模板 --> <delete id="deleteFamilyAttributeTemplate" parameterType="QcPartAttributeData"> DELETE FROM qc_attribute_template WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo} </delete>
<!-- ================================================= 抽样方案维护 ================================================= -->
<!-- 查询类别属性 --> <select id="samplingProgrammeSearch" parameterType="QcSamplingInspectionProgrammeData" resultType="QcSamplingInspectionProgrammeData"> SELECT site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, sampling_programme_no, sampling_programme_desc, sampling_programme_code, create_time, create_by, update_date, update_by FROM qc_sampling_inspection_programme <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test = "query.samplingProgrammeNo != null and query.samplingProgrammeNo != ''"> AND sampling_programme_no LIKE '%' + #{query.samplingProgrammeNo}+'%' </if> <if test = "query.samplingProgrammeCode != null and query.samplingProgrammeCode != ''"> AND sampling_programme_code LIKE '%' + #{query.samplingProgrammeCode}+'%' </if> <if test = "query.samplingProgrammeDesc != null and query.samplingProgrammeDesc != ''"> AND sampling_programme_desc LIKE '%' + #{query.samplingProgrammeDesc}+'%' </if> </where> </select>
<!-- 新增抽样方案 --> <insert id="samplingProgrammeSave" parameterType="QcSamplingInspectionProgrammeData"> INSERT INTO qc_sampling_inspection_programme (site, bu_no, sampling_programme_no, sampling_programme_desc, sampling_programme_code, create_time, create_by, update_date, update_by) VALUES(#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{samplingProgrammeCode}, getDate(), #{createBy}, getDate(), #{updateBy}) </insert>
<!-- 删除抽样方案 --> <delete id="samplingProgrammeDelete" parameterType="QcSamplingInspectionProgrammeData"> DELETE FROM qc_sampling_inspection_programme WHERE site = #{site} and bu_no = #{buNo} AND sampling_programme_no = #{samplingProgrammeNo} </delete>
<!-- 删除抽样方案中的矩阵 --> <delete id="deletePlanByProgrammeNo" parameterType="QcSamplingInspectionProgrammeData"> DELETE FROM qc_programme_plan WHERE sampling_programme_no = #{samplingProgrammeNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 根据名称查询抽样方案 --> <select id="selectSamplingProgrammeByDesc" parameterType="QcSamplingInspectionProgrammeData" resultType="QcSamplingInspectionProgrammeData"> SELECT site, bu_no, sampling_programme_no, sampling_programme_desc FROM qc_sampling_inspection_programme WHERE sampling_programme_desc = #{samplingProgrammeDesc} AND site = #{site} and bu_no = #{buNo} </select>
<!-- 获取最大抽样方案编码 --> <select id="queryLastSamplingProgrammeNo" resultType="string" parameterType="QcSamplingInspectionProgrammeData"> SELECT top 1 sampling_programme_no FROM qc_sampling_inspection_programme where site = #{site} and bu_no = #{buNo} ORDER BY sampling_programme_no Desc </select>
<!-- 搜索抽样方案中的矩阵 --> <select id="searchSamplingProgrammeDetails" parameterType="QcSamplingInspectionProgrammeData" resultType="QcSamplingInspectionProgrammeData"> SELECT qpp.site, qpp.bu_no, qpp.sampling_programme_no, qsip.sampling_plan_no, qsip.sampling_plan_Desc, qsip.sampling_qty_no, qsiq.sampling_qty_desc, qsiq.sampling_qty, qsip.sampling_qty_rank_no, qsiqr.sampling_qty_rank_desc, qsiqr.min_qty, qsiqr.max_qty, qsip.sampling_level_no, qsil.sampling_level_desc, qsip.sampling_plan_active FROM qc_programme_plan as qpp LEFT JOIN qc_sampling_inspection_plan as qsip on qpp.sampling_plan_no = qsip.sampling_plan_no and qpp.site = qsip.site and qpp.bu_no = qsip.bu_no LEFT JOIN qc_sampling_inspection_qty as qsiq on qsip.sampling_qty_no = qsiq.sampling_qty_no and qsip.site = qsiq.site and qsip.bu_no = qsiq.bu_no LEFT JOIN qc_sampling_inspection_qty_rank as qsiqr on qsip.sampling_qty_rank_no = qsiqr.sampling_qty_rank_no and qsip.site = qsiqr.site and qsip.bu_no = qsiqr.bu_no LEFT JOIN qc_sampling_inspection_level as qsil on qsip.sampling_level_no = qsil.sampling_level_no and qsip.site = qsil.site and qsip.bu_no = qsil.bu_no WHERE qpp.sampling_programme_no = #{samplingProgrammeNo} and qpp.site = #{site} and qpp.bu_no = #{buNo} </select>
<!-- 获取该方案不包含的矩阵 --> <select id="getPlanList" resultType="QcSamplingInspectionProgrammeData" parameterType="QcSamplingInspectionProgrammeData"> SELECT qip.sampling_plan_no, qip.sampling_plan_desc FROM qc_sampling_inspection_plan as qip LEFT JOIN qc_programme_plan as qpp ON qpp.sampling_plan_no = qip.sampling_plan_no and qpp.sampling_programme_no = #{samplingProgrammeNo} and qpp.site = qip.site and qpp.bu_no = qip.bu_no WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no is null </select>
<!-- 获取当前方案所包含的矩阵 --> <select id="getProgrammePlanList" resultType="QcSamplingInspectionProgrammeData" parameterType="QcSamplingInspectionProgrammeData"> SELECT qip.sampling_plan_no, qip.sampling_plan_desc FROM qc_programme_plan as qpp LEFT JOIN qc_sampling_inspection_plan as qip ON qpp.sampling_plan_no = qip.sampling_plan_no and qpp.site = qip.site and qpp.bu_no = qip.bu_no WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no = #{samplingProgrammeNo} </select>
<!-- 查重 --> <select id="searchPlanRepeat" resultType="QcSamplingInspectionProgrammeData" parameterType="QcSamplingInspectionProgrammeData"> SELECT sampling_plan_no, sampling_programme_no FROM qc_programme_plan WHERE sampling_programme_no = #{samplingProgrammeNo} AND sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 新增抽样方案中的矩阵 --> <insert id="saveSamplingProgrammeDetails" parameterType="QcSamplingInspectionProgrammeData"> INSERT INTO qc_programme_plan (site, bu_no, sampling_programme_no, sampling_plan_no) VALUES (#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingPlanNo}) </insert>
<!-- 更新抽样方案修改时间 --> <update id="updateSamplingInspectionProgrammeDate" parameterType="QcSamplingInspectionProgrammeData"> UPDATE qc_sampling_inspection_programme SET update_date = getDate(), update_by = #{updateBy} WHERE site = #{site} AND sampling_programme_no = #{samplingProgrammeNo} and bu_no = #{buNo} </update>
<!-- 删除抽样方案中的矩阵 --> <delete id="deleteSamplingProgrammeDetails" parameterType="QcSamplingInspectionProgrammeData"> DELETE FROM qc_programme_plan WHERE sampling_programme_no = #{samplingProgrammeNo} and sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- ================================================= FAI检验维护 ================================================= -->
<!-- 查询FAI基础数据 --> <select id="selectFAIBasicData" resultType="QcFAIRecordData"> SELECT top 1 a.orderno as orderNo, j.partNo, dbo.Get_Part_DescSpec(j.site, j.partNo) as partDesc, c.operation_desc, 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 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 so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site LEFT JOIN part j ON a.site = j.site and a.part_no = 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="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} <if test = "supplierNo != null and supplierNo != ''"> AND qat.manufacturer_id = #{supplierNo} </if> </where> </select>
<!-- 获取该物料属性下维护的ipqc --> <select id="selectPartAttributeByOperationAndResource" resultType="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="QcFAIRecordData" parameterType="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="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>
<!-- 新增FAI明细记录信息 --> <insert id="saveFAIDetailedRecord" parameterType="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) 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}) </insert>
<!-- 查询FAI主记录信息 --> <select id="qcFAIInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, state, inspection_result, task_date, inspection_type_no, dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName, inspection_cycle, order_no, operation_desc, resource_id, dbo.qc_get_resource_desc(site, resource_id, work_center_no) as resourceDesc, part_no, dbo.Get_Part_DescSpec(site, part_no) as part_desc, inspection_remark, roll_qty, sampling_qty, disposal_measures, disposal_remark, inspector_date, inspector_no, dbo.qc_get_inspector_name(site, inspector_no) as inspectorName, ssr_id, unqualified_qty, submit_flag, dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode, dbo.qc_get_sku(part_no) as sku, dbo.qc_get_spec(part_no) as spec, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, dbo.qc_get_um_name(site, um_id) as umName, action_date, action_by, isnull(dbo.joint_id(site, bu_no, inspection_no, 'coordination'), '') as operator, isnull(dbo.joint_name(site, bu_no, inspection_no, 'coordination'), '') as operatorName, isnull(dbo.joint_id(site, bu_no, inspection_no, 'responsible'), '') as responsiblePerson, isnull(dbo.joint_name(site, bu_no, inspection_no, 'responsible'), '') as responsiblePersonName FROM qc_fai_record <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test = "query.inspectionNo != null and query.inspectionNo != ''"> AND inspection_no LIKE '%' + #{query.inspectionNo} + '%' </if> <if test = "query.partNo != null and query.partNo != ''"> AND part_no LIKE '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.qc_get_part_desc(part_no) LIKE '%' + #{query.partDesc} + '%' </if> <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''"> AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%' </if> <if test = "query.sku != null and query.sku != ''"> AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%' </if> <if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%' </if> <if test = "query.states != null and query.states.size > 0"> AND state in <foreach item="item" collection="query.states" open="(" separator="," close=")"> #{item} </foreach> </if> <if test = "query.inspectionResult != null and query.inspectionResult != ''"> AND inspection_result = #{query.inspectionResult} </if> <if test = "query.orderNo != null and query.orderNo != ''"> AND order_no LIKE '%' + #{query.orderNo} + '%' </if> <if test = "query.seqNo != null and query.seqNo != ''"> AND seq_no LIKE '%' + #{query.seqNo} + '%' </if> <if test = "query.operationDesc != null and query.operationDesc != ''"> AND operation_desc LIKE '%' + #{query.operationDesc} + '%' </if> <if test="query.startDate != null"> AND inspector_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= inspector_date </if> <if test="query.startDate2 != null"> AND task_date >= #{query.startDate2} </if> <if test="query.endDate2 != null"> AND #{query.endDate2} >= task_date </if> </where> ORDER BY CASE WHEN state = '待检验' THEN 1 WHEN state = '待审核' THEN 2 WHEN state = '已完成' THEN 3 END, task_date desc </select>
<!-- 获取物料的类别编码 --> <select id="selectFamilyIdByPartNo" parameterType="string" resultType="string"> SELECT spec as FamilyID FROM part WHERE partNo = #{partNo} AND site = #{site} </select>
<!-- FAI明细记录查询 --> <select id="faiDetailSearch" parameterType="QcFAIRecordData" resultType="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 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} </select>
<!-- 修改FAI主记录信息 --> <update id="updateFAIMasterRecord" parameterType="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 = getDate(), sampling_qty = #{samplingQty,jdbcType=DECIMAL}, roll_qty = #{rollQty,jdbcType=DECIMAL}, unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL} WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo} </update>
<!-- 修改FAI明细记录信息 --> <update id="updateFAIDetailedRecord" parameterType="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="QcFAIRecordData"> UPDATE qc_fai_sub_detail_record SET is_submit = 'Y' WHERE inspection_no = #{inspectionNo} </update>
<!-- 删除FAI检验记录 --> <delete id="deleteFAIRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_fai_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除FAI明细记录信息 --> <delete id="deleteFAIDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_fai_detailed_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除FAI子明细记录信息 --> <delete id="deleteFAISubDetailedRecord" parameterType="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="QcFAIRecordData"> UPDATE qc_fai_record SET submit_flag = 'Y', state = '已完成' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改FAI明细记录标识为已提交 --> <update id="updateFAIDetailSubmitFlag" parameterType="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="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="SubDetailValues" resultType="QcFAIRecordData"> SELECT submit_flag FROM qc_fai_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 删除子明细的老数据 --> <delete id="delFAISubDetailedRecord" parameterType="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) VALUES <foreach collection="list" item="item" separator=","> (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}) </foreach> </insert>
<!-- 查询FAI的子明细 --> <select id="selectFAISubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues"> SELECT site, bu_no, sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_fai_sub_detail_record WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 获取该项目的子明细值 --> <select id="selectFAISubDetailValue" parameterType="string" resultType="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="QcFAIRecordData"> SELECT top 1 a.orderno as orderNo, j.partNo, dbo.Get_Part_DescSpec(j.site, j.partNo) as part_desc, c.operation_desc, 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 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 so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site LEFT JOIN part j ON a.site = j.site and a.part_no = 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="QcFAIRecordData" parameterType="string" statementType="CALLABLE"> {CALL getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR}) } </select>
<!-- 新增IPQC明细记录信息 --> <insert id="saveIPQCDetailedRecord" parameterType="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, serial_no) 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}, #{serialNo}) </insert>
<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, serial_no) 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.serialNo}) </foreach> </insert>
<!-- 新增IPQC记录到count表 --> <insert id="saveIPQCRecordCount" parameterType="QcFAIRecordData"> INSERT INTO qc_ipqc_record_count (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, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, new_data) VALUES(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId}, #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId}, 'Y') </insert>
<!-- 新增IPQC主记录信息 --> <insert id="saveIPQCRecord" parameterType="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, pass_qty, create_by, important_flag, actual_resource_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}, #{samplingQty}, #{createBy}, #{importantFlag}, #{actualResourceId}) </insert>
<!-- 查询IPQC主记录信息 --> <select id="qcIPQCInspectionSearch" parameterType="QcFAIRecordData" resultType="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, a.inspection_cycle, a.order_no, a.operation_desc, a.resource_id, dbo.qc_get_resource_desc(a.site, a.resource_id, a.work_center_no) as resourceDesc, a.part_no, p.PartDescription as part_desc, a.inspection_remark, a.roll_qty, a.sampling_qty, a.disposal_measures, a.disposal_remark, a.inspector_date, a.inspector_no,<!-- dbo.qc_get_inspector_name(a.site, a.inspector_no) as inspectorName,--> a.ssr_id, a.unqualified_qty, a.submit_flag, p.spec, a.seq_no, a.batch_roll_no, a.special_requirements, a.work_center_no, w.WorkCenterDesc, a.roll_no, a.um_id, dbo.qc_get_um_name(a.site, a.um_id) 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, 'supplier'), '') as responsiblePerson, a.pass_qty, a.not_pass_qty, p.DefaultDepartmentID as departmentID, d.DepartmentName, a.create_by, a.important_flag, c.shiftno as shiftNo, c.shiftdesc as shiftDesc, a.actual_resource_id, r.resourceDesc as actualResourceDesc FROM qc_ipqc_record as a left join WorkCenter as w on w.Site = a.Site AND w.WorkCenterNo = a.work_center_no left join part as p on a.site = p.site and a.part_no = p.partNo left join department as d on d.site = p.site and d.DepartmentID = p.DefaultDepartmentID left join SOScheduledRouting as b ON a.site = b.Site AND a.seq_no = b.BarcodeID LEFT JOIN calendar_datetype_shift as c ON b.Site = c.site AND b.ShiftId = c.ID left join WorkCenterResource as r on a.site = r.site and a.actual_resource_id = r.resourceID <where> a.site in (select site from eam_access_site where username = #{query.userName}) and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc} </if> <if test = "query.inspectionNo != null and query.inspectionNo != ''"> AND a.inspection_no LIKE #{query.inspectionNo} </if> <if test = "query.partNo != null and query.partNo != ''"> AND a.part_no LIKE #{query.partNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND p.PartDescription LIKE #{query.partDesc} </if> <if test = "query.states != null and query.states.size > 0"> AND a.state in <foreach item="item" collection="query.states" open="(" separator="," close=")"> #{item} </foreach> </if> <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''"> AND a.inspection_type_no = #{query.inspectionTypeNo} </if> <if test = "query.inspectionResult != null and query.inspectionResult != ''"> AND a.inspection_result = #{query.inspectionResult} </if> <if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> AND a.disposal_measures = #{query.disposalMeasures} </if> <if test = "query.orderNo != null and query.orderNo != ''"> AND a.order_no LIKE #{query.orderNo} </if> <if test = "query.seqNo != null and query.seqNo != ''"> AND a.seq_no LIKE #{query.seqNo} </if> <if test = "query.operationDesc != null and query.operationDesc != ''"> AND a.operation_desc LIKE #{query.operationDesc} </if> <if test="query.startDate != null"> AND a.inspector_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= a.inspector_date </if> <if test = "query.createBy != null and query.createBy != ''"> AND a.create_by LIKE #{query.createBy} </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.workCenterNo != null and query.workCenterNo != ''"> AND a.work_center_no like #{query.workCenterNo} </if> <if test = "query.shiftDesc != null and query.shiftDesc != ''"> AND c.shiftdesc = #{query.shiftDesc} </if> </where> ORDER BY CASE WHEN a.state = '待检验' THEN 1 WHEN a.state = '待审核' THEN 2 WHEN a.state = '已完成' THEN 3 END, a.task_date desc </select>
<!-- IPQC明细记录查询 --> <select id="ipqcDetailSearch" parameterType="QcFAIRecordData" resultType="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, a.unqualified_quantity,-- 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 FROM qc_ipqc_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 COALESCE(a.serial_no, 99999) ASC </select>
<!-- 删除IPQC检验记录 --> <delete id="deleteIPQCRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_ipqc_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除IPQC检验记录 --> <delete id="deleteIPQCRecordCount" parameterType="QcFAIRecordData"> DELETE FROM qc_ipqc_record_count WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除IPQC明细记录信息 --> <delete id="deleteIPQCDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_ipqc_detailed_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除IPQC子明细记录信息 --> <delete id="deleteIPQCSubDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_ipqc_sub_detail_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 修改IPQC主记录信息 --> <update id="updateIPQCMasterRecord" parameterType="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 = getDate(), 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}, actual_resource_id = #{actualResourceId} WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </update>
<!-- 修改IPQC明细记录信息 --> <update id="updateIPQCDetailedRecord" parameterType="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} WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改IPQC主记录标识为已提交 --> <update id="updateIPQCMasterSubmitFlag" parameterType="QcFAIRecordData"> UPDATE qc_ipqc_record SET submit_flag = 'Y', state = '已完成' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改IPQC明细记录标识为已提交 --> <update id="updateIPQCDetailSubmitFlag" parameterType="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="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="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) VALUES <foreach collection="list" item="item" separator=","> (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}) </foreach> </insert>
<!-- 查询IPQC的子明细 --> <select id="selectIPQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues"> SELECT sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_ipqc_sub_detail_record WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 查询IPQC检验记录是否已提交 --> <select id="checkIPQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData"> SELECT submit_flag FROM qc_ipqc_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 获取该项目的子明细值 --> <select id="selectIPQCSubDetailValue" parameterType="string" resultType="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>
<!-- 查询工序列表 --> <select id="getOperationList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT a.site, a.BarcodeID as seqNo, a.SOOrderNo as orderNo, a.PartNo, p.PartDescription + Isnull(p.Spec,'') as part_desc, t.lotsize, a.QtyRequired as qtyrequired, a.OperationDesc as operationDesc, p.UMID as umId, t.status, p.spec, a.S_ResourceID as resourceId, w.ResourceDesc as resourceDesc, a.S_workCenterNo as workCenterNo FROM SOScheduledRouting AS a inner join ShopOrder as t ON t.Site = a.Site AND t.OrderNo = a.SOOrderNo inner join WorkCenterResource as w ON w.Site = a.Site AND w.WorkCenterNo = a.S_WorkCenterNo and w.ResourceID = a.S_ResourceID left join part as p on a.site = p.site and a.partNo = p.partNo WHERE a.BarcodeID = #{seqNo} </select>
<!-- 根据工单号和工序号查出所有数据 --> <select id="getResourceList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT a.s_resourceid as resourceId, DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc, c.work_center_no FROM soscheduledrouting as a LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no LEFT JOIN so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site 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>
<!-- a.orderno = #{orderNo} and c.operation_desc = #{operationDesc}-->
<!-- 查询机台名称 --> <select id="selectResourceDesc" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT distinct resource_desc FROM resource WHERE site = #{site} and resource_id = #{resourceId} </select>
<!-- 查询物料名称 --> <select id="selectPartDesc" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT distinct dbo.Get_Part_DescSpec(site, partNo) as part_desc FROM part WHERE site = #{site} and partNo = #{partNo} </select>
<!-- ================================================= IQC检验维护 ================================================= --> <!-- 查询IQC基础数据 --> <select id="selectIQCBasicData" resultType="QcFAIRecordData" parameterType="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) part_desc, qir.roll_qty, qir.print_flag, qir.create_by, qir.supplier_no, qir.site, qir.bu_no, qir.po_orderNo, qir.po_itemNo, qir.roll_count, qir.sampling_qty 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 eam_access_site where username = #{userName}) and (qir.site + '-' + qir.bu_no) in (select * from dbo.query_bu(#{userName})) and qir.detail_flag = 'N' </select>
<!-- 新增IQC明细记录信息 --> <insert id="saveIQCDetailedRecord" parameterType="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, serial_no) 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}, #{serialNo}) </insert>
<!-- 修改IQC检验记录 --> <update id="updateIQCRecord" parameterType="QcFAIRecordData"> UPDATE qc_iqc_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 WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 查询IQC主记录信息 --> <select id="qcIQCInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, state, inspection_result, create_date as taskDate, inspection_type_no, inspection_cycle, part_no, dbo.Get_Part_DescSpec(site, part_no) as part_desc, dbo.qc_get_part_umid(site, part_no) as umId, inspection_remark, roll_qty, sampling_qty, disposal_measures, disposal_remark, inspector_date, inspector_no, dbo.qc_get_inspector_name(site, inspector_no) as inspectorName, submit_flag, roll_no, supplier_no, dbo.qc_get_supplier_name(site, supplier_no) as supplierDesc, po_orderNo, po_itemNo, roll_count, '' as orderType, action_date, action_by, isnull(dbo.joint_id(site, bu_no, inspection_no, 'coordination'), '') as operator, isnull(dbo.joint_name(site, bu_no, inspection_no, 'coordination'), '') as operatorName, isnull(dbo.joint_id(site, bu_no, inspection_no, 'supplier'), '') as responsiblePerson, receipt_no, receipt_item_no, pass_qty, not_pass_qty, ref_info1, ref_info2, ref_info3, ref_info4, ref_info5, warehouse_id, dbo.Get_WareHouseDesc(site, warehouse_id) as warehouseName, dbo.qc_get_iqc_template_id(site, bu_no, inspection_no) as templateId FROM qc_iqc_record <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test = "query.inspectionNo != null and query.inspectionNo != ''"> AND inspection_no LIKE #{query.inspectionNo} </if> <if test = "query.states != null and query.states.size > 0"> AND state in <foreach item="item" collection="query.states" open="(" separator="," close=")"> #{item} </foreach> </if> <if test = "query.inspectionResult != null and query.inspectionResult != ''"> AND inspection_result = #{query.inspectionResult} </if> <if test = "query.partNo != null and query.partNo != ''"> AND part_no LIKE #{query.partNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.Get_Part_DescSpec(site, part_no) LIKE #{query.partDesc} </if> <if test = "query.supplierNo != null and query.supplierNo != ''"> AND supplier_no like #{query.supplierNo} </if> <if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> AND disposal_measures = #{query.disposalMeasures} </if> <if test = "query.inspectorName != null and query.inspectorName != ''"> AND dbo.qc_get_inspector_name(site, inspector_no) LIKE #{query.inspectorName} </if> <if test="query.startDate != null"> AND inspector_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= inspector_date </if> <if test="query.startDate2 != null"> AND create_date >= #{query.startDate2} </if> <if test="query.endDate2 != null"> AND #{query.endDate2} >= create_date </if> <if test = "query.poOrderNo != null and query.poOrderNo != ''"> AND po_orderNo LIKE #{query.poOrderNo} </if> <if test = "query.poItemNo != null and query.poItemNo != ''"> AND po_itemNo LIKE #{query.poItemNo} </if> <if test = "query.orderType != null and query.orderType != ''"> AND dbo.qc_get_order_type(site, po_orderNo, po_itemNo) = #{query.orderType} </if> <if test = "query.warehouseId != null and query.warehouseId != ''"> AND warehouse_id like #{query.warehouseId} </if> <if test = "query.warehouseName != null and query.warehouseName != ''"> AND dbo.Get_WareHouseDesc(site, warehouse_id) like #{query.warehouseName} </if> <if test = "query.receiptNo != null and query.receiptNo != ''"> AND receipt_no LIKE #{query.receiptNo} </if> <if test = "query.refInfo1 != null and query.refInfo1 != ''"> AND ref_info1 LIKE #{query.refInfo1} </if> <if test = "query.refInfo2 != null and query.refInfo2 != ''"> AND ref_info2 LIKE #{query.refInfo2} </if> <if test = "query.refInfo3 != null and query.refInfo3 != ''"> AND ref_info3 LIKE #{query.refInfo3} </if> <if test = "query.refInfo4 != null and query.refInfo4 != ''"> AND ref_info4 LIKE #{query.refInfo4} </if> <if test = "query.refInfo5 != null and query.refInfo5 != ''"> AND ref_info5 LIKE #{query.refInfo5} </if> </where> ORDER BY CASE WHEN state = '待检验' THEN 1 WHEN state = '待审核' THEN 2 WHEN state = '已完成' THEN 3 END, create_date desc </select>
<!-- IQC明细记录查询 --> <select id="iqcDetailSearch" parameterType="QcFAIRecordData" resultType="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.is_submit, a.unqualified_quantity,-- 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, a.sampling_qty, d.defect_level_code, dbo.get_defect_level_code_desc(a.site, a.bu_no, d.defect_level_code) as defectLevelDescription FROM qc_iqc_detailed_record as a left join eam_properties_item as d on a.site = d.site and a.item_no = d.ItemNo and a.bu_no = d.bu_no 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.serial_no, 99999) ASC </select>
<!-- 查询IQC的子明细 --> <select id="selectIQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues"> SELECT site, bu_no, sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_iqc_sub_detail_record WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 获取该项目的子明细值 --> <select id="selectIQCSubDetailValue" parameterType="string" resultType="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="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 = getDate(), 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} WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo} </update>
<!-- 修改IQC明细记录信息 --> <update id="updateIQCDetailedRecord" parameterType="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} WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 查询该记录明细是否已存在 --> <select id="checkIQCDetail" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, template_id FROM qc_iqc_detailed_record WHERE inspection_no = #{inspectionNo} and site = #{site} </select>
<!-- 查询IQC检验记录是否已提交 --> <select id="checkIQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData"> SELECT submit_flag FROM qc_iqc_record WHERE inspection_no = #{inspectionNo} and site = #{site} </select>
<!-- 删除IQC子明细的老数据 --> <delete id="delIQCSubDetailedRecord" parameterType="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) VALUES <foreach collection="list" item="item" separator=","> (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}) </foreach> </insert>
<!-- 修改IQC主记录标识为已提交 --> <update id="updateIQCMasterSubmitFlag" parameterType="QcFAIRecordData"> UPDATE qc_iqc_record SET submit_flag = 'Y', state = '已完成' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改IQC明细记录标识为已提交 --> <update id="updateIQCDetailSubmitFlag" parameterType="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="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="QcFAIRecordData"> DELETE FROM qc_iqc_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除IQC明细记录信息 --> <delete id="deleteIQCDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_iqc_detailed_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除IQC子明细记录信息 --> <delete id="deleteIQCSubDetailedRecord" parameterType="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="SysOssEntity" resultType="SysOssEntity"> SELECT id, file_name FROM sys_oss WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2} </select>
<!-- 获取工序列表 --> <select id="getOperationDescList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData"> SELECT distinct operation_desc FROM so_routing <where> <if test = "operationDesc != null and operationDesc != ''"> AND operation_desc LIKE '%' + #{operationDesc} + '%' </if> </where> </select>
<!-- 获取供应商列表 --> <select id="getManufacturerList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData"> SELECT supplierID as manufacturerID, supplierName as manufacturerName FROM Supplier <where> site = #{site} <if test = "manufacturerID != null and manufacturerID != ''"> AND supplierID LIKE '%' + #{manufacturerID} + '%' </if> <if test = "manufacturerName != null and manufacturerName != ''"> AND supplierName LIKE '%' + #{manufacturerName} + '%' </if> </where> </select>
<!-- 获取客户列表 --> <select id="getCustomerList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData"> SELECT CustomerID as customerID, CustomerName as customerName FROM Customer <where> site = #{site} <if test = "customerID != null and customerID != ''"> AND CustomerID LIKE '%' + #{customerID} + '%' </if> <if test = "customerName != null and customerName != ''"> AND CustomerName LIKE '%' + #{customerName} + '%' </if> </where> </select>
<!-- 获取机台列表 --> <select id="getAllResourceList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT distinct resource_id, resource_desc FROM resource <where> site = #{site} <if test = "resourceId != null and resourceId != ''"> AND resource_id LIKE '%' + #{resourceId} + '%' </if> <if test = "resourceDesc != null and resourceDesc != ''"> AND resource_desc LIKE '%' + #{resourceDesc} + '%' </if> </where> </select>
<!-- 获取工单列表 --> <select id="getOrderNoList" parameterType="QcFAIRecordData" resultType="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 so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site 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="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, state, inspection_result, task_date, inspection_type_no, dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName, inspection_cycle, order_no, operation_desc, resource_id, dbo.qc_get_resource_desc(site, resource_id, work_center_no) as resourceDesc, part_no, dbo.qc_get_part_desc(part_no) as part_desc, inspection_remark, roll_qty, sampling_qty, disposal_measures, disposal_remark, inspector_date, inspector_no, dbo.qc_get_inspector_name(site, inspector_no) as inspectorName, ssr_id, unqualified_qty, submit_flag, dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode, dbo.qc_get_sku(part_no) as sku, dbo.qc_get_spec(part_no) as spec, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, dbo.qc_get_um_name(site, um_id) as umName, action_date, action_by, isnull(dbo.joint_id(site, bu_no, inspection_no, 'coordination'), '') as operator, isnull(dbo.joint_name(site, bu_no, inspection_no, 'coordination'), '') as operatorName, isnull(dbo.joint_id(site, bu_no, inspection_no, 'responsible'), '') as responsiblePerson, isnull(dbo.joint_name(site, bu_no, inspection_no, 'responsible'), '') as responsiblePersonName FROM qc_fqc_record <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test = "query.inspectionNo != null and query.inspectionNo != ''"> AND inspection_no LIKE '%' + #{query.inspectionNo} + '%' </if> <if test = "query.partNo != null and query.partNo != ''"> AND part_no LIKE '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.qc_get_part_desc(part_no) LIKE '%' + #{query.partDesc} + '%' </if> <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''"> AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%' </if> <if test = "query.sku != null and query.sku != ''"> AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%' </if> <if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%' </if> <if test = "query.states != null and query.states.size > 0"> AND state in <foreach item="item" collection="query.states" open="(" separator="," close=")"> #{item} </foreach> </if> <if test = "query.inspectionResult != null and query.inspectionResult != ''"> AND inspection_result = #{query.inspectionResult} </if> <if test = "query.orderNo != null and query.orderNo != ''"> AND order_no LIKE '%' + #{query.orderNo} + '%' </if> <if test = "query.seqNo != null and query.seqNo != ''"> AND seq_no LIKE '%' + #{query.seqNo} + '%' </if> <if test = "query.operationDesc != null and query.operationDesc != ''"> AND operation_desc LIKE '%' + #{query.operationDesc} + '%' </if> <if test="query.startDate != null"> AND inspector_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= inspector_date </if> <if test="query.startDate2 != null"> AND task_date >= #{query.startDate2} </if> <if test="query.endDate2 != null"> AND #{query.endDate2} >= task_date </if> </where> ORDER BY CASE WHEN state = '待检验' THEN 1 WHEN state = '待审核' THEN 2 WHEN state = '已完成' THEN 3 END, task_date desc </select>
<!-- 新增FQC明细记录信息 --> <insert id="saveFQCDetailedRecord" parameterType="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) 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}) </insert>
<!-- 新增FQC主记录信息 --> <insert id="saveFQCRecord" parameterType="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) 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>
<!-- FQC明细记录查询 --> <select id="fqcDetailSearch" parameterType="QcFAIRecordData" resultType="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_fqc_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 FROM qc_fqc_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} </select>
<!-- 删除FQC检验记录 --> <delete id="deleteFQCRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_fqc_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除FQC明细记录信息 --> <delete id="deleteFQCDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_fqc_detailed_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除FQC子明细记录信息 --> <delete id="deleteFQCSubDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_fqc_sub_detail_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 修改FQC主记录信息 --> <update id="updateFQCMasterRecord" parameterType="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 = getDate(), sampling_qty = #{samplingQty,jdbcType=DECIMAL}, roll_qty = #{rollQty,jdbcType=DECIMAL}, unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL} WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo} </update>
<!-- 修改FQC明细记录信息 --> <update id="updateFQCDetailedRecord" parameterType="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} WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改FQC主记录标识为已提交 --> <update id="updateFQCMasterSubmitFlag" parameterType="QcFAIRecordData"> UPDATE qc_fqc_record SET submit_flag = 'Y', state = '已完成' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改FAI明细记录标识为已提交 --> <update id="updateFQCDetailSubmitFlag" parameterType="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="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="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) VALUES <foreach collection="list" item="item" separator=","> (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}) </foreach> </insert>
<!-- 查询FQC的子明细 --> <select id="selectFQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues"> SELECT site, bu_no, sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_fqc_sub_detail_record WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 查询FQC检验记录是否已提交 --> <select id="checkFQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData"> SELECT submit_flag FROM qc_fqc_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 获取该项目的子明细值 --> <select id="selectFQCSubDetailValue" parameterType="string" resultType="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="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="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="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="PoOrderData" parameterType="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="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) VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}) </insert>
<!-- 检查动控是否开启 --> <select id="queryController" parameterType="SysSceneDynamicControlModelEntity" resultType="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="QcTemplateData" parameterType="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="QcFAIRecordData" parameterType="QcFAIRecordData"> select partNo, dbo.Get_Part_DescSpec(site, partNo) as part_desc, spec from part where site = #{site} and partNo = #{partNo} </select>
<!-- 获取特殊工序列表 --> <select id="getSpecialOperationList" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> select site, operation_no, operation_desc from qc_special_task_operation where site = #{site} </select>
<!-- 获取处置措施列表 --> <select id="disposalMeasuresSearch" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> SELECT id, disposal_measures FROM qc_disposal_measures <where> <if test = "inspectionTypeNo != '101'"> inspection_type != 'IPQC' </if> </where> </select>
<!-- 查询文件路径 --> <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="QcFAIRecordData"> SELECT id, url, file_name, new_file_name, created_by, order_ref1, order_ref2, order_ref3, order_ref4, file_type FROM sys_oss WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo} </select>
<!-- 删除图片--> <delete id="imageDelete" parameterType="SysOssEntity"> DELETE FROM sys_oss WHERE id = #{id} </delete>
<!-- 模糊查询标签号 --> <select id="getRollNo" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> SELECT DISTINCT top 3 a.seqno, a.orderno, b.roll_no FROM soscheduledrouting AS a LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno WHERE a.site = #{site} and b.roll_no like '%' + #{rollNo} + '%' </select>
<!-- 标签号回车事件 --> <select id="rollNoEnter" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> SELECT a.site, a.seqno as seqNo, a.orderno as orderNo, b.roll_no FROM soscheduledrouting AS a LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno WHERE b.roll_no = #{rollNo} </select>
<!-- 箱号回车事件 --> <select id="boxNoEnter" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> select A.Site, A.Site + '-' + B.OrderNo + '-' + CONVERT(varchar(20), B.ItemNo) AS SeqNo, B.OrderNo as orderNo, A.box_no from so_receive_boxes A LEFT JOIN SOScheduledRouting B ON A.SITE = B.SITE AND A.barcodeID = B.barcodeID where A.box_no = #{boxNo} </select>
<!-- 查询物料列表 --> <select id="queryPartList" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> SELECT site, partNo, dbo.Get_Part_DescSpec(site, partNo) as part_desc, spec FROM part <where> site = #{site} <if test = "partNo != null and partNo != ''"> AND partNo LIKE '%' + #{partNo} + '%' </if> <if test = "partDesc != null and partDesc != ''"> AND dbo.Get_Part_DescSpec(site, partNo) LIKE '%' + #{partDesc} + '%' </if> </where> </select>
<!-- 查询单位列表 --> <select id="umSearch" resultType="QcFAIRecordData" parameterType="QcFAIRecordData"> SELECT site, UMID as umId, UMName as umName FROM UM WHERE site = #{site} and active = #{active} </select>
<!-- 查询单位列表 --> <select id="checkItem" resultType="SubDetailValues" parameterType="SubDetailValues"> SELECT site, bu_no, inspection_no, item_no, value_type_db, min_value, max_value <if test = "flag == 'IPQC'"> FROM qc_ipqc_detailed_record </if> <if test = "flag == 'IQC'"> FROM qc_iqc_detailed_record </if> <if test = "flag == 'FQC'"> FROM qc_fqc_detailed_record </if> <if test = "flag == 'FAI'"> FROM qc_fai_detailed_record </if> WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo} </select>
<!-- 查询检验方法列表 --> <select id="queryMethodList" resultType="QcMethodData" parameterType="QcMethodData"> SELECT site, bu_no, method_no, method_name, inspection_type_no, dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName FROM qc_method <where> site = #{site} and bu_no = #{buNo} <if test = "methodNo != null and methodNo != ''"> AND method_no LIKE '%' + #{methodNo} + '%' </if> <if test = "methodName != null and methodName != ''"> AND method_name LIKE '%' + #{methodName} + '%' </if> <if test = "inspectionTypeNo != null and inspectionTypeNo != ''"> AND inspection_type_no = #{inspectionTypeNo} </if> <if test="inspectionTypeName != null and inspectionTypeName != ''"> AND dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName} </if> </where> </select>
<!-- 修改detailFlag字段为N --> <update id="updateIQCDetailFlag" parameterType="QcFAIRecordData"> UPDATE qc_iqc_record SET detail_flag = 'N' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 查询检验方法唯一 --> <select id="checkMethodOnlyOne" resultType="QcMethodData" parameterType="QcMethodData"> SELECT site, bu_no, method_no FROM qc_method <where> site = #{site} and bu_no = #{buNo} and method_no = #{methodNo} </where> </select>
<!-- 查询检验项目唯一 --> <select id="checkItemOnlyOne" resultType="QcItemData" parameterType="QcItemData"> SELECT site, bu_no, ItemNo, ItemDesc FROM eam_properties_item <where> site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ItemType = #{itemType} </where> </select>
<!-- 查询检验项目唯一 --> <select id="checkTemplateOnlyOne" resultType="QcTemplateData" parameterType="QcTemplateData"> SELECT site, bu_no, template_id, template_name FROM qc_template <where> site = #{site} and bu_no = #{buNo} and template_id = #{templateId} </where> </select>
<!-- <select id="searchSeqInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">--><!-- SELECT DISTINCT--><!-- a.SeqNo,--><!-- a.OrderNo,--><!-- a.PartNo,--><!-- p.PartDescription + Isnull(p.Spec,'') as part_desc,--><!-- t.lotsize,--><!-- a.qtyrequired,--><!-- a.operationDesc,--><!-- p.UMID as umId,--><!-- t.status--><!-- FROM view_virtual_SOScheduledRouting AS a--><!-- inner JOIN shoporder AS t ON t.OrderNo = a.OrderNo AND a.site = t.site--><!-- left join part as p on a.site = p.site and a.partNo = p.partNo--><!-- WHERE--><!-- a.site = #{query.site}--><!-- <if test="query.status != null and query.status != ''">--><!-- AND t.status = #{query.status}--><!-- </if>--><!-- <if test="(query.status == null or query.status == '') and query.cancelFlag == ''">--><!-- AND t.status <![CDATA[<>]]> '已取消'--><!-- </if>--><!-- <if test="query.orderNo != null and query.orderNo != ''">--><!-- AND a.orderno LIKE '%' + #{query.orderNo} + '%'--><!-- </if>--><!-- <if test="query.seqNo != null and query.seqNo != ''">--><!-- AND a.seqno LIKE '%' + #{query.seqNo} + '%'--><!-- </if>--><!-- <if test="query.partNo != null and query.partNo != ''">--><!-- AND a.partNo LIKE '%' + #{query.partNo} + '%'--><!-- </if>--><!-- <if test="query.partDesc != null and query.partDesc != ''">--><!-- AND dbo.Get_Part_DescSpec(a.site, a.partNo) LIKE '%' + #{query.partDesc} + '%'--><!-- </if>--><!-- <if test="query.operationDesc != null and query.operationDesc != ''">--><!-- AND a.operationDesc LIKE '%' + #{query.operationDesc} + '%'--><!-- </if>--><!-- </select>-->
<select id="searchSeqInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData"> SELECT a.site, a.BarcodeID as seqNo, a.SOOrderNo as orderNo, a.PartNo, p.PartDescription + Isnull(p.Spec,'') as part_desc, t.lotsize, a.QtyRequired as qtyrequired, a.OperationDesc as operationDesc, p.UMID as umId, t.status, p.spec, a.S_ResourceID as resourceId, w.ResourceDesc as resourceDesc, a.S_workCenterNo as workCenterNo FROM SOScheduledRouting AS a inner join ShopOrder as t ON t.Site = a.Site AND t.OrderNo = a.SOOrderNo inner join WorkCenterResource as w ON w.Site = a.Site AND w.WorkCenterNo = a.S_WorkCenterNo and w.ResourceID = a.S_ResourceID left join part as p on a.site = p.site and a.partNo = p.partNo WHERE a.site = #{query.site} <if test="query.status != null and query.status != ''"> AND t.status = #{query.status} </if> <if test="(query.status == null or query.status == '') and (query.cancelFlag == null or query.cancelFlag == '')"> AND t.status <![CDATA[<>]]> '已取消' </if> <if test="query.orderNo != null and query.orderNo != ''"> AND a.SOOrderNo LIKE '%' + #{query.orderNo} + '%' </if> <if test="query.seqNo != null and query.seqNo != ''"> AND a.BarcodeID LIKE '%' + #{query.seqNo} + '%' </if> <if test="query.partNo != null and query.partNo != ''"> AND a.partNo LIKE '%' + #{query.partNo} + '%' </if> <if test="query.partDesc != null and query.partDesc != ''"> AND (p.PartDescription + Isnull(p.Spec,'')) LIKE '%' + #{query.partDesc} + '%' </if> <if test="query.operationDesc != null and query.operationDesc != ''"> AND a.operationDesc LIKE '%' + #{query.operationDesc} + '%' </if> </select>
<select id="searchSeqInfo2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData"> SELECT a.site, a.BarcodeID as seqNo, a.SOOrderNo as orderNo, a.PartNo, p.PartDescription + Isnull(p.Spec,'') as part_desc, t.lotsize, a.QtyRequired as qtyrequired, a.OperationDesc as operationDesc, p.UMID as umId, t.status, p.spec, a.S_ResourceID as resourceId, w.ResourceDesc as resourceDesc, a.S_workCenterNo as workCenterNo, w2.WorkCenterDesc, p.DefaultDepartmentID as departmentID, d.DepartmentName, a.ScheduledDate, a.CreatedBy as createBy, isnull(a.roll_qty, 0) as rollQty, u.UserName as OperatorName, type_flag1, type_flag2, type_flag3, type_flag4, c.shiftno as shiftNo, c.shiftdesc as shiftDesc FROM SOScheduledRouting AS a inner join ShopOrder as t ON t.Site = a.Site AND t.OrderNo = a.SOOrderNo inner join WorkCenterResource as w ON w.Site = a.Site AND w.WorkCenterNo = a.S_WorkCenterNo and w.ResourceID = a.S_ResourceID left join part as p on a.site = p.site and a.partNo = p.partNo left join department as d on d.site = p.site and d.DepartmentID = p.DefaultDepartmentID left join WorkCenter as w2 on w2.Site = a.Site AND w2.WorkCenterNo = a.S_WorkCenterNo left join users as u on a.site = u.site and a.CreatedBy = u.UserID LEFT JOIN calendar_datetype_shift as c ON a.Site = c.site AND a.ShiftId = c.ID WHERE a.site in (select site from eam_access_site where username = #{query.userName}) <if test="query.cancelFlag == null or query.cancelFlag == ''"> AND a.QtyRequired <![CDATA[>]]> isnull(a.roll_qty, 0) </if> <if test="query.orderNo != null and query.orderNo != ''"> AND a.SOOrderNo LIKE #{query.orderNo} </if> <if test="query.seqNo != null and query.seqNo != ''"> AND a.BarcodeID LIKE #{query.seqNo} </if> <if test="query.partNo != null and query.partNo != ''"> AND a.partNo LIKE #{query.partNo} </if> <if test="query.partDesc != null and query.partDesc != ''"> AND (p.PartDescription + Isnull(p.Spec,'')) LIKE #{query.partDesc} </if> <if test="query.departmentID != null and query.departmentID != ''"> AND p.DefaultDepartmentID LIKE #{query.departmentID} </if> <if test="query.workCenterNo != null and query.workCenterNo != ''"> AND a.S_workCenterNo LIKE #{query.workCenterNo} </if> <if test="query.operationDesc != null and query.operationDesc != ''"> AND a.operationDesc LIKE #{query.operationDesc} </if> <if test="query.operatorName != null and query.operatorName != ''"> AND u.UserName LIKE #{query.operatorName} </if> <if test="query.startDate != null"> AND a.ScheduledDate >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= a.ScheduledDate </if> <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != '' and query.inspectionTypeNo == '首件检'"> AND a.type_flag1 = 'Y' </if> <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != '' and query.inspectionTypeNo == '自检'"> AND a.type_flag2 = 'Y' </if> <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != '' and query.inspectionTypeNo == '巡检'"> AND a.type_flag3 = 'Y' </if> <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != '' and query.inspectionTypeNo == '末件检'"> AND a.type_flag4 = 'Y' </if> <if test="query.shiftDesc != null and query.shiftDesc != ''"> AND c.shiftdesc = #{query.shiftDesc} </if> </select>
<select id="searchPartInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData"> select partNo, dbo.Get_Part_DescSpec(site, partNo) as part_desc from part where site = #{query.site} <if test='query.attributeFlag != null and query.attributeFlag != "" and query.attributeFlag == "Y"'> AND attribute_flag = 'Y' </if> <if test='query.attributeFlag != null and query.attributeFlag != "" and query.attributeFlag == "N"'> AND (attribute_flag is null or attribute_flag = '' or attribute_flag = 'N') </if> <if test="query.partNo != null and query.partNo != ''"> AND partNo LIKE '%' + #{query.partNo} + '%' </if> <if test="query.partDesc != null and query.partDesc != ''"> AND dbo.Get_Part_DescSpec(site, partNo) LIKE '%' + #{query.partDesc} + '%' </if> </select>
<select id="getInterfaceTimeData" parameterType="String" resultType="InterfaceTimeData"> SELECT id, start_time, end_time, del_flag FROM interface_time WHERE del_flag = 'N' and site = #{site} </select>
<update id="updateInterfaceTimeData" parameterType="InterfaceTimeData"> UPDATE interface_time set updated_by = #{updatedBy}, updated_date = #{updatedDate}, del_flag = #{delFlag} </update>
<select id="getInterfaceRdStyleData" parameterType="String" resultType="RdStyleData"> SELECT crdcode, crdname, iRdGrade, rdtype, brdend FROM view_custdev_mes_rdstyle WHERE crdname = #{crdName} </select>
<insert id="insertHardtagPurchaseInStorageData" parameterType="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="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="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="MailAddressData"> SELECT id, site, mail_address, send_type, del_flag, created_by, created_date, orderref1 FROM mailAddress WHERE site = #{site} and send_type = #{type} and del_flag = 'N' </select>
<select id="getSendMailFromAddress" resultType="MailSendAddressData"> SELECT port, host, username, password, emailForm, timeout, personal, id FROM mailSendAddress where delFlag = 'N' </select>
<!-- 新增发送邮件记录 --> <insert id="saveSendMailRecord" parameterType="SendMailRecord"> insert into send_mail_record (site, bu_no, document_no, sender, recipient, send_date) values (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate()) </insert>
<select id="orderTypeSearch" resultType="QcFAIRecordData"> SELECT distinct order_type FROM view_po_order </select>
<update id="actionIQCInspection" parameterType="QcFAIRecordData"> 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="QcFAIRecordData"> 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="QcFAIRecordData"> 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="QcFAIRecordData"> 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.collectionCondition}, #{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="QcFAIRecordData"> DELETE FROM eam_actual_operator WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo} </delete>
<select id="getInspectionNo" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData"> select site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method from Equipment_data_acquisition where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </select>
<select id="dataAcquisition" parameterType="EquipmentDataAcquisitionData" resultType="SubDetailValues"> select site, bu_no, #{inspectionNo} as inspectionNo, item_no, ${collectionSource} as subDetailValue from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> '' and item_no = #{itemNo} 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="EquipmentDataAcquisitionData" resultType="SysOssEntity"> select site as orderRef1, bu_no as orderRef4, #{inspectionNo} as orderRef2, item_no as orderRef3, ${collectionSource} as url from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> '' and item_no = #{itemNo} 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="QcFAIRecordData" resultType="EquipmentDataAcquisitionData"> select a.site, a.bu_no, b.collection_condition as equipmentNo, #{inspectionNo} as inspectionNo, a.item_no, b.collection_source, b.collection_condition, 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' </select>
<select id="getFAIDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData"> select a.site, a.bu_no, b.collection_condition as equipmentNo, #{inspectionNo} as inspectionNo, a.item_no, b.collection_source, b.collection_condition, 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' </select>
<select id="getIPQCDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData"> select a.site, a.bu_no, b.collection_condition as equipmentNo, #{inspectionNo} as inspectionNo, a.item_no, b.collection_source, b.collection_condition, 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' </select>
<select id="getFQCDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData"> select a.site, a.bu_no, b.collection_condition as equipmentNo, #{inspectionNo} as inspectionNo, a.item_no, b.collection_source, b.collection_condition, 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' </select>
<select id="querySubDetails" parameterType="QcFAIRecordData" resultType="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 == '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> where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} </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>
<!-- 查询DQAS基础数据 --> <select id="selectFQASBasicData" resultType="QcFAIRecordData" parameterType="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.create_by, qir.site, qir.bu_no, qir.roll_count FROM qc_stock_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 eam_access_site where username = #{userName}) and (qir.site + '-' + qir.bu_no) in (select * from dbo.query_bu(#{userName})) and qir.detail_flag = 'N' and qir.order_ref_type <![CDATA[<>]]> '发货通知单' </select>
<!-- 新增FQAS明细记录信息 --> <insert id="saveFQASDetailedRecord" parameterType="QcFAIRecordData"> INSERT INTO qc_stock_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, serial_no) 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}, #{serialNo}) </insert>
<!-- 修改FQAS检验记录 --> <update id="updateFQASRecord" parameterType="QcFAIRecordData"> UPDATE qc_stock_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 WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 查询FQAS主记录信息 --> <select id="qcFQASInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, state, inspection_result, create_date as taskDate, inspection_type_no, inspection_cycle, part_no, dbo.Get_Part_DescSpec(site, part_no) as part_desc, dbo.qc_get_part_umid(site, part_no) as umId, inspection_remark, roll_qty, sampling_qty, disposal_measures, disposal_remark, inspector_date, inspector_no, dbo.qc_get_inspector_name(site, inspector_no) as inspectorName, submit_flag, roll_no, roll_count, action_date, action_by, isnull(dbo.joint_id(site, bu_no, inspection_no, 'coordination'), '') as operator, isnull(dbo.joint_name(site, bu_no, inspection_no, 'coordination'), '') as operatorName, isnull(dbo.joint_id(site, bu_no, inspection_no, 'supplier'), '') as responsiblePerson, pass_qty, not_pass_qty, order_ref_type, order_ref1, order_ref2, order_ref3, order_ref4, order_ref5, order_ref6, create_by, dbo.qc_get_fqas_template_id(site, bu_no, inspection_no) as templateId FROM qc_stock_record <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) and order_ref_type <![CDATA[<>]]> '发货通知单' <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test = "query.inspectionNo != null and query.inspectionNo != ''"> AND inspection_no LIKE #{query.inspectionNo} </if> <if test = "query.states != null and query.states.size > 0"> AND state in <foreach item="item" collection="query.states" open="(" separator="," close=")"> #{item} </foreach> </if> <if test = "query.inspectionResult != null and query.inspectionResult != ''"> AND inspection_result = #{query.inspectionResult} </if> <if test = "query.createBy != null and query.createBy != ''"> AND create_by LIKE #{query.createBy} </if> <if test = "query.partNo != null and query.partNo != ''"> AND part_no LIKE #{query.partNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.Get_Part_DescSpec(site, part_no) LIKE #{query.partDesc} </if> <if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> AND disposal_measures LIKE #{query.disposalMeasures} </if> <if test = "query.inspectorName != null and query.inspectorName != ''"> AND dbo.qc_get_inspector_name(site, inspector_no) LIKE #{query.inspectorName} </if> <if test="query.startDate != null"> AND inspector_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= inspector_date </if> <if test="query.startDate2 != null"> AND create_date >= #{query.startDate2} </if> <if test="query.endDate2 != null"> AND #{query.endDate2} >= create_date </if> <if test = "query.orderRef1 != null and query.orderRef1 != ''"> AND order_ref1 LIKE #{query.orderRef1} </if> <if test = "query.orderRef2 != null and query.orderRef2 != ''"> AND order_ref2 LIKE #{query.orderRef2} </if> <if test = "query.orderRef3 != null and query.orderRef3 != ''"> AND order_ref3 LIKE #{query.orderRef3} </if> <if test = "query.orderRef4 != null and query.orderRef4 != ''"> AND order_ref4 LIKE #{query.orderRef4} </if> <if test = "query.orderRef5 != null and query.orderRef5 != ''"> AND order_ref5 LIKE #{query.orderRef5} </if> <if test = "query.orderRef6 != null and query.orderRef6 != ''"> AND order_ref6 LIKE #{query.orderRef6} </if> </where> ORDER BY CASE WHEN state = '待检验' THEN 1 WHEN state = '待审核' THEN 2 WHEN state = '已完成' THEN 3 END, create_date desc </select>
<!-- 获取该物料属性下维护的FQAS --> <select id="selectFQASPartAttributeByPartNo" resultType="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>
<update id="actionFQASInspection" parameterType="QcFAIRecordData"> update qc_stock_record set action_date = getDate(), action_by = #{actionBy}, state = #{state} where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </update>
<!-- IQC明细记录查询 --> <select id="fqasDetailSearch" parameterType="QcFAIRecordData" resultType="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.is_submit, a.unqualified_quantity,-- isnull(a.unqualified_quantity,0) as unqualifiedQuantity, 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, a.sampling_qty FROM qc_stock_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 COALESCE(a.serial_no, 99999) ASC </select>
<!-- 查询FQAS的子明细 --> <select id="selectFQASSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues"> SELECT site, bu_no, sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_stock_sub_detail_record WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 删除FQAS子明细的老数据 --> <delete id="delFQASSubDetailedRecord" parameterType="QcSubDetailInformationData"> DELETE FROM qc_stock_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_stock_sub_detail_record (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no) VALUES <foreach collection="list" item="item" separator=","> (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}) </foreach> </insert>
<!-- 查询FQAS检验记录是否已提交 --> <select id="checkFQASIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData"> SELECT submit_flag FROM qc_stock_record WHERE inspection_no = #{inspectionNo} and site = #{site} </select>
<!-- 修改FQAS主记录信息 --> <update id="updateFQASMasterRecord" parameterType="QcFAIRecordData"> UPDATE qc_stock_record SET disposal_measures = #{disposalMeasures}, disposal_remark = #{disposalRemark}, inspection_result = #{inspectionResult}, inspector_no = #{inspectorNo}, state = #{state}, inspection_remark = #{inspectionRemark}, inspector_date = getDate(), 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} WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo} </update>
<!-- 修改FQAS明细记录信息 --> <update id="updateFQASDetailedRecord" parameterType="QcFAIRecordData"> UPDATE qc_stock_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>
<!-- 修改FQAS主记录标识为已提交 --> <update id="updateFQASMasterSubmitFlag" parameterType="QcFAIRecordData"> UPDATE qc_stock_record SET submit_flag = 'Y', state = '已完成' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改FQAS明细记录标识为已提交 --> <update id="updateFQASDetailSubmitFlag" parameterType="QcFAIRecordData"> UPDATE qc_stock_detailed_record SET is_submit = 'Y' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 修改FQAS子明细记录标识为已提交 --> <update id="updateFQASSubDetailSubmitFlag" parameterType="QcFAIRecordData"> UPDATE qc_stock_sub_detail_record SET is_submit = 'Y' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<!-- 删除FQAS检验记录 --> <delete id="deleteFQASRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_stock_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除FQAS明细记录信息 --> <delete id="deleteFQASDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_stock_detailed_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 删除FQAS子明细记录信息 --> <delete id="deleteFQASSubDetailedRecord" parameterType="QcFAIRecordData"> DELETE FROM qc_stock_sub_detail_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 修改detailFlag字段为N --> <update id="updateFQASDetailFlag" parameterType="QcFAIRecordData"> UPDATE qc_stock_record SET detail_flag = 'N' WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </update>
<delete id="delTemplateItem" parameterType="QcTemplateData"> delete qc_template_detailed WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo} </delete>
<!-- 修改项目明细的最大最小值 --> <insert id="saveItemDetailed"> INSERT INTO qc_template_detailed (site, bu_no, template_id, ItemNo, default_value, max_value, min_value, serial_no) VALUES (#{site}, #{buNo}, #{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{serialNo}) </insert>
<!-- 校验物料属性设置中的模板是否已存在 --> <select id="getPA" parameterType="QcTemplateData" resultType="QcTemplateData"> SELECT site, bu_no, attribute_no, template_id, sampling_level_no, sampling_programme_no, attribute_type, resource_id, operation FROM qc_attribute_template WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and template_id = #{templateId} and resource_id = #{resourceID} and operation = #{operation} </select> <!-- 校验物料属性设置中的模板是否已存在 --> <select id="getPA2" parameterType="QcTemplateData" resultType="QcTemplateData"> SELECT site, bu_no, attribute_no, template_id, sampling_level_no, sampling_programme_no, attribute_type, manufacturer_id FROM qc_attribute_template WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and template_id = #{templateId} and manufacturer_id = #{manufacturerID} </select>
<!-- 校验物料属性设置中的模板是否已存在 --> <select id="getPA3" parameterType="QcTemplateData" resultType="QcTemplateData"> SELECT site, bu_no, attribute_no, template_id, sampling_level_no, sampling_programme_no, attribute_type, customer_id FROM qc_attribute_template WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and template_id = #{templateId} and customer_id = #{customerID} </select>
<!-- 查询IQC主记录信息 --> <select id="getIQCInspectionRecord" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, site, bu_no, receipt_no, receipt_item_no, inspector_date, roll_count, sampling_qty, pass_qty, not_pass_qty, inspection_result, disposal_measures, inspector_no as updateBy, dbo.qc_get_inspector_name(site, inspector_no) as inspectorName FROM qc_iqc_record where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </select>
<!-- 查询FQAS主记录信息 --> <select id="getFQASInspectionRecord" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT site, bu_no, inspection_no, order_ref1, not_pass_qty, roll_count, inspection_result, disposal_measures, part_no, order_ref_type, order_ref2 FROM qc_stock_record where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </select>
<update id="updatePartAttributeFlag"> UPDATE Part SET attribute_flag = #{attributeFlag} WHERE Site = #{site} and PartNo = #{partNo} </update>
<!-- 查询IQC的子明细 --> <select id="getIQCFirstInfoSub" parameterType="QcFAIRecordData" resultType="SubDetailValues"> SELECT site, bu_no, inspection_no, item_no, sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_iqc_sub_detail_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </select>
<!-- 查询文件路径 --> <select id="searchFileUrl" resultType="SysOssEntity" parameterType="QcFAIRecordData"> SELECT id, url, file_name, new_file_name, created_by, order_ref1, order_ref2, order_ref3, order_ref4, file_type FROM sys_oss WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo} </select>
<update id="updateSamplingQty" parameterType="QcFAIRecordData"> update <if test = "inspectionTypeNo == '105'"> qc_iqc_record </if> <if test = "inspectionTypeNo == '108'"> qc_stock_record </if> set sampling_qty = #{samplingQty,jdbcType=DECIMAL} where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </update>
<update id="updateDetailSamplingQty" parameterType="QcFAIRecordData"> update <if test = "inspectionTypeNo == '105'"> qc_iqc_detailed_record </if> <if test = "inspectionTypeNo == '108'"> qc_stock_detailed_record </if> set sampling_qty = #{samplingQty,jdbcType=DECIMAL} where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </update>
<!-- 查询OQC基础数据 --> <select id="selectOQCBasicData" resultType="QcFAIRecordData" parameterType="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.create_by, qir.site, qir.bu_no, qir.roll_count FROM qc_stock_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 eam_access_site where username = #{userName}) and (qir.site + '-' + qir.bu_no) in (select * from dbo.query_bu(#{userName})) and qir.detail_flag = 'N' and qir.order_ref_type = '发货通知单' </select>
<!-- 查询OQC主记录信息 --> <select id="qcOQCInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData"> SELECT inspection_no, site, bu_no, dbo.get_bu_desc(site, bu_no) as buDesc, state, inspection_result, create_date as taskDate, inspection_type_no, inspection_cycle, part_no, dbo.Get_Part_DescSpec(site, part_no) as part_desc, dbo.qc_get_part_umid(site, part_no) as umId, inspection_remark, roll_qty, sampling_qty, disposal_measures, disposal_remark, inspector_date, inspector_no, dbo.qc_get_inspector_name(site, inspector_no) as inspectorName, submit_flag, roll_no, roll_count, action_date, action_by, isnull(dbo.joint_id(site, bu_no, inspection_no, 'coordination'), '') as operator, isnull(dbo.joint_name(site, bu_no, inspection_no, 'coordination'), '') as operatorName, isnull(dbo.joint_id(site, bu_no, inspection_no, 'responsible'), '') as responsiblePerson, isnull(dbo.joint_name(site, bu_no, inspection_no, 'responsible'), '') as responsiblePersonName, pass_qty, not_pass_qty, order_ref_type, order_ref1, order_ref2, order_ref3, order_ref4, order_ref5, order_ref6, create_by FROM qc_stock_record <where> site in (select site from eam_access_site where username = #{query.userName}) and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName})) and order_ref_type = '发货通知单' <if test="query.buDesc != null and query.buDesc != ''"> AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc} </if> <if test = "query.inspectionNo != null and query.inspectionNo != ''"> AND inspection_no LIKE #{query.inspectionNo} </if> <if test = "query.states != null and query.states.size > 0"> AND state in <foreach item="item" collection="query.states" open="(" separator="," close=")"> #{item} </foreach> </if> <if test = "query.inspectionResult != null and query.inspectionResult != ''"> AND inspection_result = #{query.inspectionResult} </if> <if test = "query.partNo != null and query.partNo != ''"> AND part_no LIKE #{query.partNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.Get_Part_DescSpec(site, part_no) LIKE #{query.partDesc} </if> <if test = "query.disposalMeasures != null and query.disposalMeasures != ''"> AND disposal_measures LIKE #{query.disposalMeasures} </if> <if test = "query.inspectorName != null and query.inspectorName != ''"> AND dbo.qc_get_inspector_name(site, inspector_no) LIKE #{query.inspectorName} </if> <if test="query.startDate != null"> AND inspector_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= inspector_date </if> <if test="query.startDate2 != null"> AND create_date >= #{query.startDate2} </if> <if test="query.endDate2 != null"> AND #{query.endDate2} >= create_date </if> <if test = "query.orderRef1 != null and query.orderRef1 != ''"> AND order_ref1 LIKE #{query.orderRef1} </if> <if test = "query.orderRef2 != null and query.orderRef2 != ''"> AND order_ref2 LIKE #{query.orderRef2} </if> <if test = "query.orderRef3 != null and query.orderRef3 != ''"> AND order_ref3 LIKE #{query.orderRef3} </if> <if test = "query.orderRef4 != null and query.orderRef4 != ''"> AND order_ref4 LIKE #{query.orderRef4} </if> <if test = "query.orderRef5 != null and query.orderRef5 != ''"> AND order_ref5 LIKE #{query.orderRef5} </if> <if test = "query.orderRef6 != null and query.orderRef6 != ''"> AND order_ref6 LIKE #{query.orderRef6} </if> </where> ORDER BY CASE WHEN state = '待检验' THEN 1 WHEN state = '待审核' THEN 2 WHEN state = '已完成' THEN 3 END, create_date desc </select>
<select id="getSupplier" parameterType="java.lang.String" resultType="SupplierData"> SELECT site, SupplierID, SupplierName FROM Supplier WHERE site = #{site} and SupplierID = #{supplierID} and Active = #{active} </select>
<!-- 修改IQC明细记录信息 --> <update id="updateIQCDetailedRecordByNos" parameterType="QcFAIRecordData"> UPDATE qc_iqc_detailed_record SET item_result = #{itemResult}, text_value = #{textValue}, number_value = #{numberValue,jdbcType=DECIMAL} WHERE inspection_no in (#{inspectionNo}) and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </update>
<delete id="deleteInspectionFiles" parameterType="QcFAIRecordData"> delete sys_oss where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo} </delete>
<!-- 修改IQC明细记录信息 --> <update id="updateSOScheduledRoutingRollQty"> UPDATE SOScheduledRouting SET roll_qty = isnull(roll_qty, 0) + #{rollQty} WHERE site = #{site} and BarcodeID = #{seqNo} </update>
<update id="updateSOScheduledRoutingTypeFlag"> UPDATE SOScheduledRouting <set> <if test="inspectionTypeNo == '首件检'"> type_flag1 = 'Y', </if> <if test="inspectionTypeNo == '自检'"> type_flag2 = 'Y', </if> <if test="inspectionTypeNo == '巡检'"> type_flag3 = 'Y', </if> <if test="inspectionTypeNo == '末件检'"> type_flag4 = 'Y' </if> </set> WHERE site = #{site} and BarcodeID = #{seqNo} </update>
<!-- 修改IQC明细记录信息 --> <update id="updateSOScheduledRoutingTypeFlag2"> UPDATE SOScheduledRouting <set> <if test="inspectionTypeNo == '首件检'"> type_flag1 = '', </if> <if test="inspectionTypeNo == '自检'"> type_flag2 = '', </if> <if test="inspectionTypeNo == '巡检'"> type_flag3 = '', </if> <if test="inspectionTypeNo == '末件检'"> type_flag4 = '' </if> </set> WHERE site = #{site} and BarcodeID = #{seqNo} </update> <update id="updateFQASDetailedRecordByNos"> UPDATE qc_stock_detailed_record SET item_result = #{itemResult}, text_value = #{textValue}, number_value = #{numberValue,jdbcType=DECIMAL} WHERE inspection_no in (#{inspectionNo}) and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo} </update>
<select id="selectIPQCRecordByType" parameterType="QcFAIRecordData" resultType="QcRecordData"> SELECT site, bu_no, inspection_no FROM qc_ipqc_record WHERE site = #{site} and bu_no = #{buNo} and seq_no = #{seqNo} and inspection_type_no = #{inspectionTypeNo} </select>
<select id="getShiftList" parameterType="ShiftData" resultType="ShiftData"> SELECT distinct shiftdesc FROM calendar_datetype_shift WHERE site = #{site} </select> <select id="getFQASFirstInfoSub" resultType="com.xujie.sys.modules.pms.data.SubDetailValues"> SELECT site, bu_no, inspection_no, item_no, sub_detail_value, sampling_location, is_submit, sampling_location_b FROM qc_stock_sub_detail_record WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo} </select>
<select id="getIPQCDetailInfo" resultType="com.xujie.sys.modules.pms.data.QcDetailInformationData"> SELECT site, bu_no, inspection_no, template_id FROM qc_ipqc_detailed_record where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </select>
<update id="updateIPQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData"> UPDATE qc_ipqc_record SET sampling_qty = #{samplingQty}, inspection_cycle = #{inspectionCycle}, pass_qty = #{samplingQty}, not_pass_qty = 0 WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} </update></mapper>
|