Insert into plm_properties_item ( site, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag
, CreatedDate
, CreatedBy, MaxValue, MinValue, ItemType)
values (#{site}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag},
GetDate(),
#{createdBy}, #{maxValue,jdbcType=DOUBLE}, #{minValue,jdbcType=DOUBLE}, #{itemType})
update plm_properties_item
set ItemDesc=#{itemDesc},
DefaultValue=#{defaultValue},
ValueType=#{valueType},
ValueType_DB=#{valueTypeDb},
ValueChooseFlag=#{valueChooseFlag},
update_date=GetDate()
,
update_by=#{updateBy},
MaxValue=#{maxValue,jdbcType=DOUBLE},
MinValue=#{minValue,jdbcType=DOUBLE},
ItemType=#{itemType}
WHERE ItemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
Delete
FROM plm_properties_item
WHERE ItemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
insert into plm_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType,
site)
values (#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site})
update plm_properties_item_available
set AvailableValue = #{availableValue}
where itemNo = #{itemNo}
and ItemType = #{itemType}
and ValueNo = #{valueNo}
and site = #{site}
delete
from plm_properties_item_available
where itemNo = #{itemNo}
and ItemType = #{itemType}
and ValueNo = #{valueNo}
and site = #{site}
insert into plm_properties_model_header
(function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by,
site, function_group)
values (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(),
#{updateBy}, #{site}, #{functionGroup})
update plm_properties_model_header
set version = version + 1,
code_desc = #{codeDesc},
function_group = #{functionGroup},
active = #{active},
update_by = #{updateBy},
update_date = GetDate()
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
delete
from plm_properties_model_header
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
insert into plm_properties_model_detail
(function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, order_id)
values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{orderId})
delete
from plm_properties_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and properties_item_no = #{itemNo}
and site = #{site}
delete
from PartSubPropertiesValueHeader
where PartNo = #{testPartNo}
and site = #{site}
and RecordType = 'IP'
delete
from PartSubPropertiesValue
where PartNo = #{testPartNo}
and site = #{site}
and RecordType = 'IP'
insert into PartSubPropertiesValueHeader (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
select #{testPartNo}, #{site}, #{codeNo}, 1, Code_Desc, 'IP'
from plm_properties_model_header
where Code_No = #{codeNo}
and site = #{site}
and function_type = 'IP'
insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select #{testPartNo},
#{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,
'IP'
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 = 'IP'
update PartSubPropertiesValue
set TextValue=#{textValue},
NumValue=#{numValue,jdbcType=DOUBLE}
where PropertiesItemNo = #{propertiesItemNo}
and site = #{site}
and PartNo = #{partNo}
and RecordType = 'IP'
insert into PartSubPropertiesValue(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc,
ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select #{partNo},
#{site},
a.CodeNo,
1,
a.SubCodeDesc,
b.seq_No,
b.properties_item_no,
case
when e.ValueType_DB = 'T' then e.DefaultValue
else null end,
case when e.ValueType_DB = 'N' and e.DefaultValue != '' then e.DefaultValue else null end,
'IP'
from PartSubPropertiesValueHeader a
left join plm_properties_model_detail b
on a.CodeNo = b.Code_No and a.site = b.site and a.RecordType = b.function_type
left join PartSubPropertiesValue c
on c.Site = #{site} and c.PartNo = #{partNo} and c.RecordType = 'IP' and
b.seq_no = c.ItemNo and a.RecordType = b.function_type
left join plm_properties_item e
on b.properties_item_no = e.ItemNo and a.site = e.site and a.RecordType = e.ItemType
where c.ItemNo is null
and a.RecordType = 'IP'
and a.PartNo = #{partNo}
and a.site = #{site}
insert into plm_bm_model_detail
(function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, bu_no,
order_id)
values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo},
#{orderId})
update PartSubPropertiesValue
set TextValue=#{textValue},
NumValue=#{numValue,jdbcType=DOUBLE}
where Site = #{site}
and CodeNo = #{codeNo}
and PartNo = #{partNo}
and SubCodeSeqNo = #{subCodeSeqNo}
and itemNo = #{itemNo}
delete
from plm_bm_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and properties_item_no = #{itemNo}
and site = #{site}
and bu_no = #{buNo}
update plm_properties_model_detail
set order_id=#{orderId}
where site = #{site}
and code_no = #{codeNo}
and function_type = #{functionType}
and seq_no = #{seqNo}
delete
from WorkCenter_BMType
where site = #{site}
and workCenterNo = #{workCenterNo}
update WorkCenter_BMType
set itemType=#{itemType},
update_by=#{updateBy},
update_date=GetDate()
where site = #{site}
and workCenterNo = #{workCenterNo}
insert into WorkCenter_BMType (site, workCenterNo, itemType, update_by, update_date)
values (#{site}, #{workCenterNo}, #{itemType}, #{updateBy}, GetDate())
insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id)
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},
isnull(b.order_id, 999)
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}
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, order_id)
select #{partNo},
#{site},
#{codeNo},
1,
d.SubCodeDesc,
#{itemNo,jdbcType=DOUBLE},
#{propertiesItemNo},
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},
#{itemNo,jdbcType=DOUBLE}
from plm_properties_item c
left join PartSubPropertiesValueHeader d
on d.PartNo = #{partNo} and d.site = #{site} and CodeNo = #{codeNo} and
RecordType = #{recordType}
where c.ItemNo = #{propertiesItemNo}
and c.site = #{site}
and c.itemType = #{recordType}
delete
from PartSubPropertiesValue
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and PropertiesItemNo = #{propertiesItemNo}
and RecordType = #{recordType}
delete
from PartSubPropertiesValue
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and RecordType = #{recordType}
delete from PartSubPropertiesValueHeader
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and RecordType = #{recordType}