YZ_MES/数据库迁移sql/存储过程/UpdateRecyclematerialoutput...

31 lines
1022 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

##############################
##@author:gong.chengbo ##
##@createdate:2023-08-10 ##
##@for: ##
##############################
drop procedure if exists UpdateRecyclematerialouput;
create
definer = admin@`%` procedure UpdateRecyclematerialouput()
BEGIN
replace into reportdata.recyclematerialouput(lotsn,prodname,proddesc,prodtype,level,
resistivity,weight,cate1,type,cate2,cate3,update_time,mfgdate,month)
SELECT order_no lotsn,
material_code prodname,
material_name proddesc,
replace(replace(product_type,'',''),'','') prodtype,
material_type level,
resistivity,
weight,
pd.cate1,
pd.type,
pd.cate2,
pd.cate3,
update_time,
DATE_FORMAT(DATE_add(ms.update_time,interval -510 MINUTE),'%Y-%m-%d') mfgdate,
CONCAT('M',DATE_FORMAT(DATE_add(ms.update_time,interval -510 MINUTE),'%m')) `month`
FROM mes_sync.mes_recycle_material_storage ms
left join reportdata.product pd on (ms.material_code = pd.prodname)
and substring(material_code,6,1) = '1'
where `status` = '2';
END;