更新逻辑

This commit is contained in:
xiaochou164 2023-08-12 17:17:09 +08:00
parent 631d68fd61
commit 8d7603b580
2 changed files with 50 additions and 17 deletions

View File

@ -13,12 +13,40 @@ create table eqponstovestatustmp
eqpstatus varchar(50), eqpstatus varchar(50),
crusize varchar(50), crusize varchar(50),
subprod varchar(50), subprod varchar(50),
lastreporttime datetime, Areport datetime,
laststovetime datetime, Astove datetime,
lastopentime datetime, Aout datetime,
lastouttime datetime, Breport datetime,
finishtime datetime, Bstove datetime,
lastchaiqingtime datetime Bout datetime,
Creport datetime,
Cstove datetime,
Cout datetime,
Dreport datetime,
Dstove datetime,
Dout datetime,
Ereport datetime,
Estove datetime,
Eout datetime,
Freport datetime,
Fstove datetime,
Fout datetime,
Greport datetime,
Gstove datetime,
Gout datetime,
Hreport datetime,
Hstove datetime,
Hout datetime,
Ireport datetime,
Istove datetime,
Iout datetime,
Jreport datetime,
Jstove datetime,
Jout datetime,
Kreport datetime,
Kstove datetime,
Kout datetime,
chaiqingtime datetime
); );
replace into eqponstovestatustmp(area, area1, eqpid, eqpmodel) replace into eqponstovestatustmp(area, area1, eqpid, eqpmodel)
select area, area1, eqpid, eqpmodel select area, area1, eqpid, eqpmodel

View File

@ -24,7 +24,7 @@ BEGIN
end if; end if;
###报料记录 ###报料记录
insert into eqponstatuslogs(eqpname, event, eventtime, eventid, eqpid, eventtype, rx, eventstatus) insert into eqponstatuslogs(eqpname, event, eventtime, eventid, eqpid, eventtype, rx, eventstatus,mesmoname)
select substring(crystal_code, 5, 5) eqpname, select substring(crystal_code, 5, 5) eqpname,
case case
when report_type = '1' then '初装报料' when report_type = '1' then '初装报料'
@ -38,7 +38,8 @@ BEGIN
when report_type = '1' then '0' when report_type = '1' then '0'
when report_type = '2' then substring(task_code, 13, 1) when report_type = '2' then substring(task_code, 13, 1)
else '' end rx, else '' end rx,
'已完成' #状态 1:待处理、2:进行中 3:已完成 4:暂停 '已完成', #状态 1:待处理、2:进行中 3:已完成 4:暂停
substring(task_code, 1, 10)
from mes_sync.mes_report_task mrt from mes_sync.mes_report_task mrt
left join reportdata.equipment eq on (substring(mrt.crystal_code, 5, 5) = eq.eqpname) left join reportdata.equipment eq on (substring(mrt.crystal_code, 5, 5) = eq.eqpname)
where update_time between begindate and enddate where update_time between begindate and enddate
@ -46,7 +47,7 @@ BEGIN
###加料记录 ###加料记录
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus, mesmoname)
SELECT substring(order_no, 5, 5) eqpname, SELECT substring(order_no, 5, 5) eqpname,
stove_no, stove_no,
case case
@ -63,7 +64,8 @@ BEGIN
when ft.status = 1 then '待处理' when ft.status = 1 then '待处理'
when ft.status = 2 then '进行中' when ft.status = 2 then '进行中'
when ft.status = 3 then '已完成' when ft.status = 3 then '已完成'
when ft.status = 4 then '暂停' end #状态 1:待处理、2:进行中 3:已完成 4:暂停 when ft.status = 4 then '暂停' end, #状态 1:待处理、2:进行中 3:已完成 4:暂停
substring(feeding_task_code, 1, 10)
from mes_sync.mes_furnace_task ft from mes_sync.mes_furnace_task ft
right join mes_sync.mes_feeding_detail fd right join mes_sync.mes_feeding_detail fd
on (ft.feeding_task_id = fd.feeding_task_id and fd.material_type = '2') on (ft.feeding_task_id = fd.feeding_task_id and fd.material_type = '2')
@ -72,7 +74,7 @@ BEGIN
###开副室记录 ###开副室记录
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus, mesmoname)
select substring(order_no, 5, 5) eqpname, select substring(order_no, 5, 5) eqpname,
stove_no, stove_no,
concat( concat(
@ -86,14 +88,15 @@ BEGIN
code, code,
'开副室', '开副室',
substring(code, 11, 1), substring(code, 11, 1),
'已完成' '已完成',
substring(code, 1, 10)
from mes_sync.mes_sub_chamber_task from mes_sync.mes_sub_chamber_task
where 1 = 1 where 1 = 1
and delete_flag = '0' and delete_flag = '0'
and opening_time between begindate and enddate; and opening_time between begindate and enddate;
###晶棒产出 ###晶棒产出
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus, mesmoname)
select substring(order_no, 5, 5) eqpname, select substring(order_no, 5, 5) eqpname,
stove_no, stove_no,
concat(right(code, 3), '晶棒产出'), concat(right(code, 3), '晶棒产出'),
@ -103,23 +106,25 @@ BEGIN
substring(code, 11, 1), substring(code, 11, 1),
case case
when is_transport = 0 then '未质检' when is_transport = 0 then '未质检'
when is_transport = 1 then '已质检' end when is_transport = 1 then '已质检' end,
substring(code, 1, 10)
from mes_sync.mes_production from mes_sync.mes_production
where update_time between begindate and enddate; where update_time between begindate and enddate;
###拆清 ###拆清
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus, mesmoname)
select substring(order_no, 5, 5) eqpname, select substring(order_no, 5, 5) eqpname,
stove_no, stove_no,
'拆清', '拆清',
update_time, update_time,
order_no, order_no,
'5', '拆清',
'99', '99',
case case
when status = 1 then '待处理' when status = 1 then '待处理'
when status = 2 then '进行中' when status = 2 then '进行中'
when status = 3 then '已完成' end when status = 3 then '已完成' end,
order_no
from mes_sync.mes_dismantle_task from mes_sync.mes_dismantle_task
where 1 = 1 where 1 = 1
and update_time between begindate and enddate and update_time between begindate and enddate