生产派工查询条件修改。

master
Leon 3 years ago
parent 987415f7b7
commit 32ed7520d8

@ -668,99 +668,101 @@
</select> </select>
<select id="findSfcDispatchList" resultMap="FullResultMap"> <select id="findSfcDispatchList" resultMap="FullResultMap">
SELECT WIP.*, V1.STEP_ID PREPOSITION_STEP_ID, V1.OPERATION PREPOSITION_OPERATION, SELECT WIP.*
CASE WHEN WIP.DISPATCH_SEQ = 1 OR V1.DISPATCH_STATUS = 'COMPLETE' THEN N'是' ELSE N'否' END IS_COMPLETED,
CASE WHEN WIP.DISPATCH_STATUS = 'NEW' THEN N'新建' WHEN WIP.DISPATCH_STATUS = 'CANCEL' THEN N'取消'
WHEN WIP.DISPATCH_STATUS = 'PAUSE' THEN N'暂停' WHEN WIP.DISPATCH_STATUS = 'RELEASE' THEN N'发布'
END AS STATUS_NAME, 'ADMINISTRATOR' AS ROLE
FROM ( FROM (
SELECT DISTINCT SD.HANDLE, SD.SITE, SD.SHOP_ORDER, SD.DISPATCH_NO, C2.VALUE ITEM_NUMBER, C1.VALUE WORK_ORDER, IM.HANDLE ITEM_BO, IM.ITEM, IT.DESCRIPTION ITEM_DESCRIPTION, SD.SFC, SD.DISPATCH_STATUS, SELECT WIP.*, V1.STEP_ID PREPOSITION_STEP_ID, V1.OPERATION PREPOSITION_OPERATION,
SD.STEP_ID, SD.OPERATION, OT.DESCRIPTION OPERATION_DESCRIPTION, SD.RESOURCE_TYPE, SD.RESRCE, SD.EMPLOYEE, SD.EMPLOYEE USER_NAME, SD.DISPATCH_QTY, SD.PROD_HOURS, RS.DESCRIPTION RESOURCE_DESCRIPTION, CASE WHEN WIP.DISPATCH_SEQ = 1 OR V1.DISPATCH_STATUS = 'COMPLETE' THEN N'是' ELSE N'否' END IS_COMPLETED,
CASE WHEN SD.DISPATCH_STATUS = 'COMPLETE' THEN SD.DISPATCH_QTY ELSE 0 END COMPLETED_QTY, SD.PLANNED_START_DATE, SD.PLANNED_COMP_DATE, SD.WORK_CENTER, SD.IS_DISPATCH, SD.EMPLOYEE_DESCRIPTION, CASE WHEN WIP.DISPATCH_STATUS = 'NEW' THEN N'新建' WHEN WIP.DISPATCH_STATUS = 'CANCEL' THEN N'取消'
SD.ACTUAL_START_DATE, SD.ACTUAL_COMPLETE_DATE, SD.REMARK, SD.DISPATCH_SEQ, SD.DISPATCH_SEQ-1 BEFORE_SEQ, SD.DISPATCH_SEQ+1 AFTER_SEQ, SD.EARLIEST_START_DATE, SD.LATEST_END_DATE, WHEN WIP.DISPATCH_STATUS = 'PAUSE' THEN N'暂停' WHEN WIP.DISPATCH_STATUS = 'RELEASE' THEN N'发布'
CASE WHEN IM.LOT_SIZE = 1 THEN N'是' ELSE N'否' END IS_MAJOR, CASE WHEN SD.TURN_OPERATION = 'true' THEN N'是' ELSE N'否' END TURN_OPERATION, SD.BLANKING_SIZE, END AS STATUS_NAME, 'ADMINISTRATOR' AS ROLE
WR.WORK_CENTER RESOURCE_WORK_CENTER FROM (
FROM Z_SFC_DISPATCH SD SELECT DISTINCT SD.HANDLE, SD.SITE, SD.SHOP_ORDER, SD.DISPATCH_NO, C2.VALUE ITEM_NUMBER, C1.VALUE WORK_ORDER, IM.HANDLE ITEM_BO, IM.ITEM, IT.DESCRIPTION ITEM_DESCRIPTION, SD.SFC, SD.DISPATCH_STATUS,
LEFT JOIN RESRCE RS ON SD.SITE = RS.SITE AND SD.RESRCE = RS.RESRCE SD.STEP_ID, SD.OPERATION, OT.DESCRIPTION OPERATION_DESCRIPTION, SD.RESOURCE_TYPE, SD.RESRCE, SD.EMPLOYEE, SD.EMPLOYEE USER_NAME, SD.DISPATCH_QTY, SD.PROD_HOURS, RS.DESCRIPTION RESOURCE_DESCRIPTION,
INNER JOIN SHOP_ORDER SO ON SO.SITE = SD.SITE AND SO.SHOP_ORDER = SD.SHOP_ORDER CASE WHEN SD.DISPATCH_STATUS = 'COMPLETE' THEN SD.DISPATCH_QTY ELSE 0 END COMPLETED_QTY, SD.PLANNED_START_DATE, SD.PLANNED_COMP_DATE, SD.WORK_CENTER, SD.IS_DISPATCH, SD.EMPLOYEE_DESCRIPTION,
LEFT JOIN CUSTOM_FIELDS C1 ON C1.HANDLE = SO.HANDLE AND C1."ATTRIBUTE" = 'WORK_ORDER' SD.ACTUAL_START_DATE, SD.ACTUAL_COMPLETE_DATE, SD.REMARK, SD.DISPATCH_SEQ, SD.DISPATCH_SEQ-1 BEFORE_SEQ, SD.DISPATCH_SEQ+1 AFTER_SEQ, SD.EARLIEST_START_DATE, SD.LATEST_END_DATE,
LEFT JOIN CUSTOM_FIELDS C2 ON C2.HANDLE = SO.HANDLE AND C2."ATTRIBUTE" = 'ITEM_NUMBER' CASE WHEN IM.LOT_SIZE = 1 THEN N'是' ELSE N'否' END IS_MAJOR, CASE WHEN SD.TURN_OPERATION = 'true' THEN N'是' ELSE N'否' END TURN_OPERATION, SD.BLANKING_SIZE,
INNER JOIN ITEM IM ON IM.HANDLE = SO.ITEM_BO WR.WORK_CENTER RESOURCE_WORK_CENTER
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh' FROM Z_SFC_DISPATCH SD
INNER JOIN OPERATION O ON O.SITE = SD.SITE AND O.OPERATION = SD.OPERATION AND O.CURRENT_REVISION = 'true' LEFT JOIN RESRCE RS ON SD.SITE = RS.SITE AND SD.RESRCE = RS.RESRCE
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = O.HANDLE AND OT.LOCALE = 'zh' INNER JOIN SHOP_ORDER SO ON SO.SITE = SD.SITE AND SO.SHOP_ORDER = SD.SHOP_ORDER
INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SO.BOM_BO LEFT JOIN CUSTOM_FIELDS C1 ON C1.HANDLE = SO.HANDLE AND C1."ATTRIBUTE" = 'WORK_ORDER'
INNER JOIN ITEM CP ON CP.HANDLE = BC.COMPONENT_GBO LEFT JOIN CUSTOM_FIELDS C2 ON C2.HANDLE = SO.HANDLE AND C2."ATTRIBUTE" = 'ITEM_NUMBER'
LEFT JOIN ITEM_T CPT ON CPT.ITEM_BO = CP.HANDLE AND CPT.LOCALE = 'zh' INNER JOIN ITEM IM ON IM.HANDLE = SO.ITEM_BO
LEFT JOIN WORK_CENTER_MEMBER WCM ON WCM.WORK_CENTER_OR_RESOURCE_GBO = 'ResourceBO:' || SD.SITE || ',' || SD.RESRCE LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
LEFT JOIN WORK_CENTER WR ON WR.HANDLE = WCM.WORK_CENTER_BO INNER JOIN OPERATION O ON O.SITE = SD.SITE AND O.OPERATION = SD.OPERATION AND O.CURRENT_REVISION = 'true'
WHERE SD.SITE = #{site} LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = O.HANDLE AND OT.LOCALE = 'zh'
<if test="workCenter != null and workCenter != ''"> INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SO.BOM_BO
AND SD.OPERATION LIKE #{workCenter}||'%' INNER JOIN ITEM CP ON CP.HANDLE = BC.COMPONENT_GBO
</if> LEFT JOIN ITEM_T CPT ON CPT.ITEM_BO = CP.HANDLE AND CPT.LOCALE = 'zh'
<if test="dispatchStatus != null and dispatchStatus != ''"> LEFT JOIN WORK_CENTER_MEMBER WCM ON WCM.WORK_CENTER_OR_RESOURCE_GBO = 'ResourceBO:' || SD.SITE || ',' || SD.RESRCE
AND SD.DISPATCH_STATUS = #{dispatchStatus} LEFT JOIN WORK_CENTER WR ON WR.HANDLE = WCM.WORK_CENTER_BO
</if> WHERE SD.SITE = #{site}
<if test="item != null and item != ''"> <if test="workCenter != null and workCenter != ''">
AND IM.ITEM = #{item} AND SD.OPERATION LIKE #{workCenter}||'%'
</if> </if>
<if test="workOrder != null and workOrder != ''"> <if test="dispatchStatus != null and dispatchStatus != ''">
AND C1.VALUE LIKE '%' ||#{workOrder}|| '%' AND SD.DISPATCH_STATUS = #{dispatchStatus}
</if> </if>
<if test="itemNumber != null and itemNumber != ''"> <if test="item != null and item != ''">
AND C2.VALUE LIKE '%' ||#{itemNumber}|| '%' AND IM.ITEM = #{item}
</if> </if>
<if test="shopOrder != null and shopOrder != ''"> <if test="workOrder != null and workOrder != ''">
AND SD.SHOP_ORDER = #{shopOrder} AND C1.VALUE LIKE '%' ||#{workOrder}|| '%'
</if> </if>
<if test="resourceType != null and resourceType != ''"> <if test="itemNumber != null and itemNumber != ''">
AND SD.RESOURCE_TYPE = #{resourceType} AND C2.VALUE LIKE '%' ||#{itemNumber}|| '%'
</if> </if>
<if test="resrce != null and resrce != ''"> <if test="shopOrder != null and shopOrder != ''">
AND SD.RESRCE = #{resrce} AND SD.SHOP_ORDER = #{shopOrder}
</if> </if>
<if test="operation != null and operation != ''"> <if test="resourceType != null and resourceType != ''">
AND SD.OPERATION = #{operation} AND SD.RESOURCE_TYPE = #{resourceType}
</if> </if>
<if test="operationDescription != null and operationDescription != ''"> <if test="resrce != null and resrce != ''">
AND OT.DESCRIPTION = #{operationDescription} AND SD.RESRCE = #{resrce}
</if> </if>
<if test="sfc != null and sfc != ''"> <if test="operation != null and operation != ''">
AND SD.SFC = #{sfc} AND SD.OPERATION = #{operation}
</if> </if>
<if test="turnOperation != null and turnOperation != ''"> <if test="operationDescription != null and operationDescription != ''">
AND SD.TURN_OPERATION = #{turnOperation} AND OT.DESCRIPTION = #{operationDescription}
</if> </if>
<if test="component != null and component != ''"> <if test="sfc != null and sfc != ''">
AND CP.ITEM = #{component} AND SD.SFC = #{sfc}
</if> </if>
<if test="componentDescription != null and componentDescription != ''"> <if test="turnOperation != null and turnOperation != ''">
AND CPT.DESCRIPTION LIKE '%' || #{componentDescription} || '%' AND SD.TURN_OPERATION = #{turnOperation}
</if> </if>
<if test="isDispatch != null and isDispatch != ''"> <if test="component != null and component != ''">
AND SD.IS_DISPATCH = #{isDispatch} AND CP.ITEM = #{component}
</if> </if>
<if test="blankingSize != null and blankingSize != ''"> <if test="componentDescription != null and componentDescription != ''">
AND SD.BLANKING_SIZE LIKE '%'||#{blankingSize}||'%' AND CPT.DESCRIPTION LIKE '%' || #{componentDescription} || '%'
</if> </if>
<if test="startFromDate != null"> <if test="isDispatch != null and isDispatch != ''">
AND SO.PLANNED_START_DATE >= #{startFromDate} AND SD.IS_DISPATCH = #{isDispatch}
</if> </if>
<if test="startToDate != null"> <if test="blankingSize != null and blankingSize != ''">
AND SO.PLANNED_START_DATE &lt;= #{startToDate} AND SD.BLANKING_SIZE LIKE '%'||#{blankingSize}||'%'
</if> </if>
<if test="completeFromDate != null"> <if test="startFromDate != null">
AND SO.PLANNED_COMP_DATE >= TO_DATE(#{completeFromDate}, 'YYYY-MM-DD') AND SO.PLANNED_START_DATE >= TO_DATE(#{startFromDate}, 'YYYY-MM-DD')
</if> </if>
<if test="completeToDate != null"> <if test="startToDate != null">
AND SO.PLANNED_COMP_DATE &lt;= TO_DATE(#{completeToDate}|| '23:59:59', 'YYYY-MM-DD HH24:MI:SS') AND SO.PLANNED_START_DATE &lt;= TO_DATE(#{startToDate}|| '23:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if> </if>
<if test="completeFromDate != null">
AND SO.PLANNED_COMP_DATE >= TO_DATE(#{completeFromDate}, 'YYYY-MM-DD')
</if>
<if test="completeToDate != null">
AND SO.PLANNED_COMP_DATE &lt;= TO_DATE(#{completeToDate}|| '23:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
) WIP
LEFT JOIN Z_SFC_DISPATCH V1 ON V1.SITE = WIP.SITE AND V1.SFC = WIP.SFC AND V1.DISPATCH_SEQ = WIP.BEFORE_SEQ
LEFT JOIN Z_SFC_DISPATCH V2 ON V2.SITE = WIP.SITE AND V2.SFC = WIP.SFC AND V2.DISPATCH_SEQ = WIP.AFTER_SEQ
) WIP ) WIP
LEFT JOIN Z_SFC_DISPATCH V1 ON V1.SITE = WIP.SITE AND V1.SFC = WIP.SFC AND V1.DISPATCH_SEQ = WIP.BEFORE_SEQ <if test="isCompleted != null and isCompleted != ''">
LEFT JOIN Z_SFC_DISPATCH V2 ON V2.SITE = WIP.SITE AND V2.SFC = WIP.SFC AND V2.DISPATCH_SEQ = WIP.AFTER_SEQ WHERE WIP.IS_COMPLETED = #{isCompleted}
WHERE 1 = 1
<if test="isCompleted != null and isCompleted != '' and isCompleted = 'true'">
AND V1.DISPATCH_STATUS = 'COMPLETE'
</if> </if>
ORDER BY WIP.SHOP_ORDER, WIP.SFC, TO_NUMBER(WIP.DISPATCH_SEQ) ORDER BY WIP.SHOP_ORDER, WIP.SFC, TO_NUMBER(WIP.DISPATCH_SEQ)
</select> </select>

Loading…
Cancel
Save