From 0414ddb0b2b3a7199ae6181a770f97ac140dbd73 Mon Sep 17 00:00:00 2001
From: zhangf <1603559716@qq.com>
Date: 星期三, 08 五月 2024 16:46:22 +0800
Subject: [PATCH] spi统计

---
 incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java b/incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java
index 4cc8a20..39c1f2e 100644
--- a/incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java
+++ b/incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java
@@ -2,24 +2,21 @@
 
 
 import com.gkhy.safePlatform.commons.enums.ResultCodes;
+import com.gkhy.safePlatform.commons.exception.BusinessException;
 import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
 import com.gkhy.safePlatform.commons.vo.ResultVO;
 import com.gkhy.safePlatform.commons.vo.SearchResultVO;
 import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes;
 import com.gkhy.safePlatform.incidentManage.exception.AccidentException;
-import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentLevelResultCountRespDTO;
-import com.gkhy.safePlatform.incidentManage.model.dto.resp.StatisticsDepLevelMonthAccidentRespDTO;
-import com.gkhy.safePlatform.incidentManage.model.dto.resp.StatisticsDeptLevelYearAccidentRespDTO;
+import com.gkhy.safePlatform.incidentManage.model.dto.resp.*;
 import com.gkhy.safePlatform.incidentManage.query.IncidentManageCountQuery;
 import com.gkhy.safePlatform.incidentManage.rpc.api.IncidentManageRpcAPi;
 import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req.IncidentManageCountRPCReq;
-import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.AccidentLevelResultCountRPCRespDTO;
-import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.IncidentManageRPCResp;
-import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.StatisticsDepLevelMonthAccidentRPCRespDTO;
-import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.StatisticsDeptLevelYearAccidentRPCRespDTO;
+import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.*;
 import com.gkhy.safePlatform.incidentManage.service.AccidentCountService;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.ArrayList;
@@ -182,4 +179,51 @@
         }
         return result;
     }
+
+    @Override
+    public ResultVO<List<IncidentStatisticCountRPCRespDTO>> getAccidentCountByGradeAndTime(IncidentManageCountRPCReq query){
+        ResultVO<List<IncidentStatisticCountRPCRespDTO>> result = new ResultVO<>(ResultCodes.OK);
+        try{
+            List<AccidentStatisticDTO> countByAccidentGradeList = accidentCountService.getCountByAccidentGrade(query.getYear(), query.getMonth());
+
+            List<IncidentStatisticCountRPCRespDTO> statisticCountRPCRespDTOList = new ArrayList<>();
+            for(AccidentStatisticDTO accidentStatisticDTO:countByAccidentGradeList){
+                IncidentStatisticCountRPCRespDTO accidentRPCRespDTO = new IncidentStatisticCountRPCRespDTO();
+                accidentRPCRespDTO.setAccidentGrade(accidentStatisticDTO.getAccidentGrade());
+                accidentRPCRespDTO.setCount(accidentStatisticDTO.getCount());
+                statisticCountRPCRespDTOList.add(accidentRPCRespDTO);
+            }
+            result.setData(statisticCountRPCRespDTOList);
+        }catch (AccidentException e){
+            result.setCode(e.getCode());
+            result.setMsg(e.getMessage());
+        }catch (BusinessException e){
+            result.setCode(e.getCode());
+            result.setMsg(e.getMessage());
+        }catch (Exception e) {
+            result.setCode(AccidentResultCodes.ERROR.getCode());
+            result.setMsg(AccidentResultCodes.ERROR.getDesc());
+        }
+        return result;
+    }
+    @Override
+    public ResultVO<AccidentCountByGradeRPCRespDTO> getSpiAccidentCountByGradeAndTime(IncidentManageCountRPCReq query){
+        ResultVO<AccidentCountByGradeRPCRespDTO> result = new ResultVO<>(ResultCodes.OK);
+        try{
+            AccidentCountByGradeRespDTO accidentCountByGradeRespDTO = accidentCountService.getSpiAccidentCountByAccidentGrade(query.getYear(), query.getMonth());
+            AccidentCountByGradeRPCRespDTO accidentRPCRespDTO = new AccidentCountByGradeRPCRespDTO();
+            BeanUtils.copyProperties(accidentCountByGradeRespDTO, accidentRPCRespDTO);
+            result.setData(accidentRPCRespDTO);
+        }catch (AccidentException e){
+            result.setCode(e.getCode());
+            result.setMsg(e.getMessage());
+        }catch (BusinessException e){
+            result.setCode(e.getCode());
+            result.setMsg(e.getMessage());
+        }catch (Exception e) {
+            result.setCode(AccidentResultCodes.ERROR.getCode());
+            result.setMsg(AccidentResultCodes.ERROR.getDesc());
+        }
+        return result;
+    }
 }

--
Gitblit v1.9.2