SELECT DISTINCT eq.area 车间, eq.area1 片区, eq.eqpid 炉台号, case when mo.mesmoname is null then m.mesmoname else mo.mesmoname end MES炉次号 , case when mo.mesmoname is null then '' else mo.erpmoname end ERP工单号 , case when mo.mesmoname is null then m.prodname else mo.prodname end 物料编码, case when mo.mesmoname is null then m.proddesc else mo.proddesc end 物料描述, case when mo.mesmoname is null then m.crusize else mo.crusize end 热场尺寸, case when mo.mesmoname is null then m.plantime else mo.stovetime end 初投时间, case when mo.mesmoname is null then '' else mo.crucible end 坩埚厂商, case when mo.mesmoname is null then m.subprod else mo.subprod end 产品规格, case when mo.mesmoname is null then '未投炉' else mo.mostatusdesc end 工单状态, case when mo.mesmoname is null then '' else mo.rx end 棒次, case when mo.mesmoname is null then (case when LOCATE('自产',m.proddesc) >0 then mid(m.proddesc,LOCATE('自产',m.proddesc)+10,15) when LOCATE('代工',m.proddesc) >0 then mid(m.proddesc,LOCATE('代工',m.proddesc)+10,15) end) else (case when LOCATE('自产',mo.proddesc) >0 then mid(mo.proddesc,LOCATE('自产',mo.proddesc)+10,15) when LOCATE('代工',mo.proddesc) >0 then mid(mo.proddesc,LOCATE('代工',mo.proddesc)+10,15) end) end remark from reportdata.equipment eq ##处理产品规格 LEFT JOIN (SELECT * from reportdata.mostatus where mostatus = 0) mo on (eq.eqpid = mo.eqpid) LEFT JOIN ( SELECT order_no mesmoname,stove_no eqpid,thermal_field crusize,material_code prodname,material_name proddesc,schedule_time plantime, case when LOCATE('自产',material_name) >0 then mid(material_name,LOCATE('自产',material_name)+3,6) when LOCATE('代工',material_name) >0 then mid(material_name,LOCATE('代工',material_name)+3,6) end subprod from mes_sync.mes_crystal_order where 1=1 and `status` = '1' and finish_flag = '0' ) m on (eq.eqpid = m.eqpid) order by eq.eqpid;