修正逻辑
This commit is contained in:
parent
8d7603b580
commit
09b3ecdff0
|
@ -1,6 +1,6 @@
|
||||||
drop procedure if exists UpdateEqpOnStoveStatusLog;
|
drop procedure if exists UpdateEqpOnStoveStatusLog;
|
||||||
create
|
create
|
||||||
definer = admin@`%` procedure UpdateEqpOnStoveStatusLog()
|
definer = admin@`%` procedure UpdateEqpOnStoveStatusLog() comment '更新开炉记录日志表'
|
||||||
BEGIN
|
BEGIN
|
||||||
DROP TABLE IF EXISTS `eqponstovestatustmp`;
|
DROP TABLE IF EXISTS `eqponstovestatustmp`;
|
||||||
create table eqponstovestatustmp
|
create table eqponstovestatustmp
|
||||||
|
@ -13,40 +13,13 @@ create table eqponstovestatustmp
|
||||||
eqpstatus varchar(50),
|
eqpstatus varchar(50),
|
||||||
crusize varchar(50),
|
crusize varchar(50),
|
||||||
subprod varchar(50),
|
subprod varchar(50),
|
||||||
Areport datetime,
|
firststovetime datetime,
|
||||||
Astove datetime,
|
lastreporttime datetime,
|
||||||
Aout datetime,
|
laststovetime datetime,
|
||||||
Breport datetime,
|
lastopentime datetime,
|
||||||
Bstove datetime,
|
lastouttime datetime,
|
||||||
Bout datetime,
|
finishtime datetime,
|
||||||
Creport datetime,
|
lastchaiqingtime 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
|
||||||
|
@ -55,22 +28,31 @@ from reportdata.equipment;
|
||||||
###更新最新有执行记录的工单
|
###更新最新有执行记录的工单
|
||||||
update eqponstovestatustmp es
|
update eqponstovestatustmp es
|
||||||
left join
|
left join
|
||||||
(select eqpid, substring(eventid, 1, 10) mesmoname, max(eventtime)
|
(select eql.eqpid, substring(eql.eventid, 1, 10) mesmoname, max(eql.eventtime)
|
||||||
from eqponstatuslogs
|
from eqponstatuslogs eql
|
||||||
group by eqpid) b on (es.eqpid = b.eqpid)
|
left join reportdata.mostatus mo on (eql.mesmoname = mo.MESmoname)
|
||||||
|
where mo.mostatus = '0'
|
||||||
|
group by eql.eqpid) b on (es.eqpid = b.eqpid)
|
||||||
set es.mesmoname = b.mesmoname;
|
set es.mesmoname = b.mesmoname;
|
||||||
|
|
||||||
##1 报料,2 加料,3 开副室,4 晶棒产出,5 拆清
|
##1 报料,2 加料,3 开副室,4 晶棒产出,5 拆清
|
||||||
|
update eqponstovestatustmp eqs
|
||||||
|
left join
|
||||||
|
(select mesmoname, min(eventtime) stovetime
|
||||||
|
from eqponstatuslogs
|
||||||
|
where eventtype = '加料'
|
||||||
|
group by mesmoname) eql on eqs.mesmoname = eql.mesmoname
|
||||||
|
set eqs.firststovetime = eql.stovetime;
|
||||||
|
|
||||||
update eqponstovestatustmp eqs
|
update eqponstovestatustmp eqs
|
||||||
left join
|
left join
|
||||||
(select es.eqpid,
|
(select es.eqpid,
|
||||||
epl.mesmoname,
|
epl.mesmoname,
|
||||||
max(case when eventtype = '1' then eventtime end) lastreporttime,
|
max(case when eventtype = '报料' then eventtime end) lastreporttime,
|
||||||
max(case when eventtype = '2' then eventtime end) laststovetime,
|
max(case when eventtype = '加料' then eventtime end) laststovetime,
|
||||||
max(case when eventtype = '3' then eventtime end) lastopentime,
|
max(case when eventtype = '开副室' then eventtime end) lastopentime,
|
||||||
max(case when eventtype = '3' then eventtime end) lastouttime,
|
max(case when eventtype = '晶棒产出' then eventtime end) lastouttime,
|
||||||
max(case when eventtype = '3' then eventtime end) lastchaiqingtime,
|
max(case when eventtype = '拆清' then eventtime end) lastchaiqingtime,
|
||||||
case when substring(eventid,13,1) = 'W' then eventtime end finishtime
|
case when substring(eventid,13,1) = 'W' then eventtime end finishtime
|
||||||
from eqponstatuslogs es
|
from eqponstatuslogs es
|
||||||
inner join eqponstovestatustmp epl on (substring(es.eventid, 1, 10) = epl.mesmoname)
|
inner join eqponstovestatustmp epl on (substring(es.eventid, 1, 10) = epl.mesmoname)
|
||||||
|
@ -81,6 +63,7 @@ set eqs.lastreporttime = b.lastreporttime,
|
||||||
eqs.lastouttime = b.lastouttime,
|
eqs.lastouttime = b.lastouttime,
|
||||||
eqs.lastchaiqingtime = b.lastchaiqingtime,
|
eqs.lastchaiqingtime = b.lastchaiqingtime,
|
||||||
eqs.finishtime = b.finishtime;
|
eqs.finishtime = b.finishtime;
|
||||||
|
|
||||||
###有工单、有投入、未产出
|
###有工单、有投入、未产出
|
||||||
update eqponstovestatustmp
|
update eqponstovestatustmp
|
||||||
set eqpstatus = '投料后未产出'
|
set eqpstatus = '投料后未产出'
|
||||||
|
@ -160,6 +143,7 @@ insert into eqponstovestatus(
|
||||||
eqpstatus,
|
eqpstatus,
|
||||||
crusize,
|
crusize,
|
||||||
subprod,
|
subprod,
|
||||||
|
firststovetime,
|
||||||
lastreporttime,
|
lastreporttime,
|
||||||
laststovetime,
|
laststovetime,
|
||||||
lastopentime,
|
lastopentime,
|
||||||
|
@ -176,3 +160,4 @@ update eqponstovestatus set mfgdate = date_format(now()-8.5/24,'%Y-%m-%d') where
|
||||||
drop table eqponstovestatustmp;
|
drop table eqponstovestatustmp;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
drop procedure if exists UpdateMostatus;
|
||||||
create
|
create
|
||||||
definer = admin@`%` procedure UpdateMostatus()
|
definer = admin@`%` procedure UpdateMostatus()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -38,12 +39,31 @@ and mo.stovetime < st.newtime;
|
||||||
|
|
||||||
|
|
||||||
##异常完结的更新完结时间及运行时间
|
##异常完结的更新完结时间及运行时间
|
||||||
update reportdata.mostatus mo,(SELECT DISTINCT order_no,max(create_time) max_time,max(substring(code,11,1)) rx from mes_sync.mes_production GROUP BY order_no) f
|
update reportdata.mostatus mo
|
||||||
set mo.finish_time = f.max_time,mo.runtime = datediff(f.max_time,mo.stovetime)
|
inner join (SELECT DISTINCT order_no, max(create_time) max_time, max(substring(code, 11, 1)) rx
|
||||||
where 1=1
|
from mes_sync.mes_production
|
||||||
and mo.MESmoname = f.order_no
|
GROUP BY order_no) f on (mo.MESmoname = f.order_no
|
||||||
and mo.finish_time is null
|
and mo.finish_time is null
|
||||||
and mo.mostatus = '1' ;
|
and mo.mostatus = '1')
|
||||||
|
set mo.finish_time = f.max_time,
|
||||||
|
mo.mostatus = '1',
|
||||||
|
mo.mostatusdesc = '完结',
|
||||||
|
mo.runtime = datediff(f.max_time, mo.stovetime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##更新20天前未完结的
|
||||||
|
update reportdata.mostatus mo
|
||||||
|
inner join (SELECT DISTINCT order_no, max(create_time) max_time, max(substring(code, 11, 1)) rx
|
||||||
|
from mes_sync.mes_production
|
||||||
|
GROUP BY order_no) f on (mo.MESmoname = f.order_no
|
||||||
|
and mo.finish_time is null
|
||||||
|
and mo.mostatus = '0'
|
||||||
|
and mo.stovetime <date_format(date_sub(now(), interval 20 day), '%Y-%m-%d'))
|
||||||
|
set mo.finish_time = f.max_time,
|
||||||
|
mo.mostatus = '1',
|
||||||
|
mo.mostatusdesc = '完结',
|
||||||
|
mo.runtime = datediff(f.max_time, mo.stovetime);
|
||||||
|
|
||||||
update reportdata.mostatus mo
|
update reportdata.mostatus mo
|
||||||
inner join
|
inner join
|
||||||
|
@ -52,5 +72,6 @@ select DISTINCT mesmoname,rx from reportdata.allfeedingdetail
|
||||||
)af on(mo.mesmoname = af.mesmoname)
|
)af on(mo.mesmoname = af.mesmoname)
|
||||||
set mo.rx=af.rx ;
|
set mo.rx=af.rx ;
|
||||||
|
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue