From 0414ddb0b2b3a7199ae6181a770f97ac140dbd73 Mon Sep 17 00:00:00 2001
From: zhangf <1603559716@qq.com>
Date: Wed, 08 May 2024 16:46:22 +0800
Subject: [PATCH] spi统计
---
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java
index 14a25f3..9349596 100644
--- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java
+++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java
@@ -2,6 +2,7 @@
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO;
+import com.gkhy.safePlatform.commons.enums.E;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
@@ -9,6 +10,7 @@
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.incidentManage.entity.*;
+import com.gkhy.safePlatform.incidentManage.enums.AccidentReportGradeEnum;
import com.gkhy.safePlatform.incidentManage.enums.AccidentReportLevelEnum;
import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes;
import com.gkhy.safePlatform.incidentManage.enums.DepartmentLevelEnum;
@@ -30,6 +32,7 @@
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
+import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@@ -558,4 +561,55 @@
}
return respDTOList;
}
+
+ /**
+ * 统计数据
+ */
+ @Override
+ public List<AccidentStatisticDTO> getCountByAccidentGrade(Integer year, Integer month) {
+ if(null == year && null != month){
+ throw new BusinessException(ResultCodes.CLIENT_PARAM_ERROR,"年份不可为空");
+ }
+ if(null == year && null == month) {
+ year = LocalDate.now().getYear();
+ }
+ List<AccidentStatisticDTO> accidentStatisticDTOList = new ArrayList<>();
+ List<AccidentStatisticCountDO> countByAccidentGrades = accidentReportInfoService.getCountByAccidentGrade(year, month);
+ for (AccidentReportGradeEnum gradeEnum : AccidentReportGradeEnum.values()) {
+ AccidentStatisticDTO accidentStatisticDTO = new AccidentStatisticDTO();
+ accidentStatisticDTO.setAccidentGrade(gradeEnum.getValue());
+ List<AccidentStatisticCountDO> collect = countByAccidentGrades.stream().filter(c -> c.getAccidentGrade().equals(gradeEnum.getCode())).collect(Collectors.toList());
+ accidentStatisticDTO.setCount(collect.size()>0 ? collect.get(0).getCount() : 0);
+ accidentStatisticDTOList.add(accidentStatisticDTO);
+ }
+ return accidentStatisticDTOList;
+ }
+
+ /**
+ * 统计数据
+ */
+ @Override
+ public AccidentCountByGradeRespDTO getSpiAccidentCountByAccidentGrade(Integer year, Integer month) {
+
+ List<AccidentStatisticCountDO> countByAccidentGrades = accidentReportInfoService.getCountByAccidentGrade(year, month);
+ AccidentCountByGradeRespDTO accidentCountByGradeRespDTO = new AccidentCountByGradeRespDTO();
+ int total = 0;
+ for (AccidentStatisticCountDO countByAccidentGrade : countByAccidentGrades) {
+ if(countByAccidentGrade.getAccidentGrade().equals(AccidentReportGradeEnum.GRADE_ONE.getCode())){
+ accidentCountByGradeRespDTO.setAccidentOne(countByAccidentGrade.getCount());
+ }
+ if(countByAccidentGrade.getAccidentGrade().equals(AccidentReportGradeEnum.GRADE_TWO.getCode())){
+ accidentCountByGradeRespDTO.setAccidentTwo(countByAccidentGrade.getCount());
+ }
+ if(countByAccidentGrade.getAccidentGrade().equals(AccidentReportGradeEnum.GRADE_THREE.getCode())){
+ accidentCountByGradeRespDTO.setAccidentThree(countByAccidentGrade.getCount());
+ }
+ if(countByAccidentGrade.getAccidentGrade().equals(AccidentReportGradeEnum.GRADE_FOUR.getCode())){
+ accidentCountByGradeRespDTO.setAccidentFour(countByAccidentGrade.getCount());
+ }
+ total += countByAccidentGrade.getCount();
+ }
+
+ return accidentCountByGradeRespDTO;
+ }
}
--
Gitblit v1.9.2