master
philip 3 years ago
parent edfc15b5fd
commit daad2e4a8e

@ -144,4 +144,26 @@ public class ReportDataController {
}
}
@GetMapping("/inspectionDetailPassRate")
public R findInspectionDetailPassRate(@RequestParam(required = false) Map paramMap) {
try {
paramMap.put("site", CommonMethods.getSite());
List<Map<String, Object>> result = reportDataService.findInspectionDetailPassRate(paramMap);
return R.ok(result);
} catch (Exception e) {
return R.failed(e.getMessage());
}
}
@GetMapping("/sectionPassRate")
public R findSectionPassRate(@RequestParam(required = false) Map paramMap) {
try {
paramMap.put("site", CommonMethods.getSite());
List<Map<String, Object>> result = reportDataService.findSectionPassRate(paramMap);
return R.ok(result);
} catch (Exception e) {
return R.failed(e.getMessage());
}
}
}

@ -1,6 +1,5 @@
package com.foreverwin.mesnac.common.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -31,4 +30,7 @@ public interface ReportDataMapper {
List<Map<String, Object>> findUserPassRate(Map paramMap);
List<Map<String, Object>> findInspectionDetailPassRate(Map paramMap);
List<Map<String, Object>> findSectionPassRate(Map paramMap);
}

@ -50,4 +50,8 @@ public interface ReportDataService {
List<Map<String, Object>> findUserPassRate(Map paramMap);
List<Map<String, Object>> findInspectionDetailPassRate(Map paramMap);
List<Map<String, Object>> findSectionPassRate(Map paramMap);
}

@ -9,7 +9,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -85,4 +84,14 @@ public class ReportDataServiceImpl implements ReportDataService{
public List<Map<String, Object>> findUserPassRate(Map paramMap) {
return reportDataMapper.findUserPassRate(paramMap);
}
@Override
public List<Map<String, Object>> findInspectionDetailPassRate(Map paramMap) {
return reportDataMapper.findInspectionDetailPassRate(paramMap);
}
@Override
public List<Map<String, Object>> findSectionPassRate(Map paramMap) {
return reportDataMapper.findSectionPassRate(paramMap);
}
}

@ -410,7 +410,7 @@
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' AND zit.STATUS='COMPLETE'
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>
@ -423,7 +423,6 @@
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
) GROUP BY DESCRIPTION, "MONTH"
ORDER BY DESCRIPTION,"MONTH"
</select>
<select id="findCheckUserPassRate" resultType="java.util.HashMap" parameterType="java.util.HashMap">
@ -441,7 +440,7 @@
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' AND zit.STATUS='COMPLETE'
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>
@ -483,7 +482,7 @@
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' AND zit.STATUS='COMPLETE'
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>
@ -502,4 +501,83 @@
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 FROM
(
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY zit.sfc ,zit.OPERATION,zit.STEP_ID ORDER BY zit.CREATED_DATE_TIME DESC)=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 DESC)=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 DESC) 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 DESC)=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 DESC)=1 AND zit."RESULT"='NG' THEN 0
ELSE 0 END OK_QTY,zsd.DISPATCH_QTY,
zit."RESULT",COUNT(ZIT.HANDLE) check_qty, zit.sfc ,zit.STEP_ID,zit.CATEGORY,zit.COMMENTS,ZABD.DUTY_USER,ZABD.DUTY_DEPART
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 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
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>
GROUP BY ZABD.DUTY_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
) 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
</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,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 DESC)=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 DESC)=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 DESC)=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 DESC)=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 DESC) 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
) GROUP BY "MONTH","SECTION"
ORDER BY "SECTION","MONTH"
</select>
</mapper>
Loading…
Cancel
Save