CONCAT('MSCLL', DATE_FORMAT(t1.creation_date, '%Y%m%d'), t1.iface_id) AS '单据编号',
t1.material_code AS '物料编号',
IFNULL((SELECT aft_quiet_time FROM ty_mes.mt_account_period WHERE t1.creation_date < aft_quiet_time ORDER BY account_period_id DESC LIMIT 1), t1.creation_date) AS '单据日期',
...
FROM
ty_mes.hme_wo_material_sum_iface t1
LEFT JOIN ty_aps.hps_make_order_iface t2 ON t1.wo_number = t2.make_order_num
LEFT JOIN ty_aps.mt_bom_component_iface t3 ON t1.wo_number = t3.bom_code AND t1.material_code=t3.component_item_code
LEFT JOIN hzero_platform.hpfm_lov_value t4 ON t2.department = t4.meaning AND t4.lov_code = 'TY.KINGDEE.WORKSHOP' AND t2.manufacturing_site_code = t4.tag AND t4.enabled_flag = 1