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.

720 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.common.mapper.ReportDataMapper">
<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, ROWNUM SEQ,
CASE WHEN ZT."RESULT" = 'OK' THEN N'合格' WHEN ZT."RESULT" = 'NG' THEN N'不合格' ELSE N'--' END RESULT_DESC,
CASE WHEN ZT.CATEGORY = 'S' THEN N'首检' WHEN ZT.CATEGORY = 'Z' THEN N'自检'
WHEN ZT.CATEGORY = 'H' THEN N'互检' WHEN ZT.CATEGORY = 'P' THEN N'专检' ELSE N'--' END CATEGORY_DESC,
CASE WHEN ZT."RESULT" = 'NG' THEN TO_CHAR(zab.NC_QTY) ELSE '' END NG_QTY,
zsd.DISPATCH_QTY ,zsd.EMPLOYEE_DESCRIPTION
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.USER_NAME = ZT.MODIFY_USER
INNER JOIN Z_SFC_DISPATCH zsd ON zsd.HANDLE = ZT.SFC_DISPATCH_BO
LEFT JOIN Z_ABNORMAL_BILL zab ON zab.OBJECT_BO = ZT.HANDLE
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="shopOrder != null and shopOrder != ''">
AND SO.SHOP_ORDER = #{shopOrder}
</if>
<if test="model != null and model != ''" >
AND C3.VALUE LIKE '%'||#{model}||'%'
</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}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
</select>
<!--设备负荷率报表-->
<select id="findResourceLoadRateInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap" >
WITH
TEMP AS (
SELECT ZSD.PLANNED_COMP_DATE ,ZSD.PLANNED_START_DATE ,ZSD.RESRCE ,ZSD.PROD_HOURS , ZSD.DISPATCH_QTY
FROM Z_SFC_DISPATCH ZSD WHERE ZSD.SITE = #{site} AND ZSD.DISPATCH_STATUS IN ('START','NEW','RELEASE') ),
Z_REPORT_DATE_TIME AS (SELECT '1000' SITE ,TO_CHAR(TO_DATE(#{startFromDate},'YYYY-MM-DD') + ROWNUM -1, 'YYYY-MM-DD') DATE_TIME,
TO_DATE(#{startFromDate} || '00:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 AM_START_DATE_TIME,
TO_DATE(#{startFromDate} || '04:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 AM_END_DATE_TIME,
TO_DATE(#{startFromDate} || '05:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 PM_START_DATE_TIME ,
TO_DATE(#{startFromDate} || '09:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 PM_END_DATE_TIME
FROM dual CONNECT BY rownum &lt;= to_date( #{startToDate}, 'yyyy-mm-dd') - to_date( #{startFromDate}, 'yyyy-mm-dd') + 1 ) ,
RDT AS ( SELECT R.SITE,R.RESRCE , R.DESCRIPTION RESOURCE_DESCRIPTION, DATE_TIME, DECODE(CF.VALUE,NULL,0,CF.VALUE) CAPACITY_MAN_HOUR , WCA.WORK_CENTER CENTER ,
WCTA.DESCRIPTION CENTER_DESCRIPTION , WCB.WORK_CENTER , WCTB.DESCRIPTION WORK_CENTER_DESCRIPTION ,RT.RESOURCE_TYPE ,RT.DESCRIPTION RESOURCE_TYPE_DESCRIPTION
FROM RESRCE R
LEFT JOIN WORK_CENTER_MEMBER WCMA ON WCMA.WORK_CENTER_OR_RESOURCE_GBO = R.HANDLE
LEFT JOIN WORK_CENTER WCA ON WCA.HANDLE = WCMA.WORK_CENTER_BO
INNER JOIN WORK_CENTER_T WCTA ON WCTA.WORK_CENTER_BO = WCA.HANDLE AND WCTA.LOCALE = 'zh'
LEFT JOIN WORK_CENTER_MEMBER WCMB ON WCMB.WORK_CENTER_OR_RESOURCE_GBO = WCMA.WORK_CENTER_BO
LEFT JOIN WORK_CENTER WCB ON WCB.HANDLE = WCMB.WORK_CENTER_BO
INNER JOIN WORK_CENTER_T WCTB ON WCTB.WORK_CENTER_BO = WCB.HANDLE AND WCTB.LOCALE = 'zh'
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = R.HANDLE AND CF."ATTRIBUTE" = 'CAPACITY_MAN_HOUR'
LEFT JOIN Z_REPORT_DATE_TIME ZRDT ON ZRDT.SITE = R.SITE
LEFT JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = R.HANDLE
LEFT JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
LEFT JOIN STATUS STU ON R.STATUS_BO=STU.HANDLE
WHERE R.SITE = #{site} AND STU.STATUS='301'
<if test="center != null and center != ''" >
AND WCA.WORK_CENTER = #{center}
</if>
<if test="workCenter != null and workCenter != ''" >
AND WCB.WORK_CENTER = #{workCenter}
</if>
<if test="resrce != null and resrce != ''" >
AND R.RESRCE = #{resrce}
</if>
<if test="resourceType != null and resourceType != ''" >
AND RT.RESOURCE_TYPE = #{resourceType}
</if> )
SELECT T.*,T.RATE_DATA_INT || '%' RATE_DATA FROM
(
SELECT RDT.* , ROUND((SUM( (DECODE(A.CNT,NULL,0,A.CNT) + DECODE(B.CNT,NULL,0,B.CNT) + DECODE(C.CNT,NULL,0,C.CNT) + DECODE(D.CNT,NULL,0,D.CNT)
+ DECODE(E.CNT,NULL,0,E.CNT) + DECODE(F.CNT,NULL,0,F.CNT) + DECODE(G.CNT,NULL,0,G.CNT) + DECODE(H.CNT,NULL,0,H.CNT)
+ DECODE(I.CNT,NULL,0,I.CNT) + DECODE(J.CNT,NULL,0,J.CNT) ) + DECODE(K.CNT,NULL,0,K.CNT) + DECODE(L.CNT,NULL,0,L.CNT) ) * RDT.CAPACITY_MAN_HOUR / 8),4) PLAN_HOUR_OLD
,SUM( (DECODE(A.CNT,NULL,0,A.CNT) + DECODE(B.CNT,NULL,0,B.CNT) + DECODE(C.CNT,NULL,0,C.CNT) + DECODE(D.CNT,NULL,0,D.CNT)
+ DECODE(E.CNT,NULL,0,E.CNT) + DECODE(F.CNT,NULL,0,F.CNT) + DECODE(G.CNT,NULL,0,G.CNT) + DECODE(H.CNT,NULL,0,H.CNT)
+ DECODE(I.CNT,NULL,0,I.CNT) + DECODE(J.CNT,NULL,0,J.CNT) ) + DECODE(K.CNT,NULL,0,K.CNT) + DECODE(L.CNT,NULL,0,L.CNT) ) PLAN_HOUR
,CASE WHEN RDT.CAPACITY_MAN_HOUR = 0 THEN 0
ELSE ROUND(SUM( ( DECODE(A.CNT,NULL,0,A.CNT) + DECODE(B.CNT,NULL,0,B.CNT) + DECODE(C.CNT,NULL,0,C.CNT) + DECODE(D.CNT,NULL,0,D.CNT)
+ DECODE(E.CNT,NULL,0,E.CNT) + DECODE(F.CNT,NULL,0,F.CNT) + DECODE(G.CNT,NULL,0,G.CNT) + DECODE(H.CNT,NULL,0,H.CNT)
+ DECODE(I.CNT,NULL,0,I.CNT) + DECODE(J.CNT,NULL,0,J.CNT) + DECODE(K.CNT,NULL,0,K.CNT) + DECODE(L.CNT,NULL,0,L.CNT)
) ) / 8 , 4) * 100
END RATE_DATA_INT_OLD
,CASE WHEN RDT.CAPACITY_MAN_HOUR = 0 THEN 0
ELSE ROUND(SUM( ( DECODE(A.CNT,NULL,0,A.CNT) + DECODE(B.CNT,NULL,0,B.CNT) + DECODE(C.CNT,NULL,0,C.CNT) + DECODE(D.CNT,NULL,0,D.CNT)
+ DECODE(E.CNT,NULL,0,E.CNT) + DECODE(F.CNT,NULL,0,F.CNT) + DECODE(G.CNT,NULL,0,G.CNT) + DECODE(H.CNT,NULL,0,H.CNT)
+ DECODE(I.CNT,NULL,0,I.CNT) + DECODE(J.CNT,NULL,0,J.CNT) + DECODE(K.CNT,NULL,0,K.CNT) + DECODE(L.CNT,NULL,0,L.CNT)
) ) / CAPACITY_MAN_HOUR , 4) * 100
END RATE_DATA_INT
FROM
RDT
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) A ON A.DATE_TIME = RDT.DATE_TIME AND A.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &lt;= AM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) B ON B.DATE_TIME = RDT.DATE_TIME AND B.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_START_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) C ON C.DATE_TIME = RDT.DATE_TIME AND C.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) D ON D.DATE_TIME = RDT.DATE_TIME AND D.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_COMP_DATE &lt;= AM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) E ON E.DATE_TIME = RDT.DATE_TIME AND E.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_START_DATE &lt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &lt;= PM_START_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) F ON F.DATE_TIME = RDT.DATE_TIME AND F.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_START_DATE &lt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) G ON G.DATE_TIME = RDT.DATE_TIME AND G.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_START_DATE &lt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) H ON H.DATE_TIME = RDT.DATE_TIME AND H.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_END_DATE_TIME AND PLANNED_START_DATE &lt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) I ON I.DATE_TIME = RDT.DATE_TIME AND I.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_END_DATE_TIME AND PLANNED_START_DATE &lt; PM_START_DATE_TIME AND PLANNED_COMP_DATE &gt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) J ON J.DATE_TIME = RDT.DATE_TIME AND J.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) K ON K.DATE_TIME = RDT.DATE_TIME AND K.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; PM_START_DATE_TIME AND PLANNED_START_DATE &lt; PM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) L ON L.DATE_TIME = RDT.DATE_TIME AND L.RESRCE = RDT.RESRCE
GROUP BY RDT.SITE,RDT.RESRCE, RDT.RESOURCE_DESCRIPTION, RDT.DATE_TIME ,RDT.CAPACITY_MAN_HOUR , RDT.CENTER ,RDT.CENTER_DESCRIPTION ,RDT.WORK_CENTER ,RDT.WORK_CENTER_DESCRIPTION ,RDT.RESOURCE_TYPE ,RDT.RESOURCE_TYPE_DESCRIPTION
ORDER BY RDT.WORK_CENTER ,RDT.RESRCE, RDT.DATE_TIME ) T
WHERE T.SITE = #{site}
<if test="startRate != null and startRate != ''">
AND T.RATE_DATA_INT &gt;= #{startRate}
</if>
<if test="endRate != null and endRate != ''">
AND T.RATE_DATA_INT &lt;= #{endRate}
</if>
</select>
<!--设备类型负荷率报表-->
<select id="findResourceTypeLoadRateInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap" >
WITH TEMP AS (
SELECT ZSD.PLANNED_COMP_DATE ,ZSD.PLANNED_START_DATE ,ZSD.RESRCE ,ZSD.PROD_HOURS , ZSD.DISPATCH_QTY
FROM Z_SFC_DISPATCH ZSD WHERE ZSD.SITE = #{site} AND ZSD.DISPATCH_STATUS IN ('START','NEW','RELEASE')
AND ZSD.PLANNED_COMP_DATE IS NOT NULL AND ZSD.PLANNED_START_DATE IS NOT NULL
),
Z_REPORT_DATE_TIME AS (SELECT '1000' SITE ,TO_CHAR(TO_DATE(#{startFromDate},'YYYY-MM-DD') + ROWNUM -1, 'YYYY-MM-DD') DATE_TIME,
TO_DATE(#{startFromDate} || '00:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 AM_START_DATE_TIME,
TO_DATE(#{startFromDate} || '04:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 AM_END_DATE_TIME,
TO_DATE(#{startFromDate} || '05:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 PM_START_DATE_TIME ,
TO_DATE(#{startFromDate} || '09:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 PM_END_DATE_TIME
FROM dual CONNECT BY rownum &lt;= to_date( #{startToDate}, 'yyyy-mm-dd') - to_date( #{startFromDate}, 'yyyy-mm-dd') + 1) ,
RDT AS ( SELECT R.SITE,R.RESRCE , R.DESCRIPTION RESOURCE_DESCRIPTION, DATE_TIME, DECODE(CF.VALUE,NULL,0,CF.VALUE) CAPACITY_MAN_HOUR ,
WCB.WORK_CENTER , WCTB.DESCRIPTION WORK_CENTER_DESCRIPTION ,RT.RESOURCE_TYPE ,RT.DESCRIPTION RESOURCE_TYPE_DESCRIPTION
FROM RESRCE R
LEFT JOIN WORK_CENTER_MEMBER WCMA ON WCMA.WORK_CENTER_OR_RESOURCE_GBO = R.HANDLE
LEFT JOIN WORK_CENTER WCA ON WCA.HANDLE = WCMA.WORK_CENTER_BO
INNER JOIN WORK_CENTER_T WCTA ON WCTA.WORK_CENTER_BO = WCA.HANDLE AND WCTA.LOCALE = 'zh'
LEFT JOIN WORK_CENTER_MEMBER WCMB ON WCMB.WORK_CENTER_OR_RESOURCE_GBO = WCMA.WORK_CENTER_BO
LEFT JOIN WORK_CENTER WCB ON WCB.HANDLE = WCMB.WORK_CENTER_BO
INNER JOIN WORK_CENTER_T WCTB ON WCTB.WORK_CENTER_BO = WCB.HANDLE AND WCTB.LOCALE = 'zh'
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = R.HANDLE AND CF."ATTRIBUTE" = 'CAPACITY_MAN_HOUR'
LEFT JOIN Z_REPORT_DATE_TIME ZRDT ON ZRDT.SITE = R.SITE
LEFT JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = R.HANDLE
LEFT JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
LEFT JOIN STATUS STU ON R.STATUS_BO=STU.HANDLE
WHERE R.SITE = #{site} AND STU.STATUS='301'
<if test="workCenter != null and workCenter != ''" >
AND WCB.WORK_CENTER = #{workCenter}
</if>
<if test="resourceType != null and resourceType != ''" >
AND RT.RESOURCE_TYPE = #{resourceType}
</if>)
<if test="reportType != null and reportType.contains('true')">
SELECT TD.RESOURCE_TYPE ,TD.RESOURCE_TYPE_DESCRIPTION ,TD.WORK_CENTER, TD.WORK_CENTER_DESCRIPTION,
SUM(TD.PLAN_HOUR) PLAN_HOUR, SUM(TD.CAPACITY_MAN_HOUR) CAPACITY_MAN_HOUR,
CASE WHEN SUM(TD.CAPACITY_MAN_HOUR) = 0 THEN 0 || '%'
ELSE ROUND(SUM(TD.PLAN_HOUR)/SUM(TD.CAPACITY_MAN_HOUR),4)*100 || '%' END RATE_DATA
FROM (
</if>
SELECT M.*,M.RATE_DATA_INT || '%' RATE_DATA FROM (
SELECT T.SITE,T.RESOURCE_TYPE, T.RESOURCE_TYPE_DESCRIPTION, T.WORK_CENTER, T.WORK_CENTER_DESCRIPTION,T.DATE_TIME,
SUM(T.PLAN_HOUR) PLAN_HOUR, SUM(T.CAPACITY_MAN_HOUR) CAPACITY_MAN_HOUR,
CASE WHEN SUM(T.PLAN_HOUR) = 0 OR SUM(T.CAPACITY_MAN_HOUR) = 0 THEN 0 ELSE ROUND(SUM(T.PLAN_HOUR)/SUM(T.CAPACITY_MAN_HOUR),4)*100 END RATE_DATA_INT
FROM
(
SELECT RDT.* , SUM( (DECODE(A.CNT,NULL,0,A.CNT) + DECODE(B.CNT,NULL,0,B.CNT) + DECODE(C.CNT,NULL,0,C.CNT) + DECODE(D.CNT,NULL,0,D.CNT)
+ DECODE(E.CNT,NULL,0,E.CNT) + DECODE(F.CNT,NULL,0,F.CNT) + DECODE(G.CNT,NULL,0,G.CNT) + DECODE(H.CNT,NULL,0,H.CNT)
+ DECODE(I.CNT,NULL,0,I.CNT) + DECODE(J.CNT,NULL,0,J.CNT) ) + DECODE(K.CNT,NULL,0,K.CNT) + DECODE(L.CNT,NULL,0,L.CNT) ) PLAN_HOUR
FROM
RDT
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) A ON A.DATE_TIME = RDT.DATE_TIME AND A.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &lt;= AM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) B ON B.DATE_TIME = RDT.DATE_TIME AND B.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_START_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) C ON C.DATE_TIME = RDT.DATE_TIME AND C.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt;= AM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) D ON D.DATE_TIME = RDT.DATE_TIME AND D.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_COMP_DATE &lt;= AM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) E ON E.DATE_TIME = RDT.DATE_TIME AND E.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_START_DATE &lt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &lt;= PM_START_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) F ON F.DATE_TIME = RDT.DATE_TIME AND F.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_START_DATE &lt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) G ON G.DATE_TIME = RDT.DATE_TIME AND G.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_START_DATE_TIME AND PLANNED_START_DATE &lt;= AM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) H ON H.DATE_TIME = RDT.DATE_TIME AND H.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_END_DATE_TIME AND PLANNED_START_DATE &lt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) I ON I.DATE_TIME = RDT.DATE_TIME AND I.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; AM_END_DATE_TIME AND PLANNED_START_DATE &lt; PM_START_DATE_TIME AND PLANNED_COMP_DATE &gt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) J ON J.DATE_TIME = RDT.DATE_TIME AND J.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; PM_START_DATE_TIME AND PLANNED_COMP_DATE &lt; PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) K ON K.DATE_TIME = RDT.DATE_TIME AND K.RESRCE = RDT.RESRCE
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , SUM(PROD_HOURS*DISPATCH_QTY ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; PM_START_DATE_TIME AND PLANNED_START_DATE &lt; PM_END_DATE_TIME AND PLANNED_COMP_DATE &gt;= PM_END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) L ON L.DATE_TIME = RDT.DATE_TIME AND L.RESRCE = RDT.RESRCE
GROUP BY RDT.SITE,RDT.RESRCE, RDT.RESOURCE_DESCRIPTION, RDT.DATE_TIME ,RDT.CAPACITY_MAN_HOUR , RDT.WORK_CENTER ,RDT.WORK_CENTER_DESCRIPTION ,RDT.RESOURCE_TYPE ,RDT.RESOURCE_TYPE_DESCRIPTION
) T
GROUP BY T.RESOURCE_TYPE, T.RESOURCE_TYPE_DESCRIPTION, T.WORK_CENTER, T.WORK_CENTER_DESCRIPTION,T.SITE,T.DATE_TIME ) M
WHERE M.SITE = #{site}
<if test="startRate != null and startRate != ''">
AND M.RATE_DATA_INT &gt;= #{startRate}
</if>
<if test="endRate != null and endRate != ''">
AND M.RATE_DATA_INT &lt;= #{endRate}
</if>
ORDER BY M.WORK_CENTER_DESCRIPTION,M.RESOURCE_TYPE_DESCRIPTION,M.DATE_TIME
<if test="reportType != null and reportType.contains('true')">
) TD
GROUP BY TD.RESOURCE_TYPE ,TD.RESOURCE_TYPE_DESCRIPTION ,TD.WORK_CENTER, TD.WORK_CENTER_DESCRIPTION
ORDER BY TD.WORK_CENTER_DESCRIPTION ,TD.RESOURCE_TYPE_DESCRIPTION
</if>
</select>
<!--设备维修数据统计报表-->
<select id="findResourceRepairDataStatInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap" >
WITH RUN_NUM AS (
SELECT sum(zrrt.RUN_TIME) RUN_TIME , NVL( TO_DATE(SUBSTR(ZRRT.SEND_DATE,0,7) ,'YYYY-MM') ,MAX(UP_TIME)) UP_TIME , ZRRT.RESRCE , SUBSTR(ZRRT.SEND_DATE,0,7) SEND_DATE
FROM Z_RESOURCE_RUN_TIME zrrt
WHERE ZRRT.SITE = #{site} AND TO_DATE(ZRRT.SEND_DATE ,'YYYY-MM-DD') &gt; TO_DATE(SUBSTR(#{startFromDate},0,7) ,'YYYY-MM')
AND TO_DATE(ZRRT.SEND_DATE,'YYYY-MM-DD') &lt; TO_DATE(SUBSTR(#{startToDate},0,7) ,'YYYY-MM')
GROUP BY ZRRT.RESRCE , SUBSTR(ZRRT.SEND_DATE,0,7)
) ,
REPAIR_INFO AS (
SELECT T.RESRCE, T.MON_DATE , SUM(REPAIR_TIME) - SUM(WAIT_TIME) REPAIR_STOP_TIME , SUM(REPAIR_TIME) REPAIR_TIME FROM
(SELECT ZRRT.RESOURCE_NO RESRCE , TO_CHAR(ZRRT.CREATED_DATE_TIME + 8/24 ,'YYYY-MM' ) MON_DATE ,
ROUND(NVL(0,ZRRT.WAIT_TIME)*24*60*60,0) WAIT_TIME,
CASE WHEN ZRRT.ACTUAL_COMPLETE_DATE IS NOT NULL THEN ROUND((ZRRT.ACTUAL_COMPLETE_DATE - ZRRT.ACTUAL_START_DATE)*24*60*60,0)
ELSE ROUND((SYSDATE - ZRRT.ACTUAL_START_DATE)*24*60*60,0) END REPAIR_TIME
FROM Z_RESOURCE_REPAIR_TASK zrrt
WHERE ZRRT.STATUS != '401' AND (ZRRT.CREATED_DATE_TIME + 8/24) &gt; TO_DATE(SUBSTR(#{startFromDate},0,7) ,'YYYY-MM')
AND (ZRRT.CREATED_DATE_TIME + 8/24) &lt; TO_DATE(SUBSTR(#{startToDate},0,7) ,'YYYY-MM') ) T
GROUP BY T.RESRCE ,T.MON_DATE
) ,
MN AS (
SELECT WC.WORK_CENTER, WCT.DESCRIPTION WORK_CENTER_DESCRIPTION , R.RESRCE , R.DESCRIPTION , TP.MON_DATE
FROM RESRCE r
LEFT JOIN (SELECT '1000' SITE ,TO_CHAR(add_months(TO_DATE(SUBSTR(#{startFromDate},0,7) ,'YYYY-MM') , ROWNUM -1), 'YYYY-MM') MON_DATE
FROM dual CONNECT BY rownum &lt;= months_between(TO_DATE(SUBSTR(#{startToDate},0,7) ,'YYYY-MM') , TO_DATE(SUBSTR(#{startFromDate},0,7) ,'YYYY-MM') + 1)) TP ON TP.SITE = R.SITE
LEFT JOIN WORK_CENTER_MEMBER wcm ON WCM.WORK_CENTER_OR_RESOURCE_GBO = R.HANDLE
LEFT JOIN WORK_CENTER_MEMBER wcm2 ON WCM2.WORK_CENTER_OR_RESOURCE_GBO = WCM.WORK_CENTER_BO
LEFT JOIN WORK_CENTER_T wct ON WCT.WORK_CENTER_BO = WCM2.WORK_CENTER_BO
LEFT JOIN WORK_CENTER WC ON WC.HANDLE = WCM2.WORK_CENTER_BO
WHERE R.SITE = #{site}
<if test="workCenter != null and workCenter != ''" >
AND WC.WORK_CENTER = #{workCenter}
</if>
<if test="resrce != null and resrce != ''" >
AND R.RESRCE = #{resrce}
</if>
)
SELECT MN.WORK_CENTER_DESCRIPTION , MN.RESRCE , MN.DESCRIPTION RESOURCE_DESCRIPTION, RN.UP_TIME UP_DATE, NVL(0,RN.RUN_TIME) RUN_TIME,
NVL(0,RI.REPAIR_STOP_TIME) REPAIR_STOP_TIME, NVL(0,RI.REPAIR_TIME) REPAIR_TIME,
CASE WHEN RI.REPAIR_STOP_TIME IS NOT NULL AND RN.RUN_TIME &gt; 0 THEN ROUND(RI.REPAIR_STOP_TIME/RN.RUN_TIME,2) * 100 || '%'
ELSE 0 || '%' END RATE , MN.MON_DATE
FROM MN
LEFT JOIN REPAIR_INFO RI ON RI.RESRCE = MN.RESRCE AND RI.MON_DATE = MN.MON_DATE
LEFT JOIN RUN_NUM RN ON RN.RESRCE = MN.RESRCE AND RN.SEND_DATE = MN.MON_DATE
ORDER BY MN.MON_DATE, MN.RESRCE
</select>
<!--每日生产状态报表-->
<select id="findProductStateInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap" >
SELECT CFB.VALUE ITEM_NUMBER , ZSD.SHOP_ORDER , I.ITEM , IT.DESCRIPTION ITEM_DESCRIPTION , S.QTY PLAN_QTY ,CFA.VALUE WORK_ORDER ,
ZSD.SFC , ZSD.WORK_CENTER , WCT.DESCRIPTION WORK_CENTER_DESCRIPTION , RU.ROUTER_TYPE , ZSD.STEP_ID , ZSD.OPERATION ,CF.VALUE CHECK_USR,
OT.DESCRIPTION OPERATION_DESCRIPTION, ZSD.RESRCE , R.DESCRIPTION RESOURCE_DESCRIPTION , ZSD.DISPATCH_STATUS OPERATION_STATUS ,
ZSD.PROD_HOURS ,ZSD.ACTUAL_PROD_HOURS , ZSD.PLANNED_START_DATE , ZSD.PLANNED_COMP_DATE , ZSD.ACTUAL_START_DATE , ZSD.ACTUAL_COMPLETE_DATE
FROM Z_SFC_DISPATCH ZSD
LEFT JOIN SHOP_ORDER SO ON SO.SHOP_ORDER = ZSD.SHOP_ORDER
LEFT JOIN CUSTOM_FIELDS CFA ON CFA.HANDLE = SO.HANDLE AND CFA."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN CUSTOM_FIELDS CFB ON CFB.HANDLE = SO.HANDLE AND CFB."ATTRIBUTE" = 'ITEM_NUMBER'
LEFT JOIN SFC S ON S.SFC = ZSD.SFC
LEFT JOIN ITEM I ON I.HANDLE = S.ITEM_BO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = S.ITEM_BO
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
LEFT JOIN OPERATION O ON O.OPERATION = ZSD.OPERATION
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = O.HANDLE
LEFT JOIN RESRCE R ON R.RESRCE = ZSD.RESRCE
LEFT JOIN ROUTER RU ON RU.HANDLE = ZSD.ROUTER_BO
LEFT JOIN RESRCE R ON R.RESRCE = ZSD.RESRCE AND R.SITE = ZSD.SITE
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = R.HANDLE AND CF."ATTRIBUTE" = 'CHECK_USR'
WHERE ZSD.SITE = #{site}
<if test="itemNumber != null and itemNumber != ''" >
AND CFB.VALUE LIKE '%'||#{itemNumber}||'%'
</if>
<if test="workOrder != null and workOrder != ''" >
AND CFA.VALUE LIKE '%'||#{workOrder}||'%'
</if>
<if test="shopOrder != null and shopOrder != ''" >
AND ZSD.SHOP_ORDER = #{shopOrder}
</if>
<if test="workCenter != null and workCenter != ''" >
AND ZSD.WORK_CENTER = #{workCenter}
</if>
<if test="resrce != null and resrce != ''" >
AND ZSD.RESRCE = #{resrce}
</if>
<if test="checkUsr != null and checkUsr != ''" >
AND CF.VALUE = #{checkUsr}
</if>
<if test="operation != null and operation != ''" >
AND ZSD.OPERATION = #{operation}
</if>
<if test="item != null and item != ''" >
AND I.ITEM = #{item}
</if>
<if test="sfc != null and sfc != ''" >
AND ZSD.SFC = #{sfc}
</if>
<if test="routerType != null and routerType != ''" >
<choose>
<when test="routerType != 'OTHER'.toString()">
AND RU.ROUTER_TYPE = #{routerType}
</when>
<otherwise>
AND RU.ROUTER_TYPE != 'C'
</otherwise>
</choose>
</if>
<if test="operationStatus != null and operationStatus != ''" >
<choose>
<when test="operationStatus != 'OTHER'.toString()">
AND ZSD.DISPATCH_STATUS = #{operationStatus}
</when>
<otherwise>
AND ZSD.DISPATCH_STATUS != 'START' AND ZSD.DISPATCH_STATUS != 'COMPLETE' AND ZSD.DISPATCH_STATUS != 'CANCEL'
</otherwise>
</choose>
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND ZSD.PLANNED_START_DATE >= TO_DATE(#{startFromDate}, 'YYYY-MM-DD') - 8/24
</if>
<if test="startToDate != null and startToDate != ''" >
AND ZSD.PLANNED_COMP_DATE &lt;= TO_DATE(#{startToDate}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="actualStartFromDate != null and actualStartFromDate != ''" >
AND ZSD.ACTUAL_START_DATE >= TO_DATE(#{actualStartFromDate}, 'YYYY-MM-DD') - 8/24
</if>
<if test="actualStartToDate != null and actualStartToDate != ''" >
AND ZSD.ACTUAL_COMPLETE_DATE &lt;= TO_DATE(#{actualStartToDate}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
ORDER BY CFA.VALUE, ZSD.SHOP_ORDER,ZSD.STEP_ID
</select>
<!--清空日期表-->
<delete id="deleteAllReportDateTime">
DELETE FROM Z_REPORT_DATE_TIME
</delete>
<!--插入日期数据-->
<insert id="insertReportDateTime" >
INSERT INTO Z_REPORT_DATE_TIME (SITE,DATE_TIME,START_DATE_TIME,END_DATE_TIME)
<foreach collection="list" item="reportDateTime" index="index" open="(" separator=" union all " close=")" >
SELECT #{reportDateTime.site, jdbcType=NVARCHAR},
#{reportDateTime.dateTime, jdbcType=NVARCHAR},
#{reportDateTime.startDateTime, jdbcType=DATE},
#{reportDateTime.endDateTime, jdbcType=DATE}
FROM DUAL
</foreach>
</insert>
<!--创建数据日期表-->
<insert id="insertReportDateTimeByStartToDate" >
INSERT INTO Z_REPORT_DATE_TIME
SELECT '1000' SITE ,TO_CHAR(TO_DATE(#{startFromDate},'YYYY-MM-DD') + ROWNUM -1, 'YYYY-MM-DD') DATE_TIME,
TO_DATE(#{startFromDate} || '00:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 AM_START_DATE_TIME,
TO_DATE(#{startFromDate} || '04:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 AM_END_DATE_TIME,
TO_DATE(#{startFromDate} || '05:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 PM_START_DATE_TIME ,
TO_DATE(#{startFromDate} || '09:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 PM_END_DATE_TIME
FROM dual CONNECT BY rownum &lt;= to_date( #{startToDate}, 'yyyy-mm-dd') - to_date( #{startFromDate}, 'yyyy-mm-dd') + 1
</insert>
<select id="findInspectionTaskDetail" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT ROWNUM SEQ, A.SITE, A.TASK_NO, A.DESCRIPTION, A.RESULT CHECK_RESULT, A.CREATE_USER CHECK_USER, A.CREATED_DATE_TIME CHECK_DATE, C.INSPECTION_ITEM_NO, C.DESCRIPTION, D.PARAM_NO, D.DESCRIPTION PARAM_DESC, D.INSPECTION_METHOD, D.MIN_VALUE, D.STANDARD_VALUE, D.MAX_VALUE, B.CHECK_VALUES, B."RESULT"
FROM Z_INSPECTION_TASK A
LEFT JOIN Z_INSPECTION_ITEM C ON A.INSPECTION_ITEM_BO = C.HANDLE
INNER JOIN Z_INSPECTION_TASK_DETAIL B ON A.HANDLE = B.TASK_BO
LEFT JOIN Z_INSPECTION_ITEM_DETAIL D ON B.INSPECTION_ITEM_DETAIL_BO = D.HANDLE AND C.HANDLE = D.INSPECTION_ITEM_BO
WHERE A.SITE = #{site} AND A.TASK_NO = #{taskNo}
</select>
<select id="findWorkShopPassRate" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT DESCRIPTION WORK_CENTER_DESCRIPTION, "MONTH",sum(NG_QTY) NC_QTY, sum(OK_QTY) OK_QTY,sum(CHECK_QTY) CHECK_QTY,sum(DISPATCH_QTY) DISPATCH_QTY,round(sum(OK_QTY)*100/sum(DISPATCH_QTY),2)||'% ' OK_RATE FROM
(
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC )=1 AND zit."RESULT"='OK' THEN 0
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN TO_NUMBER(zab.NC_QTY)
ELSE 0 END NG_QTY , TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') "MONTH",
CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN zsd.DISPATCH_QTY
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN 0
ELSE 0 END OK_QTY
,ZSD.DISPATCH_QTY, WT.DESCRIPTION,
ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC) seq,
zit."RESULT",COUNT(ZIT.HANDLE) check_qty, zit.sfc ,zit.OPERATION,zit.STEP_ID FROM Z_INSPECTION_TASK zit
JOIN sfc S ON S.SFC=zit.SFC AND s.SITE=zit.SITE
JOIN Z_SFC_DISPATCH ZSD ON ZSD.SFC=zit.SFC AND ZSD.SITE=zit.SITE AND zit.STEP_ID=ZSD.STEP_ID
JOIN WORK_CENTER WC ON WC.SITE = zit.SITE AND WC.WORK_CENTER = zit.WORK_CENTER
LEFT JOIN WORK_CENTER_T WT ON WT.WORK_CENTER_BO = WC.HANDLE AND WT.LOCALE = 'zh'
LEFT JOIN Z_ABNORMAL_BILL ZAB ON zit.SFC=ZAB.SFC AND zit.SITE=ZAB.SITE AND zit.STEP_ID=ZAB.STEP_ID AND zab."TYPE"='Z'
WHERE zit.SITE= #{site} AND (zit.CATEGORY='P' OR zit.CATEGORY='S') AND zit.STATUS='COMPLETE'
<if test="workCenter != null and workCenter != ''" >
AND zit.WORK_CENTER = #{workCenter}
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') >=#{startFromDate}
</if>
<if test="startToDate != null and startToDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') &lt;= #{startToDate}
</if>
GROUP BY zit."RESULT",zit.sfc ,zit.OPERATION,zit.STEP_ID, zit.CREATED_DATE_TIME,zit.RESRCE,zab.NC_QTY, WT.DESCRIPTION,ZSD.DISPATCH_QTY
)
WHERE SEQ='1'
GROUP BY DESCRIPTION, "MONTH"
ORDER BY DESCRIPTION,"MONTH"
</select>
<select id="findCheckUserPassRate" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT DESCRIPTION WORK_CENTER_DESCRIPTION, FULL_NAME,"MONTH",sum(NG_QTY) NC_QTY, sum(CHECK_QTY) CHECK_QTY,sum(DISPATCH_QTY) DISPATCH_QTY FROM
(
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN 0
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN TO_NUMBER(zab.NC_QTY)
ELSE 0 END NG_QTY , TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') "MONTH"
, WT.DESCRIPTION,ZNU.FULL_NAME,
ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC) seq,
zit."RESULT",COUNT(ZIT.HANDLE) check_qty,zsd.DISPATCH_QTY, zit.sfc ,zit.OPERATION,zit.STEP_ID FROM Z_INSPECTION_TASK zit
JOIN sfc S ON S.SFC=zit.SFC AND s.SITE=zit.SITE
JOIN Z_SFC_DISPATCH ZSD ON ZSD.SFC=zit.SFC AND ZSD.SITE=zit.SITE AND zit.STEP_ID=ZSD.STEP_ID
JOIN WORK_CENTER WC ON WC.SITE = zit.SITE AND WC.WORK_CENTER = zit.WORK_CENTER
LEFT JOIN WORK_CENTER_T WT ON WT.WORK_CENTER_BO = WC.HANDLE AND WT.LOCALE = 'zh'
LEFT JOIN Z_ABNORMAL_BILL ZAB ON zit.SFC=ZAB.SFC AND zit.SITE=ZAB.SITE AND zit.STEP_ID=ZAB.STEP_ID AND zab."TYPE"='Z'
LEFT JOIN Z_NWA_USER ZNU ON ZNU.USER_NAME = ZIT.MODIFY_USER
WHERE zit.SITE= #{site} AND (zit.CATEGORY='P' OR zit.CATEGORY='S') AND zit.STATUS='COMPLETE'
<if test="workCenter != null and workCenter != ''" >
AND zit.WORK_CENTER = #{workCenter}
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') >=#{startFromDate}
</if>
<if test="startToDate != null and startToDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') &lt;= #{startToDate}
</if>
<if test="userId != null and userId != ''" >
AND ZIT.MODIFY_USER = #{userId}
</if>
GROUP BY zit."RESULT",zit.sfc ,zit.OPERATION,zit.STEP_ID, zit.CREATED_DATE_TIME,zit.RESRCE,zab.NC_QTY, ZNU.FULL_NAME,WT.DESCRIPTION,zsd.DISPATCH_QTY
)
WHERE SEQ='1'
GROUP BY DESCRIPTION, "MONTH",FULL_NAME
ORDER BY DESCRIPTION,"MONTH"
</select>
<select id="findUserPassRate" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT ZNU.FULL_NAME,DUTY_USER,DESCRIPTION WORK_CENTER_DESCRIPTION, "MONTH",sum(NG_QTY) NC_QTY, sum(OK_QTY) OK_QTY,sum(CHECK_QTY) CHECK_QTY,sum(DISPATCH_QTY) DISPATCH_QTY,round(sum(OK_QTY)*100/sum(DISPATCH_QTY),2)||'% ' OK_RATE FROM
(
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN 0
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN TO_NUMBER(zab.NC_QTY)
ELSE 0 END NG_QTY , TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') "MONTH",
CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN zsd.DISPATCH_QTY
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN 0
ELSE 0 END OK_QTY,E.EMPLOYEE,ZABD.PRINCIPAL_USER DUTY_USER
,ZSD.DISPATCH_QTY, WT.DESCRIPTION,
ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC) seq,
zit."RESULT",COUNT(ZIT.HANDLE) check_qty, zit.sfc ,zit.OPERATION,zit.STEP_ID FROM Z_INSPECTION_TASK zit
JOIN sfc S ON S.SFC=zit.SFC AND s.SITE=zit.SITE
JOIN Z_SFC_DISPATCH ZSD ON ZSD.SFC=zit.SFC AND ZSD.SITE=zit.SITE AND zit.STEP_ID=ZSD.STEP_ID
JOIN WORK_CENTER WC ON WC.SITE = zit.SITE AND WC.WORK_CENTER = zit.WORK_CENTER
JOIN (
SELECT HANDLE,
REGEXP_SUBSTR(EMPLOYEE, '[^,]+', 1, l) AS EMPLOYEE
FROM Z_SFC_DISPATCH c,
(SELECT LEVEL l FROM DUAL CONNECT BY LEVEL &lt;= 5)
WHERE l &lt;= LENGTH(EMPLOYEE) - LENGTH(REPLACE(EMPLOYEE, ',')) + 1) E ON ZSD.HANDLE=E.HANDLE
LEFT JOIN WORK_CENTER_T WT ON WT.WORK_CENTER_BO = WC.HANDLE AND WT.LOCALE = 'zh'
LEFT JOIN Z_ABNORMAL_BILL ZAB ON zit.SFC=ZAB.SFC AND zit.SITE=ZAB.SITE AND zit.STEP_ID=ZAB.STEP_ID AND zab."TYPE"='Z'
LEFT JOIN Z_ABNORMAL_BILL_DISPOSE ZABD ON ZAB.HANDLE=ZABD.ABNORMAL_BILL_BO
WHERE zit.SITE= #{site} AND (zit.CATEGORY='P' OR zit.CATEGORY='S') AND zit.STATUS='COMPLETE'
<if test="workCenter != null and workCenter != ''" >
AND zit.WORK_CENTER = #{workCenter}
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') >=#{startFromDate}
</if>
<if test="startToDate != null and startToDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') &lt;= #{startToDate}
</if>
<if test="userId != null and userId != ''" >
AND E.EMPLOYEE = #{userId}
</if>
GROUP BY zit."RESULT",zit.sfc ,zit.OPERATION,zit.STEP_ID, zit.CREATED_DATE_TIME,zit.RESRCE,zab.NC_QTY, WT.DESCRIPTION,ZSD.DISPATCH_QTY,E.EMPLOYEE,ZABD.PRINCIPAL_USER
) D
LEFT JOIN Z_NWA_USER ZNU ON ZNU.USER_NAME = D.EMPLOYEE
WHERE SEQ='1'
GROUP BY DESCRIPTION, "MONTH",ZNU.FULL_NAME,DUTY_USER
ORDER BY DESCRIPTION,"MONTH"
</select>
<select id="findInspectionDetailPassRate" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT DATE_TIME,sum(NG_QTY) NC_QTY, sum(OK_QTY) OK_QTY,sum(CHECK_QTY) CHECK_QTY,sum(DISPATCH_QTY) DISPATCH_QTY,FULL_NAME,DUTY_USER,DUTY_DEPART,WORK_ORDER,ITEM_NUMBER,ITEM,ITEM_DESC,OPERATION_DESC,CATEGORY,EMPLOYEE_DESCRIPTION,COMMENTS,DESCRIPTION WORK_CENTER_DESCRIPTION,SHOP_ORDER,ABNORMAL_NO FROM
(
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN 0
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN TO_NUMBER(zab.NC_QTY)
ELSE 0 END NG_QTY, WT.DESCRIPTION,ZNU.FULL_NAME,ZSD.EMPLOYEE,ZSD.EMPLOYEE_DESCRIPTION,CFA.VALUE WORK_ORDER,CFB.VALUE ITEM_NUMBER,O.OPERATION,OT.DESCRIPTION OPERATION_DESC,
ROW_NUMBER() OVER(PARTITION BY zit.sfc,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC) seq,I.ITEM,IT.DESCRIPTION ITEM_DESC,TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM-DD') DATE_TIME,
CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN zsd.DISPATCH_QTY
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN 0
ELSE 0 END OK_QTY,
zit."RESULT",COUNT(ZIT.HANDLE) check_qty, zit.sfc ,zit.STEP_ID,zit.CATEGORY,zit.COMMENTS,ZABD.PRINCIPAL_USER DUTY_USER,ZABD.DUTY_DEPART,SO.SHOP_ORDER,zsd.DISPATCH_QTY,zab.ABNORMAL_NO
FROM Z_INSPECTION_TASK zit
JOIN OPERATION O ON O.OPERATION = zit.OPERATION AND O.SITE = zit.SITE AND o.CURRENT_REVISION='true'
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = O.HANDLE AND OT.LOCALE = 'zh'
JOIN sfc S ON S.SFC=zit.SFC AND s.SITE=zit.SITE
LEFT JOIN SHOP_ORDER SO ON SO.HANDLE = S.SHOP_ORDER_BO
JOIN ITEM I ON I.HANDLE = SO.ITEM_BO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = S.ITEM_BO
LEFT JOIN CUSTOM_FIELDS CFA ON CFA.HANDLE = SO.HANDLE AND CFA."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN CUSTOM_FIELDS CFB ON CFB.HANDLE = SO.HANDLE AND CFB."ATTRIBUTE" = 'ITEM_NUMBER'
JOIN Z_SFC_DISPATCH ZSD ON ZSD.SFC=zit.SFC AND ZSD.SITE=zit.SITE AND zit.STEP_ID=ZSD.STEP_ID
JOIN WORK_CENTER WC ON WC.SITE = zit.SITE AND WC.WORK_CENTER = zit.WORK_CENTER
LEFT JOIN WORK_CENTER_T WT ON WT.WORK_CENTER_BO = WC.HANDLE AND WT.LOCALE = 'zh'
LEFT JOIN Z_ABNORMAL_BILL ZAB ON ZAB.OBJECT_BO = zit.HANDLE
LEFT JOIN Z_ABNORMAL_BILL_DISPOSE ZABD ON ZAB.HANDLE=ZABD.ABNORMAL_BILL_BO
LEFT JOIN Z_NWA_USER ZNU ON ZNU.SITE = ZIT.SITE AND ZNU.USER_NAME = ZIT.MODIFY_USER
WHERE zit.SITE= #{site} AND (zit.CATEGORY='P' OR zit.CATEGORY='S') AND zit.STATUS='COMPLETE'
<if test="workCenter != null and workCenter != ''" >
AND zit.WORK_CENTER = #{workCenter}
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND zit.CREATED_DATE_TIME >= TO_DATE(#{startFromDate}, 'YYYY-MM-DD') - 8/24
</if>
<if test="startToDate != null and startToDate != ''" >
AND zit.CREATED_DATE_TIME &lt;= TO_DATE(#{startToDate}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="userId != null and userId != ''" >
AND zsd.EMPLOYEE like '%'||#{userId}||'%'
</if>
<if test="workOrder != null and workOrder != ''" >
AND CFA.VALUE LIKE '%'||#{workOrder}||'%'
</if>
<if test="shopOrder != null and shopOrder != ''" >
AND SO.SHOP_ORDER = #{shopOrder}
</if>
<if test="abnormalNo != null and abnormalNo != ''" >
AND zab.ABNORMAL_NO = #{abnormalNo}
</if>
GROUP BY ZABD.PRINCIPAL_USER,zsd.DISPATCH_QTY,ZABD.DUTY_DEPART,zit."RESULT",zit.sfc ,zit.OPERATION,zit.STEP_ID,CFA.VALUE,CFB.VALUE, zit.CREATED_DATE_TIME,zit.RESRCE,zab.NC_QTY,zit.CREATED_DATE_TIME, ZNU.FULL_NAME,WT.DESCRIPTION,I.ITEM,IT.DESCRIPTION,O.OPERATION,OT.DESCRIPTION,ZSD.EMPLOYEE,ZSD.EMPLOYEE_DESCRIPTION,zit.COMMENTS,zit.CATEGORY,SO.SHOP_ORDER,zab.ABNORMAL_NO
)
WHERE SEQ='1'
GROUP BY DATE_TIME,DESCRIPTION,FULL_NAME,DUTY_USER,DUTY_DEPART,WORK_ORDER,ITEM_NUMBER,ITEM,ITEM_DESC,OPERATION,OPERATION_DESC,CATEGORY,EMPLOYEE,EMPLOYEE_DESCRIPTION,COMMENTS,SHOP_ORDER,ABNORMAL_NO
</select>
<select id="findSectionPassRate" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT "SECTION","MONTH",sum(NG_QTY) NC_QTY, sum(OK_QTY) OK_QTY,sum(CHECK_QTY) CHECK_QTY,sum(DISPATCH_QTY) DISPATCH_QTY,round(sum(OK_QTY)*100/sum(DISPATCH_QTY),2)||'% ' OK_RATE FROM
(
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN 0
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN TO_NUMBER(zab.NC_QTY)
ELSE 0 END NG_QTY , TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') "MONTH",
CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='OK' THEN zsd.DISPATCH_QTY
WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC)=1 AND zit."RESULT"='NG' THEN 0
ELSE 0 END OK_QTY,CS1.VALUE "SECTION"
,ZSD.DISPATCH_QTY,
ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME ASC) seq,
zit."RESULT",COUNT(ZIT.HANDLE) check_qty, zit.sfc ,zit.OPERATION,zit.STEP_ID FROM Z_INSPECTION_TASK zit
JOIN RESRCE R ON zit.SITE = R.SITE AND R.RESRCE = zit.RESRCE
LEFT JOIN CUSTOM_FIELDS CS1 ON CS1.HANDLE = R.HANDLE AND CS1.ATTRIBUTE = 'SECTION'
JOIN sfc S ON S.SFC=zit.SFC AND s.SITE=zit.SITE
JOIN Z_SFC_DISPATCH ZSD ON ZSD.SFC=zit.SFC AND ZSD.SITE=zit.SITE AND zit.STEP_ID=ZSD.STEP_ID
JOIN WORK_CENTER WC ON WC.SITE = zit.SITE AND WC.WORK_CENTER = zit.WORK_CENTER
LEFT JOIN WORK_CENTER_T WT ON WT.WORK_CENTER_BO = WC.HANDLE AND WT.LOCALE = 'zh'
LEFT JOIN Z_ABNORMAL_BILL ZAB ON zit.SFC=ZAB.SFC AND zit.SITE=ZAB.SITE AND zit.STEP_ID=ZAB.STEP_ID AND zab."TYPE"='Z'
WHERE zit.SITE= #{site} AND (zit.CATEGORY='P' OR zit.CATEGORY='S') AND zit.STATUS='COMPLETE'
<if test="section != null and section != ''" >
AND CS1.VALUE = #{section}
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') >=#{startFromDate}
</if>
<if test="startToDate != null and startToDate != ''" >
AND TO_CHAR(zit.CREATED_DATE_TIME,'YYYY-MM') &lt;= #{startToDate}
</if>
GROUP BY zit."RESULT",zit.sfc ,zit.OPERATION,zit.STEP_ID, zit.CREATED_DATE_TIME,zit.RESRCE,zab.NC_QTY,ZSD.DISPATCH_QTY,CS1.VALUE
)
WHERE SEQ='1'
GROUP BY "MONTH","SECTION"
ORDER BY "SECTION","MONTH"
</select>
<select id="selectItemMoveData" resultType="java.util.HashMap" parameterType="java.util.HashMap">
WITH TEMP AS (SELECT MAX(ZSD.HANDLE) HANDLE FROM Z_SFC_DISPATCH ZSD
WHERE ZSD.SITE = #{site} AND ZSD.OTHER_2 IS NOT NULL
GROUP BY ZSD.SFC )
SELECT ZSD.SHOP_ORDER ,ZSD.SFC , CF.VALUE WORK_ORDER , I.ITEM , IT.DESCRIPTION ITEM_DESCRIPTION ,
ZSD.BLANKING_SIZE , ZSD.OPERATION , OT.DESCRIPTION OPERATION_DESCRIPTION , ZSD.EMPLOYEE_DESCRIPTION ,
ZSD.DISPATCH_QTY ,ZSD.OTHER_2 , ZSD.OTHER_3 , ZSD.HANDLE , ZSD.BLANKING_SIZE ,
CASE WHEN ZSD.OTHER_2 = 'H' THEN '转入焊接'
WHEN ZSD.OTHER_2 = 'Z' THEN '转装配'
WHEN ZSD.OTHER_2 = 'RK' THEN '入库' END OTHER_2_DESC ,
CASE WHEN ZSD.OTHER_3 = 'true' THEN '已流转'
ELSE '未流转' END OTHER_3_DESC
FROM Z_SFC_DISPATCH ZSD
LEFT JOIN SHOP_ORDER SO ON SO.SHOP_ORDER = ZSD.SHOP_ORDER
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = SO.HANDLE AND CF."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN OPERATION O ON O.OPERATION = ZSD.OPERATION
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = O.HANDLE
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = SO.ITEM_BO
LEFT JOIN ITEM I ON I.HANDLE = SO.ITEM_BO
INNER JOIN TEMP ON TEMP.HANDLE = ZSD.HANDLE
WHERE ZSD.SITE = #{site} AND ZSD.DISPATCH_STATUS = 'COMPLETE'
<if test="other2 != null and other2 != ''">
AND ZSD.OTHER_2 = #{other2}
</if>
<if test="other3 != null and other3 != ''">
AND ZSD.OTHER_3 = #{other3}
</if>
<if test="operation != null and operation != ''">
AND ZSD.OPERATION = #{operation}
</if>
<if test="workCenter != null and workCenter != ''">
AND ZSD.WORK_CENTER = #{workCenter}
</if>
<if test="startFromDate != null and startFromDate != ''" >
AND TO_CHAR(ZSD.ACTUAL_COMPLETE_DATE,'YYYY-MM-DD') >=#{startFromDate}
</if>
<if test="startToDate != null and startToDate != ''" >
AND TO_CHAR(ZSD.ACTUAL_COMPLETE_DATE,'YYYY-MM-DD') &lt;= #{startToDate}
</if>
</select>
<update id="doItemMove">
UPDATE Z_SFC_DISPATCH ZSD SET ZSD.OTHER_3 = 'true' WHERE ZSD.HANDLE IN
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
AND ZSD.SITE = #{site}
</update>
</mapper>