You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

913 lines
51 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.foreverwin.mesnac.anomaly.mapper.ReportMapper">
<resultMap id="IntegrationLogDto" type="com.foreverwin.mesnac.anomaly.dto.IntegrationLogDto">
<result column="HANDLE" property="handle"/>
<result column="INTEGRATION_TYPE" property="integrationType"/>
<result column="CATEGORY" property="category"/>
<result column="STATUS" property="status"/>
<result column="REQUEST_DATE_TIME" property="requestDateTime"/>
<result column="RESULT_MESSAGE" property="resultMessage"/>
<result column="PARAM" property="param"/>
</resultMap>
<select id="findIntegrationLog" resultMap="IntegrationLogDto">
SELECT HANDLE,INTEGRATION_TYPE, CATEGORY, INTEGRATION_WAY,STATUS,
REQUEST_DATE_TIME,RESULT_MESSAGE RESULT_MESSAGE,PARAM PARAM
FROM Z_INTEGRATION_LOG
<where>
SITE = #{site}
<if test="param.integrationType != null and param.integrationType != ''">
AND INTEGRATION_TYPE = #{param.integrationType}
</if>
<if test="param.integrationWay != null and param.integrationWay != ''">
AND INTEGRATION_WAY = #{param.integrationWay}
</if>
<if test="param.status != null and param.status != ''">
AND STATUS = #{param.status}
</if>
<if test="param.startDateTime != null and param.startDateTime != ''">
AND REQUEST_DATE_TIME &gt;= TO_DATE(#{param.startDateTime}, 'YYYY-MM-DD') - 8/24
</if>
<if test="param.endDateTime != null and param.endDateTime != ''">
AND REQUEST_DATE_TIME &lt;= TO_DATE(#{param.endDateTime}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="param.param != null and param.param != ''">
AND PARAM LIKE '%${param.param}%'
</if>
</where>
ORDER BY REQUEST_DATE_TIME DESC
</select>
<select id="partsManufacturing" parameterType="java.util.HashMap" resultType="java.util.HashMap">
WITH ZSD AS (
SELECT * FROM
( SELECT TEMP.* , ROW_NUMBER() OVER(PARTITION BY TEMP.FINISHED_SFC , TEMP.FINISHED_SHOP_ORDER ORDER BY STEP_ID_A) RN FROM
(
SELECT
cf.VALUE FINISHED_WORK_ORDER,
so.SHOP_ORDER FINISHED_SHOP_ORDER,
zsd.SFC FINISHED_SFC,
i.ITEM FINISHED_ITEM,
it.DESCRIPTION FINISHED_ITEM_DESCRIPTION,
o.OPERATION FINISHED_OPERATION,
ot.DESCRIPTION FINISHED_OPERATION_DESCRIPTION,
so.BOM_BO ,
zsd.SITE,
zsd.DISPATCH_STATUS FINISHED_STATUS,
ZSD.STEP_ID STEP_ID_A
FROM
Z_SFC_DISPATCH zsd
INNER JOIN SHOP_ORDER so ON
so.SHOP_ORDER = zsd.SHOP_ORDER
AND so.SITE = zsd.SITE
INNER JOIN ITEM i ON
i.HANDLE = so.ITEM_BO
LEFT JOIN ITEM_T it ON
it.ITEM_BO = i.HANDLE
AND it.LOCALE = 'zh'
INNER JOIN OPERATION o ON
o.OPERATION = zsd.OPERATION
AND o.SITE = zsd.SITE
AND o.CURRENT_REVISION = 'true'
LEFT JOIN OPERATION_T ot ON
ot.OPERATION_BO = o.HANDLE
INNER JOIN CUSTOM_FIELDS cf ON
cf.HANDLE = so.HANDLE
AND cf."ATTRIBUTE" = 'WORK_ORDER'
WHERE
zsd.OPERATION IN ('HJ_6106HJH1', 'HJ_6106HJH2', 'HJ_6106HJH3')
AND cf.VALUE = #{workOrder}
AND zsd.SITE = #{site}
) TEMP
) WHERE RN = 1
) ,
zsdTemplate AS (
SELECT COUNT(ZSD2.SHOP_ORDER) NUM , ZSD.FINISHED_SHOP_ORDER FINISHED_SHOP_ORDER_TEMP , ZSD.FINISHED_SFC FINISHED_SFC_TEMP FROM ZSD
INNER JOIN BOM_COMPONENT bc ON bc.BOM_BO = zsd.BOM_BO
INNER JOIN SHOP_ORDER so ON so.ITEM_BO = BC.COMPONENT_GBO
INNER JOIN CUSTOM_FIELDS cf ON cf.HANDLE = so.HANDLE AND cf."ATTRIBUTE" = 'WORK_ORDER' AND cf.VALUE = zsd.FINISHED_WORK_ORDER
INNER JOIN Z_SFC_DISPATCH zsd2 ON zsd2.SHOP_ORDER = so.SHOP_ORDER AND zsd2.SITE = #{site}
WHERE zsd2.DISPATCH_STATUS != 'COMPLETE' AND zsd2.DISPATCH_STATUS != 'CANCEL'
GROUP BY ZSD.FINISHED_SHOP_ORDER , ZSD.FINISHED_SFC
)
SELECT
DISTINCT
SITE,
FINISHED_WORK_ORDER,
FINISHED_SHOP_ORDER,
FINISHED_SFC,
FINISHED_ITEM,
FINISHED_ITEM_DESCRIPTION,
FINISHED_OPERATION,
FINISHED_OPERATION_DESCRIPTION,
CASE WHEN FINISHED_STATUS = 'NEW'THEN '新建'
WHEN FINISHED_STATUS = 'RELEASE' THEN '发布'
WHEN FINISHED_STATUS = 'PAUSE' THEN '暂挂'
WHEN FINISHED_STATUS = 'START'THEN '已开始'
WHEN FINISHED_STATUS = 'COMPLETE' THEN '已完成'
WHEN FINISHED_STATUS = 'CANCEL' THEN '已取消'
ELSE '' END FINISHED_STATUS,
HJ_IS_COMPLETE,
ITEM_NUMBER,
SHOP_ORDER ,
ITEM ,
ITEM_DESCRIPTION,
DISPATCH_QTY ,
BLANKING_SIZE ,
SFC ,
OPERATION ,
OPERATION_DESCRIPTION,
STEP_ID,
CASE WHEN DISPATCH_STATUS = 'NEW'THEN '新建'
WHEN DISPATCH_STATUS = 'RELEASE' THEN '发布'
WHEN DISPATCH_STATUS = 'PAUSE' THEN '暂挂'
WHEN DISPATCH_STATUS = 'START'THEN '已开始'
WHEN DISPATCH_STATUS = 'COMPLETE' THEN '已完成'
WHEN DISPATCH_STATUS = 'CANCEL' THEN '已取消'
ELSE '' END DISPATCH_STATUS,
CURRENT_OPERATION,
CURRENT_OPERATION_DESCRIPTION,
IS_COMPLETE,
EMPLOYEE_DESCRIPTION,
PLANNED_START_DATE ,
PLANNED_COMP_DATE,
ACTUAL_START_DATE,
ACTUAL_COMPLETE_DATE
FROM
(
SELECT
FINISHED_WORK_ORDER,
FINISHED_SHOP_ORDER,
FINISHED_SFC,
FINISHED_ITEM,
FINISHED_ITEM_DESCRIPTION,
FINISHED_OPERATION,
FINISHED_OPERATION_DESCRIPTION,
FINISHED_STATUS,
zsd.SITE,
CASE
WHEN zsdTemplate.NUM > 1 THEN '否'
ELSE '是'
END HJ_IS_COMPLETE,
cf2.VALUE ITEM_NUMBER,
so.SHOP_ORDER ,
i.ITEM ,
it.DESCRIPTION ITEM_DESCRIPTION,
zsd2.DISPATCH_QTY ,
zsd2.BLANKING_SIZE ,
zsd2.SFC ,
zsd2.OPERATION ,
ot2.DESCRIPTION OPERATION_DESCRIPTION,
zsd2.DISPATCH_STATUS ,
o3.OPERATION CURRENT_OPERATION,
ot3.DESCRIPTION CURRENT_OPERATION_DESCRIPTION,
CASE
WHEN zsd3.NUM > 1 THEN '否'
ELSE '是'
END IS_COMPLETE,
zsd2.EMPLOYEE_DESCRIPTION,
zsd2.PLANNED_START_DATE ,
zsd2.PLANNED_COMP_DATE,
zsd2.ACTUAL_START_DATE ,
zsd2.ACTUAL_COMPLETE_DATE,
zsd2.STEP_ID
FROM
zsd
LEFT JOIN zsdTemplate ON
zsdTemplate.FINISHED_SHOP_ORDER_TEMP = zsd.FINISHED_SHOP_ORDER AND zsdTemplate.FINISHED_SFC_TEMP = ZSD.FINISHED_SFC
INNER JOIN BOM_COMPONENT bc ON
bc.BOM_BO = zsd.BOM_BO
INNER JOIN ITEM i ON
i.HANDLE = bc.COMPONENT_GBO
LEFT JOIN ITEM_T it ON
it.ITEM_BO = i.HANDLE
AND it.LOCALE = 'zh'
INNER JOIN SHOP_ORDER so ON
so.ITEM_BO = i.HANDLE
AND i.SITE = so.SITE
INNER JOIN CUSTOM_FIELDS cf ON
cf.HANDLE = so.HANDLE
AND cf."ATTRIBUTE" = 'WORK_ORDER'
AND cf.VALUE = zsd.FINISHED_WORK_ORDER
/*子件的查询*/
INNER JOIN Z_SFC_DISPATCH zsd2 ON
zsd2.SHOP_ORDER = so.SHOP_ORDER
AND zsd.SITE = zsd2.SITE
LEFT JOIN CUSTOM_FIELDS cf2 ON
so.HANDLE = cf2.HANDLE
AND cf2."ATTRIBUTE" = 'ITEM_NUMBER'
INNER JOIN OPERATION o2 ON
o2.OPERATION = zsd2.OPERATION
AND o2.SITE = zsd.SITE
LEFT JOIN OPERATION_T ot2 ON
ot2.OPERATION_BO = o2.HANDLE
AND ot2.LOCALE = 'zh'
INNER JOIN SFC s2 ON
s2.SFC = zsd2.SFC
AND s2.SITE = zsd.SITE
LEFT JOIN SFC_ROUTING sr ON
sr.SFC_BO = s2.HANDLE
LEFT JOIN SFC_ROUTER st ON
st.SFC_ROUTING_BO = sr.HANDLE
AND st.IN_USE = 'true'
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 o3 ON
o3.OPERATION = SPLIT(ss.OPERATION_BO,
2)
AND o3.SITE = zsd.SITE
AND o3.CURRENT_REVISION = 'true'
LEFT JOIN OPERATION_T ot3 ON
ot3.OPERATION_BO = o3.HANDLE
AND ot3.LOCALE = 'zh'
LEFT JOIN (
SELECT
COUNT(HANDLE) NUM,
SHOP_ORDER,
SITE
FROM
Z_SFC_DISPATCH zsd
WHERE
SITE = #{site}
AND zsd.DISPATCH_STATUS != 'COMPLETE'
AND zsd.DISPATCH_STATUS != 'CANCEL'
GROUP BY
SITE ,
SHOP_ORDER
) zsd3 ON
zsd3.SHOP_ORDER = so.SHOP_ORDER
AND zsd3.SITE = zsd.SITE
)
<where>
SITE = #{site} AND FINISHED_WORK_ORDER = #{workOrder}
<if test="itemNumber != null and itemNumber != ''">
AND ITEM_NUMBER = #{itemNumber}
</if>
<if test="shopOrder != null and shopOrder != ''">
AND (FINISHED_SHOP_ORDER = #{shopOrder} OR SHOP_ORDER = #{shopOrder})
</if>
<if test="item != null and item != ''">
AND (FINISHED_ITEM = #{item} OR FINISHED_ITEM_DESCRIPTION = #{item}
OR ITEM = #{item} OR ITEM_DESCRIPTION = #{item}
)
</if>
<if test="currentOperation != null and currentOperation != ''">
AND (CURRENT_OPERATION LIKE '%${currentOperation}%' OR
CURRENT_OPERATION_DESCRIPTION LIKE '%${currentOperation}%'
)
</if>
<if test="operation != null and operation != ''">
AND (FINISHED_OPERATION LIKE '%${operation}%'
OR FINISHED_OPERATION_DESCRIPTION LIKE '%${operation}%'
OR OPERATION LIKE '%${operation}%'
OR OPERATION_DESCRIPTION LIKE '%${operation}%'
)
</if>
<!-- <if test="finishedStatus != null and finishedStatus != ''">-->
<!-- AND FINISHED_STATUS = #{finishedStatus}-->
<!-- </if>-->
<if test="startDateTime != null and startDateTime != ''">
AND ACTUAL_START_DATE &gt;= TO_DATE(#{startDateTime}, 'YYYY-MM-DD') - 8/24
</if>
<if test="endDateTime != null and endDateTime != ''">
AND ACTUAL_START_DATE &lt;= TO_DATE(#{endDateTime}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="completeStartDateTime != null and completeStartDateTime != ''">
AND ACTUAL_COMPLETE_DATE &gt;= TO_DATE(#{completeStartDateTime}, 'YYYY-MM-DD') - 8/24
</if>
<if test="completeEndDateTime != null and completeEndDateTime != ''">
AND ACTUAL_COMPLETE_DATE &lt;= TO_DATE(#{completeEndDateTime}|| '15:59:59',
'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="hjIsCompleted != null and hjIsCompleted != ''">
AND FINISHED_STATUS = #{hjIsCompleted}
</if>
<if test="isCompleted != null and isCompleted != ''">
AND HJ_IS_COMPLETE = #{isCompleted}
</if>
</where>
ORDER BY FINISHED_OPERATION,FINISHED_SHOP_ORDER,SFC,STEP_ID
</select>
<select id="surplusReturnTable" resultType="java.util.HashMap">
SELECT ZSR.INVENTORY INVENTORY,ZSR.ITEM_BO ITEM_BO,IT.DESCRIPTION ITEM_DESCRIPTION,ZSR.LENGHT LENGHT,
ZSR.WIDTH WIDTH,ZSR.NUMBERS NUMBERS,ZSR.QTY QTY,ZSR.CREATED_DATE_TIME CREATED_DATE_TIME,I.ITEM ITEM
FROM
Z_SURPLUS_RETURN ZSR
INNER JOIN ITEM I ON I.HANDLE = ZSR.ITEM_BO
INNER JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE
<where>
ZSR.SITE = #{site}
<if test="item != null and item != ''">
AND I.ITEM LIKE '%${item}%'
</if>
<if test="itemDescription != null and itemDescription != ''">
AND IT.DESCRIPTION LIKE '%${itemDescription}%'
</if>
</where>
</select>
<select id="resourceRepair" resultType="java.util.HashMap">
SELECT
ZRRT.HANDLE HANDLE,
CASE WHEN WC2.WORK_CENTER != 'NULL' THEN WC2.WORK_CENTER
ELSE WC.WORK_CENTER
END WORK_CENTER,
CASE WHEN WCT2.DESCRIPTION != 'NULL' THEN WCT2.DESCRIPTION
ELSE WCT.DESCRIPTION
END WORK_CENTER_DESCRIPTION,
ZRRT.RESOURCE_NO,R.DESCRIPTION RESOURCE_DESCRIPTION,ZRRT.NC_CODE_NO, /*不良代码描述,维修人员*/
ZRRT.PRELIMINARY_REASON ,dflt.DATA_TAG DEAL_WAY ,ZRRT.DEAL_WAY_DESCRIPTION ,
I.ITEM ITEM,
CASE WHEN ZRITS.ITEM_BO != 'NULL' THEN IT.DESCRIPTION
ELSE ZRITS.DESCRIPTION
END ITEM_DESCRIPTION,
CF.VALUE ITEM_SPEC,
ZRRT.ACTUAL_START_DATE ACTUAL_START_DATE,ZRRT.ACTUAL_COMPLETE_DATE ACTUAL_COMPLETE_DATE,
'' SHUT_DOWN_TIME,/*暂时无法计算*/
CASE WHEN ZRRT.ACTUAL_START_DATE IS NOT NULL THEN TO_CHAR(TO_NUMBER((ZRRT.ACTUAL_START_DATE -ZRRT.CREATED_DATE_TIME)*24),'FM9999990.000')
ELSE TO_CHAR(TO_NUMBER((SYSDATE -ZRRT.CREATED_DATE_TIME)*24),'FM9999990.000')
END REPORT_WAIT_TIME ,
CASE WHEN ZRRT.ACTUAL_COMPLETE_DATE IS NOT NULL THEN TO_CHAR(TO_NUMBER((ZRRT.ACTUAL_COMPLETE_DATE-ZRRT.CREATED_DATE_TIME)*24) - NVL(ZRRT.WAIT_TIME,0),'FM9999990.000')
ELSE TO_CHAR(TO_NUMBER((SYSDATE- 8/24 - ZRRT.CREATED_DATE_TIME-ZRRT.WAIT_TIME)*24),'FM9999990.000')
END REPAIR_TIME ,
CASE WHEN ZRRT.STATUS = '401' THEN '待维修'
WHEN ZRRT.STATUS = '501' THEN '维修中'
WHEN ZRRT.STATUS = '502' THEN '维修等待'
WHEN ZRRT.STATUS = '302' THEN '关闭'
WHEN ZRRT.STATUS = '301' THEN '维修完成'
WHEN ZRRT.STATUS = '601' THEN '报修单确认'
END STATUS
,ZRRT.REPORT_USER REPORT_USER,ZNU.FULL_NAME REPORT_USER_DESCRIPTION,
ZRRT.REPAIR_USERS ,ZRRT.REMARK , ZRRT.CREATED_DATE_TIME REPORT_DATE_TIME
FROM
Z_RESOURCE_REPAIR_TASK ZRRT
INNER JOIN RESRCE R ON R.RESRCE = ZRRT.RESOURCE_NO AND R.SITE = ZRRT.SITE
INNER JOIN WORK_CENTER_MEMBER WCM ON WCM.WORK_CENTER_OR_RESOURCE_GBO = R.HANDLE
LEFT JOIN WORK_CENTER WC ON WC.HANDLE = WCM.WORK_CENTER_BO AND WC.WC_CATEGORY ='LEVEL2'
LEFT JOIN WORK_CENTER_MEMBER WCM2 ON WCM2.WORK_CENTER_OR_RESOURCE_GBO = WC.HANDLE
LEFT JOIN WORK_CENTER WC2 ON WC2.HANDLE = WCM2.WORK_CENTER_BO AND WC2.WC_CATEGORY = 'LEVEL4'
LEFT JOIN WORK_CENTER_T WCT ON WCT.WORK_CENTER_BO = WC.HANDLE AND WCT.LOCALE = #{locale}
LEFT JOIN WORK_CENTER_T WCT2 ON WCT2.WORK_CENTER_BO = WC2.HANDLE AND WCT2.LOCALE = #{locale}
LEFT JOIN Z_RESOURCE_INSPECT_TASK_SPARE ZRITS ON ZRITS.RESOURCE_INSPECT_TASK_BO = ZRRT.HANDLE
LEFT JOIN ITEM I ON I.HANDLE = ZRITS.ITEM_BO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = ZRITS.ITEM_BO AND IT.LOCALE = #{locale}
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = ZRITS.ITEM_BO AND CF."ATTRIBUTE" = 'MAT_SPEC'
LEFT JOIN Z_NWA_USER ZNU ON ZNU.USER_NAME = ZRRT.REPORT_USER AND ZNU.SITE = ZRRT.SITE
LEFT JOIN DATA_FIELD df ON df.DATA_FIELD = 'REPAIR_DEAL_WAY'
LEFT JOIN DATA_FIELD_LIST dfl ON dfl.DATA_FIELD_BO = df.HANDLE AND dfl.DATA_VALUE = ZRRT.DEAL_WAY
LEFT JOIN DATA_FIELD_LIST_T dflt ON dflt.DATA_FIELD_LIST_BO = dfl.HANDLE AND dflt.LOCALE = #{locale}
<where>
ZRRT.SITE = #{site}
<if test="param.workCenter != null and param.workCenter != ''">
AND (WC.WORK_CENTER LIKE '%${param.workCenter}%' OR WC2.WORK_CENTER LIKE '%${param.workCenter}%' OR
WCT.DESCRIPTION LIKE '%${param.workCenter}%' OR WCT2.DESCRIPTION LIKE '%${param.workCenter}%')
</if>
<if test="param.resource != null and param.resource != ''">
AND (R.RESRCE LIKE '%${param.resource}%' OR R.DESCRIPTION LIKE '%${param.resource}%')
</if>
<if test="param.startDateTime != null and param.startDateTime != ''">
AND ZRRT.ACTUAL_START_DATE &gt;= TO_DATE(#{param.startDateTime},'YYYY-MM-DD') - 8/24
</if>
<if test="param.endDateTime != null and param.endDateTime != ''">
AND ZRRT.ACTUAL_START_DATE &lt;= TO_DATE(#{param.endDateTime}|| '15:59:59','YYYY-MM-DD HH24:MI:SS')
</if>
</where>
</select>
<select id="findInspectionTask" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT WT.DESCRIPTION WORK_CENTER_DESCRIPTION, C2.VALUE ITEM_NUMBER,SO.SHOP_ORDER, C3.VALUE PRODUCT_MODEL,IM.ITEM ITEM, IT.DESCRIPTION ITEM_DESCRIPTION,
ZT.SFC, ZT.OPERATION, OT.DESCRIPTION OPERATION_DESCRIPTION, ZT.RESRCE, RS.DESCRIPTION RESOURCE_DESCRIPTION, ZT.TASK_NO, ZT.CATEGORY,
ZT."RESULT", ZT.CREATE_USER, ZNU.FULL_NAME, ZT.MODIFIED_DATE_TIME
FROM Z_INSPECTION_TASK ZT
LEFT JOIN WORK_CENTER WC ON WC.SITE = ZT.SITE AND WC.WORK_CENTER = ZT.WORK_CENTER
LEFT JOIN WORK_CENTER_T WT ON WT.WORK_CENTER_BO = WC.HANDLE AND WT.LOCALE = 'zh'
INNER JOIN SHOP_ORDER SO ON ZT.SITE = SO.SITE AND ZT.SHOP_ORDER = SO.SHOP_ORDER
LEFT JOIN CUSTOM_FIELDS C1 ON C1.HANDLE = SO.HANDLE AND C1."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN CUSTOM_FIELDS C2 ON C2.HANDLE = SO.HANDLE AND C2."ATTRIBUTE" = 'ITEM_NUMBER'
LEFT JOIN CUSTOM_FIELDS C3 ON C3.HANDLE = SO.HANDLE AND C3."ATTRIBUTE" = 'PRODUCT_MODEL'
INNER JOIN ITEM IM ON IM.HANDLE = SO.ITEM_BO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
INNER JOIN OPERATION OP ON OP.SITE = ZT.SITE AND OP.OPERATION = ZT.OPERATION AND OP.CURRENT_REVISION = 'true'
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE = 'zh'
INNER JOIN RESRCE RS ON RS.SITE = ZT.SITE AND RS.RESRCE = ZT.RESRCE
LEFT JOIN Z_NWA_USER ZNU ON ZNU.SITE = ZT.SITE AND ZNU.USER_NAME = ZT.CREATE_USER
WHERE ZT.SITE = #{site}
<if test="workCenter != null and workCenter != ''">
AND (WC.WORK_CENTER = #{workCenter} OR WT.DESCRIPTION = #{workCenter})
</if>
<if test="category != null and category != ''">
AND ZT.CATEGORY = #{category}
</if>
<if test="itemNumber != null and itemNumber != ''">
AND C2.VALUE LIKE '%'||#{itemNumber}||'%'
</if>
<if test="model != null and model != ''">
AND C3.VALUE LIKE '%'||#{model}||'%'
</if>
<if test="shopOrder != null and shopOrder != ''">
AND SO.SHOP_ORDER = #{shopOrder}
</if>
<if test="operation != null and operation != ''">
AND ZT.OPERATION = #{operation}
</if>
<if test="resrce != null and resrce != ''">
AND ZT.RESRCE = #{resrce}
</if>
<if test="result != null and result != ''">
AND ZT.RESULT = #{result}
</if>
<if test="startFromDate != null and startFromDate != ''">
AND ZT.MODIFIED_DATE_TIME >= TO_DATE(#{startFromDate}, 'YYYY-MM-DD') - 8/24
</if>
<if test="startToDate != null and startToDate != ''">
AND ZT.MODIFIED_DATE_TIME &lt;= TO_DATE(#{startToDate}|| '23:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
</select>
<select id="findQualityInspectionReport" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT zab.CREATED_DATE_TIME,zab.ABNORMAL_NO ABNORMAL_NO,
dflt.DATA_TAG PRODUCT_CATEGORY,
dflt2.DATA_TAG DISCOVER,
i.ITEM ITEM ,it.DESCRIPTION ITEM_DESCRIPTION,
COALESCE(itemNumber.VALUE,zab.ITEM_NUMBER) ITEM_NUMBER,
zab.SHOP_ORDER,
mapNo.VALUE MAP_NO,zab.PB_DESCRIPTION PB_DESCRIPTION,zsd.EMPLOYEE_DESCRIPTION OPERATOR,
CASE WHEN zab."TYPE" = 'Z' THEN '质量异常'
WHEN zab."TYPE" = 'Q' THEN '其他异常'
WHEN zab."TYPE" = 'S' THEN '设备异常' END "TYPE",
znu.FULL_NAME INSPECTOR ,
zab.PB_GRADE PB_GRADE ,
zabd.PRINCIPAL_USER PRINCIPAL_USER,
LISTAGG(nct.DESCRIPTION , ';') WITHIN GROUP(ORDER BY zab.ABNORMAL_NO) NC_CODE_DESCRIPTION,
zabd.DUTY_CAUSE_DESCRIPTION DUTY_CAUSE_DESCRIPTION,zabd.BEFORE_MEASURE BEFORE_MEASURE,
CASE WHEN zabd.ABNORMAL_METHOD = 'X' THEN '线下换料'
WHEN zabd.ABNORMAL_METHOD = 'S' THEN '试装'
WHEN zabd.ABNORMAL_METHOD = 'R' THEN '让步放心'
WHEN zabd.ABNORMAL_METHOD = 'C' THEN '报废'
WHEN zabd.ABNORMAL_METHOD = 'P' THEN '配作'
WHEN zabd.ABNORMAL_METHOD = 'F' THEN '返修'
WHEN zabd.ABNORMAL_METHOD = 'FW' THEN '返修(外协)'
WHEN zabd.ABNORMAL_METHOD = 'FB' THEN '返修(不返回原工艺)'
ELSE ''
END ABNORMAL_METHOD,zabd.RESOLVE_REMARK RESOLVE_REMARK,znu2.FULL_NAME RESOLVE_USER,
zabd.CLOSED_DATE_TIME CLOSED_DATE_TIME,zab.NC_QTY NC_QTY,zab.PB_QTY PB_QTY,
CASE WHEN (zabd.ABNORMAL_METHOD ='F' AND zab.SHOP_ORDER IS NOT NULL) THEN TO_CHAR(so.QTY_TO_BUILD,'9999')
WHEN zabd.ABNORMAL_METHOD = 'F' THEN TO_CHAR(zab.PB_QTY,'9999') ELSE '' END NUMBERS,
zsd.EMPLOYEE_DESCRIPTION DISPATCH_USER ,ot.DESCRIPTION OPERATION ,
r2.RESRCE RESRCE,r2.DESCRIPTION RESRCE_DESCRIPTION,zsd.RESOURCE_TYPE RESOURCE_TYPE,
rt.DESCRIPTION RESOURCE_TYPE_DESCRIPTION,zabd.DUTY_CAUSE_TYPE DUTY_CAUSE_TYPE,zabd.DUTY_TYPE DUTY_TYPE,
zabd.DUTY_DEPART DUTY_DEPART,TO_CHAR(TO_NUMBER(zabd.CLOSED_DATE_TIME - zab.RESPONSE_DATE_TIME)*24,'FM9999990.000') WORKING_HOURS,
CASE WHEN zab.SFC IS NOT NULL THEN '质量异常'
ELSE '外协质量异常'
END ABNORMAL_TYPE
FROM Z_ABNORMAL_BILL zab
INNER JOIN Z_ABNORMAL_BILL_DISPOSE zabd ON zab.HANDLE = zabd.ABNORMAL_BILL_BO
LEFT JOIN Z_ABNORMAL_NC_CODE zanc ON zab.HANDLE = zanc.ABNORMAL_BILL_BO
LEFT JOIN NC_CODE nc ON zanc.NC_CODE = nc.NC_CODE AND nc.SITE = zab.SITE
LEFT JOIN NC_CODE_T nct ON nct.NC_CODE_BO = nc.HANDLE AND nct.LOCALE = #{locale}
INNER JOIN ITEM i ON i.HANDLE = zab.ITEM_BO
LEFT JOIN ITEM_T it ON it.ITEM_BO = i.HANDLE AND it.LOCALE = #{locale}
INNER JOIN DATA_FIELD df ON df.DATA_FIELD = 'PRODUCT_CATEGORY'
LEFT JOIN DATA_FIELD_LIST dfl ON dfl.DATA_FIELD_BO = df.HANDLE AND dfl.DATA_VALUE = zab.PRODUCT_CATEGORY
LEFT JOIN DATA_FIELD_LIST_T dflt ON dflt.DATA_FIELD_LIST_BO = dfl.HANDLE AND dflt.LOCALE = #{locale}
INNER JOIN DATA_FIELD df2 ON df2.DATA_FIELD = 'DISCOVER'
LEFT JOIN DATA_FIELD_LIST dfl2 ON dfl2.DATA_FIELD_BO = df2.HANDLE AND dfl2.DATA_VALUE = zab.DISCOVER
LEFT JOIN DATA_FIELD_LIST_T dflt2 ON dflt2.DATA_FIELD_LIST_BO = dfl2.HANDLE AND dflt2.LOCALE = #{locale}
LEFT JOIN CUSTOM_FIELDS mapNo ON mapNo."ATTRIBUTE" = 'DWG_NO' AND mapNo.HANDLE = i.HANDLE
LEFT JOIN SHOP_ORDER so ON so.SHOP_ORDER = zab.SHOP_ORDER AND so.SITE = zab.SITE
LEFT JOIN ROUTER r ON r.HANDLE = zabd.ROUTER_BO
LEFT JOIN CUSTOM_FIELDS itemNumber ON itemNumber.HANDLE = so.HANDLE AND itemNumber."ATTRIBUTE" = 'ITEM_NUMBER'
LEFT JOIN SFC s ON s.SFC = zab.SFC AND s.SITE = zab.SITE
LEFT JOIN SFC_ROUTING SR ON SR.SFC_BO = S.HANDLE
LEFT JOIN SFC_ROUTER ST ON ST.SFC_ROUTING_BO = SR.HANDLE AND ST.IN_USE = 'true'
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 Z_SFC_DISPATCH zsd ON zsd.DISPATCH_NO = S.SFC || '-' || SS.STEP_ID
LEFT JOIN OPERATION o ON o.OPERATION = zsd.OPERATION AND o.SITE = zab.SITE AND o.CURRENT_REVISION ='true'
LEFT JOIN OPERATION_T ot ON ot.OPERATION_BO = o.HANDLE AND ot.LOCALE = #{locale}
LEFT JOIN RESRCE r2 ON r2.RESRCE = zsd.RESRCE AND r2.SITE = zab.SITE
LEFT JOIN RESOURCE_TYPE rt ON rt.RESOURCE_TYPE = zsd.RESOURCE_TYPE AND rt.SITE = zab.SITE
LEFT JOIN WORK_CENTER wc ON wc.WORK_CENTER = SUBSTR(o.OPERATION,1,INSTR(o.OPERATION,'_')-1) AND wc.SITE = zab.SITE
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = #{locale}
LEFT JOIN Z_NWA_USER znu ON znu.USER_NAME = zab.CREATED_USER AND znu.SITE = zab.SITE
LEFT JOIN Z_NWA_USER znu2 ON znu2.USER_NAME = zabd.RESOLVE_USER AND znu2.SITE = zab.SITE
<where>
zab.SITE = #{site} AND zab."TYPE" ='Z'
<if test="abnormalNo != null and abnormalNo != ''">
AND zab.ABNORMAL_NO = #{abnormalNo}
</if>
<if test="shopOrder != null and shopOrder != ''">
AND so.SHOP_ORDER = #{shopOrder}
</if>
<if test="productCategory != null and productCategory != ''">
AND (dflt.DATA_TAG = #{productCategory} OR
zab.PRODUCT_CATEGORY = #{productCategory}
)
</if>
<if test="discover != null and discover != ''">
AND zab.DISCOVER = #{discover}
</if>
<if test="createdUser != null and createdUser != ''">
AND (zab.CREATED_USER = #{createdUser} OR znu.FULL_NAME = #{createdUser})
</if>
<if test="startDateTime != null and startDateTime != ''">
AND zab.CREATED_DATE_TIME &gt;= TO_DATE(#{startDateTime},'YYYY-MM-DD') - 8/24
</if>
<if test="endDateTime != null and endDateTime != ''">
AND zab.CREATED_DATE_TIME &lt;= TO_DATE(#{endDateTime}|| '15:59:59','YYYY-MM-DD HH24:MI:SS')
</if>
</where>
GROUP BY zab.CREATED_DATE_TIME ,zab.ABNORMAL_NO ,
i.ITEM ,it.DESCRIPTION ,itemNumber.VALUE ,zab.ITEM_NUMBER,
mapNo.VALUE ,zab.PB_DESCRIPTION ,zsd.EMPLOYEE_DESCRIPTION ,
zab."TYPE" ,zab.REPORT_SEND_USER_GROUP ,zabd.DUTY_DEPART ,zabd.PRINCIPAL_USER,
zab.PB_GRADE,zabd.DUTY_CAUSE_DESCRIPTION ,zabd.BEFORE_MEASURE,ABNORMAL_METHOD,
zabd.RESOLVE_REMARK ,zabd.RESOLVE_USER ,
zabd.CLOSED_DATE_TIME ,zab.NC_QTY ,zab.PB_QTY ,zab.SHOP_ORDER,so.QTY_TO_BUILD,
zsd.EMPLOYEE_DESCRIPTION ,ot.DESCRIPTION ,
r2.RESRCE,r2.DESCRIPTION,zsd.RESOURCE_TYPE,
rt.DESCRIPTION, dflt.DATA_TAG,zabd.DUTY_CAUSE_TYPE,zabd.DUTY_TYPE ,zabd.DUTY_DEPART,zab.SFC,
znu.FULL_NAME,znu2.FULL_NAME,zab.RESPONSE_DATE_TIME,dflt2.DATA_TAG
ORDER BY zab.CREATED_DATE_TIME DESC
</select>
<select id="findAbnormalRecord" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT wct.DESCRIPTION WORK_CENTER,
COALESCE(cf2.VALUE,zab.ITEM_NUMBER) ITEM_NUMBER,
COALESCE(zab.WORK_ORDER,cf.VALUE) WORK_ORDER,
so.SHOP_ORDER SHOP_ORDER ,
i.ITEM ITEM,it.DESCRIPTION ITEM_DESCRIPTION,zab.SFC SFC,zab.ABNORMAL_NO ABNORMAL_NO,
CASE WHEN zab."TYPE" = 'Z' THEN '质量异常'
WHEN zab."TYPE" = 'S' THEN '设备异常'
WHEN zab."TYPE" = 'Q' THEN '其他异常' END ABNORMAL_TYPE,
zab.OPERATION OPERATION ,ot.DESCRIPTION OPERATION_DESCRIPTION,r.RESRCE RESRCE,r.DESCRIPTION RESRCE_DESCRIPTION,
zab.CREATED_DATE_TIME CREATED_DATE_TIME ,znu.FULL_NAME PB_USER,znu2.FULL_NAME REPORT_USER,
LISTAGG(nct.DESCRIPTION , ';') WITHIN GROUP(ORDER BY zab.ABNORMAL_NO) NC_CODE_DESCRIPTION,
CASE WHEN zab.STATUS = 'N' THEN '新建'
WHEN zab.STATUS = 'X' THEN '响应中'
WHEN zab.STATUS = 'F' THEN '方案确认'
WHEN zab.STATUS = 'J' THEN '纠防确认'
WHEN zab.STATUS = 'Q' THEN '取消'
WHEN zab.STATUS = 'G' THEN '关闭' END ABNORMAL_STATUS,
CASE WHEN zabd.ABNORMAL_METHOD = 'X' THEN '线下换料'
WHEN zabd.ABNORMAL_METHOD = 'S' THEN '试装'
WHEN zabd.ABNORMAL_METHOD = 'R' THEN '让步放心'
WHEN zabd.ABNORMAL_METHOD = 'C' THEN '报废'
WHEN zabd.ABNORMAL_METHOD = 'P' THEN '配作'
WHEN zabd.ABNORMAL_METHOD = 'F' THEN '返修'
WHEN zabd.ABNORMAL_METHOD = 'FW' THEN '返修(外协)'
WHEN zabd.ABNORMAL_METHOD = 'FB' THEN '返修(不返回原工艺)'
ELSE ''
END ABNORMAL_METHOD,
zabd.RESOLVE_DATE_TIME RESOLVE_DATE_TIME,
znu3.FULL_NAME RESOLVE_USER,zabd.CLOSED_DATE_TIME CANCEL_DATE_TIME ,
znu4.FULL_NAME CANCEL_USER,zabd.RESOLVE_REMARK RESOLVE_REMARK,
zabd.ABNORMAL_REASON ABNORMAL_REASON,zabd.BEFORE_MEASURE BEFORE_MEASURE,
ug.DESCRIPTION RESOLVE_SEND_USER_GROUP,
CASE WHEN zsr.CREATED_DATE_TIME IS NOT NULL THEN TO_CHAR(TO_NUMBER(zabd.RESOLVE_DATE_TIME - zsr.CREATED_DATE_TIME)*24,'FM9999990.000')
WHEN zabd.RESOLVE_DATE_TIME IS NOT NULL THEN TO_CHAR(TO_NUMBER(zabd.RESOLVE_DATE_TIME - zab.CREATED_DATE_TIME)*24,'FM9999990.000')
ELSE ''
END RESOLVE_DURATION,
zabd.DUTY_DEPART DUTY_DEPART
FROM Z_ABNORMAL_BILL zab
LEFT JOIN Z_ABNORMAL_NC_CODE zanc ON zanc.ABNORMAL_BILL_BO = zab.HANDLE
LEFT JOIN Z_ABNORMAL_BILL_DISPOSE zabd ON zabd.ABNORMAL_BILL_BO = zab.HANDLE
LEFT JOIN WORK_CENTER wc ON wc.WORK_CENTER = SUBSTR(zab.OPERATION,1,INSTR(zab.OPERATION,'_')-1)
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = 'zh'
LEFT JOIN NC_CODE nc ON zanc.NC_CODE = nc.NC_CODE AND nc.SITE = zab.SITE
LEFT JOIN NC_CODE_T nct ON nct.NC_CODE_BO = nc.HANDLE AND nct.LOCALE = 'zh'
LEFT JOIN SHOP_ORDER so ON so.SHOP_ORDER = zab.SHOP_ORDER AND so.SITE = zab.SITE
LEFT JOIN CUSTOM_FIELDS cf ON cf.HANDLE = so.HANDLE AND cf."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN CUSTOM_FIELDS cf2 ON cf2.HANDLE = so.HANDLE AND cf2."ATTRIBUTE" = 'ITEM_NUMBER'
LEFT JOIN ITEM i ON i.HANDLE = zab.ITEM_BO
LEFT JOIN ITEM_T it ON it.ITEM_BO = i.HANDLE AND it.LOCALE = 'zh'
LEFT JOIN OPERATION o ON o.OPERATION = zab.OPERATION AND o.SITE = zab.SITE
LEFT JOIN OPERATION_T ot ON ot.OPERATION_BO = o.HANDLE AND ot.LOCALE = 'zh'
LEFT JOIN RESRCE r ON r.RESRCE = zab.RESRCE AND r.SITE = zab.SITE
LEFT JOIN Z_NWA_USER znu ON znu.USER_NAME = zab.PB_USER
LEFT JOIN Z_NWA_USER znu2 ON znu2.USER_NAME = zab.CREATED_USER
LEFT JOIN Z_NWA_USER znu3 ON znu3.USER_NAME = zabd.RESOLVE_USER
LEFT JOIN Z_NWA_USER znu4 ON znu4.USER_NAME = zabd.CLOSED_USER
LEFT JOIN Z_SELF_REPORT zsr ON zsr.HANDLE = zab.OBJECT_BO
LEFT JOIN USER_GROUP ug ON ug.USER_GROUP = zabd.RESOLVE_SEND_USER_GROUP AND ug.SITE = zab.SITE
<where>
zab.SITE = #{site}
<if test="abnormalNo != null and abnormalNo != ''">
AND zab.ABNORMAL_NO = #{abnormalNo}
</if>
<if test="sfc != null and sfc != ''">
AND zab.sfc = #{sfc}
</if>
<if test="workCenter != null and workCenter != ''">
AND (wc.WORK_CENTER = #{workCenter} OR wct.DESCRIPTION = #{workCenter})
</if>
<if test="itemNumber != null and itemNumber != ''">
AND (CASE WHEN cf2.VALUE IS NOT NULL THEN cf2.VALUE ELSE zab.ITEM_NUMBER END) = #{itemNumber}
</if>
<if test="workOrder != null and workOrder != ''">
AND (CASE WHEN zab.WORK_ORDER IS NOT NULL THEN zab.WORK_ORDER ELSE cf2.VALUE END) = #{workOrder}
</if>
<if test="operation != null and operation != ''">
AND (zab.OPERATION LIKE '%${operation}%'
OR ot.DESCRIPTION LIKE '%${operation}%')
</if>
<if test="resrce != null and resrce != ''">
AND (r.RESRCE LIKE '%${resrce}%'
OR r.DESCRIPTION LIKE '%${resrce}%')
</if>
<if test="abnormalType != null and abnormalType != ''">
AND zab.TYPE = #{abnormalType}
</if>
<if test="pbUser != null and pbUser != ''">
AND (zab.PB_USER = #{pbUser} OR znu.FULL_NAME = #{pbUser})
</if>
<if test="createdUser != null and createdUser != ''">
AND (zab.CREATED_USER = #{createdUser} OR znu2.FULL_NAME = #{createdUser})
</if>
</where>
GROUP BY wct.DESCRIPTION ,zab.PRODUCT_CATEGORY ,cf.VALUE ,so.SHOP_ORDER ,
i.ITEM ,it.DESCRIPTION,zab.SFC,zab."TYPE" ,zab.ABNORMAL_NO,
zab.OPERATION,ot.DESCRIPTION,r.RESRCE,r.DESCRIPTION,
zab.CREATED_DATE_TIME ,znu.FULL_NAME,znu2.FULL_NAME,
zab.STATUS,zabd.ABNORMAL_METHOD,zabd.RESOLVE_DATE_TIME ,
znu3.FULL_NAME,zabd.CLOSED_DATE_TIME ,znu4.FULL_NAME,
zabd.RESOLVE_REMARK,zabd.ABNORMAL_REASON,zabd.BEFORE_MEASURE,
zsr.CREATED_DATE_TIME,zab.ITEM_NUMBER,
zabd.DUTY_DEPART,ug.DESCRIPTION,cf2.VALUE,zab.WORK_ORDER
ORDER BY zab.CREATED_DATE_TIME DESC
</select>
<select id="shopOrderSchedule" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT ROWNUM SEQ,S.* FROM (
SELECT wct.DESCRIPTION WORK_CENTER_DESCRIPTION,cf.VALUE ITEM_NUMBER,
COALESCE(dflt.DATA_TAG,cf2.VALUE) WORK_ORDER,
zsd.SHOP_ORDER,it.DESCRIPTION ITEM_DESCRIPTION,zsd.PLANNED_START_DATE,zsd.PLANNED_START_DATE PREDICT_COMP_DATE,
zsd.PLANNED_COMP_DATE ,zsd.ACTUAL_START_DATE ,zsd.ACTUAL_COMPLETE_DATE,
CASE WHEN zsd.DISPATCH_STATUS = 'NEW' THEN '新建'
WHEN zsd.DISPATCH_STATUS = 'RELEASE' THEN '发布'
WHEN zsd.DISPATCH_STATUS = 'PAUSE' THEN '暂挂'
WHEN zsd.DISPATCH_STATUS = 'START' ThEN '已开始'
WHEN zsd.DISPATCH_STATUS = 'COMPLETE' THEN '已完成'
WHEN zsd.DISPATCH_STATUS = 'CANCEL' THEN '已取消'
ELSE ''
END DISPATCH_STATUS,
ot.DESCRIPTION CURRENT_OPERATION_DESCRIPTION,
-- CASE WHEN ss.STEP_ID = zsd.STEP_ID AND zsd.DISPATCH_STATUS != 'START' AND o.OPERATION = zsd.OPERATION THEN ''
-- ELSE ot.DESCRIPTION
-- END CURRENT_OPERATION_DESCRIPTION,
ot2.DESCRIPTION OPERATION_DESCRIPTION,
CASE WHEN zab.HANDLE IS NOT NULL THEN '是'
ELSE '否'
END IS_ANOMALY,
CASE WHEN zsd.PLANNED_COMP_DATE IS NOT NULL AND zsd.ACTUAL_COMPLETE_DATE IS NULL AND zsd.DISPATCH_STATUS != 'CANCEL' THEN TO_CHAR(TO_NUMBER(zsd.PLANNED_COMP_DATE + 8/24 - SYSDATE),'FM9999990.000')
ELSE ''
END SURPLUS_DAY,
CASE WHEN zsd.ACTUAL_START_DATE IS NOT NULL AND cf3.VALUE IS NOT NULL AND cf3.VALUE != 0 AND zsd.ACTUAL_COMPLETE_DATE IS NULL
THEN ROUND(TO_NUMBER(SYSDATE - (zsd.ACTUAL_START_DATE+8/24))*24/TO_NUMBER(cf3.VALUE * zsd.DISPATCH_QTY),2)*100 || '%'
WHEN zsd.ACTUAL_START_DATE IS NOT NULL AND cf3.VALUE IS NOT NULL AND cf3.VALUE != 0 AND zsd.ACTUAL_COMPLETE_DATE IS NOT NULL
THEN ROUND(TO_NUMBER((zsd.ACTUAL_COMPLETE_DATE+8/24) - (zsd.ACTUAL_START_DATE+8/24))*24/TO_NUMBER(cf3.VALUE * zsd.DISPATCH_QTY),2)*100 || '%'
ELSE ''
END PROCESS_HOURS
FROM Z_SFC_DISPATCH zsd
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" = 'WORK_ORDER'
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 AND st.IN_USE = 'true'
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'
LEFT JOIN Z_ABNORMAL_BILL zab ON zab.SFC = zsd.SFC AND zab.OPERATION = zsd.OPERATION AND zab.SITE = zsd.SITE
LEFT JOIN ROUTER_STEP rs ON zsd.ROUTER_BO = rs.ROUTER_BO AND rs.STEP_ID = zsd.STEP_ID
LEFT JOIN ROUTER_OPERATION ro ON ro.ROUTER_STEP_BO = rs.HANDLE AND ro.OPERATION_BO = ss.OPERATION_BO
LEFT JOIN CUSTOM_FIELDS cf3 ON cf3.HANDLE = ro.HANDLE AND cf3."ATTRIBUTE" = 'PROD_TIME'
LEFT JOIN DATA_FIELD df ON df.DATA_FIELD = 'WORK_ORDER'
LEFT JOIN DATA_FIELD_LIST dfl ON dfl.DATA_FIELD_BO = df.HANDLE AND dfl.DATA_VALUE = zab.WORK_ORDER
LEFT JOIN DATA_FIELD_LIST_T dflt ON dflt.DATA_FIELD_LIST_BO = dfl.HANDLE AND dflt.LOCALE = #{locale}
<where>
zsd.SITE = #{site}
<if test="workCenter != null and workCenter != ''">
AND (wc.WORK_CENTER = #{workCenter} OR wct.DESCRIPTION = #{workCenter})
</if>
<if test="itemNumber != null and itemNumber != ''">
AND cf.VALUE = #{itemNumber}
</if>
<if test="workOrder != null and workOrder != ''">
AND (dflt.DATA_TAG like '%${workOrder}%' OR
zab.WORK_ORDER like '%${workOrder}%' OR
cf2.VALUE like '%${workOrder}%'
)
</if>
<if test="shopOrder != null and shopOrder != ''">
AND so.SHOP_ORDER LIKE '%${shopOrder}%'
</if>
<if test="startDateTime != null and startDateTime != ''">
AND zsd.PLANNED_COMP_DATE &gt;= TO_DATE(#{startDateTime},'YYYY-MM-DD')-8/24
</if>
<if test="endDateTime != null and endDateTime != ''">
AND zsd.PLANNED_COMP_DATE &lt;= TO_DATE(#{endDateTime}|| '15:59:59','YYYY-MM-DD HH24:MI:SS')
</if>
</where>
ORDER BY zsd.SFC DESC,zsd.STEP_ID) S
</select>
<select id="findOperatorScheduleReport" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT cf.VALUE ITEM_NUMBER,
so.SHOP_ORDER,
i.ITEM,
it.DESCRIPTION ITEM_DESCRIPTION,
zsd.DISPATCH_QTY,
cf2.VALUE WORK_ORDER,
zsd.SFC,
wct.DESCRIPTION WORK_CENTER_DESCRIPTION,
zsd.OPERATION,
ot.DESCRIPTION OPERATION_DESCRIPTION,
zsd.RESRCE,
CASE
WHEN zab.NC_QTY IS NOT NULL THEN zsd.DISPATCH_QTY - TO_NUMBER(zab.NC_QTY)
ELSE zsd.DISPATCH_QTY END QUALIFIED_NUM,
NVL(zsd.PROD_HOURS,0) PROD_HOURS,
NVL(zsd.ACTUAL_PROD_HOURS,0) ACTUAL_PROD_HOURS,
CASE WHEN ZSD.PROD_HOURS IS NULL THEN 0
WHEN zab.NC_QTY IS NOT NULL THEN ROUND((zsd.DISPATCH_QTY - TO_NUMBER(zab.NC_QTY))*ZSD.PROD_HOURS ,4)
ELSE ROUND(zsd.DISPATCH_QTY*ZSD.PROD_HOURS ,4) END TOTAL_PROD_HOURS ,
zsd.EMPLOYEE_DESCRIPTION,
zsd.ACTUAL_START_DATE,
zsd.ACTUAL_COMPLETE_DATE,
zsd.REMARK
FROM Z_SFC_DISPATCH zsd
INNER 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" = 'WORK_ORDER'
INNER JOIN ITEM i ON i.HANDLE = so.ITEM_BO
LEFT JOIN ITEM_T it ON it.ITEM_BO = i.HANDLE AND it.LOCALE = 'zh'
INNER JOIN WORK_CENTER wc ON wc.WORK_CENTER = zsd.WORK_CENTER AND wc.SITE = zsd.SITE
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = 'zh'
INNER JOIN OPERATION o
ON o.OPERATION = zsd.OPERATION AND o.CURRENT_REVISION = 'true' AND o.SITE = zsd.SITE
LEFT JOIN OPERATION_T ot ON ot.OPERATION_BO = o.HANDLE AND ot.LOCALE = 'zh'
LEFT JOIN Z_INSPECTION_TASK zit ON zit.SFC_DISPATCH_BO = zsd.HANDLE
LEFT JOIN Z_ABNORMAL_BILL zab ON zab.OBJECT_BO = zit.HANDLE
<where>
zsd.SITE = #{site}
<if test="workCenter != null and workCenter != ''">
AND (wc.WORK_CENTER = #{workCenter} OR wct.DESCRIPTION = #{workCenter})
</if>
<if test="shopOrder != null and shopOrder != ''">
AND zsd.SHOP_ORDER = #{shopOrder}
</if>
<if test="workOrder != null and workOrder != ''">
AND cf2.VALUE = #{workOrder}
</if>
<if test="itemNumber != null and itemNumber != ''">
AND cf.VALUE = #{itemNumber}
</if>
<if test="operator != null and operator != ''">
AND zsd.EMPLOYEE_DESCRIPTION LIKE '%${operator}%'
</if>
<if test="startDateTime != null and startDateTime != ''">
AND zsd.ACTUAL_START_DATE &gt;= TO_DATE(#{startDateTime},'YYYY-MM-DD')-8/24
</if>
<if test="endDateTime != null and endDateTime != ''">
AND zsd.ACTUAL_START_DATE &lt;= TO_DATE(#{endDateTime}|| '15:59:59','YYYY-MM-DD HH24:MI:SS')
</if>
<if test="completeStartDateTime != null and completeStartDateTime != ''">
AND zsd.ACTUAL_COMPLETE_DATE &gt;= TO_DATE(#{completeStartDateTime},'YYYY-MM-DD')-8/24
</if>
<if test="completeEndDateTime != null and completeEndDateTime != ''">
AND zsd.ACTUAL_COMPLETE_DATE &lt;= TO_DATE(#{completeEndDateTime}|| '15:59:59','YYYY-MM-DD HH24:MI:SS')
</if>
</where>
</select>
<select id="findWorkOrderSchedule" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT DISTINCT *
FROM (
SELECT zsd.WORK_ORDER,
zsd.ITEM_NUMBER,
zsd.DISPATCH_QTY,
TO_CHAR(TO_NUMBER(zsd.HOURS_PERCENT), 'FM9999990.00') || '%' HOURS_PERCENT,
TO_CHAR(TO_NUMBER(zsd.OPERATION_PERCENT), 'FM9999990.00') || '%' OPERATION_PERCENT,
zsd.CREATED_DATE_TIME,
zsd.WORK_CENTER,
wct.DESCRIPTION WORK_CENTER_DESCRIPTION,
zsd.SUM_HOURS,
CASE WHEN zsd2.QTY > 0 THEN '未完成' ELSE '完成' END IS_COMPLETE,
zsd.SITE
FROM (
SELECT WORK_ORDER,
ITEM_NUMBER,
MIN(CREATED_DATE_TIME) CREATED_DATE_TIME,
SUM(DISPATCH_QTY) DISPATCH_QTY,
WORK_CENTER,
SITE,
SUM(COMP_HOURS) SUM_HOURS,
CASE
WHEN SUM(COMP_HOURS) != 0 THEN (SUM(COMP_HOURS) / SUM(HOURS) * 100)
ELSE 0 END HOURS_PERCENT,
CASE
WHEN SUM(COMP_OPERATION) != 0
THEN (SUM(COMP_OPERATION) / SUM(OPERATION_NUM) * 100)
ELSE 0 END OPERATION_PERCENT
FROM (
SELECT cf2.VALUE WORK_ORDER,
cf.VALUE ITEM_NUMBER,
zsd.CREATED_DATE_TIME,
zsd.SITE,
zsd.DISPATCH_QTY,
zsd.PROD_HOURS * zsd.DISPATCH_QTY HOURS,
zsd.WORK_CENTER WORK_CENTER,
CASE
WHEN zsd.DISPATCH_STATUS = 'COMPLETE' OR zsd.DISPATCH_STATUS = 'CANCEL'
THEN zsd.PROD_HOURS * zsd.DISPATCH_QTY
ELSE 0 END COMP_HOURS,
CASE
WHEN zsd.DISPATCH_STATUS = 'COMPLETE' OR zsd.DISPATCH_STATUS = 'CANCEL'
THEN 1
ELSE 0 END COMP_OPERATION,
ROW_NUMBER() OVER (PARTITION BY zsd.HANDLE ORDER BY zsd.HANDLE) OPERATION_NUM
FROM Z_SFC_DISPATCH zsd
INNER 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" = 'WORK_ORDER'
WHERE zsd.SITE = #{site}
<if test="workOrder != null and workOrder != ''">
AND cf2.VALUE = #{workOrder}
</if>
<if test="itemNumber != null and itemNumber != ''">
AND cf.VALUE = #{itemNumber}
</if>
)
GROUP BY SITE,WORK_ORDER, ITEM_NUMBER,WORK_CENTER
) zsd
LEFT JOIN (
SELECT cf2.VALUE WORK_ORDER, cf.VALUE ITEM_NUMBER, COUNT(zsd.HANDLE) QTY,zsd.WORK_CENTER
FROM Z_SFC_DISPATCH zsd
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" = 'WORK_ORDER'
WHERE zsd.DISPATCH_STATUS != 'COMPLETE' AND zsd.DISPATCH_STATUS != 'CANCEL' AND zsd.SITE= #{site}
<if test="workOrder != null and workOrder != ''">
AND cf2.VALUE = #{workOrder}
</if>
<if test="itemNumber != null and itemNumber != ''">
AND cf.VALUE = #{itemNumber}
</if>
GROUP BY cf2.VALUE, cf.VALUE,zsd.WORK_CENTER
) zsd2 ON zsd2.WORK_CENTER = zsd.WORK_CENTER AND zsd2.WORK_ORDER || zsd2.ITEM_NUMBER = zsd.WORK_ORDER || zsd.ITEM_NUMBER
LEFT JOIN (
SELECT cf2.VALUE WORK_ORDER, cf.VALUE ITEM_NUMBER, COUNT(zsd.HANDLE) QTY,zsd.WORK_CENTER
FROM Z_SFC_DISPATCH zsd
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" = 'WORK_ORDER'
WHERE zsd.SITE = #{site}
<if test="workOrder != null and workOrder != ''">
AND cf2.VALUE = #{workOrder}
</if>
<if test="itemNumber != null and itemNumber != ''">
AND cf.VALUE = #{itemNumber}
</if>
GROUP BY cf2.VALUE, cf.VALUE,zsd.WORK_CENTER
) zsd3 ON zsd3.WORK_CENTER = zsd.WORK_CENTER AND zsd3.WORK_ORDER || zsd3.ITEM_NUMBER = zsd.WORK_ORDER || zsd.ITEM_NUMBER
INNER JOIN WORK_CENTER wc ON wc.WORK_CENTER = zsd.WORK_CENTER AND wc.SITE = zsd.SITE
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = 'zh'
WHERE (zsd.WORK_ORDER IS NOT NULL OR zsd.ITEM_NUMBER IS NOT NULL)
)
<where>
1 = 1
<if test="workCenter != null and workCenter != ''">
AND (WORK_CENTER = #{workCenter} OR WORK_CENTER_DESCRIPTION = #{workCenter})
</if>
<if test="isCompleted != null and isCompleted != ''">
AND IS_COMPLETE = #{isCompleted}
</if>
<if test="startDateTime != null and startDateTime != ''">
AND CREATED_DATE_TIME &gt;= TO_DATE(#{startDateTime},'YYYY-MM-DD')-8/24
</if>
<if test="endDateTime != null and endDateTime != ''">
AND CREATED_DATE_TIME &lt;= TO_DATE(#{endDateTime}|| '15:59:59','YYYY-MM-DD HH24:MI:SS')
</if>
</where>
ORDER BY CREATED_DATE_TIME ASC
</select>
</mapper>