From 90a86453a5266a88c8cbdbbddc888070ccb8df29 Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期一, 05 九月 2022 18:47:46 +0800 Subject: [PATCH] rpc统计fix --- incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml | 64 ++++ incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountDetailRPCResp.java | 70 +++++ incident-manage/incident-manage-service/pom.xml | 17 + incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java | 11 incident-manage/incident-manage-rpc-provider/pom.xml | 20 + incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/req/IncidentManageCountRPCReq.java | 42 +++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java | 10 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java | 9 equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/model/dto/equ.zip | 0 incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java | 29 ++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java | 14 incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/IncidentManageCountData.java | 25 + incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java | 18 + incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentReportCountRPC.java | 78 ++++++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java | 2 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java | 149 +++++++++++ emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java | 5 incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java | 18 + incident-manage/incident-manage-rpc-api/pom.xml | 88 ++++++ incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountRPCResp.java | 30 ++ incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageRPCResp.java | 52 ++++ 21 files changed, 716 insertions(+), 35 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 7f97c87..4df5244 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 @@ -10,12 +10,15 @@ public interface EmergencyRpcAPi { - + // RPC接口--1、传入部门ID,查询该部门最后一次完成应急演练的时间 SearchResultVO<EmergencyExecuteTimeRPCResp> getTimeByDeptId(EmergencyExecuteTimeRPCReq query); + // RPC接口--2、传入部门ID,查询该部门及其子部门的最后一次完成应急演练的时间 SearchResultVO<List<EmergencyExecuteTimeRPCResp>> getTimeByDeptIds(EmergencyExecuteTimeRPCReq query); + // RPC接口--3、传入部门ID和年份月份,查询该部门在指定的年份,或者指定的月份的应急演练的次数 SearchResultVO<EmergencyExecuteNumRPCResp> getNumByDeptId(EmergencyExecuteNumRPCReq query); + // RPC接口--4、传入部门ID和年份月份,查询该部门及其子部门,在指定的年份,或者指定的月份的应急演练的次数 SearchResultVO<List<EmergencyExecuteNumRPCResp>> getNumByDeptIds(EmergencyExecuteNumRPCReq query); } diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/model/dto/equ.zip b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/model/dto/equ.zip new file mode 100644 index 0000000..a7b305a --- /dev/null +++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/model/dto/equ.zip Binary files differ diff --git a/incident-manage/incident-manage-rpc-api/pom.xml b/incident-manage/incident-manage-rpc-api/pom.xml index f274386..1c11129 100644 --- a/incident-manage/incident-manage-rpc-api/pom.xml +++ b/incident-manage/incident-manage-rpc-api/pom.xml @@ -2,18 +2,86 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>incident-manage</artifactId> - <groupId>com.gkhy.safePlatfrom</groupId> - <version>1.0-SNAPSHOT</version> - </parent> + <!-- <parent>--> + <!-- <artifactId>emergency</artifactId>--> + <!-- <groupId>com.gkhy.safePlatfrom</groupId>--> + <!-- <version>1.0-SNAPSHOT</version>--> + <!-- </parent>--> <modelVersion>4.0.0</modelVersion> + <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>com.gkhy.safePlatfrom</groupId> + <artifactId>commons</artifactId> + <version>1.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + </dependencies> + <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>incident-manage-rpc-api</artifactId> + <version>1.0-SNAPSHOT</version> - <properties> - <maven.compiler.source>8</maven.compiler.source> - <maven.compiler.target>8</maven.compiler.target> - </properties> -</project> \ No newline at end of file + <distributionManagement> + <!--稳定版本的仓库地址,必须是允许上传的私服地址--> + <repository> + <id>nexus-gkhy-releases</id> + <url>http://121.239.169.27:28080/repository/guotai-release/</url> + </repository> + <!--开发版本的仓库地址,必须是允许上传的私服地址--> + <snapshotRepository> + <id>nexus-gkhy-snapshots</id> + <url>http://121.239.169.27:28080/repository/guotai-snapshot/</url> + </snapshotRepository> + </distributionManagement> + + <build> + <extensions> + <extension> + <groupId>kr.motd.maven</groupId> + <artifactId>os-maven-plugin</artifactId> + </extension> + </extensions> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>src/main/java</source> + <!-- <source>build/generated/source/proto/main/java</source>--> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <!-- 上传源码 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>3.2.1</version> + <configuration> + <attach>true</attach> + </configuration> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + +</project> 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 new file mode 100644 index 0000000..1ef58be --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java @@ -0,0 +1,18 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api; + +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 java.util.List; + +public interface IncidentManageRpcAPi { + + // RPC接口--1、传入部门ID和年份、月份,查询该部门在指定年份、或者指定月份的事故统计,(特别重大、重大、较大、一般、未遂)这5个档次来分别统计, + // 并且统计不同等级的事故所造成的后果(死亡人数、重伤人数、轻伤人数、经济损失) + SearchResultVO<IncidentManageRPCResp> getCountByDeptId(IncidentManageCountRPCReq query); + + // RPC接口--1、传入部门ID和年份、月份,查询该部门及其子部门在指定年份、或者指定月份的事故统计,(特别重大、重大、较大、一般、未遂)这5个档次来分别统计, + // 并且统计不同等级的事故所造成的后果(死亡人数、重伤人数、轻伤人数、经济损失) + SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query); +} diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/IncidentManageCountData.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/IncidentManageCountData.java new file mode 100644 index 0000000..ec024e4 --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/IncidentManageCountData.java @@ -0,0 +1,25 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model; + + +public class IncidentManageCountData { + + private Integer num ; + + private String name ; + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/req/IncidentManageCountRPCReq.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/req/IncidentManageCountRPCReq.java new file mode 100644 index 0000000..e2e43a6 --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/req/IncidentManageCountRPCReq.java @@ -0,0 +1,42 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req; + +public class IncidentManageCountRPCReq { + + /** + * 1、指定年份,查该年度12个月份的 + * 2、指定年份月份,查该指定月份的 + */ + + // 部门id + private Long deptId; + + //年 + private Integer year; + + // 月 + private Integer month; + + public Long getDeptId() { + return deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + public Integer getMonth() { + return month; + } + + public void setMonth(Integer month) { + this.month = month; + } +} diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountDetailRPCResp.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountDetailRPCResp.java new file mode 100644 index 0000000..2aee10c --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountDetailRPCResp.java @@ -0,0 +1,70 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; + + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +public class IncidentManageCountDetailRPCResp { + + // 事故等级 + private String level ; + // 事故数量 + private Integer num ; + // 轻伤 + private Integer minorInjuryNum; + // 重伤 + private Integer seriousInjuryNum; + // 经济损失 + private Integer deathNum; + + private BigDecimal economicLoss; + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Integer getMinorInjuryNum() { + return minorInjuryNum; + } + + public void setMinorInjuryNum(Integer minorInjuryNum) { + this.minorInjuryNum = minorInjuryNum; + } + + public Integer getSeriousInjuryNum() { + return seriousInjuryNum; + } + + public void setSeriousInjuryNum(Integer seriousInjuryNum) { + this.seriousInjuryNum = seriousInjuryNum; + } + + public Integer getDeathNum() { + return deathNum; + } + + public void setDeathNum(Integer deathNum) { + this.deathNum = deathNum; + } + + public BigDecimal getEconomicLoss() { + return economicLoss; + } + + public void setEconomicLoss(BigDecimal economicLoss) { + this.economicLoss = economicLoss; + } +} diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountRPCResp.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountRPCResp.java new file mode 100644 index 0000000..0ce3a41 --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageCountRPCResp.java @@ -0,0 +1,30 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; + + +import java.util.List; +import java.util.Map; + +public class IncidentManageCountRPCResp { + + // 时间 + private String time ; + + // 数据 + private List<IncidentManageCountDetailRPCResp> detail; + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public List<IncidentManageCountDetailRPCResp> getDetail() { + return detail; + } + + public void setDetail(List<IncidentManageCountDetailRPCResp> detail) { + this.detail = detail; + } +} diff --git a/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageRPCResp.java b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageRPCResp.java new file mode 100644 index 0000000..4c16e49 --- /dev/null +++ b/incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageRPCResp.java @@ -0,0 +1,52 @@ +package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; + + +import java.util.List; +import java.util.Map; + +public class IncidentManageRPCResp { + + // 部门id + private Long deptId; + + // 部门名称 + private String deptName; + + // 部门级别 + private Integer deptLevel; + + // 名称+数据 + private List<IncidentManageCountRPCResp> data; + + public Long getDeptId() { + return deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public Integer getDeptLevel() { + return deptLevel; + } + + public void setDeptLevel(Integer deptLevel) { + this.deptLevel = deptLevel; + } + + public List<IncidentManageCountRPCResp> getData() { + return data; + } + + public void setData(List<IncidentManageCountRPCResp> data) { + this.data = data; + } +} diff --git a/incident-manage/incident-manage-rpc-provider/pom.xml b/incident-manage/incident-manage-rpc-provider/pom.xml index 7e6d616..871e237 100644 --- a/incident-manage/incident-manage-rpc-provider/pom.xml +++ b/incident-manage/incident-manage-rpc-provider/pom.xml @@ -8,12 +8,22 @@ <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> + <packaging>jar</packaging> <artifactId>incident-manage-rpc-provider</artifactId> - <properties> - <maven.compiler.source>8</maven.compiler.source> - <maven.compiler.target>8</maven.compiler.target> - </properties> + <dependencies> + <dependency> + <groupId>com.gkhy.safePlatfrom</groupId> + <artifactId>incident-manage-rpc-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>com.gkhy.safePlatfrom</groupId> + <artifactId>incident-manage-service</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> -</project> \ No newline at end of file + +</project> 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 new file mode 100644 index 0000000..1a1bd5e --- /dev/null +++ b/incident-manage/incident-manage-rpc-provider/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/provider/IncidentManageRpcProvider.java @@ -0,0 +1,29 @@ +package com.gkhy.safePlatform.incidentManage.rpc.provider; + + +import com.gkhy.safePlatform.commons.vo.SearchResultVO; +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.IncidentManageRPCResp; +import com.gkhy.safePlatform.incidentManage.service.AccidentCountService; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +@DubboService +public class IncidentManageRpcProvider implements IncidentManageRpcAPi { + + @Autowired + private AccidentCountService accidentCountService; + + @Override + public SearchResultVO<IncidentManageRPCResp> getCountByDeptId(IncidentManageCountRPCReq query) { + return accidentCountService.getCountByDeptId(query); + } + + @Override + public SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query) { + return accidentCountService.getCountByDeptIds(query); + } +} diff --git a/incident-manage/incident-manage-service/pom.xml b/incident-manage/incident-manage-service/pom.xml index ffb55bc..9a7f899 100644 --- a/incident-manage/incident-manage-service/pom.xml +++ b/incident-manage/incident-manage-service/pom.xml @@ -8,7 +8,7 @@ <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - + <packaging>jar</packaging> <artifactId>incident-manage-service</artifactId> <properties> @@ -16,4 +16,17 @@ <maven.compiler.target>8</maven.compiler.target> </properties> -</project> \ No newline at end of file + <dependencies> + <dependency> + <groupId>com.gkhy.safePlatfrom</groupId> + <artifactId>incident-manage-rpc-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>com.gkhy.safePlatfrom</groupId> + <artifactId>account-rpc-api</artifactId> + </dependency> + </dependencies> + + +</project> 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 581eb80..8086ba2 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 @@ -3,6 +3,8 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO; import com.gkhy.safePlatform.incidentManage.query.AccidentReportCountQuery; +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.service.AccidentCountService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -25,4 +27,20 @@ return accidentCountService.countAccidentReport(query); } + /** + * 事故报告统计的rpc接口 + */ + @RequestMapping(value = "/getCountByDeptId/count",method = RequestMethod.POST) + public ResultVO<IncidentManageRPCResp> getCountByDeptId(@RequestBody IncidentManageCountRPCReq query){ + return accidentCountService.getCountByDeptId(query); + } + + /** + * 事故报告统计的rpc接口 + */ + @RequestMapping(value = "/getCountByDeptIds/count",method = RequestMethod.POST) + public ResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(@RequestBody IncidentManageCountRPCReq query){ + return accidentCountService.getCountByDeptIds(query); + } + } diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentReportCountRPC.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentReportCountRPC.java new file mode 100644 index 0000000..ca051ee --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentReportCountRPC.java @@ -0,0 +1,78 @@ +package com.gkhy.safePlatform.incidentManage.entity; + + +import java.math.BigDecimal; + +public class AccidentReportCountRPC { + + private String time; + + private String level ; + + private Integer num ; + + private Integer minorInjuryNum; + + private Integer seriousInjuryNum; + + private Integer deathNum; + + private BigDecimal economicLoss; + + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Integer getMinorInjuryNum() { + return minorInjuryNum; + } + + public void setMinorInjuryNum(Integer minorInjuryNum) { + this.minorInjuryNum = minorInjuryNum; + } + + public Integer getSeriousInjuryNum() { + return seriousInjuryNum; + } + + public void setSeriousInjuryNum(Integer seriousInjuryNum) { + this.seriousInjuryNum = seriousInjuryNum; + } + + public Integer getDeathNum() { + return deathNum; + } + + public void setDeathNum(Integer deathNum) { + this.deathNum = deathNum; + } + + public BigDecimal getEconomicLoss() { + return economicLoss; + } + + public void setEconomicLoss(BigDecimal economicLoss) { + this.economicLoss = economicLoss; + } +} diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java index 6ff39ca..5ed5295 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java @@ -45,6 +45,8 @@ CASE_TITLE_NULL("C1003", "事故案例标题不可为空"), CASE_CONTENT_NULL("C1004", "事故案例内容不可为空"), + YEAR_NULL("Y1001" , "年份不能为空"), + ERROR("A3000", "未知错误"); private String code; 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 4990ae1..462a292 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 @@ -2,10 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO; +import com.gkhy.safePlatform.incidentManage.entity.*; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportCountDBQuery; import org.apache.ibatis.annotations.Param; @@ -27,4 +24,9 @@ void deleteAccidentReportById(@Param("id") Long id); List<AccidentReportCount> selectByTimeAndType(@Param("query") AccidentReportCountDBQuery dbQuery); + + List<AccidentReportCountRPC> getCountForRPCByDeptIdAndMonth(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("deptId")Long deptId); + + List<AccidentReportCountRPC> getCountForRPCByDeptIdAndDay(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("deptId")Long deptId); + } 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 dff27a0..9b6c34a 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 @@ -1,12 +1,23 @@ package com.gkhy.safePlatform.incidentManage.service; 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.query.AccidentReportCountQuery; +import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req.IncidentManageCountRPCReq; +import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.IncidentManageRPCResp; import java.util.List; public interface AccidentCountService { ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportCountQuery query); + + // RPC接口--1、传入部门ID和年份、月份,查询该部门在指定年份、或者指定月份的事故统计,(特别重大、重大、较大、一般、未遂)这5个档次来分别统计, + // 并且统计不同等级的事故所造成的后果(死亡人数、重伤人数、轻伤人数、经济损失) + SearchResultVO<IncidentManageRPCResp> getCountByDeptId(IncidentManageCountRPCReq query); + + // RPC接口--1、传入部门ID和年份、月份,查询该部门及其子部门在指定年份、或者指定月份的事故统计,(特别重大、重大、较大、一般、未遂)这5个档次来分别统计, + // 并且统计不同等级的事故所造成的后果(死亡人数、重伤人数、轻伤人数、经济损失) + SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query); } 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 6abc9a1..1047886 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 @@ -2,10 +2,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO; +import com.gkhy.safePlatform.incidentManage.entity.*; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportCountDBQuery; @@ -26,4 +23,8 @@ List<AccidentReportCount> selectByTimeAndType(AccidentReportCountDBQuery dbQuery); + List<AccidentReportCountRPC> getCountForRPCByDeptIdAndMonth(String startTime, String endTime, Long deptId); + + List<AccidentReportCountRPC> getCountForRPCByDeptIdAndDay(String startTime, String endTime, Long deptId); + } 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 b251e44..f612a4b 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 @@ -2,10 +2,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO; -import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO; +import com.gkhy.safePlatform.incidentManage.entity.*; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportCountDBQuery; import com.gkhy.safePlatform.incidentManage.repository.AccidentReportInfoRepository; @@ -51,4 +48,13 @@ return accidentReportInfoRepository.selectByTimeAndType(dbQuery); } + @Override + public List<AccidentReportCountRPC> getCountForRPCByDeptIdAndMonth(String startTime, String endTime, Long deptId) { + return accidentReportInfoRepository.getCountForRPCByDeptIdAndMonth(startTime,endTime,deptId); + } + + @Override + public List<AccidentReportCountRPC> getCountForRPCByDeptIdAndDay(String startTime, String endTime, Long deptId) { + return accidentReportInfoRepository.getCountForRPCByDeptIdAndDay(startTime,endTime,deptId); + } } 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 e68f8bd..b6ac38e 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 @@ -1,19 +1,33 @@ package com.gkhy.safePlatform.incidentManage.service.impl; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService; +import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO; 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.entity.*; +import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes; +import com.gkhy.safePlatform.incidentManage.exception.AccidentException; import com.gkhy.safePlatform.incidentManage.model.dto.resp.*; import com.gkhy.safePlatform.incidentManage.query.AccidentReportCountQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportCountDBQuery; +import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req.IncidentManageCountRPCReq; +import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.IncidentManageCountDetailRPCResp; +import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.IncidentManageCountRPCResp; +import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.IncidentManageRPCResp; import com.gkhy.safePlatform.incidentManage.service.AccidentCountService; import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportInfoService; import com.gkhy.safePlatform.incidentManage.utils.TimeUtils; +import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import javax.print.DocFlavor; import java.util.*; +import java.util.stream.Collectors; @Service("accidentCountService") public class AccidentCountServiceImpl implements AccidentCountService { @@ -21,6 +35,141 @@ @Autowired private AccidentReportInfoService accidentReportInfoService; + @DubboReference(check = false) + private AccountDepartmentService accountDepartmentService; + + + @Override + public SearchResultVO<IncidentManageRPCResp> getCountByDeptId(IncidentManageCountRPCReq query) { + if (query.getYear() == null) { + throw new AccidentException(AccidentResultCodes.YEAR_NULL); + } + IncidentManageRPCResp incidentManageCountRPCResp = new IncidentManageRPCResp(); + // 获取id对应的部门 + DepInfoRPCRespDTO depInfoRPCRespDTO = getDepInfoByDepId(query.getDeptId()); + incidentManageCountRPCResp.setDeptId(depInfoRPCRespDTO.getDepId()); + incidentManageCountRPCResp.setDeptName(depInfoRPCRespDTO.getDepName()); + incidentManageCountRPCResp.setDeptLevel(depInfoRPCRespDTO.getDepLevel()); + + getSingleTimeData(incidentManageCountRPCResp, query); + + return new SearchResultVO<>( + false, + null, + null, + null, + 1L, + incidentManageCountRPCResp, + ResultCodes.OK + ); + } + + @Override + public SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query) { + List<IncidentManageRPCResp> list = new ArrayList<>(); + + // 获取该部门及其子部门的所有信息 + List<DepInfoRPCRespDTO> deptList = getDepListInfoByDepId(query.getDeptId()); + + for (DepInfoRPCRespDTO depInfoRPCRespDTO : deptList) { + IncidentManageRPCResp incidentManageCountRPCResp = new IncidentManageRPCResp(); + incidentManageCountRPCResp.setDeptId(depInfoRPCRespDTO.getDepId()); + incidentManageCountRPCResp.setDeptName(depInfoRPCRespDTO.getDepName()); + incidentManageCountRPCResp.setDeptLevel(depInfoRPCRespDTO.getDepLevel()); + + getSingleTimeData(incidentManageCountRPCResp, query); + list.add(incidentManageCountRPCResp); + } + return new SearchResultVO<>( + false, + null, + null, + null, + (long) list.size(), + list, + ResultCodes.OK + ); + } + + private void getSingleTimeData(IncidentManageRPCResp incidentManageRPCResp, IncidentManageCountRPCReq query) { + List<IncidentManageCountRPCResp> resList = new ArrayList<>(); + + + List<AccidentReportCountRPC> accidentReportCountRPCList = new ArrayList<>(); + Long deptId = query.getDeptId(); + String startTime; + String endTime; + if (query.getMonth() == null) { + // 查该年度12个月份的 + startTime = TimeUtils.getYearFirst(query.getYear()); + endTime = TimeUtils.getYearLast(query.getYear()); + accidentReportCountRPCList= accidentReportInfoService.getCountForRPCByDeptIdAndMonth(startTime, endTime, deptId); + + } else { + // 查该年度指定月份的 + startTime = TimeUtils.getMonthFirst(query.getYear(), query.getMonth()); + endTime = TimeUtils.getMonthLast(query.getYear(), query.getMonth()); + accidentReportCountRPCList = accidentReportInfoService.getCountForRPCByDeptIdAndDay(startTime, endTime, deptId); + } + + // 拼装第一层时间(去重) + Set<String> timeSET = accidentReportCountRPCList.stream().map(AccidentReportCountRPC::getTime).collect(Collectors.toSet()); + // 拼装第一层时间(排序) + List<String> timeList = timeSET.stream().sorted().collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(timeSET)) { + for (String str : timeSET) { + IncidentManageCountRPCResp incidentManageCountRPCResp = new IncidentManageCountRPCResp(); + incidentManageCountRPCResp.setTime(str); + incidentManageCountRPCResp.setDetail(new ArrayList<>()); + resList.add(incidentManageCountRPCResp); + } + } + // 拼装第二层事故详情 + if (!CollectionUtils.isEmpty(timeList)) { + for (AccidentReportCountRPC accidentReportCountRPC : accidentReportCountRPCList) { + for (IncidentManageCountRPCResp incidentManageCountRPCResp : resList) { + if (accidentReportCountRPC.getTime().equals(incidentManageCountRPCResp.getTime())) { + IncidentManageCountDetailRPCResp incidentManageCountDetailRPCResp = new IncidentManageCountDetailRPCResp(); + + incidentManageCountDetailRPCResp.setLevel(accidentReportCountRPC.getLevel()); + incidentManageCountDetailRPCResp.setNum(accidentReportCountRPC.getNum()); + incidentManageCountDetailRPCResp.setMinorInjuryNum(accidentReportCountRPC.getMinorInjuryNum()); + incidentManageCountDetailRPCResp.setSeriousInjuryNum(accidentReportCountRPC.getSeriousInjuryNum()); + incidentManageCountDetailRPCResp.setDeathNum(accidentReportCountRPC.getDeathNum()); + incidentManageCountDetailRPCResp.setEconomicLoss(accidentReportCountRPC.getEconomicLoss()); + incidentManageCountRPCResp.getDetail().add(incidentManageCountDetailRPCResp); + } + } + } + } + incidentManageRPCResp.setData(resList); + } + + private DepInfoRPCRespDTO getDepInfoByDepId(Long deptId) { + DepInfoRPCRespDTO dep = new DepInfoRPCRespDTO(); + ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(deptId); + if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) { + if (rpcResult.getData() != null) { + dep = (DepInfoRPCRespDTO) rpcResult.getData(); + } + } else { + throw new BusinessException(ResultCodes.CLIENT_DEP_NOT_EXIST); + } + return dep; + } + + private List<DepInfoRPCRespDTO> getDepListInfoByDepId(Long deptId) { + List<DepInfoRPCRespDTO> depList = new ArrayList<>(); + ResultVO<List<DepInfoRPCRespDTO>> rpcResult = accountDepartmentService.listDepAndSubDepByDepId(deptId); + if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) { + if (rpcResult.getData() != null) { + depList = (List<DepInfoRPCRespDTO>) rpcResult.getData(); + } + } else { + throw new BusinessException(ResultCodes.CLIENT_DEP_NOT_EXIST); + } + return depList; + } @Override public ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportCountQuery query) { 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 3a9ba3d..d9a0ee3 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 @@ -203,20 +203,74 @@ </resultMap> <select id="selectByTimeAndType" resultMap="emergencyDrillExecuteCountChart"> SELECT - a.accident_level AS `name`, + accident_level AS `name`, count( 0 ) AS num, sum( economic_loss ) AS economicLoss, sum( minor_injury_num ) AS minorInjuryNum, sum( serious_injury_num ) AS seriousInjuryNum, sum( death_num ) AS deathNum FROM - `accident_report` a + `accident_report` WHERE del_flag = 0 - AND a.gmt_create <![CDATA[ >= ]]> #{query.startTime} - AND a.gmt_create <![CDATA[ <= ]]> #{query.endTime} - <if test="query.level != null and query.level != ''" >and b.drill_level = #{query.level}</if> + AND gmt_create <![CDATA[ >= ]]> #{query.startTime} + AND gmt_create <![CDATA[ <= ]]> #{query.endTime} + <if test="query.level != null and query.level != ''" >and accident_level = #{query.level}</if> GROUP BY accident_level </select> + + <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportCountRPC" + id="accidentReportCountRPC"> + <result column="time" property="time"/> + <result column="num" property="num"/> + <result column="level" property="level"/> + <result column="minorInjuryNum" property="minorInjuryNum"/> + <result column="seriousInjuryNum" property="seriousInjuryNum"/> + <result column="deathNum" property="deathNum"/> + <result column="economicLoss" property="economicLoss"/> + </resultMap> + <select id="getCountForRPCByDeptIdAndMonth" resultMap="accidentReportCountRPC"> + SELECT + DATE_FORMAT( a.gmt_create, '%Y-%m' ) as time, + a.accident_level AS `level`, + count( 0 ) AS num, + sum( a.economic_loss ) AS economicLoss, + sum( a.minor_injury_num ) AS minorInjuryNum, + sum( a.serious_injury_num ) AS seriousInjuryNum, + sum( a.death_num ) AS deathNum + FROM + `accident_report` a + INNER JOIN `accident_express` b ON a.accident_express_id = b.id + AND b.accident_department_id = #{deptId} + WHERE + a.del_flag = 0 + AND a.gmt_create <![CDATA[ >= ]]> #{startTime} + AND a.gmt_create <![CDATA[ <= ]]> #{endTime} + GROUP BY + DATE_FORMAT( a.gmt_create, '%Y-%m' ), + a.accident_level + </select> + + <select id="getCountForRPCByDeptIdAndDay" resultMap="accidentReportCountRPC"> + SELECT + DATE_FORMAT( a.gmt_create, '%Y-%m-%d' ) as time, + a.accident_level AS `level`, + count( 0 ) AS num, + sum( a.economic_loss ) AS economicLoss, + sum( a.minor_injury_num ) AS minorInjuryNum, + sum( a.serious_injury_num ) AS seriousInjuryNum, + sum( a.death_num ) AS deathNum + FROM + `accident_report` a + INNER JOIN `accident_express` b ON a.accident_express_id = b.id + AND b.accident_department_id = #{deptId} + WHERE + a.del_flag = 0 + AND a.gmt_create <![CDATA[ >= ]]> #{startTime} + AND a.gmt_create <![CDATA[ <= ]]> #{endTime} + GROUP BY + DATE_FORMAT( a.gmt_create, '%Y-%m-%d' ), + a.accident_level + </select> </mapper> -- Gitblit v1.9.2