where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2);
delete cux_bill_temp a
where not exists (select null from mtl_system_items where segment1=a.assembly_item and organization_id=2);
14、对没有物品item的进行处理,把其放入另一临时表cux_item_temp中(以备查询及导入mtl_system_items表中)
delete cux_item_temp;
insert into cux_item_temp(
segment1,description)
select distinct item,item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
)
;
将找到没有item的bom数据放到另一个表中,以备下次item导入后在导bom
create table cux_bom_temp1
select distinct item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
)
-----------------------------------------------------------------------------------------------------------
15、从表mtl_system_items中把物品的编码id加入中转表cux_bill_temp表(从项目主组织)中
update cux_bill_temp b
set assembly_item_id=(select inventory_item_id from mtl_system_items
where segment1=b.assembly_item and organization_id=2),
component_item_id=(select inventory_item_id from mtl_system_items
where segment1=b.component_item and organization_id=2);
16、查看是否有没有物品id的编码存在(既没有物品的id被导入临时表cux_bill_temp中)
select row_num
from cux_bill_temp
where assembly_item_id is null or component_item_id is null;
17、对其中导入的数据进行处理
update cux_bill_temp
set optional=1
where upper(optional_disp) like 'y%';
update cux_bill_temp
set optional=2
where optional is null;
update cux_bill_temp
set mutually_exclusive_options=1
where upper(mutually_exclusive_o_disp) like 'y%';
update cux_bill_temp
set mutually_exclusive_options=2
where mutually_exclusive_o_disp is null;
18、查看cux_bill_temp中的数据处理是否有漏
select count(*)
from cux_bill_temp
where optional is null
or mutually_exclusive_options is null
or assembly_item_id is null
or component_item_id is null;
19、更新其内的wip_supply_type;
update cux_bill_temp
set wip_supply_type=6
where component_item like 'b%';
20、删除表中的包(cux_bill_temp中),其相对应于表bom_bill_of_materials(既在表中已经存在了些选项包,不必导入包头,只需导入包内容既可)
delete cux_bill_temp t
where exists (select null from bom_bill_of_materials where assembly_item_id=t.assembly_item_id and organization_id=2);
21、利用已经写好的包写入数据(既写入接口表bom_bill_of_mtls_interface)
exec cux_bom_temp.insert_bill_15(1);
select count(*) from cux_bill_temp temp
where exits (select null from bom_inventory_components b
where temp.bill_sequence_id=b.bill_sequence_id
and temp.component_item_id=b.component_item_id);
delete cux_bill_temp temp
where exists (select null from bom_inventory_components b
where b.bill_sequence_id=temp.bill_sequence_id
and b.component_item_id=temp.component_item_id);
exec cux_bom_temp.insert_bill_10(1);
22、对写入的数据在接口表中的情况进行查看
select count(*) from bom_bill_of_mtls_interface;
23、接着更新
exec cux_bom_temp.insert_bill_15(1);
select count(*) from cux_bill_temp where bill_sequence_id is null;
exec cux_bom_temp.insert_bill_20(1);
去提交请求
select count(*) from bom_inventory_comps_interface;
(导入成功后)对组件进行排序