delete from PartSubPropertiesValueHeader
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType}
delete from PartSubPropertiesValue
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType}
insert into PartSubPropertiesValueHeader
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
select
#{partNo},
#{site},
#{codeNo},
1,
Code_Desc,
#{recordType}
from plm_properties_model_header
where Code_No = #{codeNo} and site = #{site} and function_type = #{recordType}
insert into PartSubPropertiesValue (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select
#{partNo},
#{site},
#{codeNo},
1,
a.Code_Desc,
b.seq_No,
b.properties_item_no,
case when c.ValueType_DB = 'T' then c.DefaultValue else null end,
case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end,
#{recordType}
from plm_properties_model_header a
left join plm_properties_model_detail b on a.Code_No = b.Code_No and a.site = b.site and a.function_type = b.function_type
left join plm_properties_item c on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
where a.Code_No = #{codeNo} and a.site = #{site} AND B.SITE IS NOT NULL AND A.function_type = #{recordType}
update PartSubPropertiesValue
set TextValue = #{textValue},
NumValue = #{numValue, jdbcType=DOUBLE}
where PropertiesItemNo = #{propertiesItemNo} and site = #{site} and PartNo = #{partNo} and RecordType = #{recordType}
insert into part_agent (site, part_no, agent_id)
values (#{site}, #{partNo}, #{agentId})
delete from part_agent
where part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
delete from part_agent
where part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
insert into part_manufacturer (site, part_no, manufacturer_id)
values (#{site}, #{partNo}, #{manufacturerId})
delete from part_manufacturer
where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
delete from part_manufacturer
where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
UPDATE PartSubPropertiesValue
SET TextValue = #{textValue},
NumValue = #{numValue,jdbcType=DECIMAL}
WHERE PartNo = #{partNo} and Site = #{site} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo} and RecordType = #{recordType}
delete from PartSubPropertiesValue
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo}
insert into PartSubPropertiesValue
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
values (#{partNo}, #{site}, #{codeNo}, #{subCodeSeqNo,jdbcType=FLOAT}, #{codeDesc}, #{itemNo, jdbcType=FLOAT}, #{itNo}, #{textValue}, #{numValue, jdbcType=FLOAT}, #{recordType})
delete from PartSubPropertiesValue
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo}
insert into plm_part_location (site, part_no, location_id)
values (#{site}, #{partNo}, #{locationId})
delete from plm_part_location
where part_no = #{partNo} and site = #{site} and location_id = #{locationId}
delete from part_agent
where part_no = #{partNo} and site = #{site}
delete from part_manufacturer
where part_no = #{partNo} and site = #{site}
delete from plm_part_location
where part_no = #{partNo} and site = #{site}
UPDATE part
SET status = #{status},
update_date = #{updateDate},
update_by = #{updateBy}
WHERE part_no = #{partNo} and Site = #{site}
UPDATE part_revision
SET eff_phase_in_date = #{effPhaseInDate},
eff_phase_out_date = #{effPhaseOutDate},
revision_text = #{revisionText},
eng_revision = #{engRevision},
update_date = getDate(),
update_by = #{updateBy}
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
UPDATE plm_bom_header
SET official_flag = #{status}
WHERE part_no = #{partNo} and Site = #{site}
insert into part_revision (site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by)
values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{revisionText}, #{productStatus}, #{repairStatus}, #{engRevision}, getDate(), #{createBy})
UPDATE plm_bom_header
SET note_text = #{revisionText},
eff_phase_in_date = #{effPhaseInDate},
eff_phase_out_date = #{effPhaseOutDate},
eng_revision = #{engRevision}
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
delete from part_revision
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
delete from plm_bom_detail
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
delete from plm_bom_component
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
delete from plm_bom_manuf_struct_cost_distrib
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
insert into plm_project_part
(site, project_id, test_part_no, base_no, rev_no, part_no_source)
values
(#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource})
UPDATE plm_project_part
SET final_part_no = #{ifsPartNo},
update_date = getDate(),
update_by = #{updateBy}
WHERE site = #{site} and test_part_no = #{partNo}
insert into plm_customer_part_info
(site, customer_no, part_no, customer_part_no, create_date, create_by)
values
(#{site}, #{customerNo}, #{partNo}, #{customerPartNo}, getDate(), #{createBy})
insert into plm_project_part
(site, project_id, test_part_no, create_date, create_by, part_no_source) VALUES
(#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource})
insert into plm_customer_part_info
(site, customer_no, part_no, customer_part_no, create_date, create_by) VALUES
(#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
delete from plm_bom_header
where site = #{site} and part_no = #{partNo}
delete from plm_bom_detail
where site = #{site} and part_no = #{partNo}
delete from plm_bom_component
where site = #{site} and part_no = #{partNo}
delete from plm_bom_manuf_struct_cost_distrib
where site = #{site} and part_no = #{partNo}
delete from plm_routing_header
where site = #{site} and part_no = #{partNo}
delete from plm_routing_detail
where site = #{site} and part_no = #{partNo}
delete from plm_routing_component
where site = #{site} and part_no = #{partNo}
delete from routing_tool
where site = #{site} and part_no = #{partNo}
delete from plm_routing_work_guide
where site = #{site} and part_no = #{partNo}
insert into part_revision
(site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by) VALUES
(#{item.site}, #{item.partNo}, #{item.engChgLevel},CONVERT(datetime2, #{item.effPhaseInDate, jdbcType=TIMESTAMP}),
CONVERT(datetime2, #{item.effPhaseOutDate, jdbcType=TIMESTAMP}), #{item.revisionText}, #{item.productStatus}, #{item.repairStatus}, #{item.engRevision}, getDate(), #{item.createBy})
insert into plm_bom_detail
(site, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by, official_flag) VALUES
(#{item.site}, #{item.ifsPartNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.status}, #{item.minLotQty}, #{item.defaultFlag}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.officialFlag})
insert into plm_routing_detail
(site, part_no, routing_revision, routing_type, alternative_no, alternative_description, fixed_lead_time_day, fixed_lead_time_hour, variable_lead_time_day, variable_lead_time_hour, for_std_lot_by_day, for_lot_by_day, min_lot_qty, note_text, create_date, create_by, status, official_flag) VALUES
(#{item.site}, #{item.ifsPartNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.fixedLeadTimeDay}, #{item.fixedLeadTimeHour}, #{item.variableLeadTimeDay}, #{item.variableLeadTimeHour}, #{item.forStdLotByDay}, #{item.forLotByDay}, #{item.minLotQty}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.status}, #{item.officialFlag})
insert into part_agent
(site, part_no, agent_id) VALUES
(#{item.site}, #{item.partNo}, #{item.agentId})
insert into part_manufacturer
(site, part_no, manufacturer_id) VALUES
(#{item.site}, #{item.partNo}, #{item.manufacturerId})
insert into plm_part_location
(site, part_no, location_id) VALUES
(#{item.site}, #{item.partNo}, #{item.locationId})
insert into sys_oss
(url, create_date, file_name, new_file_name, create_by, order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code, file_remark) VALUES
(#{item.url}, #{item.createDate}, #{item.fileName}, #{item.newFileName}, #{item.createBy}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.fileType}, #{item.fileSuffix}, #{item.fileTypeCode}, #{item.fileRemark})
UPDATE part_revision
SET eff_phase_out_date = #{effPhaseOutDate}
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{effPhaseOutDate}
insert into PartSubPropertiesValueHeader
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType) VALUES
(#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.recordType})
insert into PartSubPropertiesValue
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id) VALUES
(#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.itemNo,jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue,jdbcType=FLOAT}, #{item.recordType}, #{item.orderId})