diff --git a/数据库迁移sql/存储过程&定时任务/存储过程/UpdateEqpStatusLogs.sql b/数据库迁移sql/存储过程&定时任务/存储过程/UpdateEqpStatusLogs.sql index e751d20..6fa8edf 100644 --- a/数据库迁移sql/存储过程&定时任务/存储过程/UpdateEqpStatusLogs.sql +++ b/数据库迁移sql/存储过程&定时任务/存储过程/UpdateEqpStatusLogs.sql @@ -24,7 +24,7 @@ BEGIN 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, case when report_type = '1' then '初装报料' @@ -33,14 +33,20 @@ BEGIN update_time, task_code, 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 left join reportdata.equipment eq on (substring(mrt.crystal_code, 5, 5) = eq.eqpname) where update_time between begindate and enddate 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, stove_no, case @@ -49,50 +55,78 @@ BEGIN right(task_code, 1), '桶加料') end event, ft.update_time, 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 right join mes_sync.mes_feeding_detail fd 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; + ###开副室记录 - insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype) - select substring(order_no, 5, 5) eqpname, + insert into eqponstatuslogs(eqpname, eqpid, event, eventtime, eventid, eventtype, rx, eventstatus) + select substring(order_no, 5, 5) eqpname, 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, code, - '3' + '开副室', + substring(code, 11, 1), + '已完成' 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, stove_no, concat(right(code, 3), '晶棒产出'), update_time, code, - '4' + '产出晶棒', + substring(code, 11, 1), + case + when is_transport = 0 then '未质检' + when is_transport = 1 then '已质检' end from mes_sync.mes_production 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, stove_no, '拆清', update_time, order_no, '5', - status + '99', + case + when status = 1 then '待处理' + when status = 2 then '进行中' + when status = 3 then '已完成' end from mes_sync.mes_dismantle_task where 1 = 1 and update_time between begindate and enddate and status = '3'; - ##更新归档时间 + +##更新归档时间 update eqponstatuslogs set savedate = now() where eventtime between begindate and enddate;