增加rx和事件状态字段

This commit is contained in:
xiaochou164 2023-08-12 09:38:02 +08:00
parent fde6acae1a
commit 631d68fd61
1 changed files with 49 additions and 15 deletions

View File

@ -24,7 +24,7 @@ BEGIN
end if; end if;
###报料记录 ###报料记录
insert into eqponstatuslogs(eqpname, event, eventtime, eventid, eqpid, eventtype) insert into eqponstatuslogs(eqpname, event, eventtime, eventid, eqpid, eventtype, rx, eventstatus)
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 '初装报料'
@ -33,14 +33,20 @@ BEGIN
update_time, update_time,
task_code, task_code,
eq.eqpid, eq.eqpid,
'1' '报料',
case
when report_type = '1' then '0'
when report_type = '2' then substring(task_code, 13, 1)
else '' end rx,
'已完成' #状态 1:待处理、2:进行中 3:已完成 4:暂停
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
order by create_time desc; order by create_time desc;
###加料记录 ###加料记录
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus)
SELECT substring(order_no, 5, 5) eqpname, SELECT substring(order_no, 5, 5) eqpname,
stove_no, stove_no,
case case
@ -49,50 +55,78 @@ BEGIN
right(task_code, 1), '桶加料') end event, right(task_code, 1), '桶加料') end event,
ft.update_time, ft.update_time,
feeding_task_code, feeding_task_code,
'2' '加料',
case
when feeding_task_code like '%CZ%' then '0'
else substring(feeding_task_code, 13, 1) end rx,
case
when ft.status = 1 then '待处理'
when ft.status = 2 then '进行中'
when ft.status = 3 then '已完成'
when ft.status = 4 then '暂停' end #状态 1:待处理、2:进行中 3:已完成 4:暂停
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')
where ft.`status` = '3' where 1 = 1
and ft.update_time between begindate and enddate; and ft.update_time between begindate and enddate;
###开副室记录 ###开副室记录
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus)
select substring(order_no, 5, 5) eqpname, select substring(order_no, 5, 5) eqpname,
stove_no, stove_no,
'开副室' event, concat(
case
when type = 0 then ''
when type = 1 then '正常取棒'
when type = 2 then '断棒'
when type = 3 then '余料提出' end,
'/开副室/', case when cold_stoking = 0 then '焖炉' else '' end) event,#物料类型 1:正常取棒 2:断棒 3:拉晶余料
opening_time, opening_time,
code, code,
'3' '开副室',
substring(code, 11, 1),
'已完成'
from mes_sync.mes_sub_chamber_task from mes_sync.mes_sub_chamber_task
where opening_time between begindate and enddate; where 1 = 1
and delete_flag = '0'
and opening_time between begindate and enddate;
###晶棒产出 ###晶棒产出
insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus)
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), '晶棒产出'),
update_time, update_time,
code, code,
'4' '产出晶棒',
substring(code, 11, 1),
case
when is_transport = 0 then '未质检'
when is_transport = 1 then '已质检' end
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, eventstatus) insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus)
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', '5',
status '99',
case
when status = 1 then '待处理'
when status = 2 then '进行中'
when status = 3 then '已完成' end
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
and status = '3'; and status = '3';
##更新归档时间
##更新归档时间
update eqponstatuslogs update eqponstatuslogs
set savedate = now() set savedate = now()
where eventtime between begindate and enddate; where eventtime between begindate and enddate;