SELECT S.SFC,S.QTY,IT.DESCRIPTION ITEM_DESCRIPTION FROM SFC S
SELECT PREZSD.EMPLOYEE_DESCRIPTION,CASE WHEN TO_NUMBER(zsd.DISPATCH_SEQ)=1 THEN NULL
WHEN SS.STEP_SEQUENCE>TO_NUMBER(zsd.DISPATCH_SEQ)-1 THEN '完成'
ELSE '未完成' END LAST_OPERATION_STATUS,
S.SFC,S.QTY,IT.DESCRIPTION ITEM_DESCRIPTION FROM SFC S
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE=#{locale}
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE=#{locale}
JOIN Z_SFC_DISPATCH zsd ON S.SFC=zsd.SFC AND S.SITE=zsd.SITE
JOIN Z_SFC_DISPATCH zsd ON S.SFC=zsd.SFC AND S.SITE=zsd.SITE
LEFT JOIN Z_SFC_DISPATCH PREZSD ON zsd.SFC=PREZSD.SFC AND PREZSD.DISPATCH_SEQ=TO_NUMBER(zsd.DISPATCH_SEQ)-1
JOIN Z_PROD_READY_TASK zprt ON ZPRT.SFC_DISPATCH_BO=zsd.HANDLE
JOIN Z_PROD_READY_TASK zprt ON ZPRT.SFC_DISPATCH_BO=zsd.HANDLE
JOIN SFC S ON S.SFC=ZSD.SFC AND S.SITE=ZSD.SITE
JOIN SFC_ROUTING SR ON SR.SFC_BO=S.HANDLE
JOIN SFC_ROUTER SR2 ON SR.HANDLE =SR2.SFC_ROUTING_BO AND SR2.IN_USE = 'true'
LEFT JOIN SFC_STEP SS ON SR2.HANDLE =SS.SFC_ROUTER_BO AND (SS.QTY_IN_QUEUE>0 or SS.QTY_IN_WORK>0)
WHERE S.SITE=#{ew.entity.site} AND ZSD.RESRCE=#{ew.entity.resrce} AND ZSD.DISPATCH_STATUS!='CANCEL' AND ZSD.DISPATCH_STATUS!='COMPLETE'
WHERE S.SITE=#{ew.entity.site} AND ZSD.RESRCE=#{ew.entity.resrce} AND ZSD.DISPATCH_STATUS!='CANCEL' AND ZSD.DISPATCH_STATUS!='COMPLETE'
AND S.STATUS_BO IN ('StatusBO:'||#{ew.entity.site}||',401','StatusBO:'||#{ew.entity.site}||',402','StatusBO:'||#{ew.entity.site}||',403','StatusBO:'||#{ew.entity.site}||',404')
AND S.STATUS_BO IN ('StatusBO:'||#{ew.entity.site}||',401','StatusBO:'||#{ew.entity.site}||',402','StatusBO:'||#{ew.entity.site}||',403','StatusBO:'||#{ew.entity.site}||',404')