资源负荷率报表

master
zpl 3 years ago
parent 580251fa90
commit 3fe6bdef33

@ -48,7 +48,6 @@ public class ReportDataController {
@GetMapping("/findResourceLoadRateInfo") @GetMapping("/findResourceLoadRateInfo")
public R findResourceLoadRateInfo(@RequestParam(required = false) Map paramMap) { public R findResourceLoadRateInfo(@RequestParam(required = false) Map paramMap) {
try { try {
paramMap.put("site", CommonMethods.getSite());
List<Map<String, Object>> result = reportDataService.findResourceLoadRateInfo(paramMap); List<Map<String, Object>> result = reportDataService.findResourceLoadRateInfo(paramMap);
return R.ok(result); return R.ok(result);
} catch (Exception e) { } catch (Exception e) {

@ -1,5 +1,6 @@
package com.foreverwin.mesnac.common.mapper; package com.foreverwin.mesnac.common.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -16,6 +17,9 @@ public interface ReportDataMapper {
List<Map<String, Object>> findProductStateInfo(Map paramMap); List<Map<String, Object>> findProductStateInfo(Map paramMap);
void insertReportDateTimeByStartToDate(@Param("site") String site ,@Param("startFromDate") String startFromDate,@Param("startToDate") String startToDate);
void deleteAllReportDateTime();
} }

@ -2,11 +2,13 @@ package com.foreverwin.mesnac.common.service.impl;
import com.foreverwin.mesnac.common.mapper.ReportDataMapper; import com.foreverwin.mesnac.common.mapper.ReportDataMapper;
import com.foreverwin.mesnac.common.service.ReportDataService; import com.foreverwin.mesnac.common.service.ReportDataService;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods; import com.foreverwin.modular.core.util.CommonMethods;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -24,7 +26,25 @@ public class ReportDataServiceImpl implements ReportDataService{
@Override @Override
public List<Map<String, Object>> findResourceLoadRateInfo(Map paramMap) { public List<Map<String, Object>> findResourceLoadRateInfo(Map paramMap) {
return reportDataMapper.findResourceLoadRateInfo(paramMap); String site = CommonMethods.getSite();
paramMap.put("site",site);
String startFromDate = (String) paramMap.get("startFromDate");
String startToDate = (String) paramMap.get("startToDate");
try{
LocalDate.parse(startToDate);
LocalDate.parse(startFromDate);
}catch (Exception e){
throw BusinessException.build("时间格式错误!");
}
// 清空日期表数据
reportDataMapper.deleteAllReportDateTime();
// 插入日期查询范围
reportDataMapper.insertReportDateTimeByStartToDate(site,startFromDate,startToDate);
List<Map<String, Object>> resourceLoadRateInfo = reportDataMapper.findResourceLoadRateInfo(paramMap);
if (resourceLoadRateInfo.size() < 1){
throw BusinessException.build("按条件查询未找到数据!");
}
return resourceLoadRateInfo;
} }
@Override @Override

@ -52,9 +52,62 @@
</if> </if>
</select> </select>
<!--设备符合率报表--> <!--设备负荷率报表-->
<select id="findResourceLoadRateInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap" > <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
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) ) ) 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) ) ) / RDT.CAPACITY_MAN_HOUR , 4) * 100 || '%'
END RATE_DATA
FROM
( SELECT 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 , SUM( ROUND((PLANNED_COMP_DATE - START_DATE_TIME)*24, 4) ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt; START_DATE_TIME AND PLANNED_COMP_DATE &gt; START_DATE_TIME AND PLANNED_COMP_DATE &lt; 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 , COUNT(*) * 24 CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &lt; START_DATE_TIME AND PLANNED_COMP_DATE &gt; 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( ROUND((PLANNED_COMP_DATE - PLANNED_START_DATE)*24 , 4) ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; START_DATE_TIME AND PLANNED_COMP_DATE &lt; END_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((END_DATE_TIME - PLANNED_START_DATE)*24 , 4) ) CNT FROM Z_REPORT_DATE_TIME
LEFT JOIN TEMP ON PLANNED_START_DATE &gt; START_DATE_TIME AND PLANNED_START_DATE &lt; END_DATE_TIME AND PLANNED_COMP_DATE &gt; END_DATE_TIME
GROUP BY RESRCE , DATE_TIME ) D ON D.DATE_TIME = RDT.DATE_TIME AND D.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
</select> </select>
<!--设备维修数据统计报表--> <!--设备维修数据统计报表-->
@ -125,7 +178,32 @@
<if test="actualStartToDate != null and actualStartToDate != ''" > <if test="actualStartToDate != null and actualStartToDate != ''" >
AND ZSD.ACTUAL_COMPLETE_DATE &lt;= TO_DATE(#{actualStartToDate}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS') AND ZSD.ACTUAL_COMPLETE_DATE &lt;= TO_DATE(#{actualStartToDate}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if> </if>
</select> </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 #{site} ,TO_CHAR(TO_DATE(#{startFromDate},'YYYY-MM-DD') + ROWNUM -1, 'YYYY-MM-DD') , TO_DATE(#{startFromDate} || '16:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -2 ,
TO_DATE(#{startFromDate} || '16:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1
FROM dual CONNECT BY rownum &lt;= to_date( #{startToDate}, 'yyyy-mm-dd') - to_date( #{startFromDate}, 'yyyy-mm-dd') + 1
</insert>
</mapper> </mapper>
Loading…
Cancel
Save