You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1700 lines
79 KiB
1700 lines
79 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
<mapper namespace="com.gaotao.modules.pms.mapper.QcBaseInfoMapper">
|
|
<!-- ================================================= 检验方法 ================================================= -->
|
|
|
|
<!-- 条件查询检验方法 -->
|
|
<select id="qcMethodSearch" parameterType="com.gaotao.modules.pms.data.QcMethodData" resultType="com.gaotao.modules.pms.data.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,
|
|
dbo.getOperatorDesc(qm.site, qm.create_by) as createByDesc,
|
|
qm.method_remark,
|
|
qm.update_date,
|
|
qm.update_by,
|
|
dbo.getOperatorDesc(qm.site, qm.update_by) as updateByDesc,
|
|
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 AccessSite where userID = #{query.userName})
|
|
and qm.bu_no in (select bu_no from AccessBu where username = #{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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcMethodData" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
|
|
SELECT
|
|
ItemNo
|
|
FROM qc_method_item
|
|
WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 删除检验方法 -->
|
|
<delete id="qcMethodDelete" parameterType="com.gaotao.modules.pms.data.QcMethodData">
|
|
DELETE FROM qc_method
|
|
WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 查询检验方法唯一 -->
|
|
<select id="checkMethodOnlyOne" resultType="com.gaotao.modules.pms.data.QcMethodData" parameterType="com.gaotao.modules.pms.data.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="qcItemSearch" parameterType="com.gaotao.modules.pms.data.QcItemData" resultType="com.gaotao.modules.pms.data.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,
|
|
dbo.getOperatorDesc(epi.site, epi.CreatedBy) as createdByDesc,
|
|
epi.MaxValue,
|
|
epi.MinValue,
|
|
epi.ItemRemark,
|
|
epi.ItemType,
|
|
epi.update_date,
|
|
epi.update_by,
|
|
dbo.getOperatorDesc(epi.site, epi.update_by) as updateByDesc,
|
|
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.collection_flag,
|
|
epi.collection_source,
|
|
epi.collection_method,
|
|
CASE WHEN epi.collection_method = 'plc' THEN 'PLC'
|
|
WHEN epi.collection_method = 'file' THEN '文件'
|
|
WHEN epi.collection_method = 'image' THEN '图片'
|
|
else '' end as collectionMethodDesc,
|
|
epi.collection_condition,
|
|
epi.collection_data_content
|
|
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
|
|
<where>
|
|
epi.site in (select site from AccessSite where userID = #{query.userName})
|
|
and epi.bu_no in (select bu_no from AccessBu where username = #{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>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 检测是否存在该项目 -->
|
|
<select id="checkQcItem" parameterType="com.gaotao.modules.pms.data.QcItemData" resultType="com.gaotao.modules.pms.data.QcItemData">
|
|
SELECT ItemNo,
|
|
ItemDesc
|
|
FROM eam_properties_item
|
|
WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType}
|
|
</select>
|
|
|
|
<!-- 获得检验项目单号 -->
|
|
<select id="getItemNo" resultType="string" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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, collection_flag, collection_source, collection_method, collection_condition, collection_data_content)
|
|
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}, #{collectionFlag}, #{collectionSource}, #{collectionMethod}, #{collectionCondition}, #{collectionDataContent})
|
|
</insert>
|
|
|
|
<!-- 新增项目里的方法 -->
|
|
<insert id="qcItemMethodSave" parameterType="com.gaotao.modules.pms.data.QcItemData">
|
|
INSERT INTO qc_method_item (ItemNo, method_no, site, bu_no)
|
|
VALUES (#{itemNo}, #{methodNo}, #{site}, #{buNo})
|
|
</insert>
|
|
|
|
<!-- 修改检验项目 -->
|
|
<update id="qcItemUpdate" parameterType="com.gaotao.modules.pms.data.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},
|
|
collection_flag = #{collectionFlag},
|
|
collection_source = #{collectionSource},
|
|
collection_method = #{collectionMethod},
|
|
collection_condition = #{collectionCondition},
|
|
collection_data_content = #{collectionDataContent}
|
|
WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo}
|
|
</update>
|
|
|
|
<!-- 修改项目中的方法 -->
|
|
<update id="qcItemMethodUpdate" parameterType="com.gaotao.modules.pms.data.QcItemData">
|
|
UPDATE qc_method_item
|
|
SET method_no = #{methodNo}
|
|
WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
|
|
</update>
|
|
|
|
<!-- 检查项目是否在被模板使用 -->
|
|
<select id="checkItemIsUsed" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcItemData">
|
|
DELETE
|
|
FROM eam_properties_item
|
|
WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 删除项目-方法中间表数据 -->
|
|
<delete id="qcItemMethodDelete" parameterType="com.gaotao.modules.pms.data.QcItemData">
|
|
DELETE
|
|
FROM qc_method_item
|
|
WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 查询检验项目唯一 -->
|
|
<select id="checkItemOnlyOne" resultType="com.gaotao.modules.pms.data.QcItemData" parameterType="com.gaotao.modules.pms.data.QcItemData">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
ItemNo,
|
|
ItemDesc
|
|
FROM eam_properties_item
|
|
<where>
|
|
site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ItemType = #{itemType} and inspection_type_no = #{inspectionTypeNo}
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 可选模板 -->
|
|
<select id="getTemplateList" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.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
|
|
<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="getPartTemplateList" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.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>
|
|
|
|
<!-- ================================================= 抽样矩阵维护 ================================================= -->
|
|
|
|
<!-- 查询抽样矩阵 -->
|
|
<select id="samplingInspectionPlanSearch" parameterType="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData" resultType="com.gaotao.modules.pms.data.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,
|
|
case when qsip.sampling_plan_active = 'Y' then '是' when qsip.sampling_plan_active = 'N' then '否' else '' end as samplingPlanActiveDesc,
|
|
qsip.create_date,
|
|
qsip.create_by,
|
|
dbo.getOperatorDesc(qsip.site, qsip.create_by) as createByDesc,
|
|
qsip.update_date,
|
|
qsip.update_by,
|
|
dbo.getOperatorDesc(qsip.site, qsip.update_by) as updateByDesc
|
|
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 AccessSite where userID = #{query.userName})
|
|
and qsip.bu_no in (select bu_no from AccessBu where username = #{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="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData">
|
|
DELETE FROM qc_sampling_inspection_plan
|
|
WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- ================================================= 检验模板维护 ================================================= -->
|
|
|
|
<!-- 查询模板 -->
|
|
<select id="templateSearch" parameterType="com.gaotao.modules.pms.data.QcTemplateData" resultType="com.gaotao.modules.pms.data.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,
|
|
dbo.getOperatorDesc(qt.site, qt.create_by) as createByDesc,
|
|
qt.update_date,
|
|
qt.update_by,
|
|
dbo.getOperatorDesc(qt.site, qt.update_by) as updateByDesc,
|
|
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 AccessSite where userID = #{query.userName})
|
|
and qt.bu_no in (select bu_no from AccessBu where username = #{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>
|
|
order by qt.create_time desc
|
|
</select>
|
|
|
|
<!-- 获得检验模板单号 -->
|
|
<select id="getTemplateNo" resultType="string" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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,
|
|
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.order_id
|
|
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
|
|
WHERE a.template_id = #{templateId} AND b.ItemType = #{itemType} and a.site = #{site} and a.bu_no = #{buNo}
|
|
order by order_id, ItemNo
|
|
</select>
|
|
|
|
<!-- 查询模板里是否已存在该项目 -->
|
|
<select id="selectItemDetails" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcTemplateData">
|
|
INSERT INTO qc_template_detailed (template_id, ItemNo, default_value, max_value, min_value, site, bu_no,order_id)
|
|
VALUES (#{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{site}, #{buNo},#{orderId})
|
|
</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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcTemplateData">
|
|
DELETE FROM qc_template
|
|
WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 删除模板-项目中间表 -->
|
|
<delete id="itemItemDelete" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
|
|
DELETE FROM qc_template_detailed
|
|
WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 搜索所有检验类型 -->
|
|
<select id="inspectionTypeSearch" resultType="com.gaotao.modules.pms.data.QcInspectionTypeData" parameterType="com.gaotao.modules.pms.data.QcInspectionTypeData">
|
|
SELECT inspection_type_no,
|
|
inspection_type_name
|
|
FROM qc_inspection_type
|
|
WHERE site = #{site}
|
|
</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="com.gaotao.modules.pms.data.EamPropertiesItemData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="selectTemplateByDesc" parameterType="com.gaotao.modules.pms.data.QcTemplateData" resultType="com.gaotao.modules.pms.data.QcTemplateData">
|
|
SELECT template_id,
|
|
template_name,
|
|
template_version
|
|
FROM qc_template
|
|
WHERE template_name = #{templateName}
|
|
AND site = #{site}
|
|
AND template_version = #{templateVersion}
|
|
</select>
|
|
|
|
<delete id="delTemplateItem" parameterType="com.gaotao.modules.pms.data.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, order_id)
|
|
VALUES
|
|
(#{site}, #{buNo}, #{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL},#{orderId})
|
|
</insert>
|
|
|
|
<!-- 查询项目明细 -->
|
|
<select id="selectItem" resultType="com.gaotao.modules.pms.data.QcTemplateData">
|
|
SELECT ItemNo,
|
|
ItemDesc,
|
|
DefaultValue,
|
|
ValueType,
|
|
ValueType_DB,
|
|
MaxValue,
|
|
MinValue,
|
|
ItemRemark,
|
|
ItemType,
|
|
site,
|
|
bu_no
|
|
FROM eam_properties_item
|
|
WHERE ItemNo = #{itemNo} AND ItemType = #{itemType} AND bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 查询检验项目唯一 -->
|
|
<select id="checkTemplateOnlyOne" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.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="getQCDetailOrderId" resultType="Integer">
|
|
SELECT isnull(max(order_id), 0) + 1
|
|
from qc_template_detailed
|
|
where site = #{site}
|
|
and bu_no= #{buNo}
|
|
and template_id = #{templateId}
|
|
</select>
|
|
|
|
<delete id="deleteInspectionStandard2" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
|
|
delete from qc_inspection_standards
|
|
where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
|
|
</delete>
|
|
|
|
<!-- 查询检验方法列表 -->
|
|
<select id="queryMethodList" resultType="com.gaotao.modules.pms.data.QcMethodData" parameterType="com.gaotao.modules.pms.data.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>
|
|
|
|
<select id="updateQCDetailOrderIdNull">
|
|
UPDATE qc_template_detailed
|
|
SET qc_template_detailed.order_id = oi.rn
|
|
FROM (SELECT
|
|
site,
|
|
bu_no,
|
|
template_id,
|
|
ItemNo,
|
|
ROW_NUMBER() OVER (PARTITION BY site,bu_no,template_id ORDER BY ItemNo) AS rn
|
|
FROM qc_template_detailed
|
|
) as oi
|
|
where qc_template_detailed.template_id = oi.template_id
|
|
AND qc_template_detailed.ItemNo = oi.ItemNo
|
|
and qc_template_detailed.order_id is null
|
|
</select>
|
|
|
|
<!-- ================================================= 样本量维护 ================================================= -->
|
|
|
|
<!-- 查询样本量 -->
|
|
<select id="samplingQtySearch" parameterType="com.gaotao.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.gaotao.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,
|
|
case when sampling_qty_active = 'Y' then '是' when sampling_qty_active = 'N' then '否' else '' end as samplingQtyActiveDesc,
|
|
create_date,
|
|
create_by,
|
|
dbo.getOperatorDesc(site, create_by) as createByDesc,
|
|
update_date,
|
|
update_by,
|
|
dbo.getOperatorDesc(site, update_by) as updateByDesc
|
|
FROM qc_sampling_inspection_qty
|
|
<where>
|
|
site in (select site from AccessSite where userID = #{query.userName})
|
|
and bu_no in (select bu_no from AccessBu where username = #{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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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.gaotao.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.gaotao.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,
|
|
case when sampling_qty_rank_active = 'Y' then '是' when sampling_qty_rank_active = 'N' then '否' else '' end as samplingQtyRankActiveDesc,
|
|
sampling_qty_rank_Remark,
|
|
create_date,
|
|
create_by,
|
|
dbo.getOperatorDesc(site, create_by) as createByDesc,
|
|
update_date,
|
|
update_by,
|
|
dbo.getOperatorDesc(site, update_by) as updateByDesc
|
|
FROM qc_sampling_inspection_qty_rank
|
|
<where>
|
|
site in (select site from AccessSite where userID = #{query.userName})
|
|
and bu_no in (select bu_no from AccessBu where username = #{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="com.gaotao.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionLevelData" resultType="com.gaotao.modules.pms.data.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,
|
|
case when sampling_level_active = 'Y' then '是' when sampling_level_active = 'N' then '否' else '' end as samplingLevelActiveDesc,
|
|
create_date,
|
|
create_by,
|
|
dbo.getOperatorDesc(site, create_by) as createByDesc,
|
|
update_date,
|
|
update_by,
|
|
dbo.getOperatorDesc(site, update_by) as updateByDesc
|
|
FROM qc_sampling_inspection_level
|
|
<where>
|
|
site in (select site from AccessSite where userID = #{query.userName})
|
|
and bu_no in (select bu_no from AccessBu where username = #{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="com.gaotao.modules.pms.data.QcSamplingInspectionLevelData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.entity.vo.PartInformationVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
|
|
partNo,
|
|
PartDescription as partDesc,
|
|
part_desc_en,
|
|
spec,
|
|
PartType_DB,
|
|
PartType,
|
|
FamilyID,
|
|
GroupID,
|
|
a.UMID,
|
|
e.UMName as UMName,
|
|
a.Active,
|
|
Remark,
|
|
Stock,
|
|
StockInArrive,
|
|
StockInQuality,
|
|
StockInConsignment,
|
|
StockInPicking,
|
|
StockinActive,
|
|
QtyonPO,
|
|
MinStock,
|
|
MaxStock,
|
|
SafetyStockManage,
|
|
SafetyStock,
|
|
StandardOrderQty,
|
|
SupplierID,
|
|
AccountFamilyID,
|
|
LatestPrice,
|
|
AveragePrice,
|
|
ActualCost,
|
|
StandardCost,
|
|
StandardCost_BasePrice,
|
|
LatestSalesPrice,
|
|
AverageSalesPrice,
|
|
FinanceCheck,
|
|
MRPCode,
|
|
ManuLeadtime,
|
|
DefaultWarehouseID,
|
|
CodeNo,
|
|
SubCodeNo,
|
|
StandardLotSize,
|
|
ExpireDateControlFlag,
|
|
ToExpireDays,
|
|
CreateDate,
|
|
LastUpdateBy,
|
|
NeedApproveFlag,
|
|
ApprovedFlag,
|
|
NetWeight,
|
|
OtherGroup1,
|
|
OtherGroup2,
|
|
OtherGroup3,
|
|
OtherGroup4,
|
|
DefaultDepartmentID,
|
|
DefaultLocationID,
|
|
ConfigurationFlag,
|
|
ConfigurationTemplateID,
|
|
BOMLatestRevNo,
|
|
UMID_New,
|
|
PartNo_Base,
|
|
UMID_ConvertFactor,
|
|
expiration_flag,
|
|
expiration_day,
|
|
expiration_warning_day,
|
|
inbound_warehouse_id,
|
|
b.WareHouseName as inboundWarehouseName,
|
|
outbound_warehouse_id,
|
|
c.WareHouseName as outboundWarehouseName,
|
|
inbound_location_id,
|
|
d.LocationName as inboundLocationName,
|
|
exceed_in_ratio,
|
|
exceed_out_ratio,
|
|
iqc_exempt,
|
|
fai_exempt,
|
|
ipqc_exempt,
|
|
pqc_exempt,
|
|
fqc_exempt,
|
|
oqc_exempt,
|
|
first_inspection_duration,
|
|
next_inspection_duration,
|
|
total_inspection_duration,
|
|
sku,
|
|
cinv_source_code,
|
|
invtype,
|
|
standard_value,
|
|
default_value,
|
|
max_value,
|
|
min_value,
|
|
adhesive_active_period_flag,
|
|
thawing_duration,
|
|
accumulated_exposure_duration
|
|
from part as a
|
|
left join wareHouse as b on a.site = b.site and a.bu_no = b.bu_no and a.inbound_warehouse_id = b.WarehouseID
|
|
left join wareHouse as c on a.site = c.site and a.bu_no = c.bu_no and a.outbound_warehouse_id = c.WarehouseID
|
|
left join location as d on a.site = d.site and a.bu_no = d.bu_no and a.inbound_location_id = d.LocationID
|
|
left join um as e on a.site = e.site and a.UMID = e.UMID
|
|
<where>
|
|
a.site in (select site from AccessSite where userID = #{query.userName})
|
|
and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
|
|
<if test="query.buDesc != null and query.buDesc != ''">
|
|
AND dbo.get_bu_desc (site, bu_no) = #{query.buDesc}
|
|
</if>
|
|
<if test = "query.partNo != null and query.partNo != ''">
|
|
AND partNo LIKE '%' + #{query.partNo} + '%'
|
|
</if>
|
|
<if test = "query.partDesc != null and query.partDesc != ''">
|
|
AND PartDescription LIKE '%' + #{query.partDesc} + '%'
|
|
</if>
|
|
<if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
|
|
AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
|
|
</if>
|
|
<if test = "query.sku != null and query.sku != ''">
|
|
AND sku LIKE '%' + #{query.sku} + '%'
|
|
</if>
|
|
<if test = "query.familyName != null and query.familyName != ''">
|
|
AND invtype LIKE '%' + #{query.familyName} + '%'
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 查询是否已有该物料属性 -->
|
|
<select id="selectPartAttributeByNo" resultType="com.gaotao.modules.pms.entity.vo.PartInformationVo" parameterType="com.gaotao.modules.pms.entity.vo.PartInformationVo">
|
|
SELECT
|
|
site,
|
|
partNo,
|
|
bu_no
|
|
FROM part
|
|
WHERE site = #{site} and partNo = #{partNo} and bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 物料属性修改 -->
|
|
<update id="qcPartAttributeEdit" parameterType="com.gaotao.modules.pms.entity.vo.PartInformationVo">
|
|
UPDATE part
|
|
SET expiration_flag = #{expirationFlag},
|
|
expiration_day = #{expirationDay},
|
|
expiration_warning_day = #{expirationWarningDay},
|
|
exceed_in_ratio = #{exceedInRatio, jdbcType=FLOAT},
|
|
exceed_out_ratio = #{exceedOutRatio, jdbcType=FLOAT},
|
|
inbound_warehouse_id = #{inboundWarehouseId},
|
|
outbound_warehouse_id = #{outboundWarehouseId},
|
|
inbound_location_id = #{inboundLocationId},
|
|
iqc_exempt = #{iqcExempt},
|
|
fai_exempt = #{faiExempt},
|
|
ipqc_exempt = #{ipqcExempt},
|
|
pqc_exempt = #{pqcExempt},
|
|
fqc_exempt = #{fqcExempt},
|
|
oqc_exempt = #{oqcExempt},
|
|
first_inspection_duration = #{firstInspectionDuration, jdbcType=FLOAT},
|
|
next_inspection_duration = #{nextInspectionDuration, jdbcType=FLOAT},
|
|
total_inspection_duration = #{totalInspectionDuration, jdbcType=FLOAT},
|
|
LastUpdateBy = #{lastUpdateBy},
|
|
standard_value = #{standardValue, jdbcType=DECIMAL},
|
|
default_value = #{defaultValue, jdbcType=DECIMAL},
|
|
max_value = #{maxValue, jdbcType=DECIMAL},
|
|
min_value = #{minValue, jdbcType=DECIMAL},
|
|
adhesive_active_period_flag = #{adhesiveActivePeriodFlag},
|
|
thawing_duration = #{thawingDuration},
|
|
accumulated_exposure_duration = #{accumulatedExposureDuration}
|
|
WHERE site = #{site} and partNo = #{partNo} and bu_no = #{buNo}
|
|
</update>
|
|
|
|
<!-- 删除物料属性模板 -->
|
|
<delete id="deletePartAttributeTemplate" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData">
|
|
DELETE FROM qc_attribute_template
|
|
WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo} and attribute_type = #{attributeType}
|
|
</delete>
|
|
|
|
<!-- 查询类别模板 -->
|
|
<select id="searchPartAttributeDetails" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.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
|
|
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="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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>
|
|
|
|
<!-- 删除物料属性模板 -->
|
|
<delete id="deletePartAttributeDetails" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
|
|
SELECT
|
|
template_id,
|
|
template_name,
|
|
sampling_programme_no,
|
|
sampling_level_no,
|
|
inspection_cycle,
|
|
AQL,
|
|
AC,
|
|
RE,
|
|
inspection_type_no
|
|
FROM qc_template
|
|
WHERE site = #{site} AND template_id = #{templateId} and bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 新增物料属性模板详情 -->
|
|
<update id="saveAttributeDetailed" parameterType="com.gaotao.modules.pms.data.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>
|
|
|
|
<!-- ================================================= 抽样方案维护 ================================================= -->
|
|
|
|
<!-- 查询类别属性 -->
|
|
<select id="samplingProgrammeSearch" parameterType="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.gaotao.modules.pms.data.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,
|
|
dbo.getOperatorDesc(site, create_by) as createByDesc,
|
|
update_date,
|
|
update_by,
|
|
dbo.getOperatorDesc(site, update_by) as updateByDesc
|
|
FROM qc_sampling_inspection_programme
|
|
<where>
|
|
site in (select site from AccessSite where userID = #{query.userName})
|
|
and bu_no in (select bu_no from AccessBu where username = #{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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData">
|
|
DELETE FROM qc_sampling_inspection_programme
|
|
WHERE site = #{site} and bu_no = #{buNo}
|
|
AND sampling_programme_no = #{samplingProgrammeNo}
|
|
</delete>
|
|
|
|
<!-- 删除抽样方案中的矩阵 -->
|
|
<delete id="deletePlanByProgrammeNo" parameterType="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData">
|
|
DELETE FROM qc_programme_plan
|
|
WHERE sampling_programme_no = #{samplingProgrammeNo} and site = #{site} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 根据名称查询抽样方案 -->
|
|
<select id="selectSamplingProgrammeByDesc" parameterType="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcSamplingInspectionProgrammeData">
|
|
DELETE FROM qc_programme_plan
|
|
WHERE sampling_programme_no = #{samplingProgrammeNo} and sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<select id="getSiteAndBuByUserName" parameterType="com.gaotao.modules.base.data.BuData" resultType="com.gaotao.modules.base.data.BuData">
|
|
SELECT
|
|
b.id,
|
|
a.site,
|
|
c.sitename,
|
|
(a.site + '_' + a.bu_no) as buNo,
|
|
b.bu_desc
|
|
FROM AccessBu as a
|
|
left join bu as b on a.bu_no = b.bu_no and a.site = b.site
|
|
left join site as c on a.site = c.siteid
|
|
WHERE a.username = #{username}
|
|
</select>
|
|
|
|
<select id="getSiteAndBuByUserName2" parameterType="com.gaotao.modules.base.data.BuData" resultType="com.gaotao.modules.base.data.BuData">
|
|
SELECT
|
|
a.site,
|
|
c.sitename,
|
|
a.bu_no,
|
|
b.bu_desc
|
|
FROM AccessBu as a
|
|
left join bu as b on a.bu_no = b.bu_no and a.site = b.site
|
|
left join site as c on a.site = c.siteid
|
|
WHERE a.username = #{username}
|
|
</select>
|
|
|
|
<!-- 查询类别模板 -->
|
|
<select id="getPartDefectTracking" resultType="com.gaotao.modules.pms.entity.vo.PartDefectTrackingVo" parameterType="com.gaotao.modules.pms.entity.vo.PartDefectTrackingVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.supplier_id,
|
|
b.SupplierName,
|
|
a.defect_threshold,
|
|
a.recovery_batch_count,
|
|
a.current_defect_count,
|
|
a.last_defect_count
|
|
FROM part_defect_tracking as a
|
|
left join Supplier as b on a.site = b.site and a.supplier_id = b.SupplierID
|
|
<where>
|
|
a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
|
|
<if test = "supplierId != null and supplierId != ''">
|
|
AND a.supplier_id = #{supplierId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 新增跟踪缺陷 -->
|
|
<insert id="saveDefectTracking" parameterType="com.gaotao.modules.pms.entity.vo.PartDefectTrackingVo">
|
|
INSERT INTO part_defect_tracking (site, bu_no, part_no, supplier_id, defect_threshold, recovery_batch_count, current_defect_count, last_defect_count)
|
|
VALUES (#{site}, #{buNo}, #{partNo}, #{supplierId}, #{defectThreshold,jdbcType=INTEGER}, #{recoveryBatchCount,jdbcType=INTEGER}, #{currentDefectCount,jdbcType=INTEGER}, #{lastDefectCount,jdbcType=INTEGER})
|
|
</insert>
|
|
|
|
<!-- 删除跟踪缺陷 -->
|
|
<delete id="deleteDefectTracking" parameterType="com.gaotao.modules.pms.entity.vo.PartDefectTrackingVo">
|
|
DELETE FROM part_defect_tracking
|
|
WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and supplier_id = #{supplierId}
|
|
</delete>
|
|
|
|
<!-- 编辑跟踪缺陷 -->
|
|
<update id="updateDefectTracking" parameterType="com.gaotao.modules.pms.entity.vo.PartDefectTrackingVo">
|
|
UPDATE part_defect_tracking
|
|
SET defect_threshold = #{defectThreshold,jdbcType=INTEGER},
|
|
recovery_batch_count = #{recoveryBatchCount,jdbcType=INTEGER},
|
|
current_defect_count = #{currentDefectCount,jdbcType=INTEGER},
|
|
last_defect_count = #{lastDefectCount,jdbcType=INTEGER}
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} AND supplier_id = #{supplierId}
|
|
</update>
|
|
|
|
<!-- 查询类别模板 -->
|
|
<select id="getPartLabelTemplate" resultType="com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo" parameterType="com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.label_type_tb,
|
|
a.label_type,
|
|
a.default_flag,
|
|
case when a.default_flag = '1' then '默认' when a.default_flag = '0' then '非默认' else '' end as defaultFlagDesc,
|
|
a.created_by,
|
|
a.created_date
|
|
FROM part_label_template as a
|
|
<where>
|
|
a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
|
|
<if test = "labelTypeTb != null and labelTypeTb != ''">
|
|
AND a.label_type_tb = #{labelTypeTb}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 新增标签模版设置 -->
|
|
<insert id="saveLabelTemplate" parameterType="com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo">
|
|
INSERT INTO part_label_template (site, bu_no, part_no, label_type_tb, label_type, default_flag, created_by, created_date)
|
|
VALUES (#{site}, #{buNo}, #{partNo}, #{labelTypeTb}, #{labelType}, #{defaultFlag}, #{createdBy}, getDate())
|
|
</insert>
|
|
|
|
<!-- 删除标签模版设置 -->
|
|
<delete id="deleteLabelTemplate" parameterType="com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo">
|
|
DELETE FROM part_label_template
|
|
WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and label_type_tb = #{labelTypeTb}
|
|
</delete>
|
|
|
|
<!-- 编辑标签模版设置 -->
|
|
<update id="updateLabelTemplate" parameterType="com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo">
|
|
UPDATE part_label_template
|
|
SET default_flag = #{defaultFlag}
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} AND label_type_tb = #{labelTypeTb}
|
|
</update>
|
|
|
|
<!-- 获取客户列表 -->
|
|
<select id="getCustomerList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.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="getPA" parameterType="com.gaotao.modules.pms.data.QcTemplateData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcTemplateData" resultType="com.gaotao.modules.pms.data.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="com.gaotao.modules.pms.data.QcTemplateData" resultType="com.gaotao.modules.pms.data.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>
|
|
|
|
<select id="getStandardOperation" resultType="com.gaotao.modules.pms.entity.StandardOperationEntity">
|
|
select
|
|
id,
|
|
site,
|
|
operation_desc
|
|
from standard_operation
|
|
where site = #{site}
|
|
</select>
|
|
</mapper>
|