LEFT JOIN WORK_CENTER wc ON wc.WORK_CENTER = zsd.WORK_CENTER
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = 'zh'
LEFT JOIN SHOP_ORDER so ON so.SHOP_ORDER = zsd.SHOP_ORDER AND so.SITE = zsd.SITE
LEFT JOIN CUSTOM_FIELDS cf ON cf.HANDLE = so.HANDLE AND cf."ATTRIBUTE" = 'ITEM_NUMBER'
LEFT JOIN CUSTOM_FIELDS cf2 ON cf2.HANDLE = so.HANDLE AND cf2."ATTRIBUTE" = 'PRODUCT_CATEGORY'
LEFT JOIN ITEM i On i.HANDLE = so.ITEM_BO
LEFT JOIN ITEM_T it ON it.ITEM_BO = so.ITEM_BO
LEFT JOIN RESRCE r ON r.RESRCE = zsd.RESRCE AND r.SITE = zsd.SITE
LEFT JOIN SFC s ON s.SFC = zsd.SFC AND s.SITE = zsd.SITE
LEFT JOIN SFC_ROUTING sr ON sr.SFC_BO = s.HANDLE
LEFT JOIN SFC_ROUTER st ON st.SFC_ROUTING_BO = sr.HANDLE
LEFT JOIN SFC_STEP ss ON ss.SFC_ROUTER_BO = st.HANDLE AND (ss.QTY_IN_QUEUE > 0 OR ss.QTY_IN_WORK > 0)
LEFT JOIN OPERATION o ON o.OPERATION = SUBSTR(SS.OPERATION_BO,INSTR(SS.OPERATION_BO,',',1,1)+1,INSTR(SS.OPERATION_BO,',',1,2) - INSTR(SS.OPERATION_BO,',') -1) AND o.SITE = zsd.SITE
LEFT JOIN OPERATION_T ot ON ot.OPERATION_BO = o.HANDLE AND ot.LOCALE = 'zh'
LEFT JOIN OPERATION o2 ON o2.OPERATION = zsd.OPERATION AND o2.SITE = zsd.SITE
LEFT JOIN OPERATION_T ot2 ON ot2.OPERATION_BO = o2.HANDLE AND ot2.LOCALE = 'zh'
<where>
zsd.SITE = #{site}
<iftest="workCenter != null and workCenter != ''">
AND (wc.WORK_CENTER = #{workCenter} OR wct.DESCRIPTION = #{workCenter})
</if>
<iftest="itemNumber != null and itemNumber != ''">
AND cf.VALUE = #{itemNumber}
</if>
<iftest="productCategory != null and productCategory != ''">
AND cf2.VALUE = #{productCategory}
</if>
<iftest="operation != null and operation != ''">
AND (o2.OPERATION LIKE '%${operation}%'
OR ot2.DESCRIPTION LIKE '%${operation}%')
</if>
<iftest="resrce != null and resrce != ''">
AND (r.RESRCE LIKE '%${resrce}%'
OR r.DESCRIPTION LIKE '%${resrce}%')
</if>
<iftest="item != null and item != ''">
AND (i.ITEM LIKE '%${item}%' OR it.DESCRIPTION LIKE '%${item}%')
CASE WHEN CC.VALUE = '9' THEN N'是' ELSE N'否' END IS_MAJOR, CASE WHEN SD.TURN_OPERATION = 'true' THEN N'是' ELSE N'否' END TURN_OPERATION, SD.BLANKING_SIZE, MAX(BC.COMPONENT_GBO) COMPONENT_BO,