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})
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}
DELETE FROM qc_method
WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
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 INTO qc_method_item (ItemNo, method_no, site, bu_no)
VALUES (#{itemNo}, #{methodNo}, #{site}, #{buNo})
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 qc_method_item
SET method_no = #{methodNo}
WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
DELETE
FROM eam_properties_item
WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo}
DELETE
FROM qc_method_item
WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
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})
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}
DELETE FROM qc_sampling_inspection_plan
WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo}
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})
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}
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})
DELETE FROM qc_template_detailed
WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
DELETE FROM qc_template
WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
DELETE FROM qc_template_detailed
WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
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})
delete qc_template_detailed
WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
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})
delete from qc_inspection_standards
where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
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})
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}
DELETE FROM qc_sampling_inspection_qty
WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} AND sampling_qty_desc = #{samplingQtyDesc} and bu_no = #{buNo}
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})
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}
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}
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})
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}
DELETE FROM qc_sampling_inspection_level
WHERE site = #{site} and bu_no = #{buNo}
AND sampling_level_no = #{samplingLevelNo}
AND sampling_level_desc = #{samplingLevelDesc}
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}
DELETE FROM qc_attribute_template
WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo} and attribute_type = #{attributeType}
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})
DELETE FROM qc_attribute_template
site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId} and attribute_type = #{attributeType}
and operation = #{operation}
and resource_id = #{resourceID}
and manufacturer_id = #{manufacturerID}
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}
site = #{site} and attribute_no = #{attributeNo} AND template_id = #{templateId} AND attribute_type = #{attributeType} and bu_no = #{buNo}
AND operation = #{operation}
AND resource_id = #{resourceID}
AND manufacturer_id = #{manufacturerID}
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})
DELETE FROM qc_sampling_inspection_programme
WHERE site = #{site} and bu_no = #{buNo}
AND sampling_programme_no = #{samplingProgrammeNo}
DELETE FROM qc_programme_plan
WHERE sampling_programme_no = #{samplingProgrammeNo} and site = #{site} and bu_no = #{buNo}
INSERT INTO qc_programme_plan (site, bu_no, sampling_programme_no, sampling_plan_no)
VALUES (#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingPlanNo})
UPDATE qc_sampling_inspection_programme
SET update_date = getDate(),
update_by = #{updateBy}
WHERE site = #{site} AND sampling_programme_no = #{samplingProgrammeNo} and bu_no = #{buNo}
DELETE FROM qc_programme_plan
WHERE sampling_programme_no = #{samplingProgrammeNo} and sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
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})
DELETE FROM part_defect_tracking
WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and supplier_id = #{supplierId}
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}
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())
DELETE FROM part_label_template
WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and label_type_tb = #{labelTypeTb}
UPDATE part_label_template
SET default_flag = #{defaultFlag}
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} AND label_type_tb = #{labelTypeTb}