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-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentStatisticCountDO.java | 24 ++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentStatisticDTO.java | 23 ++ incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/AccidentCountByGradeRPCRespDTO.java | 50 +++++ emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencySuppliesInfoRespDTO.java | 86 ++++++++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java | 6 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentCountByGradeRespDTO.java | 50 +++++ emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencySuppliesInfoServiceImpl.java | 6 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java | 54 +++++ emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencySuppliesInfoService.java | 2 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java | 1 emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java | 19 + incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentStatisticCountRPCRespDTO.java | 25 ++ incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml | 19 + emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencySuppliesService.java | 7 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java | 2 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java | 2 emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencySuppliesInfoRPCRespDTO.java | 89 ++++++++ emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyRpcProvider.java | 23 ++ incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java | 58 +++++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java | 5 safePlatfrom-out-web/src/main/resources/config/application.yaml | 2 emergency/emergency-service/src/main/resources/config/mapper/emergency/EmergencySuppliesInfoMapper.xml | 14 + emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencySuppliesInfoRepository.java | 3 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java | 10 + incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java | 4 emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java | 2 incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java | 7 27 files changed, 574 insertions(+), 19 deletions(-) diff --git a/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java b/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java index d54c4dc..25daa34 100644 --- a/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java +++ b/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java @@ -56,5 +56,7 @@ ResultVO<List<StatisticsDepLevelMonthEexcuteRPCRespDTO>> getExecuteCountByDeptIdsAndMonth(EmergencyExecuteCountRPCReq query); // RPC接口--6、传入部门ID,指定年份 ,查询部门以及子级部门演练数据 并按部门等级,月份,统计演练次数 ResultVO<List<StatisticsDepLevelYearExecuteRPCRespDTO>> getExecuteCountByDeptIdsAndYear(EmergencyExecuteCountRPCReq query); + ResultVO<List<EmergencySuppliesInfoRPCRespDTO>> getEmergencySupplies(); + } diff --git a/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencySuppliesInfoRPCRespDTO.java b/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencySuppliesInfoRPCRespDTO.java new file mode 100644 index 0000000..535a60f --- /dev/null +++ b/emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencySuppliesInfoRPCRespDTO.java @@ -0,0 +1,89 @@ +package com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp; + + + +public class EmergencySuppliesInfoRPCRespDTO { + private Long id; + + private String name; + private String number; + private Long departmentId; + private String classification; + private String classificationName; + private String place; + private Integer count; + private String departmentName; + + public String getDepartmentName() { + return departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public Long getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(Long departmentId) { + this.departmentId = departmentId; + } + + public String getClassification() { + return classification; + } + + public void setClassification(String classification) { + this.classification = classification; + } + + public String getPlace() { + return place; + } + + public void setPlace(String place) { + this.place = place; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getClassificationName() { + return classificationName; + } + + public void setClassificationName(String classificationName) { + this.classificationName = classificationName; + } + +} diff --git a/emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyRpcProvider.java b/emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyRpcProvider.java index 52220f8..91dc006 100644 --- a/emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyRpcProvider.java +++ b/emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyRpcProvider.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @DubboService public class EmergencyRpcProvider implements EmergencyRpcAPi { @@ -314,5 +315,27 @@ return result; } + @Override + public ResultVO<List<EmergencySuppliesInfoRPCRespDTO>> getEmergencySupplies() { + ResultVO<List<EmergencySuppliesInfoRPCRespDTO>> result = new ResultVO<>(ResultCodes.OK); + try{ + List<EmergencySuppliesInfoRespDTO> emergencySupplies = emergencySuppliesService.getEmergencySupplies(); + List<EmergencySuppliesInfoRPCRespDTO> collect = emergencySupplies.stream().map(es -> { + EmergencySuppliesInfoRPCRespDTO emergencySuppliesInfoRPCRespDTO = new EmergencySuppliesInfoRPCRespDTO(); + BeanUtils.copyProperties(es, emergencySuppliesInfoRPCRespDTO); + return emergencySuppliesInfoRPCRespDTO; + }).collect(Collectors.toList()); + result.setData(collect); + }catch (EmergencyException e){ + result.setCode(e.getCode()); + result.setMsg(e.getMessage()); + }catch (Exception e) { + e.printStackTrace(); + result.setCode(EmergencyResultCodes.ERROR.getCode()); + result.setMsg(EmergencyResultCodes.ERROR.getDesc()); + } + return result; + } + } diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencySuppliesInfoRespDTO.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencySuppliesInfoRespDTO.java new file mode 100644 index 0000000..db297b0 --- /dev/null +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencySuppliesInfoRespDTO.java @@ -0,0 +1,86 @@ +package com.gkhy.safePlatform.emergency.model.dto.resp; + +public class EmergencySuppliesInfoRespDTO { + private Long id; + + private String name; + private String number; + private Long departmentId; + private String classification; + private String classificationName; + private String place; + private Integer count; + private String departmentName; + + public String getDepartmentName() { + return departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public Long getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(Long departmentId) { + this.departmentId = departmentId; + } + + public String getClassification() { + return classification; + } + + public void setClassification(String classification) { + this.classification = classification; + } + + public String getPlace() { + return place; + } + + public void setPlace(String place) { + this.place = place; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getClassificationName() { + return classificationName; + } + + public void setClassificationName(String classificationName) { + this.classificationName = classificationName; + } +} diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencySuppliesInfoRepository.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencySuppliesInfoRepository.java index 8aec9d6..4c5a871 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencySuppliesInfoRepository.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencySuppliesInfoRepository.java @@ -31,4 +31,7 @@ List<EmergencySuppliesInfo> listCountByIds(@Param("ids")List<Long> ids,@Param("delFlag") Byte delFlag,@Param("status") Byte status); + + List<EmergencySuppliesInfo> getAllEmergencySupplies(); + } diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencySuppliesService.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencySuppliesService.java index bf6d411..1b153fc 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencySuppliesService.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencySuppliesService.java @@ -5,10 +5,7 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.emergency.model.dto.req.EmergencySuppliesReqDTO; -import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesDetailRespDTO; -import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesPageRespDTO; -import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesRespDTO; -import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesTypeRespDTO; +import com.gkhy.safePlatform.emergency.model.dto.resp.*; import com.gkhy.safePlatform.emergency.query.EmergencySuppliesQuery; import java.util.List; @@ -31,4 +28,6 @@ List<EmergencySuppliesTypeRespDTO> emergencySuppliesList(ContextCacheUser currentUser); List<EmergencySuppliesRespDTO> listCountByIds(ContextCacheUser currentUser, List<Long> ids); + List<EmergencySuppliesInfoRespDTO> getEmergencySupplies(); + } diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencySuppliesInfoService.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencySuppliesInfoService.java index 795c46a..60aefda 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencySuppliesInfoService.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencySuppliesInfoService.java @@ -28,4 +28,6 @@ List<EmergencySuppliesInfo> listByNoConditions(); List<EmergencySuppliesInfo> listCountByIds(List<Long> ids); + + List<EmergencySuppliesInfo> getAllEmergencySupplies(); } diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencySuppliesInfoServiceImpl.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencySuppliesInfoServiceImpl.java index 7987312..6f86c50 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencySuppliesInfoServiceImpl.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencySuppliesInfoServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.List; @Service("emergencySuppliesInfoService") @@ -71,5 +72,8 @@ return baseMapper.listCountByIds(ids, (byte) 0,EmergencySuppliesStatusEnum.STATUS_ONE.getCode()); } - + @Override + public List<EmergencySuppliesInfo> getAllEmergencySupplies() { + return baseMapper.getAllEmergencySupplies(); + } } diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java index c7ac66d..b05a09b 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java @@ -281,4 +281,23 @@ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_ENUM_STATUS_NOT_EXIST); } } + + public List<EmergencySuppliesInfoRespDTO> getEmergencySupplies(){ + List<EmergencySuppliesInfo> allEmergencySupplies = emergencySuppliesInfoService.getAllEmergencySupplies(); + List<EmergencySuppliesInfoRespDTO> collect = allEmergencySupplies.stream().map(es -> { + EmergencySuppliesInfoRespDTO e = new EmergencySuppliesInfoRespDTO(); + BeanUtils.copyProperties(es,e); + e.setClassificationName(EmergencySuppliesClassificationEnum.getByCode(es.getClassification()).getValue()); + ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(es.getDepartmentId()); + if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) { + if (rpcResult.getData() != null) { + DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData(); + e.setDepartmentName(dep.getDepName()); + } + } + return e; + }).collect(Collectors.toList()); + return collect; + + } } diff --git a/emergency/emergency-service/src/main/resources/config/mapper/emergency/EmergencySuppliesInfoMapper.xml b/emergency/emergency-service/src/main/resources/config/mapper/emergency/EmergencySuppliesInfoMapper.xml index fd9b894..06bbf66 100644 --- a/emergency/emergency-service/src/main/resources/config/mapper/emergency/EmergencySuppliesInfoMapper.xml +++ b/emergency/emergency-service/src/main/resources/config/mapper/emergency/EmergencySuppliesInfoMapper.xml @@ -173,5 +173,19 @@ #{id} </foreach> </select> + <select id="getAllEmergencySupplies" resultType="com.gkhy.safePlatform.emergency.entity.EmergencySuppliesInfo"> + select id, + name, + number, + model, + count, + classification, + place, + use_explain, + department_id + from emergency_supplies + where del_flag = 0 + </select> + </mapper> diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java index 248a8c6..3793536 100644 --- a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java @@ -3,9 +3,7 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req.IncidentManageCountRPCReq; -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 java.util.List; @@ -27,4 +25,7 @@ ResultVO<List<StatisticsDepLevelMonthAccidentRPCRespDTO>> getAccidentCountByDeptIdsAndMonth(IncidentManageCountRPCReq query); // RPC接口--4、传入部门ID,指定年份 ,查询部门以及子级部门演练数据 并按部门等级,月份,统计演练次数 ResultVO<List<StatisticsDeptLevelYearAccidentRPCRespDTO>> getAccidentCountByDeptIdsAndYear(IncidentManageCountRPCReq query); + + ResultVO<List<IncidentStatisticCountRPCRespDTO>> getAccidentCountByGradeAndTime(IncidentManageCountRPCReq query); + ResultVO<AccidentCountByGradeRPCRespDTO> getSpiAccidentCountByGradeAndTime(IncidentManageCountRPCReq query); } diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/AccidentCountByGradeRPCRespDTO.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/AccidentCountByGradeRPCRespDTO.java new file mode 100644 index 0000000..2f4fda8 --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/AccidentCountByGradeRPCRespDTO.java @@ -0,0 +1,50 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; + + +public class AccidentCountByGradeRPCRespDTO { + private int accidentOne; + private int accidentTwo; + private int accidentThree; + private int accidentFour; + private int accidentTotal; + + public int getAccidentOne() { + return accidentOne; + } + + public void setAccidentOne(int accidentOne) { + this.accidentOne = accidentOne; + } + + public int getAccidentTwo() { + return accidentTwo; + } + + public void setAccidentTwo(int accidentTwo) { + this.accidentTwo = accidentTwo; + } + + public int getAccidentThree() { + return accidentThree; + } + + public void setAccidentThree(int accidentThree) { + this.accidentThree = accidentThree; + } + + public int getAccidentFour() { + return accidentFour; + } + + public void setAccidentFour(int accidentFour) { + this.accidentFour = accidentFour; + } + + public int getAccidentTotal() { + return accidentTotal; + } + + public void setAccidentTotal(int accidentTotal) { + this.accidentTotal = accidentTotal; + } +} diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentStatisticCountRPCRespDTO.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentStatisticCountRPCRespDTO.java new file mode 100644 index 0000000..965ccd9 --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentStatisticCountRPCRespDTO.java @@ -0,0 +1,25 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; + + + +public class IncidentStatisticCountRPCRespDTO { + + private String accidentGrade; + private int count; + + public String getAccidentGrade() { + return accidentGrade; + } + + public void setAccidentGrade(String accidentGrade) { + this.accidentGrade = accidentGrade; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} 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; + } } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java index ac02cf6..effc382 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java @@ -1,7 +1,9 @@ package com.gkhy.safePlatform.incidentManage.controller; +import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO; +import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentStatisticDTO; import com.gkhy.safePlatform.incidentManage.model.dto.resp.StatisticsDepLevelMonthAccidentRespDTO; import com.gkhy.safePlatform.incidentManage.model.dto.resp.StatisticsDeptLevelYearAccidentRespDTO; import com.gkhy.safePlatform.incidentManage.query.AccidentReportCountQuery; @@ -63,4 +65,12 @@ public List<StatisticsDeptLevelYearAccidentRespDTO> getCountByDeptIdsAndYear(@RequestBody IncidentManageCountQuery query){ return accidentCountService.getCountByDeptIdsAndYear(query); } + /** + * 事故统计,根据事故级别统计 + */ + @RequestMapping(value = "/accidentGrade/count",method = RequestMethod.GET) + public ResultVO getCountByAccidentGrade(Integer year, Integer month){ + return new ResultVO<>(ResultCodes.OK,accidentCountService.getCountByAccidentGrade(year, month)); + } + } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentStatisticCountDO.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentStatisticCountDO.java new file mode 100644 index 0000000..6d8f0bd --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentStatisticCountDO.java @@ -0,0 +1,24 @@ +package com.gkhy.safePlatform.incidentManage.entity; + + + +public class AccidentStatisticCountDO { + private Byte accidentGrade; + private int count; + + public Byte getAccidentGrade() { + return accidentGrade; + } + + public void setAccidentGrade(Byte accidentGrade) { + this.accidentGrade = accidentGrade; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentCountByGradeRespDTO.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentCountByGradeRespDTO.java new file mode 100644 index 0000000..ed01199 --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentCountByGradeRespDTO.java @@ -0,0 +1,50 @@ +package com.gkhy.safePlatform.incidentManage.model.dto.resp; + + +public class AccidentCountByGradeRespDTO { + private int accidentOne; + private int accidentTwo; + private int accidentThree; + private int accidentFour; + private int accidentTotal; + + public int getAccidentOne() { + return accidentOne; + } + + public void setAccidentOne(int accidentOne) { + this.accidentOne = accidentOne; + } + + public int getAccidentTwo() { + return accidentTwo; + } + + public void setAccidentTwo(int accidentTwo) { + this.accidentTwo = accidentTwo; + } + + public int getAccidentThree() { + return accidentThree; + } + + public void setAccidentThree(int accidentThree) { + this.accidentThree = accidentThree; + } + + public int getAccidentFour() { + return accidentFour; + } + + public void setAccidentFour(int accidentFour) { + this.accidentFour = accidentFour; + } + + public int getAccidentTotal() { + return accidentTotal; + } + + public void setAccidentTotal(int accidentTotal) { + this.accidentTotal = accidentTotal; + } +} diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentStatisticDTO.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentStatisticDTO.java new file mode 100644 index 0000000..5b1d819 --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentStatisticDTO.java @@ -0,0 +1,23 @@ +package com.gkhy.safePlatform.incidentManage.model.dto.resp; + + +public class AccidentStatisticDTO { + private String accidentGrade; + private int count; + + public String getAccidentGrade() { + return accidentGrade; + } + + public void setAccidentGrade(String accidentGrade) { + this.accidentGrade = accidentGrade; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java index 2986891..56ab8fe 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java @@ -32,4 +32,6 @@ List<AccidentResultCountDO> getAccidentCountByDeptIdsAndTime(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("deptIds")List<Long> deptIds); List<AccidentResultCountDO> getAccidentCountByDeptIdAndTime(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("deptId")Long deptId); + + List<AccidentStatisticCountDO> getCountByAccidentGrade(@Param("year")Integer year, @Param("month")Integer month); } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java index 8d364ae..e82aca1 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java @@ -2,9 +2,7 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; -import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO; -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.AccidentReportCountQuery; import com.gkhy.safePlatform.incidentManage.query.IncidentManageCountQuery; import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req.IncidentManageCountRPCReq; @@ -31,4 +29,6 @@ List<StatisticsDeptLevelYearAccidentRespDTO> getCountByDeptIdsAndYear(IncidentManageCountQuery query); List<StatisticsDepLevelMonthAccidentRespDTO> getCountByDeptIdsAndMonth(IncidentManageCountQuery query); + List<AccidentStatisticDTO> getCountByAccidentGrade(Integer year, Integer month); + AccidentCountByGradeRespDTO getSpiAccidentCountByAccidentGrade(Integer year, Integer month); } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java index 9f6b0ad..1b29d60 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java @@ -6,6 +6,7 @@ import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportReqDTO; import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportDetailRespDTO; import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportPageRespDTO; +import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentStatisticDTO; import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery; import java.util.List; diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java index a515cc6..798e99a 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java @@ -30,4 +30,6 @@ List<AccidentResultCountDO> getAccidentCountByDeptIdsAndTime(String startTime, String endTime, List<Long> deptIds); List<AccidentResultCountDO> getAccidentCountByDeptIdAndTime(String startTime, String endTime, Long deptId); + + List<AccidentStatisticCountDO> getCountByAccidentGrade(Integer year, Integer month); } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java index 0fa4e9d..155e7a6 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java @@ -77,4 +77,9 @@ return accidentReportInfoRepository.getAccidentCountByDeptIdAndTime(startTime,endTime,deptId); } + @Override + public List<AccidentStatisticCountDO> getCountByAccidentGrade(Integer year, Integer month) { + return accidentReportInfoRepository.getCountByAccidentGrade(year,month); + } + } 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; + } } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java index 72b3cc9..958088c 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java @@ -31,6 +31,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -331,4 +333,6 @@ } } + + } diff --git a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml index fde785e..94ea4c4 100644 --- a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml +++ b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml @@ -327,4 +327,23 @@ DATE_FORMAT( a.gmt_create, '%Y-%m' ), DATE_FORMAT( a.gmt_create, '%m' ) </select> + + <select id="getCountByAccidentGrade" resultType="com.gkhy.safePlatform.incidentManage.entity.AccidentStatisticCountDO"> + SELECT + a.accident_grade, + count( id ) count + FROM + accident_report a + WHERE + a.del_flag = 0 + <if test="year != null"> + AND YEAR ( a.gmt_create ) = #{year} + </if> + <if test="month != null"> + AND MONTH ( a.gmt_create ) = #{month} + </if> + GROUP BY + a.accident_grade + </select> + </mapper> diff --git a/safePlatfrom-out-web/src/main/resources/config/application.yaml b/safePlatfrom-out-web/src/main/resources/config/application.yaml index 640b5fb..0a373c5 100644 --- a/safePlatfrom-out-web/src/main/resources/config/application.yaml +++ b/safePlatfrom-out-web/src/main/resources/config/application.yaml @@ -4,7 +4,7 @@ profiles: #active: uat #### dev out-dev test uat online-uat guotai-demo - active: guotai-prod + active: dev # active: online-uat 线上预发环境 # active: dev 本地开发环境 # active: out-dev 外包对接环境 -- Gitblit v1.9.2