Browse Source

消缺统计月报

zhongwei
ty 10 months ago
parent
commit
1a87e98e8e
  1. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.java
  2. 70
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.xml
  3. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.java

@ -26,6 +26,7 @@ public interface OperDefectMapper extends UserDataScopeBaseMapper<OperDefectEnti
* @param month 格式'2021-01' * @param month 格式'2021-01'
* @return * @return
*/ */
@SqlParser(filter=true)
List<OperDefectStatisticsStatusDTO> getStatisticByMonth(@Param("month") String month, List<OperDefectStatisticsStatusDTO> getStatisticByMonth(@Param("month") String month,
@Param("createDept") List<String> createDept); @Param("createDept") List<String> createDept);

70
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.xml

@ -7,9 +7,14 @@
SELECT P.DEFECT_GRADING as defectLevel,P.HANDLE_STATUS,COUNT(P.ID) AS DEFECT_NUM from SELECT P.DEFECT_GRADING as defectLevel,P.HANDLE_STATUS,COUNT(P.ID) AS DEFECT_NUM from
hzims_oper_phenomenon P hzims_oper_phenomenon P
WHERE DATE_FORMAT(P.CREATE_TIME,'%Y-%m') = #{month} WHERE DATE_FORMAT(P.CREATE_TIME,'%Y-%m') = #{month}
<if test="createDept != null and createDept != ''"> <if test="createDept != null and createDept.size > 0">
AND P.CREATE_DEPT = #{createDept} AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if> </if>
and P.DEFECT_GRADING IS NOT NULL
AND P.IS_DEFECT='1'
AND P.IS_DELETED = '0' AND P.IS_DELETED = '0'
GROUP BY P.DEFECT_GRADING,P.HANDLE_STATUS GROUP BY P.DEFECT_GRADING,P.HANDLE_STATUS
ORDER BY P.DEFECT_GRADING ORDER BY P.DEFECT_GRADING
@ -20,37 +25,46 @@
SELECT P.DEFECT_GRADING as defectLevel,P.HANDLE_STATUS,COUNT(P.ID) AS DEFECT_NUM SELECT P.DEFECT_GRADING as defectLevel,P.HANDLE_STATUS,COUNT(P.ID) AS DEFECT_NUM
from hzims_oper_phenomenon P from hzims_oper_phenomenon P
WHERE P.CREATE_TIME BETWEEN #{firstMonth} AND #{endMonth} WHERE P.CREATE_TIME BETWEEN #{firstMonth} AND #{endMonth}
<if test="createDept != null and createDept != ''"> <if test="createDept != null and createDept.size > 0">
AND P.CREATE_DEPT = #{createDept} AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if> </if>
AND P.IS_DEFECT='1'
AND P.IS_DELETED = 0 AND P.IS_DELETED = 0
and P.DEFECT_GRADING IS NOT NULL
GROUP BY P.DEFECT_GRADING,P.HANDLE_STATUS GROUP BY P.DEFECT_GRADING,P.HANDLE_STATUS
ORDER BY P.DEFECT_GRADING ORDER BY P.DEFECT_GRADING
</select> </select>
<select id="getRepetStatistics" <select id="getRepetStatistics"
resultType="com.hnac.hzims.operational.defect.dto.OperDefectStatisticsCodeDTO"> resultType="com.hnac.hzims.operational.defect.dto.OperDefectStatisticsCodeDTO">
SELECT P.DEFECT_LEVEL,P.FAULT_CODE,COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D LEFT JOIN SELECT P.DEFECT_GRADING as defectLevel,P.FAULT_CODE,COUNT(P.ID) AS DEFECT_NUM from
hzims_oper_phenomenon P hzims_oper_phenomenon P
ON D.DEFECT_CODE = P.DEFECT_CODE
WHERE 1=1 WHERE 1=1
<if test="createDept != null and createDept.size > 0"> <if test="createDept != null and createDept.size > 0">
and D.CREATE_DEPT in AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=","> <foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
GROUP BY P.DEFECT_LEVEL,P.FAULT_CODE and P.DEFECT_GRADING IS NOT NULL
AND P.IS_DEFECT='1'
AND P.IS_DELETED = 0
GROUP BY P.DEFECT_GRADING,P.FAULT_CODE
</select> </select>
<select id="getManageIndex" resultType="java.lang.Integer"> <select id="getManageIndex" resultType="java.lang.Integer">
<!-- 本月及时消缺数 --> <!-- 本月及时消缺数 -->
(SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D LEFT JOIN hzims_oper_phenomenon P (SELECT COUNT(P.ID) AS DEFECT_NUM from hzims_oper_phenomenon P
ON D.DEFECT_CODE = P.DEFECT_CODE WHERE DATE_FORMAT(P.CREATE_TIME,'%Y-%m') = #{month}
WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} AND P.HANDLE_STATUS = 1
AND D.HANDLE_STATUS = 1 AND P.IS_DEFECT='1'
AND D.ACT_END_TIME &lt;= P.PLAN_END_TIME AND P.IS_DELETED = 0
and P.DEFECT_GRADING IS NOT NULL
AND P.ACT_END_TIME &lt;= P.PLAN_END_TIME
<if test="createDept != null and createDept.size > 0"> <if test="createDept != null and createDept.size > 0">
and D.CREATE_DEPT in AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=","> <foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
@ -59,11 +73,14 @@
UNION ALL UNION ALL
<!-- 本月总消缺数 --> <!-- 本月总消缺数 -->
( (
SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_phenomenon D
WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month}
AND D.HANDLE_STATUS = 1 AND D.HANDLE_STATUS = 1
AND D.IS_DEFECT='1'
AND D.IS_DELETED = 0
and D.DEFECT_GRADING IS NOT NULL
<if test="createDept != null and createDept.size > 0"> <if test="createDept != null and createDept.size > 0">
and D.CREATE_DEPT in AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=","> <foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
@ -72,11 +89,14 @@
UNION ALL UNION ALL
<!-- 本月遗留缺陷数 --> <!-- 本月遗留缺陷数 -->
( (
SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_phenomenon D
WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month}
AND D.HANDLE_STATUS = 0 AND D.HANDLE_STATUS = 0
AND D.IS_DELETED = 0
AND D.IS_DEFECT='1'
and D.DEFECT_GRADING IS NOT NULL
<if test="createDept != null and createDept.size > 0"> <if test="createDept != null and createDept.size > 0">
and D.CREATE_DEPT in AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=","> <foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
@ -85,11 +105,14 @@
UNION ALL UNION ALL
<!-- 历史遗留缺陷数 --> <!-- 历史遗留缺陷数 -->
( (
SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_phenomenon D
WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') &lt; CONCAT(#{month}, '-01') WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') &lt; CONCAT(#{month}, '-01')
AND D.HANDLE_STATUS = 0 AND D.HANDLE_STATUS = 0
AND D.IS_DELETED = 0
AND D.IS_DEFECT='1'
and D.DEFECT_GRADING IS NOT NULL
<if test="createDept != null and createDept.size > 0"> <if test="createDept != null and createDept.size > 0">
and D.CREATE_DEPT in AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=","> <foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
@ -98,10 +121,13 @@
UNION ALL UNION ALL
<!-- 本月总缺陷数 --> <!-- 本月总缺陷数 -->
( (
SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_phenomenon D
WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month}
AND D.IS_DELETED = 0
AND D.IS_DEFECT='1'
and D.DEFECT_GRADING IS NOT NULL
<if test="createDept != null and createDept.size > 0"> <if test="createDept != null and createDept.size > 0">
and D.CREATE_DEPT in AND P.CREATE_DEPT in
<foreach collection="createDept" item="item" index="index" open="(" close=")" separator=","> <foreach collection="createDept" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java

@ -919,12 +919,14 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
List<Integer> list = this.baseMapper.getManageIndex(month, createDeptList); List<Integer> list = this.baseMapper.getManageIndex(month, createDeptList);
manageIndex.setInTimeNum(list.get(0)); manageIndex.setInTimeNum(list.get(0));
if (!list.get(1).equals(0)) { if (!list.get(1).equals(0)) {
manageIndex.setInTimeRatio(list.get(0).equals(0) ? 0.0 : Double.valueOf(list.get(0)) / list.get(1)); double inTimeRatio = new BigDecimal(list.get(0)).divide(new BigDecimal(list.get(1)), 2, BigDecimal.ROUND_UP).doubleValue();
manageIndex.setInTimeRatio(list.get(0).equals(0) ? 0.0 : inTimeRatio);
} }
manageIndex.setHistoryRemindNum(list.get(3)); manageIndex.setHistoryRemindNum(list.get(3));
manageIndex.setMonthRemindNum(list.get(2)); manageIndex.setMonthRemindNum(list.get(2));
if (!list.get(4).equals(0)) { if (!list.get(4).equals(0)) {
manageIndex.setDealRatio(list.get(1).equals(0) ? 0.0 : Double.valueOf(list.get(1)) / list.get(4)); double dealRatio = new BigDecimal(list.get(1)).divide(new BigDecimal(list.get(4)), 2, BigDecimal.ROUND_UP).doubleValue();
manageIndex.setDealRatio(list.get(1).equals(0) ? 0.0 : dealRatio);
} }
return manageIndex; return manageIndex;
} }
@ -1043,10 +1045,12 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
ratio.setSovleNum(dto.getDefectNum()); ratio.setSovleNum(dto.getDefectNum());
ratio.setSovleRatio(Double.valueOf(dto.getDefectNum()) / collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum()); ratio.setSovleRatio(Double.valueOf(dto.getDefectNum()) / collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum());
ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum()); ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum());
ratio.setHappenRatio(ratio.getHappenNum() / Double.valueOf(total)); double v = new BigDecimal(ratio.getHappenNum()).divide(new BigDecimal(total), 2, BigDecimal.ROUND_UP).doubleValue();
ratio.setHappenRatio(v);
} else { } else {
ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum()); ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum());
ratio.setHappenRatio(ratio.getHappenNum() / Double.valueOf(total)); double v = new BigDecimal(ratio.getHappenNum()).divide(new BigDecimal(total), 2, BigDecimal.ROUND_UP).doubleValue();
ratio.setHappenRatio(v);
} }
} }

Loading…
Cancel
Save