From 1305d0aa469fe7330fd2f8e9fbb10d95042571be Mon Sep 17 00:00:00 2001 From: zhangfeng <1603559716@qq.com> Date: 星期一, 10 十月 2022 12:33:36 +0800 Subject: [PATCH] 应急系统和事故管理统计接口 --- incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 0 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 1a1bd5e..4cc8a20 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 @@ -1,14 +1,28 @@ package com.gkhy.safePlatform.incidentManage.rpc.provider; +import com.gkhy.safePlatform.commons.enums.ResultCodes; +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.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.service.AccidentCountService; +import org.apache.commons.collections.CollectionUtils; import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; import java.util.List; @DubboService @@ -26,4 +40,146 @@ public SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query) { return accidentCountService.getCountByDeptIds(query); } + + @Override + public ResultVO<StatisticsDepLevelMonthAccidentRPCRespDTO> getAccidentCountByDeptIdAndMonth(IncidentManageCountRPCReq query) { + ResultVO<StatisticsDepLevelMonthAccidentRPCRespDTO> result = new ResultVO<>(ResultCodes.OK); + IncidentManageCountQuery countQuery = new IncidentManageCountQuery(); + countQuery.setDeptId(query.getDeptId()); + countQuery.setYear(query.getYear()); + countQuery.setMonth(query.getMonth()); + try{ + StatisticsDepLevelMonthAccidentRespDTO accidentRespDTO = accidentCountService.getCountByDeptIdAndMonth(countQuery); + StatisticsDepLevelMonthAccidentRPCRespDTO accidentRPCRespDTO = new StatisticsDepLevelMonthAccidentRPCRespDTO(); + accidentRPCRespDTO.setMonth(accidentRespDTO.getMonth()); + accidentRPCRespDTO.setDepLevel(accidentRespDTO.getDepLevel()); + List<AccidentLevelResultCountRespDTO> accidentLevelList = accidentRespDTO.getAccidentLevelList(); + if(!CollectionUtils.isEmpty(accidentLevelList)){ + List<AccidentLevelResultCountRPCRespDTO> resultCountRPCRespDTOList = BeanCopyUtils.copyBeanList(accidentLevelList, AccidentLevelResultCountRPCRespDTO.class); + accidentRPCRespDTO.setAccidentLevelList(resultCountRPCRespDTOList); + } + result.setData(accidentRPCRespDTO); + }catch (AccidentException 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<StatisticsDeptLevelYearAccidentRPCRespDTO> getAccidentCountByDeptIdAndYear(IncidentManageCountRPCReq query) { + ResultVO<StatisticsDeptLevelYearAccidentRPCRespDTO> result = new ResultVO<>(ResultCodes.OK); + IncidentManageCountQuery countQuery = new IncidentManageCountQuery(); + countQuery.setDeptId(query.getDeptId()); + countQuery.setYear(query.getYear()); + countQuery.setMonth(query.getMonth()); + try{ + StatisticsDeptLevelYearAccidentRespDTO accidentRespDTO = accidentCountService.getCountByDeptIdAndYear(countQuery); + StatisticsDeptLevelYearAccidentRPCRespDTO accidentRPCRespDTO = new StatisticsDeptLevelYearAccidentRPCRespDTO(); + accidentRPCRespDTO.setYear(accidentRespDTO.getYear()); + accidentRPCRespDTO.setDepLevel(accidentRespDTO.getDepLevel()); + List<StatisticsDepLevelMonthAccidentRespDTO> monthList = accidentRespDTO.getMonthList(); + List<StatisticsDepLevelMonthAccidentRPCRespDTO> monthAccidentRPCRespDTOList = new ArrayList<>(); + if(!CollectionUtils.isEmpty(monthList)){ + for(StatisticsDepLevelMonthAccidentRespDTO monthAccidentRespDTO : monthList){ + StatisticsDepLevelMonthAccidentRPCRespDTO monthAccidentRPCRespDTO = new StatisticsDepLevelMonthAccidentRPCRespDTO(); + monthAccidentRPCRespDTO.setMonth(monthAccidentRespDTO.getMonth()); + monthAccidentRPCRespDTO.setDepLevel(monthAccidentRespDTO.getDepLevel()); + List<AccidentLevelResultCountRespDTO> accidentLevelList = monthAccidentRespDTO.getAccidentLevelList(); + if(!CollectionUtils.isEmpty(accidentLevelList)){ + List<AccidentLevelResultCountRPCRespDTO> resultCountRPCRespDTOList = BeanCopyUtils.copyBeanList(accidentLevelList, AccidentLevelResultCountRPCRespDTO.class); + monthAccidentRPCRespDTO.setAccidentLevelList(resultCountRPCRespDTOList); + } + monthAccidentRPCRespDTOList.add(monthAccidentRPCRespDTO); + } + } + accidentRPCRespDTO.setMonthList(monthAccidentRPCRespDTOList); + result.setData(accidentRPCRespDTO); + }catch (AccidentException 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<List<StatisticsDepLevelMonthAccidentRPCRespDTO>> getAccidentCountByDeptIdsAndMonth(IncidentManageCountRPCReq query) { + ResultVO<List<StatisticsDepLevelMonthAccidentRPCRespDTO>> result = new ResultVO<>(ResultCodes.OK); + IncidentManageCountQuery countQuery = new IncidentManageCountQuery(); + countQuery.setDeptId(query.getDeptId()); + countQuery.setYear(query.getYear()); + countQuery.setMonth(query.getMonth()); + try{ + List<StatisticsDepLevelMonthAccidentRespDTO> accidentRespDTOList = accidentCountService.getCountByDeptIdsAndMonth(countQuery); + List<StatisticsDepLevelMonthAccidentRPCRespDTO> accidentRPCRespDTOList = new ArrayList<>(); + for(StatisticsDepLevelMonthAccidentRespDTO accidentRespDTO:accidentRespDTOList){ + StatisticsDepLevelMonthAccidentRPCRespDTO accidentRPCRespDTO = new StatisticsDepLevelMonthAccidentRPCRespDTO(); + accidentRPCRespDTO.setMonth(accidentRespDTO.getMonth()); + accidentRPCRespDTO.setDepLevel(accidentRespDTO.getDepLevel()); + List<AccidentLevelResultCountRespDTO> accidentLevelList = accidentRespDTO.getAccidentLevelList(); + if(!CollectionUtils.isEmpty(accidentLevelList)){ + List<AccidentLevelResultCountRPCRespDTO> resultCountRPCRespDTOList = BeanCopyUtils.copyBeanList(accidentLevelList, AccidentLevelResultCountRPCRespDTO.class); + accidentRPCRespDTO.setAccidentLevelList(resultCountRPCRespDTOList); + } + accidentRPCRespDTOList.add(accidentRPCRespDTO); + } + result.setData(accidentRPCRespDTOList); + }catch (AccidentException 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<List<StatisticsDeptLevelYearAccidentRPCRespDTO>> getAccidentCountByDeptIdsAndYear(IncidentManageCountRPCReq query) { + ResultVO<List<StatisticsDeptLevelYearAccidentRPCRespDTO>> result = new ResultVO<>(ResultCodes.OK); + IncidentManageCountQuery countQuery = new IncidentManageCountQuery(); + countQuery.setDeptId(query.getDeptId()); + countQuery.setYear(query.getYear()); + countQuery.setMonth(query.getMonth()); + try{ + List<StatisticsDeptLevelYearAccidentRespDTO> yearAccidentRespDTOList = accidentCountService.getCountByDeptIdsAndYear(countQuery); + List<StatisticsDeptLevelYearAccidentRPCRespDTO> accidentRPCRespDTOList = new ArrayList<>(); + for(StatisticsDeptLevelYearAccidentRespDTO yearAccidentRespDTO:yearAccidentRespDTOList){ + StatisticsDeptLevelYearAccidentRPCRespDTO yearAccidentRPCRespDTO = new StatisticsDeptLevelYearAccidentRPCRespDTO(); + yearAccidentRPCRespDTO.setYear(yearAccidentRespDTO.getYear()); + yearAccidentRPCRespDTO.setDepLevel(yearAccidentRespDTO.getDepLevel()); + List<StatisticsDepLevelMonthAccidentRespDTO> monthList = yearAccidentRespDTO.getMonthList(); + List<StatisticsDepLevelMonthAccidentRPCRespDTO> monthAccidentRPCRespDTOList = new ArrayList<>(); + if(!CollectionUtils.isEmpty(monthList)){ + for(StatisticsDepLevelMonthAccidentRespDTO monthAccidentRespDTO:monthList){ + StatisticsDepLevelMonthAccidentRPCRespDTO monthAccidentRPCRespDTO = new StatisticsDepLevelMonthAccidentRPCRespDTO(); + monthAccidentRPCRespDTO.setMonth(monthAccidentRespDTO.getMonth()); + monthAccidentRPCRespDTO.setDepLevel(monthAccidentRespDTO.getDepLevel()); + List<AccidentLevelResultCountRespDTO> accidentLevelList = monthAccidentRespDTO.getAccidentLevelList(); + if (!CollectionUtils.isEmpty(accidentLevelList)) { + List<AccidentLevelResultCountRPCRespDTO> resultCountRPCRespDTOList = BeanCopyUtils.copyBeanList(accidentLevelList, AccidentLevelResultCountRPCRespDTO.class); + monthAccidentRPCRespDTO.setAccidentLevelList(resultCountRPCRespDTOList); + } + monthAccidentRPCRespDTOList.add(monthAccidentRPCRespDTO); + } + } + accidentRPCRespDTOList.add(yearAccidentRPCRespDTO); + + } + result.setData(accidentRPCRespDTOList); + }catch (AccidentException 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