select t1.name 流转单号,t1.date 日期,
t3.name_template 产品编码,
left(t3.name_template,3) 图,
substring(t3.name_template,6,3) 号,
t4.material 产品材质,t4.cust_spec 产品规格,
t5.name 批次卡号,
这里是取一串数据中的 头 中 尾 几个数据
case when left(t5.name,2)='20' then substring(t5.name,3,6)
when left(t5.name,4)='HY20' then substring(t5.name,5,6)
when left(t5.name,4)='PR20' then substring(t5.name,5,6)
else left(t5.name,6) end 批次卡,
这里是取一串数据中的 头 中 尾 几个数据
case when left(t5.name,2)='20' then substring(t5.name,9,2)
when left(t5.name,4)='HY20' then substring(t5.name,11,2)
when left(t5.name,4)='PR20' then substring(t5.name,11,2)
else substring(t5.name,7,2) end 工单,
right(t5.name,3) 号码,t6.name 工序,t8.name 员工名称,t2.lqty 支数
from mrp_production_report t1
left join mrp_production_report_line t2 on t1.id=t2.line_id
left join product_product t3 on t2.lproduct_id=t3.id
left join product_template t4 on t3.product_tmpl_id=t4.id
left join mrp_production_report_lot t5 on t5.id=t2.lot_id
left join mrp_routing_workcenter t6 on t6.id=t2.lprocedure
left join res_users t7 on t7.id=t2.lemployee
left join res_partner t8 on t8.id=t7.partner_id
where t1.company_id='||get_company_id(companyname)||' and t2.lstate=2 and (t6.name='分选' or t6.name='包装')