资源符合率报表新增计划使用率查询

master
zpl 3 years ago
parent aadea78601
commit 4ee3747927

@ -58,17 +58,123 @@
SELECT ZSD.PLANNED_COMP_DATE ,ZSD.PLANNED_START_DATE ,ZSD.RESRCE
FROM Z_SFC_DISPATCH ZSD WHERE ZSD.SITE = #{site} AND ZSD.DISPATCH_STATUS IN ('START','COMPLETE','RELEASE')
)
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)
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
,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
FROM
( 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
INNER 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 ON 1=1
LEFT JOIN RESOURCE_TYPE_RESOURCE RTR ON RTR.RESOURCE_BO = R.HANDLE
LEFT JOIN RESOURCE_TYPE RT ON RT.HANDLE = RTR.RESOURCE_TYPE_BO
WHERE R.SITE = #{site}
<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>) RDT
LEFT JOIN
(SELECT DATE_TIME ,RESRCE , COUNT(*) * 8 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( ROUND((PLANNED_COMP_DATE - AM_START_DATE_TIME)*24, 4) ) 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 , COUNT(*)*4 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( ROUND((PLANNED_COMP_DATE - AM_START_DATE_TIME)*24 - 1 , 4) ) 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( ROUND((PLANNED_COMP_DATE - PLANNED_START_DATE)*24 , 4) ) 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( ROUND((AM_END_DATE_TIME - PLANNED_START_DATE)*24 , 4) ) 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( ROUND((PLANNED_COMP_DATE - PLANNED_START_DATE)*24 - 1 , 4) ) 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( ROUND((PM_END_DATE_TIME - PLANNED_START_DATE)*24 - 1 , 4) ) 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( ROUND((PLANNED_COMP_DATE - PM_START_DATE_TIME)*24 , 4) ) 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 , COUNT(*)*4 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( ROUND((PLANNED_COMP_DATE - PLANNED_START_DATE)*24 , 4) ) 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( ROUND((PM_END_DATE_TIME - PLANNED_START_DATE)*24 , 4) ) 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
FROM Z_SFC_DISPATCH ZSD WHERE ZSD.SITE = #{site} AND ZSD.DISPATCH_STATUS IN ('START','COMPLETE','RELEASE')
)
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 PLAN_HOUR
,CASE WHEN RDT.CAPACITY_MAN_HOUR = 0 THEN '0%'
+ 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
,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
) ) / 8 , 4) * 100
END RATE_DATA_INT
FROM
( SELECT R.RESRCE , R.DESCRIPTION RESOURCE_DESCRIPTION, DATE_TIME, DECODE(CF.VALUE,NULL,0,CF.VALUE) CAPACITY_MAN_HOUR , WCA.WORK_CENTER CENTER ,
( 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
@ -142,8 +248,16 @@
(SELECT DATE_TIME ,RESRCE , SUM( ROUND((PM_END_DATE_TIME - PLANNED_START_DATE)*24 , 4) ) 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.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
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>
<!--设备维修数据统计报表-->

Loading…
Cancel
Save