emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyRpcAPi.java
@@ -3,12 +3,13 @@ import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteCountRPCReq; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteNumRPCReq; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteTimeRPCReq; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencyExecuteNumRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencyExecuteTimeRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencySuppliesRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencySuppliesTypeRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.*; import java.util.List; @@ -26,10 +27,27 @@ // RPC接口--4、传入部门ID和年份月份,查询该部门及其子部门,在指定的年份,或者指定的月份的应急演练的次数 SearchResultVO<List<EmergencyExecuteNumRPCResp>> getNumByDeptIds(EmergencyExecuteNumRPCReq query); //RPC接口--5、按照物资类型获取列表 //RPC接口--按照物资类型获取列表 ResultVO<List<EmergencySuppliesTypeRPCResp>> emergencySuppliesList(ContextCacheUser currentUser); //RPC接口--6、根据ids获取库存数量 //RPC接口--根据ids获取库存数量 ResultVO<List<EmergencySuppliesRPCResp>> listCountByIds(ContextCacheUser currentUser,List<Long> ids); /*****************************************重构***********************************************************/ // RPC接口--1、传入部门ID,查询该部门最后一次完成应急演练的时间 ResultVO<EmergencyExecuteLastTimeRPCResp> getExecuteLastTimeByDeptId(Long depId); // RPC接口--2、传入部门ID,查询该部门以及子级部门中最后一次完成应急演练的时间 ResultVO<EmergencyExecuteLastTimeRPCResp> getExecuteLastTimeByDeptIds(Long depId); // RPC接口--3、传入部门ID,指定月份 ,统计演练次数 ResultVO<StatisticsDepLevelMonthEexcuteRPCRespDTO> getExecuteCountByDeptIdAndMonth(EmergencyExecuteCountRPCReq query); // RPC接口--4、传入部门ID,指定年份 ,查询部门演练数据,并按月统计演练次数 ResultVO<StatisticsDepLevelYearExecuteRPCRespDTO> getExecuteCountByDeptIdAndYear(EmergencyExecuteCountRPCReq query); // RPC接口--5、传入部门ID,指定月份 ,查询部门以及子级部门演练数据,统计演练次数 ResultVO<List<StatisticsDepLevelMonthEexcuteRPCRespDTO>> getExecuteCountByDeptIdsAndMonth(EmergencyExecuteCountRPCReq query); // RPC接口--6、传入部门ID,指定年份 ,查询部门以及子级部门演练数据 并按部门等级,月份,统计演练次数 ResultVO<List<StatisticsDepLevelYearExecuteRPCRespDTO>> getExecuteCountByDeptIdsAndYear(EmergencyExecuteCountRPCReq query); } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/req/EmergencyExecuteCountRPCReq.java
对比新文件 @@ -0,0 +1,35 @@ package com.gkhy.safePlatform.emergency.rpc.api.model.dto.req; public class EmergencyExecuteCountRPCReq { //部门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; } } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencyExecuteLastTimeRPCResp.java
对比新文件 @@ -0,0 +1,40 @@ package com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp; /** * 应急演练时间 */ public class EmergencyExecuteLastTimeRPCResp { // 部门id private Long depId; // 部门级别 private Byte depLevel; //左后一次演练的时间 private String lastPricticeTime; public Long getDepId() { return depId; } public void setDepId(Long depId) { this.depId = depId; } public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public String getLastPricticeTime() { return lastPricticeTime; } public void setLastPricticeTime(String lastPricticeTime) { this.lastPricticeTime = lastPricticeTime; } } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencyExecuteNumRPCResp.java
@@ -13,7 +13,7 @@ private String deptName; // 部门级别 private Integer deptLevel; private Byte deptLevel; // 父部门id private Long parentDepId; @@ -36,11 +36,11 @@ this.deptName = deptName; } public Integer getDeptLevel() { public Byte getDeptLevel() { return deptLevel; } public void setDeptLevel(Integer deptLevel) { public void setDeptLevel(Byte deptLevel) { this.deptLevel = deptLevel; } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/EmergencyExecuteTimeRPCResp.java
@@ -10,7 +10,7 @@ private String deptName; // 部门级别 private Integer deptLevel; private Byte deptLevel; // 父部门id private Long parentDepId; @@ -34,11 +34,11 @@ this.deptName = deptName; } public Integer getDeptLevel() { public Byte getDeptLevel() { return deptLevel; } public void setDeptLevel(Integer deptLevel) { public void setDeptLevel(Byte deptLevel) { this.deptLevel = deptLevel; } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/StatisticsDepLevelMonthEexcuteRPCRespDTO.java
对比新文件 @@ -0,0 +1,39 @@ package com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp; /** * 返回指定月份演练数据统计 */ public class StatisticsDepLevelMonthEexcuteRPCRespDTO { //月份 private Integer month; //部门级别 private Byte depLevel; //演练数量 private Integer executeCount; public Integer getMonth() { return month; } public void setMonth(Integer month) { this.month = month; } public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public Integer getExecuteCount() { return executeCount; } public void setExecuteCount(Integer executeCount) { this.executeCount = executeCount; } } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/StatisticsDepLevelYearExecuteRPCRespDTO.java
对比新文件 @@ -0,0 +1,47 @@ package com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp; import java.util.List; public class StatisticsDepLevelYearExecuteRPCRespDTO { //部门级别 private Byte depLevel; //年份 private Integer year; //总计数量 private Integer yearTotalCount; //月份数据集合 List<StatisticsMonthExecuteCountRPCRespDTO> monthExecuteCountList; public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public List<StatisticsMonthExecuteCountRPCRespDTO> getMonthExecuteCountList() { return monthExecuteCountList; } public void setMonthExecuteCountList(List<StatisticsMonthExecuteCountRPCRespDTO> monthExecuteCountList) { this.monthExecuteCountList = monthExecuteCountList; } public Integer getYear() { return year; } public void setYear(Integer year) { this.year = year; } public Integer getYearTotalCount() { return yearTotalCount; } public void setYearTotalCount(Integer yearTotalCount) { this.yearTotalCount = yearTotalCount; } } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/dto/resp/StatisticsMonthExecuteCountRPCRespDTO.java
对比新文件 @@ -0,0 +1,34 @@ package com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp; public class StatisticsMonthExecuteCountRPCRespDTO { //年 private Integer year; //月 private Integer month; //数量 private Integer count; 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; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } } emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyRpcProvider.java
@@ -6,17 +6,18 @@ 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.emergency.model.dto.resp.EmergencySuppliesRespDTO; import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesTypeRespDTO; import com.gkhy.safePlatform.emergency.enums.EmergencyResultCodes; import com.gkhy.safePlatform.emergency.excepiton.EmergencyException; import com.gkhy.safePlatform.emergency.model.dto.resp.*; import com.gkhy.safePlatform.emergency.query.EmergencyDrillCountQuery; import com.gkhy.safePlatform.emergency.rpc.api.EmergencyRpcAPi; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteCountRPCReq; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteNumRPCReq; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteTimeRPCReq; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencyExecuteNumRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencyExecuteTimeRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencySuppliesRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.EmergencySuppliesTypeRPCResp; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.resp.*; import com.gkhy.safePlatform.emergency.service.EmergencyCountService; import com.gkhy.safePlatform.emergency.service.EmergencySuppliesService; import org.apache.commons.collections.CollectionUtils; import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.BeanUtils; @@ -54,32 +55,204 @@ return emergencyCountService.getNumByDeptIds(query); } @Override public ResultVO<List<EmergencySuppliesTypeRPCResp>> emergencySuppliesList(ContextCacheUser currentUser) { List<EmergencySuppliesTypeRespDTO> list = (List<EmergencySuppliesTypeRespDTO>)emergencySuppliesService.emergencySuppliesList(currentUser).getData(); List<EmergencySuppliesTypeRPCResp> typeRPCRespList = new ArrayList<>(); for (EmergencySuppliesTypeRespDTO typeRespDTO:list) { EmergencySuppliesTypeRPCResp typeRPCResp = new EmergencySuppliesTypeRPCResp(); typeRPCResp.setMaterialType(typeRespDTO.getMaterialType()); typeRPCResp.setMaterialTypeName(typeRespDTO.getMaterialTypeName()); if(!CollectionUtils.isEmpty(typeRespDTO.getList())){ List<EmergencySuppliesRPCResp> emergencySuppliesRPCRespList = BeanCopyUtils.copyBeanList(typeRespDTO.getList(), EmergencySuppliesRPCResp.class); typeRPCResp.setList(emergencySuppliesRPCRespList); ResultVO<List<EmergencySuppliesTypeRPCResp>> result = new ResultVO<>(ResultCodes.OK); List<EmergencySuppliesTypeRPCResp> typeRPCRespList = new ArrayList<>(); try{ List<EmergencySuppliesTypeRespDTO> typeRespDTOList = emergencySuppliesService.emergencySuppliesList(currentUser); for (EmergencySuppliesTypeRespDTO typeRespDTO:typeRespDTOList) { EmergencySuppliesTypeRPCResp typeRPCResp = new EmergencySuppliesTypeRPCResp(); typeRPCResp.setMaterialType(typeRespDTO.getMaterialType()); typeRPCResp.setMaterialTypeName(typeRespDTO.getMaterialTypeName()); if(!CollectionUtils.isEmpty(typeRespDTO.getList())){ List<EmergencySuppliesRPCResp> emergencySuppliesRPCRespList = BeanCopyUtils.copyBeanList(typeRespDTO.getList(), EmergencySuppliesRPCResp.class); typeRPCResp.setList(emergencySuppliesRPCRespList); } typeRPCRespList.add(typeRPCResp); } typeRPCRespList.add(typeRPCResp); result.setData(typeRPCRespList); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return new ResultVO<>(ResultCodes.OK,typeRPCRespList); return result; } @Override public ResultVO<List<EmergencySuppliesRPCResp>> listCountByIds(ContextCacheUser currentUser,List<Long> ids) { List<EmergencySuppliesRespDTO> list = (List<EmergencySuppliesRespDTO>)emergencySuppliesService.listCountByIds(currentUser,ids).getData(); List<EmergencySuppliesRPCResp> emergencySuppliesRPCRespList = null; if(!CollectionUtils.isEmpty(list)){ emergencySuppliesRPCRespList = BeanCopyUtils.copyBeanList(list, EmergencySuppliesRPCResp.class); ResultVO<List<EmergencySuppliesRPCResp>> result = new ResultVO<>(ResultCodes.OK); try{ List<EmergencySuppliesRPCResp> emergencySuppliesRPCRespList = new ArrayList<>(); List<EmergencySuppliesRespDTO> respDTOList = emergencySuppliesService.listCountByIds(currentUser, ids); if(!CollectionUtils.isEmpty(respDTOList)){ emergencySuppliesRPCRespList = BeanCopyUtils.copyBeanList(respDTOList, EmergencySuppliesRPCResp.class); } result.setData(emergencySuppliesRPCRespList); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return new ResultVO<>(ResultCodes.OK,emergencySuppliesRPCRespList); return result; } @Override public ResultVO<EmergencyExecuteLastTimeRPCResp> getExecuteLastTimeByDeptId(Long depId) { ResultVO<EmergencyExecuteLastTimeRPCResp> result = new ResultVO<>(ResultCodes.OK); try{ EmergencyExecuteLastTimeRPCResp lastTimeRPCResp = new EmergencyExecuteLastTimeRPCResp(); EmergencyExecuteTimeRespDTO timeRespDTO = emergencyCountService.getLastTimeByDeptId(depId); if(null != timeRespDTO){ BeanUtils.copyProperties(timeRespDTO,lastTimeRPCResp); } result.setData(lastTimeRPCResp); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return result; } @Override public ResultVO<EmergencyExecuteLastTimeRPCResp> getExecuteLastTimeByDeptIds(Long depId) { ResultVO<EmergencyExecuteLastTimeRPCResp> result = new ResultVO<>(ResultCodes.OK); try{ EmergencyExecuteLastTimeRPCResp lastTimeRPCResp = new EmergencyExecuteLastTimeRPCResp(); EmergencyExecuteTimeRespDTO timeRespDTO = emergencyCountService.getLastTimeByDeptIds(depId); if(null != timeRespDTO){ BeanUtils.copyProperties(timeRespDTO,lastTimeRPCResp); } result.setData(lastTimeRPCResp); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return result; } @Override public ResultVO<StatisticsDepLevelMonthEexcuteRPCRespDTO> getExecuteCountByDeptIdAndMonth(EmergencyExecuteCountRPCReq query) { ResultVO<StatisticsDepLevelMonthEexcuteRPCRespDTO> result = new ResultVO<>(ResultCodes.OK); EmergencyDrillCountQuery countQuery = new EmergencyDrillCountQuery(); countQuery.setDeptId(query.getDeptId()); countQuery.setYear(query.getYear()); countQuery.setMonth(query.getMonth()); try{ StatisticsDepLevelMonthEexcuteRespDTO monthEexcuteRespDTO = emergencyCountService.getCountByDeptIdAndMonth(countQuery); StatisticsDepLevelMonthEexcuteRPCRespDTO monthEexcuteRPCRespDTO = new StatisticsDepLevelMonthEexcuteRPCRespDTO(); monthEexcuteRPCRespDTO.setDepLevel(monthEexcuteRespDTO.getDepLevel()); monthEexcuteRPCRespDTO.setExecuteCount(monthEexcuteRespDTO.getExecuteCount()); monthEexcuteRPCRespDTO.setMonth(monthEexcuteRespDTO.getMonth()); result.setData(monthEexcuteRPCRespDTO); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return result; } @Override public ResultVO<StatisticsDepLevelYearExecuteRPCRespDTO> getExecuteCountByDeptIdAndYear(EmergencyExecuteCountRPCReq query) { ResultVO<StatisticsDepLevelYearExecuteRPCRespDTO> result = new ResultVO<>(ResultCodes.OK); EmergencyDrillCountQuery countQuery = new EmergencyDrillCountQuery(); countQuery.setDeptId(query.getDeptId()); countQuery.setYear(query.getYear()); try{ StatisticsDepLevelYearExecuteRespDTO executeRespDTO = emergencyCountService.getCountByDeptIdAndYear(countQuery); StatisticsDepLevelYearExecuteRPCRespDTO executeRPCRespDTO = new StatisticsDepLevelYearExecuteRPCRespDTO(); executeRPCRespDTO.setDepLevel(executeRespDTO.getDepLevel()); executeRPCRespDTO.setYear(executeRespDTO.getYear()); executeRPCRespDTO.setYearTotalCount(executeRespDTO.getYearTotalCount()); List<StatisticsMonthExecuteCountRespDTO> monthExecuteCountList = executeRespDTO.getMonthExecuteCountList(); if(!CollectionUtils.isEmpty(monthExecuteCountList)){ List<StatisticsMonthExecuteCountRPCRespDTO> monthExecuteCountRPCRespDTOList = BeanCopyUtils.copyBeanList(monthExecuteCountList, StatisticsMonthExecuteCountRPCRespDTO.class); executeRPCRespDTO.setMonthExecuteCountList(monthExecuteCountRPCRespDTOList); } result.setData(executeRPCRespDTO); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return result; } @Override public ResultVO<List<StatisticsDepLevelMonthEexcuteRPCRespDTO>> getExecuteCountByDeptIdsAndMonth(EmergencyExecuteCountRPCReq query) { ResultVO<List<StatisticsDepLevelMonthEexcuteRPCRespDTO>> result = new ResultVO<>(ResultCodes.OK); EmergencyDrillCountQuery countQuery = new EmergencyDrillCountQuery(); countQuery.setDeptId(query.getDeptId()); countQuery.setYear(query.getYear()); countQuery.setMonth(query.getMonth()); try{ List<StatisticsDepLevelMonthEexcuteRespDTO> monthEexcuteRespDTOList = emergencyCountService.getCountByDeptIdsAndMonth(countQuery); if(!CollectionUtils.isEmpty(monthEexcuteRespDTOList)){ List<StatisticsDepLevelMonthEexcuteRPCRespDTO> monthExecuteCountRPCRespDTOList = BeanCopyUtils.copyBeanList(monthEexcuteRespDTOList, StatisticsDepLevelMonthEexcuteRPCRespDTO.class); result.setData(monthExecuteCountRPCRespDTOList); } }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return result; } @Override public ResultVO<List<StatisticsDepLevelYearExecuteRPCRespDTO>> getExecuteCountByDeptIdsAndYear(EmergencyExecuteCountRPCReq query) { ResultVO<List<StatisticsDepLevelYearExecuteRPCRespDTO>> result = new ResultVO<>(ResultCodes.OK); EmergencyDrillCountQuery countQuery = new EmergencyDrillCountQuery(); countQuery.setDeptId(query.getDeptId()); countQuery.setYear(query.getYear()); try{ List<StatisticsDepLevelYearExecuteRespDTO> executeRespDTOList = emergencyCountService.getCountByDeptIdsAndYear(countQuery); List<StatisticsDepLevelYearExecuteRPCRespDTO> RPCRespDTO = new ArrayList<>(); for(StatisticsDepLevelYearExecuteRespDTO vo : executeRespDTOList){ StatisticsDepLevelYearExecuteRPCRespDTO executeRPCRespDTO = new StatisticsDepLevelYearExecuteRPCRespDTO(); executeRPCRespDTO.setDepLevel(vo.getDepLevel()); executeRPCRespDTO.setYear(vo.getYear()); executeRPCRespDTO.setYearTotalCount(vo.getYearTotalCount()); List<StatisticsMonthExecuteCountRespDTO> monthExecuteCountList = vo.getMonthExecuteCountList(); if(!CollectionUtils.isEmpty(monthExecuteCountList)){ List<StatisticsMonthExecuteCountRPCRespDTO> monthExecuteCountRPCRespDTOList = BeanCopyUtils.copyBeanList(monthExecuteCountList, StatisticsMonthExecuteCountRPCRespDTO.class); executeRPCRespDTO.setMonthExecuteCountList(monthExecuteCountRPCRespDTOList); } RPCRespDTO.add(executeRPCRespDTO); } result.setData(RPCRespDTO); }catch (EmergencyException e){ result.setCode(e.getCode()); result.setMsg(e.getMessage()); }catch (Exception e) { result.setCode(EmergencyResultCodes.ERROR.getCode()); result.setMsg(EmergencyResultCodes.ERROR.getDesc()); } return result; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencyCountController.java
@@ -1,11 +1,12 @@ package com.gkhy.safePlatform.emergency.controller; import com.alibaba.fastjson.JSONObject; import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.utils.PageUtils; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyDrillExecuteCountRespDTO; import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesCountRespDTO; import com.gkhy.safePlatform.emergency.model.dto.resp.*; import com.gkhy.safePlatform.emergency.query.EmergencyDrillCountQuery; import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteCountQuery; import com.gkhy.safePlatform.emergency.query.EmergencySuppliesCountQuery; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteNumRPCReq; @@ -74,4 +75,58 @@ public SearchResultVO<List<EmergencyExecuteNumRPCResp>> getNumByDeptIds(@RequestBody EmergencyExecuteNumRPCReq query){ return emergencyCountService.getNumByDeptIds(query); } /***************************重构******************************/ /** * 根据部门id查询最后一次完成应急演练的时间 */ @RequestMapping(value = "/getLastTimeByDeptId",method = RequestMethod.POST) public EmergencyExecuteTimeRespDTO getLastTimeByDeptId(@RequestBody JSONObject jsonObject){ Long deptId = jsonObject.getLong("deptId"); return emergencyCountService.getLastTimeByDeptId(deptId); } /** * 根据部门以及子级部门查询最后一次完成应急演练的时间 */ @RequestMapping(value = "/getLastTimeByDeptIds",method = RequestMethod.POST) public EmergencyExecuteTimeRespDTO getLastTimeByDeptIds(@RequestBody JSONObject jsonObject){ Long deptId = jsonObject.getLong("deptId"); return emergencyCountService.getLastTimeByDeptIds(deptId); } /** * 根据指定和年份统计演练数据 * @param query * @return */ @RequestMapping(value = "/getCountByDeptIdAndYear",method = RequestMethod.POST) public StatisticsDepLevelYearExecuteRespDTO getCountByDeptIdAndYear(@RequestBody EmergencyDrillCountQuery query){ return emergencyCountService.getCountByDeptIdAndYear(query); } /** * 根据部门,指定月份 统计演练次数 * @param query * @return */ @RequestMapping(value = "/getCountByDeptIdAndMonth",method = RequestMethod.POST) public StatisticsDepLevelMonthEexcuteRespDTO getCountByDeptIdAndMonth(@RequestBody EmergencyDrillCountQuery query){ return emergencyCountService.getCountByDeptIdAndMonth(query); } @RequestMapping(value = "/getCountByDeptIdsAndYear",method = RequestMethod.POST) public List<StatisticsDepLevelYearExecuteRespDTO> getCountByDeptIdsAndYear(@RequestBody EmergencyDrillCountQuery query){ return emergencyCountService.getCountByDeptIdsAndYear(query); } /** * 根据部门以及其子级部门,指定月份 统计演练次数 * @param query * @return */ @RequestMapping(value = "/getCountByDeptIdsAndMonth",method = RequestMethod.POST) public List<StatisticsDepLevelMonthEexcuteRespDTO> getCountByDeptIdsAndMonth(@RequestBody EmergencyDrillCountQuery query){ return emergencyCountService.getCountByDeptIdsAndMonth(query); } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/EmergencySuppliesController.java
@@ -67,22 +67,20 @@ public ResultVO batchDeleteEmergencySupplies(@RequestBody Long[] ids){ return emergencySuppliesService.batchDeleteEmergencySupplies(ids); } /** * 应急物资-列表(为特殊作业提供数据) */ @RequestMapping(value = "/emergencySuppliesList",method = RequestMethod.POST) public ResultVO<List<EmergencySuppliesTypeRespDTO>> emergencySuppliesList(Authentication authentication){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return emergencySuppliesService.emergencySuppliesList(currentUser); } /** * 应急物资-根据ids获取数据(为特殊作业提供数据) */ @RequestMapping(value = "/listCountByIds",method = RequestMethod.POST) public ResultVO<List<EmergencySuppliesRespDTO>> listCountByIds(Authentication authentication,@RequestBody List<Long> ids){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return emergencySuppliesService.listCountByIds(currentUser,ids); } // @RequestMapping(value = "/emergencySuppliesList",method = RequestMethod.POST) // public List<EmergencySuppliesTypeRespDTO> emergencySuppliesList(Authentication authentication){ // ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); // return emergencySuppliesService.emergencySuppliesList(currentUser); // } // /** // * 应急物资-根据ids获取数据(为特殊作业提供数据) // */ // @RequestMapping(value = "/listCountByIds",method = RequestMethod.POST) // public List<EmergencySuppliesRespDTO> listCountByIds(Authentication authentication,@RequestBody List<Long> ids){ // ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); // return emergencySuppliesService.listCountByIds(currentUser,ids); // } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/EmergencyDrillExecuteLastTimeDO.java
对比新文件 @@ -0,0 +1,25 @@ package com.gkhy.safePlatform.emergency.entity; public class EmergencyDrillExecuteLastTimeDO { // 部门id private Long deptId; //左后一次演练的时间 private String lastTime; public Long getDeptId() { return deptId; } public void setDeptId(Long deptId) { this.deptId = deptId; } public String getLastTime() { return lastTime; } public void setLastTime(String lastTime) { this.lastTime = lastTime; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/EmergencyExecuteCountDO.java
对比新文件 @@ -0,0 +1,44 @@ package com.gkhy.safePlatform.emergency.entity; public class EmergencyExecuteCountDO { //部门 private Long deptId; //年份 private Integer year; //月份 private Integer month; // 数量 private Integer count; public Long getDeptId() { return deptId; } public void setDeptId(Long deptId) { this.deptId = deptId; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } public Integer getMonth() { return month; } public void setMonth(Integer month) { this.month = month; } public Integer getYear() { return year; } public void setYear(Integer year) { this.year = year; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/enums/DepartmentLevelEnum.java
对比新文件 @@ -0,0 +1,67 @@ package com.gkhy.safePlatform.emergency.enums; import java.util.HashMap; import java.util.Map; public enum DepartmentLevelEnum { COMPANY((byte)1,"公司"), BUSINESS((byte)2,"事业部"), WORKSHOP((byte)3,"车间"), GROUP((byte)4,"班组"), OTHER((byte)5,"其他"), ; DepartmentLevelEnum(Byte code, String value) { this.code = code; this.value = value; } ; public Byte code; public String value; static Map<Byte, DepartmentLevelEnum> map; static { map = new HashMap<>(); for (DepartmentLevelEnum level : DepartmentLevelEnum.values()) { map.put(level.code, level); } } public static DepartmentLevelEnum parse(Byte code) { return map.get(code); } public Byte getCode() { return code; } public void setCode(Byte code) { this.code = code; } public static Map<Byte, DepartmentLevelEnum> getMap() { return map; } public static void setMap(Map<Byte, DepartmentLevelEnum> map) { DepartmentLevelEnum.map = map; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/enums/EmergencyResultCodes.java
@@ -96,7 +96,7 @@ SUPPLIES_MAINTAIN_NOT_EXIST("S1006" , "应急物资保养不存在"), SUPPLIES_PRAM_NULL("S1001" , "应急物资参数不可为空"), SUPPLIES_PARAM_NULL("S1007" , "应急物资参数不可为空"), APPROVE_RELATE_ID_NULL("A1001","审批业务类型不可为空"), @@ -110,7 +110,8 @@ YEAR_NULL("Y1001" , "年份不能为空"), //RPC相关 RPC_EXCEPTION("R1001","RPC接口异常"), ERROR("A3000", "未知错误"); emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/enums/EmergencySelectTypeEnum.java
对比新文件 @@ -0,0 +1,53 @@ package com.gkhy.safePlatform.emergency.enums; import java.util.HashMap; import java.util.Map; public enum EmergencySelectTypeEnum { SPECIFY_TINE((byte)1,"指定时间"), TIME_SLOT((byte)2,"时间段"), ; EmergencySelectTypeEnum(byte code, String value) { this.code = code; this.value = value; } ; public byte code; public String value; static Map<Byte, EmergencySelectTypeEnum> map; static { map = new HashMap<>(); for (EmergencySelectTypeEnum level : EmergencySelectTypeEnum.values()) { map.put(level.code, level); } } public static EmergencySelectTypeEnum parse(Byte code) { return map.get(code); } public byte getCode() { return code; } public void setCode(byte code) { this.code = code; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/excepiton/EmergencyException.java
@@ -12,6 +12,11 @@ this.code = error.getCode(); this.message = error.getDesc(); } public EmergencyException(EmergencyResultCodes resultCodes,String message) { super(message); this.code = resultCodes.getCode(); this.message = message; } public EmergencyException(String code, String message) { super(message); emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencyExecuteTimeRespDTO.java
对比新文件 @@ -0,0 +1,39 @@ package com.gkhy.safePlatform.emergency.model.dto.resp; public class EmergencyExecuteTimeRespDTO { // 部门id private Long depId; // 部门级别 private Byte depLevel; //左后一次演练的时间 private String lastPricticeTime; public Long getDepId() { return depId; } public void setDepId(Long depId) { this.depId = depId; } public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public String getLastPricticeTime() { return lastPricticeTime; } public void setLastPricticeTime(String lastPricticeTime) { this.lastPricticeTime = lastPricticeTime; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/StatisticsDepLevelMonthEexcuteRespDTO.java
对比新文件 @@ -0,0 +1,39 @@ package com.gkhy.safePlatform.emergency.model.dto.resp; /** * 返回指定月份演练数据统计 */ public class StatisticsDepLevelMonthEexcuteRespDTO { //月份 private Integer month; //部门级别 private Byte depLevel; //演练数量 private Integer executeCount; public Integer getMonth() { return month; } public void setMonth(Integer month) { this.month = month; } public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public Integer getExecuteCount() { return executeCount; } public void setExecuteCount(Integer executeCount) { this.executeCount = executeCount; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/StatisticsDepLevelYearExecuteRespDTO.java
对比新文件 @@ -0,0 +1,47 @@ package com.gkhy.safePlatform.emergency.model.dto.resp; import java.util.List; public class StatisticsDepLevelYearExecuteRespDTO { //部门级别 private Byte depLevel; //年份 private Integer year; //总计数量 private Integer yearTotalCount; //月份数据集合 List<StatisticsMonthExecuteCountRespDTO> monthExecuteCountList; public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public List<StatisticsMonthExecuteCountRespDTO> getMonthExecuteCountList() { return monthExecuteCountList; } public void setMonthExecuteCountList(List<StatisticsMonthExecuteCountRespDTO> monthExecuteCountList) { this.monthExecuteCountList = monthExecuteCountList; } public Integer getYear() { return year; } public void setYear(Integer year) { this.year = year; } public Integer getYearTotalCount() { return yearTotalCount; } public void setYearTotalCount(Integer yearTotalCount) { this.yearTotalCount = yearTotalCount; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/StatisticsMonthExecuteCountRespDTO.java
对比新文件 @@ -0,0 +1,34 @@ package com.gkhy.safePlatform.emergency.model.dto.resp; public class StatisticsMonthExecuteCountRespDTO { //年 private Integer year; //月 private Integer month; //数量 private Integer count; 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; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/query/EmergencyDrillCountQuery.java
对比新文件 @@ -0,0 +1,35 @@ package com.gkhy.safePlatform.emergency.query; public class EmergencyDrillCountQuery { //部门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; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencyDrillExecuteInfoRepository.java
@@ -35,4 +35,15 @@ List<EmergencyDrillExecuteCountRPC> selectByMonthAndDeptForIntegerMonth(@Param("startTime") String startTime ,@Param("endTime")String endTime ,@Param("deptIds")List<Long> deptIds); String selectEmergencyDrillExecuteIntervalTimeByDeptId(@Param("deptId")Long deptId); String getLastTimeByDeptId(@Param("deptId")Long deptId); String getLastTimeByDeptIds(@Param("deptIdList")List<Long> deptIdList); List<EmergencyExecuteCountDO> getCountByDeptIdsAndTime(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("deptIds")List<Long> deptIds); EmergencyExecuteCountDO getCountByDeptIdAndMonth(@Param("year")Integer year, @Param("month")Integer endTime, @Param("deptId")Long deptId); List<EmergencyExecuteCountDO> getCountByDeptIdAndYear(@Param("year")Integer year, @Param("deptId")Long deptId); } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencyCountService.java
@@ -3,8 +3,8 @@ import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyDrillExecuteCountRespDTO; import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencySuppliesCountRespDTO; import com.gkhy.safePlatform.emergency.model.dto.resp.*; import com.gkhy.safePlatform.emergency.query.EmergencyDrillCountQuery; import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteCountQuery; import com.gkhy.safePlatform.emergency.query.EmergencySuppliesCountQuery; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteNumRPCReq; @@ -32,4 +32,39 @@ // RPC接口--4、传入部门ID和年份月份,查询该部门及其子部门,在指定的年份,或者指定的月份的应急演练的次数 SearchResultVO<List<EmergencyExecuteNumRPCResp>> getNumByDeptIds(EmergencyExecuteNumRPCReq query); /***********************************************************************************************/ //根据部门id查询最后一次完成应急演练的时间 EmergencyExecuteTimeRespDTO getLastTimeByDeptId(Long deptId); //根据部门id查询该部门以及其子级部门最后一次完成应急演练的时间 EmergencyExecuteTimeRespDTO getLastTimeByDeptIds(Long deptId); /** * 根据部门id统计指定年份的应急演练数据 * @param query * @return */ StatisticsDepLevelYearExecuteRespDTO getCountByDeptIdAndYear(EmergencyDrillCountQuery query); /** * 根据部门id统计指定月份的应急演练数据 * @param query * @return */ StatisticsDepLevelMonthEexcuteRespDTO getCountByDeptIdAndMonth(EmergencyDrillCountQuery query); /** * 根据指定部门以及子级部门、指定年份 统计演练数据 * @param query * @return */ List<StatisticsDepLevelYearExecuteRespDTO> getCountByDeptIdsAndYear(EmergencyDrillCountQuery query); /** * 根据指定部门以及子级部门、指定月份 统计演练数据 * @param query * @return */ List<StatisticsDepLevelMonthEexcuteRespDTO> getCountByDeptIdsAndMonth(EmergencyDrillCountQuery query); } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/EmergencySuppliesService.java
@@ -25,7 +25,10 @@ ResultVO batchDeleteEmergencySupplies( Long[] ids); ResultVO<List<EmergencySuppliesTypeRespDTO>> emergencySuppliesList(ContextCacheUser currentUser); /** * 应急物资-列表(为特殊作业提供数据) */ List<EmergencySuppliesTypeRespDTO> emergencySuppliesList(ContextCacheUser currentUser); ResultVO<List<EmergencySuppliesRespDTO>> listCountByIds(ContextCacheUser currentUser, List<Long> ids); List<EmergencySuppliesRespDTO> listCountByIds(ContextCacheUser currentUser, List<Long> ids); } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencyDrillExecuteInfoService.java
@@ -34,4 +34,13 @@ String selectEmergencyDrillExecuteIntervalTimeByDeptId(Long deptId); String getLastTimeByDeptId(Long deptId); String getLastTimeByDeptIds(List<Long> deptIdList); List<EmergencyExecuteCountDO> getCountByDeptIdsAndTime(String startTime, String endTime, List<Long> deptId); EmergencyExecuteCountDO getCountByDeptIdAndMonth(Integer year,Integer month, Long deptId); List<EmergencyExecuteCountDO> getCountByDeptIdAndYear(Integer year, Long deptId); } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyDrillExecuteInfoServiceImpl.java
@@ -2,7 +2,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.safePlatform.commons.utils.StringUtils; import com.gkhy.safePlatform.emergency.entity.*; import com.gkhy.safePlatform.emergency.enums.EmergencyResultCodes; import com.gkhy.safePlatform.emergency.excepiton.EmergencyException; import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteDBQuery; import com.gkhy.safePlatform.emergency.repository.EmergencyDrillExecuteInfoRepository; import com.gkhy.safePlatform.emergency.service.baseService.EmergencyDrillExecuteInfoService; @@ -77,4 +80,43 @@ return emergencyDrillExecuteInfoRepository.selectEmergencyDrillExecuteIntervalTimeByDeptId(deptId); } @Override public String getLastTimeByDeptId(Long deptId) { if(null == deptId){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } return baseMapper.getLastTimeByDeptId(deptId); } @Override public String getLastTimeByDeptIds(List<Long> deptIdList) { if(null == deptIdList || deptIdList.size() == 0){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } return baseMapper.getLastTimeByDeptIds(deptIdList); } @Override public List<EmergencyExecuteCountDO> getCountByDeptIdsAndTime(String startTime, String endTime, List<Long> deptIds) { if(null == deptIds || StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime) || deptIds.size() == 0){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } return baseMapper.getCountByDeptIdsAndTime(startTime,endTime,deptIds); } @Override public EmergencyExecuteCountDO getCountByDeptIdAndMonth(Integer year,Integer month, Long deptId) { if(null == deptId || null == year || null == month ){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } return baseMapper.getCountByDeptIdAndMonth(year,month,deptId); } @Override public List<EmergencyExecuteCountDO> getCountByDeptIdAndYear(Integer year, Long deptId) { if(null == deptId || null == year){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } return baseMapper.getCountByDeptIdAndYear(year,deptId); } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencySuppliesInfoServiceImpl.java
@@ -66,7 +66,7 @@ @Override public List<EmergencySuppliesInfo> listCountByIds(List<Long> ids) { if(null == ids || ids.size() == 0){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PRAM_NULL); throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } return baseMapper.listCountByIds(ids, (byte) 0,EmergencySuppliesStatusEnum.STATUS_ONE.getCode()); } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyCountServiceImpl.java
@@ -11,9 +11,11 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.emergency.entity.*; import com.gkhy.safePlatform.emergency.enums.DepartmentLevelEnum; import com.gkhy.safePlatform.emergency.enums.EmergencyResultCodes; import com.gkhy.safePlatform.emergency.excepiton.EmergencyException; import com.gkhy.safePlatform.emergency.model.dto.resp.*; import com.gkhy.safePlatform.emergency.query.EmergencyDrillCountQuery; import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteCountQuery; import com.gkhy.safePlatform.emergency.query.EmergencySuppliesCountQuery; import com.gkhy.safePlatform.emergency.rpc.api.model.dto.req.EmergencyExecuteNumRPCReq; @@ -32,6 +34,7 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @Service("emergencyCountService") public class EmergencyCountServiceImpl implements EmergencyCountService { @@ -170,6 +173,8 @@ } return searchResultVO; } private void getSingleNumData(EmergencyExecuteNumRPCResp emergencyExecuteNumRPCResp,EmergencyExecuteNumRPCReq query){ List<Long> deptIds = new ArrayList<>(); @@ -337,5 +342,277 @@ ResultCodes.OK ); } /**********************************重构****************************************************/ /** * 查询部门最后一次演练时间 * @param deptId * @return */ @Override public EmergencyExecuteTimeRespDTO getLastTimeByDeptId(Long deptId) { if(null == deptId){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } //通过RPC获取部门相关数据 DepInfoRPCRespDTO depInfoRPCRespDTO = getDepInfoByDepId(deptId); // 查询该部门最后一次演练时间 String lastTime = emergencyDrillExecuteInfoService.getLastTimeByDeptId(deptId); //填充数据 EmergencyExecuteTimeRespDTO respDTO = new EmergencyExecuteTimeRespDTO(); respDTO.setDepId(depInfoRPCRespDTO.getDepId()); respDTO.setDepLevel(depInfoRPCRespDTO.getDepLevel()); respDTO.setLastPricticeTime(StringUtils.isBlank(lastTime) == true ? "" : lastTime); return respDTO; } /** * 查询部门及其子级部门最后一次演练时间 * 后面按部门等级划分 */ public EmergencyExecuteTimeRespDTO getLastTimeByDeptIds(Long deptId){ if(null == deptId){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } //通过RPC获取部门相关数据 List<DepInfoRPCRespDTO> depInfoList = getDepListInfoByDepId(deptId); //过滤获取部门id List<Long> deptIdList = depInfoList .stream() .map(dep -> dep.getDepId()) .collect(Collectors.toList()); //过滤出传入部门的信息 List<DepInfoRPCRespDTO> selectDepList = depInfoList .stream() .filter(dep -> dep.getDepId().equals(deptId)) .collect(Collectors.toList()); // 查询该部门ids最后一次演练时间 String lastTime = emergencyDrillExecuteInfoService.getLastTimeByDeptIds(deptIdList); //填充数据 EmergencyExecuteTimeRespDTO respDTO = new EmergencyExecuteTimeRespDTO(); respDTO.setDepId(deptId); respDTO.setLastPricticeTime(StringUtils.isBlank(lastTime) == true ? "" : lastTime); if(selectDepList.size()>0){ respDTO.setDepLevel(selectDepList.get(0).getDepLevel()); } return respDTO; } /** * 根据部门id和指定年份 统计演练数据 * */ public StatisticsDepLevelYearExecuteRespDTO getCountByDeptIdAndYear(EmergencyDrillCountQuery query){ if(null == query.getDeptId()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"部门id不可为空"); } if(null == query.getYear()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"年份不可为空"); } //通过RPC获取部门相关数据 DepInfoRPCRespDTO depInfoRPCRespDTO = getDepInfoByDepId(query.getDeptId()); //填充数据 StatisticsDepLevelYearExecuteRespDTO respDTO = new StatisticsDepLevelYearExecuteRespDTO(); respDTO.setDepLevel(depInfoRPCRespDTO.getDepLevel()); respDTO.setYear(query.getYear()); //获取指定部门指定时间下的应急数据 List<EmergencyExecuteCountDO> executeCountDOList = emergencyDrillExecuteInfoService.getCountByDeptIdAndYear(query.getYear(),query.getDeptId()); //声明月份 int allMonth = 12; //判断是否是当前年分 // if(query.getYear().equals(TimeUtils.getCurrentYear())){ // allMonth = TimeUtils.getCurrentMonth(); // } //总数量 int totalCount = 0; List<StatisticsMonthExecuteCountRespDTO> executeCountRespDTOList = new ArrayList<>(); //循环月份 for(int i = 1;i <= allMonth; i++){ StatisticsMonthExecuteCountRespDTO executeCountRespDTO = new StatisticsMonthExecuteCountRespDTO(); executeCountRespDTO.setYear(query.getYear()); executeCountRespDTO.setMonth(i); //获取当月数据 int month = i; List<EmergencyExecuteCountDO> selectMonthList = executeCountDOList .stream() .filter(ac -> ac.getMonth().equals(month)) .collect(Collectors.toList()); if(selectMonthList.size()>0){ executeCountRespDTO.setCount(selectMonthList.get(0).getCount()); totalCount += selectMonthList.get(0).getCount(); }else{ executeCountRespDTO.setCount(0); } executeCountRespDTOList.add(executeCountRespDTO); } respDTO.setYearTotalCount(totalCount); respDTO.setMonthExecuteCountList(executeCountRespDTOList); return respDTO; } /** * 根据指定部门、月份 统计演练数据 * @param query * @return */ @Override public StatisticsDepLevelMonthEexcuteRespDTO getCountByDeptIdAndMonth(EmergencyDrillCountQuery query) { if(null == query.getDeptId()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"部门id不可为空"); } if(null == query.getYear()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"年份不可为空"); } if(null == query.getMonth()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"月份不可为空"); } //通过RPC获取部门相关数据 DepInfoRPCRespDTO depInfoRPCRespDTO = getDepInfoByDepId(query.getDeptId()); //获取指定月份的演练数据 EmergencyExecuteCountDO executeCountDO = emergencyDrillExecuteInfoService.getCountByDeptIdAndMonth(query.getYear(),query.getMonth(), query.getDeptId()); //填充数据 StatisticsDepLevelMonthEexcuteRespDTO respDTO = new StatisticsDepLevelMonthEexcuteRespDTO(); respDTO.setDepLevel(depInfoRPCRespDTO.getDepLevel()); respDTO.setMonth(query.getMonth()); respDTO.setExecuteCount(executeCountDO.getCount()); return respDTO; } /** * 根据部门id及其子级部门和指定年份 统计演练数据 * */ public List<StatisticsDepLevelYearExecuteRespDTO> getCountByDeptIdsAndYear(EmergencyDrillCountQuery query){ if(null == query.getDeptId()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"部门id不可为空"); } if(null == query.getYear()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"年份不可为空"); } //通过RPC获取部门相关数据 List<DepInfoRPCRespDTO> depInfoList = getDepListInfoByDepId(query.getDeptId()); //过滤获取部门id List<Long> deptIds = depInfoList .stream() .map(dep -> dep.getDepId()) .collect(Collectors.toList()); //开始时间结束时间 String startTime = TimeUtils.getYearFirst(query.getYear()); String endTime = TimeUtils.getYearLast(query.getYear()); //获取指定部门指定时间下的应急数据 List<EmergencyExecuteCountDO> executeCountDOList = emergencyDrillExecuteInfoService.getCountByDeptIdsAndTime(startTime,endTime,deptIds); List<StatisticsDepLevelYearExecuteRespDTO> respDTOList = new ArrayList<>(); //循环部门等级 for(DepartmentLevelEnum departmentLevelEnum : DepartmentLevelEnum.values()){ //填充部门级别数据 StatisticsDepLevelYearExecuteRespDTO respDTO = new StatisticsDepLevelYearExecuteRespDTO(); respDTO.setDepLevel(departmentLevelEnum.getCode()); respDTO.setYear(query.getYear()); //获取该部门级别下面的相关部门 List<DepInfoRPCRespDTO> selectDepList = depInfoList .stream() .filter(dep -> dep.getDepLevel().equals(departmentLevelEnum.getCode())) .collect(Collectors.toList()); //获取该部门级别下相关部门演练数据 List<EmergencyExecuteCountDO> selectExeList = executeCountDOList .stream() .filter(exe -> selectDepList.stream().map(dep -> dep.getDepId()).collect(Collectors.toList()).contains(exe.getDeptId())) .collect(Collectors.toList()); List<StatisticsMonthExecuteCountRespDTO> monthExecuteCountList = new ArrayList<>(); //声明月份 int allMonth = 12; //声明一年总数量 int yearTotalCount =0; //判断是否是当前年分 // if(query.getYear().equals(TimeUtils.getCurrentYear())){ // allMonth = TimeUtils.getCurrentMonth(); // } //12个月份 for(int i = 1;i <= allMonth;i++){ //数量 int count = 0; //循环 for(EmergencyExecuteCountDO executeCountDO : selectExeList){ if(executeCountDO.getMonth() == i){ count += executeCountDO.getCount(); yearTotalCount += executeCountDO.getCount(); } } StatisticsMonthExecuteCountRespDTO executeCountRespDTO = new StatisticsMonthExecuteCountRespDTO(); executeCountRespDTO.setYear(query.getYear()); executeCountRespDTO.setMonth(i); executeCountRespDTO.setCount(count); monthExecuteCountList.add(executeCountRespDTO); } respDTO.setMonthExecuteCountList(monthExecuteCountList); respDTO.setYearTotalCount(yearTotalCount); respDTOList.add(respDTO); } return respDTOList; } /** * 根据部门id及其子级部门和指定者月份 统计演练数据 * */ @Override public List<StatisticsDepLevelMonthEexcuteRespDTO> getCountByDeptIdsAndMonth(EmergencyDrillCountQuery query) { if(null == query.getDeptId()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"部门id不可为空"); } if(null == query.getYear()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"年份不可为空"); } if(null == query.getMonth()){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL,"月份不可为空"); } //通过RPC获取部门相关数据 List<DepInfoRPCRespDTO> depInfoList = getDepListInfoByDepId(query.getDeptId()); //过滤获取部门id List<Long> deptIds = depInfoList .stream() .map(dep -> dep.getDepId()) .collect(Collectors.toList()); //开始时间结束时间 String startTime = TimeUtils.getMonthFirst(query.getYear(),query.getMonth()); String endTime = TimeUtils.getMonthLast(query.getYear(),query.getMonth()); //获取演练数据 List<EmergencyExecuteCountDO> executeCountDOList = emergencyDrillExecuteInfoService.getCountByDeptIdsAndTime(startTime,endTime,deptIds); List<StatisticsDepLevelMonthEexcuteRespDTO> respDTOList = new ArrayList<>(); //循环部门等级 for(DepartmentLevelEnum departmentLevelEnum : DepartmentLevelEnum.values()) { //填充部门级别数据 StatisticsDepLevelMonthEexcuteRespDTO respDTO = new StatisticsDepLevelMonthEexcuteRespDTO(); respDTO.setDepLevel(departmentLevelEnum.getCode()); respDTO.setMonth(query.getMonth()); //获取该部门级别下面的相关部门 List<DepInfoRPCRespDTO> selectDepList = depInfoList .stream() .filter(dep -> dep.getDepLevel().equals(departmentLevelEnum.getCode())) .collect(Collectors.toList()); //获取该部门级别下相关部门演练数据 List<EmergencyExecuteCountDO> selectExeList = executeCountDOList .stream() .filter(exe -> selectDepList.stream().map(dep -> dep.getDepId()).collect(Collectors.toList()).contains(exe.getDeptId())) .collect(Collectors.toList()); //数量 int count = 0; //循环 for(EmergencyExecuteCountDO executeCountDO : selectExeList){ count += executeCountDO.getCount(); } respDTO.setExecuteCount(count); respDTOList.add(respDTO); } return respDTOList; } } emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java
@@ -202,7 +202,7 @@ * @return */ @Override public ResultVO<List<EmergencySuppliesTypeRespDTO>> emergencySuppliesList(ContextCacheUser currentUser) { public List<EmergencySuppliesTypeRespDTO> emergencySuppliesList(ContextCacheUser currentUser) { List<EmergencySuppliesInfo> emergencySuppliesInfoList = emergencySuppliesInfoService.listByNoConditions(); List<EmergencySuppliesTypeRespDTO> typeRespDTOList = new ArrayList<>(); @@ -224,20 +224,20 @@ typeRespDTO.setList(respDTOList); typeRespDTOList.add(typeRespDTO); } return new ResultVO<>(ResultCodes.OK,typeRespDTOList); return typeRespDTOList; } @Override public ResultVO<List<EmergencySuppliesRespDTO>> listCountByIds(ContextCacheUser currentUser, List<Long> ids) { public List<EmergencySuppliesRespDTO> listCountByIds(ContextCacheUser currentUser, List<Long> ids) { if(null == ids || ids.size() == 0 ){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PRAM_NULL); throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL); } List<EmergencySuppliesInfo> emergencySuppliesInfos = emergencySuppliesInfoService.listCountByIds(ids); List<EmergencySuppliesRespDTO> respDTOList = new ArrayList<>(); if(!CollectionUtils.isEmpty(emergencySuppliesInfos)){ respDTOList = BeanCopyUtils.copyBeanList(emergencySuppliesInfos,EmergencySuppliesRespDTO.class); } return new ResultVO<>(ResultCodes.OK,respDTOList); return respDTOList; } private void deleteEmergencySupplies(Long id) { emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/utils/TimeUtils.java
@@ -107,6 +107,24 @@ return formatDate(currYearLast); } /** * 获取当前年份 * @return */ public static int getCurrentYear() { Calendar date = Calendar.getInstance(); int year = date.get(Calendar.YEAR); return year; } /** * 获取当前月份 * @param */ public static int getCurrentMonth() { Calendar date = Calendar.getInstance(); int month = date.get(Calendar.MONTH) + 1; return month; } } emergency/emergency-service/src/main/resources/config/mapper/emergency/EmergencyDrillExecuteInfoMapper.xml
@@ -232,5 +232,78 @@ INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id AND b.department_id = #{deptId} </select> <!----> <select id="getLastTimeByDeptId" resultType="java.lang.String"> SELECT DATE_FORMAT( max( a.gmt_create ), '%Y-%m-%d %H:%i:%s' ) AS lastTime FROM `emergency_drill_execute` a INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id AND a.del_flag = 0 AND b.department_id = #{deptId} </select> <!--根据部门及其子级获取--> <select id="getLastTimeByDeptIds" resultType="java.lang.String"> SELECT DATE_FORMAT( max( a.gmt_create ), '%Y-%m-%d %H:%i:%s' ) AS lastTime FROM `emergency_drill_execute` a INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id AND a.del_flag = 0 AND b.department_id IN <foreach collection="deptIdList" item="deptId" open="(" close=")" separator=","> #{deptId} </foreach> </select> <select id="getCountByDeptIdsAndTime" resultType="com.gkhy.safePlatform.emergency.entity.EmergencyExecuteCountDO"> SELECT COUNT( 1 ) AS count, b.department_id AS deptId, DATE_FORMAT( a.gmt_create, '%m' ) AS month, DATE_FORMAT( a.gmt_create, '%Y' ) AS year FROM `emergency_drill_execute` a INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id WHERE a.del_flag = 0 AND b.department_id in <foreach collection="deptIds" item="deptId" open="(" close=")" separator=","> #{deptId} </foreach> AND DATE( a.gmt_create ) BETWEEN #{startTime} AND #{endTime} GROUP BY b.department_id, DATE_FORMAT( a.gmt_create, '%Y-%m' ), DATE_FORMAT(a.gmt_create,'%m'), DATE_FORMAT(a.gmt_create,'%Y') </select> <select id="getCountByDeptIdAndMonth" resultType="com.gkhy.safePlatform.emergency.entity.EmergencyExecuteCountDO"> SELECT COUNT( 1 ) AS count, b.department_id AS deptId FROM `emergency_drill_execute` a INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id WHERE a.del_flag = 0 AND b.department_id = #{deptId} AND YEAR( a.gmt_create ) = #{year} AND MONTH( a.gmt_create) = #{month} </select> <select id="getCountByDeptIdAndYear" resultType="com.gkhy.safePlatform.emergency.entity.EmergencyExecuteCountDO"> SELECT COUNT( 1 ) AS count, DATE_FORMAT( a.gmt_create, '%m' ) AS month FROM `emergency_drill_execute` a INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id WHERE a.del_flag = 0 AND b.department_id = #{deptId} AND YEAR( a.gmt_create ) = #{year} GROUP BY DATE_FORMAT( a.gmt_create, '%Y-%m' ), DATE_FORMAT(a.gmt_create,'%m') </select> </mapper> incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/IncidentManageRpcAPi.java
@@ -1,8 +1,11 @@ package com.gkhy.safePlatform.incidentManage.rpc.api; 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 java.util.List; @@ -15,4 +18,13 @@ // RPC接口--1、传入部门ID和年份、月份,查询该部门及其子部门在指定年份、或者指定月份的事故统计,(特别重大、重大、较大、一般、未遂)这5个档次来分别统计, // 并且统计不同等级的事故所造成的后果(死亡人数、重伤人数、轻伤人数、经济损失) SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query); // RPC接口--1、传入部门ID,指定月份 ,查询部门演练数据 ,按照事故等级统计事故数量 ResultVO<StatisticsDepLevelMonthAccidentRPCRespDTO> getAccidentCountByDeptIdAndMonth(IncidentManageCountRPCReq query); // RPC接口--2、传入部门ID,指定年份 ,查询部门事故数据,并按月,事故等级统计事故数据 ResultVO<StatisticsDeptLevelYearAccidentRPCRespDTO> getAccidentCountByDeptIdAndYear(IncidentManageCountRPCReq query); // RPC接口--3、传入部门ID,指定月份 ,查询部门以及子级部门演练数据,统计演练次数 ResultVO<List<StatisticsDepLevelMonthAccidentRPCRespDTO>> getAccidentCountByDeptIdsAndMonth(IncidentManageCountRPCReq query); // RPC接口--4、传入部门ID,指定年份 ,查询部门以及子级部门演练数据 并按部门等级,月份,统计演练次数 ResultVO<List<StatisticsDeptLevelYearAccidentRPCRespDTO>> getAccidentCountByDeptIdsAndYear(IncidentManageCountRPCReq query); } incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/AccidentLevelResultCountRPCRespDTO.java
对比新文件 @@ -0,0 +1,77 @@ package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; import java.math.BigDecimal; //事故后果 public class AccidentLevelResultCountRPCRespDTO { //事故等级 private Byte accidentLevel; //事故等级名称 private String accidentLevelName; //事故数量 private Integer accidentCount; //死亡人数 private Integer deathCount; //重伤人数 private Integer seriousInjuryCount; //轻伤人数 private Integer minorInjuryCount; //经济损失 private BigDecimal economicLoss; public Byte getAccidentLevel() { return accidentLevel; } public void setAccidentLevel(Byte accidentLevel) { this.accidentLevel = accidentLevel; } public String getAccidentLevelName() { return accidentLevelName; } public void setAccidentLevelName(String accidentLevelName) { this.accidentLevelName = accidentLevelName; } public Integer getAccidentCount() { return accidentCount; } public void setAccidentCount(Integer accidentCount) { this.accidentCount = accidentCount; } public Integer getDeathCount() { return deathCount; } public void setDeathCount(Integer deathCount) { this.deathCount = deathCount; } public Integer getSeriousInjuryCount() { return seriousInjuryCount; } public void setSeriousInjuryCount(Integer seriousInjuryCount) { this.seriousInjuryCount = seriousInjuryCount; } public Integer getMinorInjuryCount() { return minorInjuryCount; } public void setMinorInjuryCount(Integer minorInjuryCount) { this.minorInjuryCount = minorInjuryCount; } public BigDecimal getEconomicLoss() { return economicLoss; } public void setEconomicLoss(BigDecimal economicLoss) { this.economicLoss = economicLoss; } } incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/IncidentManageRPCResp.java
@@ -12,7 +12,7 @@ private String deptName; // 部门级别 private Integer deptLevel; private Byte deptLevel; // 父部门id private Long parentDepId; @@ -36,11 +36,11 @@ this.deptName = deptName; } public Integer getDeptLevel() { public Byte getDeptLevel() { return deptLevel; } public void setDeptLevel(Integer deptLevel) { public void setDeptLevel(Byte deptLevel) { this.deptLevel = deptLevel; } incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/StatisticsDepLevelMonthAccidentRPCRespDTO.java
对比新文件 @@ -0,0 +1,41 @@ package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; import java.util.List; /** * 返回月数量 */ public class StatisticsDepLevelMonthAccidentRPCRespDTO { //部门等级 private Byte depLevel; //月份 private Integer month; //事故等级集合 private List<AccidentLevelResultCountRPCRespDTO> accidentLevelList; public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public Integer getMonth() { return month; } public void setMonth(Integer month) { this.month = month; } public List<AccidentLevelResultCountRPCRespDTO> getAccidentLevelList() { return accidentLevelList; } public void setAccidentLevelList(List<AccidentLevelResultCountRPCRespDTO> accidentLevelList) { this.accidentLevelList = accidentLevelList; } } incident-manage/incident-manage-rpc-api/src/main/java/com/gkhy/safePlatform/incidentManage/rpc/api/model/dto/resp/StatisticsDeptLevelYearAccidentRPCRespDTO.java
对比新文件 @@ -0,0 +1,36 @@ package com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp; import java.util.List; public class StatisticsDeptLevelYearAccidentRPCRespDTO { //部门等级 private Byte depLevel; //部门等级名称 private Integer year; //月数据 private List<StatisticsDepLevelMonthAccidentRPCRespDTO> monthList; public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public Integer getYear() { return year; } public void setYear(Integer year) { this.year = year; } public List<StatisticsDepLevelMonthAccidentRPCRespDTO> getMonthList() { return monthList; } public void setMonthList(List<StatisticsDepLevelMonthAccidentRPCRespDTO> monthList) { this.monthList = monthList; } } 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; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentCountController.java
@@ -2,7 +2,10 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; 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.query.AccidentReportCountQuery; import com.gkhy.safePlatform.incidentManage.query.IncidentManageCountQuery; 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; @@ -43,4 +46,21 @@ return accidentCountService.getCountByDeptIds(query); } @RequestMapping(value = "/getCountByDeptIdAndMonth/count",method = RequestMethod.POST) public StatisticsDepLevelMonthAccidentRespDTO getCountByDeptIdAndMonth(@RequestBody IncidentManageCountQuery query){ return accidentCountService.getCountByDeptIdAndMonth(query); } @RequestMapping(value = "/getCountByDeptIdAndYear/count",method = RequestMethod.POST) public StatisticsDeptLevelYearAccidentRespDTO getCountByDeptIdAndYear(@RequestBody IncidentManageCountQuery query){ return accidentCountService.getCountByDeptIdAndYear(query); } @RequestMapping(value = "/getCountByDeptIdsAndMonth/count",method = RequestMethod.POST) public List<StatisticsDepLevelMonthAccidentRespDTO> getCountByDeptIdsAndMonth(@RequestBody IncidentManageCountQuery query){ return accidentCountService.getCountByDeptIdsAndMonth(query); } @RequestMapping(value = "/getCountByDeptIdsAndYear/count",method = RequestMethod.POST) public List<StatisticsDeptLevelYearAccidentRespDTO> getCountByDeptIdsAndYear(@RequestBody IncidentManageCountQuery query){ return accidentCountService.getCountByDeptIdsAndYear(query); } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentResultCountDO.java
对比新文件 @@ -0,0 +1,97 @@ package com.gkhy.safePlatform.incidentManage.entity; import java.math.BigDecimal; //事故后果 public class AccidentResultCountDO { //部门id private Long deptId; //年份 private Integer year; //月份 private Integer month; //事故等级 private Byte accidentLevel; //事故数量 private Integer accidentCount; //死亡人数 private Integer deathCount; //重伤人数 private Integer seriousInjuryCount; //轻伤人数 private Integer minorInjuryCount; //经济损失 private BigDecimal economicLoss; 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; } public Byte getAccidentLevel() { return accidentLevel; } public void setAccidentLevel(Byte accidentLevel) { this.accidentLevel = accidentLevel; } public Integer getAccidentCount() { return accidentCount; } public void setAccidentCount(Integer accidentCount) { this.accidentCount = accidentCount; } public Integer getDeathCount() { return deathCount; } public void setDeathCount(Integer deathCount) { this.deathCount = deathCount; } public Integer getSeriousInjuryCount() { return seriousInjuryCount; } public void setSeriousInjuryCount(Integer seriousInjuryCount) { this.seriousInjuryCount = seriousInjuryCount; } public Integer getMinorInjuryCount() { return minorInjuryCount; } public void setMinorInjuryCount(Integer minorInjuryCount) { this.minorInjuryCount = minorInjuryCount; } public BigDecimal getEconomicLoss() { return economicLoss; } public void setEconomicLoss(BigDecimal economicLoss) { this.economicLoss = economicLoss; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java
@@ -50,7 +50,9 @@ YEAR_NULL("Y1001" , "年份不能为空"), SERVE_PARAM_NULL("S1001","参数不可为空"), RPC_ERROR("R1001","RPC访问异常"), ERROR("A3000", "未知错误"); incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/DepartmentLevelEnum.java
对比新文件 @@ -0,0 +1,64 @@ package com.gkhy.safePlatform.incidentManage.enums; import java.util.HashMap; import java.util.Map; public enum DepartmentLevelEnum { COMPANY((byte)1,"公司"), BUSINESS((byte)2,"事业部"), WORKSHOP((byte)3,"车间"), GROUP((byte)4,"班组"), OTHER((byte)5,"其他"), ; DepartmentLevelEnum(Byte code, String value) { this.code = code; this.value = value; } ; public Byte code; public String value; static Map<Byte, DepartmentLevelEnum> map; static { map = new HashMap<>(); for (DepartmentLevelEnum level : DepartmentLevelEnum.values()) { map.put(level.code, level); } } public static DepartmentLevelEnum parse(Byte code) { return map.get(code); } public Byte getCode() { return code; } public void setCode(Byte code) { this.code = code; } public static Map<Byte, DepartmentLevelEnum> getMap() { return map; } public static void setMap(Map<Byte, DepartmentLevelEnum> map) { DepartmentLevelEnum.map = map; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/exception/AccidentException.java
@@ -18,6 +18,11 @@ this.code = code; this.message = message; } public AccidentException(AccidentResultCodes error,String message) { super(error.getDesc()); this.code = error.getCode(); this.message = message; } public String getCode() { return this.code; incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentLevelResultCountRespDTO.java
对比新文件 @@ -0,0 +1,77 @@ package com.gkhy.safePlatform.incidentManage.model.dto.resp; import java.math.BigDecimal; //事故后果 public class AccidentLevelResultCountRespDTO { //事故等级 private Byte accidentLevel; //事故等级名称 private String accidentLevelName; //事故数量 private Integer accidentCount; //死亡人数 private Integer deathCount; //重伤人数 private Integer seriousInjuryCount; //轻伤人数 private Integer minorInjuryCount; //经济损失 private BigDecimal economicLoss; public Byte getAccidentLevel() { return accidentLevel; } public void setAccidentLevel(Byte accidentLevel) { this.accidentLevel = accidentLevel; } public String getAccidentLevelName() { return accidentLevelName; } public void setAccidentLevelName(String accidentLevelName) { this.accidentLevelName = accidentLevelName; } public Integer getAccidentCount() { return accidentCount; } public void setAccidentCount(Integer accidentCount) { this.accidentCount = accidentCount; } public Integer getDeathCount() { return deathCount; } public void setDeathCount(Integer deathCount) { this.deathCount = deathCount; } public Integer getSeriousInjuryCount() { return seriousInjuryCount; } public void setSeriousInjuryCount(Integer seriousInjuryCount) { this.seriousInjuryCount = seriousInjuryCount; } public Integer getMinorInjuryCount() { return minorInjuryCount; } public void setMinorInjuryCount(Integer minorInjuryCount) { this.minorInjuryCount = minorInjuryCount; } public BigDecimal getEconomicLoss() { return economicLoss; } public void setEconomicLoss(BigDecimal economicLoss) { this.economicLoss = economicLoss; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/StatisticsDepLevelMonthAccidentRespDTO.java
对比新文件 @@ -0,0 +1,41 @@ package com.gkhy.safePlatform.incidentManage.model.dto.resp; import java.util.List; /** * 返回月数量 */ public class StatisticsDepLevelMonthAccidentRespDTO { //部门等级 private Byte depLevel; //月份 private Integer month; //事故等级集合 private List<AccidentLevelResultCountRespDTO> accidentLevelList; public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public Integer getMonth() { return month; } public void setMonth(Integer month) { this.month = month; } public List<AccidentLevelResultCountRespDTO> getAccidentLevelList() { return accidentLevelList; } public void setAccidentLevelList(List<AccidentLevelResultCountRespDTO> accidentLevelList) { this.accidentLevelList = accidentLevelList; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/StatisticsDeptLevelYearAccidentRespDTO.java
对比新文件 @@ -0,0 +1,36 @@ package com.gkhy.safePlatform.incidentManage.model.dto.resp; import java.util.List; public class StatisticsDeptLevelYearAccidentRespDTO { //部门等级 private Byte depLevel; //部门等级名称 private Integer year; //月数据 private List<StatisticsDepLevelMonthAccidentRespDTO> monthList; public Byte getDepLevel() { return depLevel; } public void setDepLevel(Byte depLevel) { this.depLevel = depLevel; } public Integer getYear() { return year; } public void setYear(Integer year) { this.year = year; } public List<StatisticsDepLevelMonthAccidentRespDTO> getMonthList() { return monthList; } public void setMonthList(List<StatisticsDepLevelMonthAccidentRespDTO> monthList) { this.monthList = monthList; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/query/IncidentManageCountQuery.java
对比新文件 @@ -0,0 +1,36 @@ package com.gkhy.safePlatform.incidentManage.query; public class IncidentManageCountQuery { //部门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; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java
@@ -29,4 +29,7 @@ List<AccidentReportCountRPC> getCountForRPCByDeptIdAndDay(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("deptId")Long deptId); 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); } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentCountService.java
@@ -3,7 +3,10 @@ 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.query.AccidentReportCountQuery; import com.gkhy.safePlatform.incidentManage.query.IncidentManageCountQuery; import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.req.IncidentManageCountRPCReq; import com.gkhy.safePlatform.incidentManage.rpc.api.model.dto.resp.IncidentManageRPCResp; @@ -20,4 +23,12 @@ // RPC接口--1、传入部门ID和年份、月份,查询该部门及其子部门在指定年份、或者指定月份的事故统计,(特别重大、重大、较大、一般、未遂)这5个档次来分别统计, // 并且统计不同等级的事故所造成的后果(死亡人数、重伤人数、轻伤人数、经济损失) SearchResultVO<List<IncidentManageRPCResp>> getCountByDeptIds(IncidentManageCountRPCReq query); StatisticsDepLevelMonthAccidentRespDTO getCountByDeptIdAndMonth(IncidentManageCountQuery query); StatisticsDeptLevelYearAccidentRespDTO getCountByDeptIdAndYear(IncidentManageCountQuery query); List<StatisticsDeptLevelYearAccidentRespDTO> getCountByDeptIdsAndYear(IncidentManageCountQuery query); List<StatisticsDepLevelMonthAccidentRespDTO> getCountByDeptIdsAndMonth(IncidentManageCountQuery query); } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java
@@ -27,4 +27,7 @@ List<AccidentReportCountRPC> getCountForRPCByDeptIdAndDay(String startTime, String endTime, Long deptId); List<AccidentResultCountDO> getAccidentCountByDeptIdsAndTime(String startTime, String endTime, List<Long> deptIds); List<AccidentResultCountDO> getAccidentCountByDeptIdAndTime(String startTime, String endTime, Long deptId); } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java
@@ -2,7 +2,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.safePlatform.commons.utils.StringUtils; 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.query.db.AccidentReportDBQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportCountDBQuery; import com.gkhy.safePlatform.incidentManage.repository.AccidentReportInfoRepository; @@ -57,4 +60,21 @@ public List<AccidentReportCountRPC> getCountForRPCByDeptIdAndDay(String startTime, String endTime, Long deptId) { return accidentReportInfoRepository.getCountForRPCByDeptIdAndDay(startTime,endTime,deptId); } @Override public List<AccidentResultCountDO> getAccidentCountByDeptIdsAndTime(String startTime, String endTime, List<Long> deptIds) { if(StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime) || null == deptIds || deptIds.size() == 0){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL); } return accidentReportInfoRepository.getAccidentCountByDeptIdsAndTime(startTime,endTime,deptIds); } @Override public List<AccidentResultCountDO> getAccidentCountByDeptIdAndTime(String startTime, String endTime, Long deptId) { if(StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime) || null == deptId ){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL); } return accidentReportInfoRepository.getAccidentCountByDeptIdAndTime(startTime,endTime,deptId); } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java
@@ -5,13 +5,17 @@ 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.utils.StringUtils; 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.AccidentReportLevelEnum; import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes; import com.gkhy.safePlatform.incidentManage.enums.DepartmentLevelEnum; 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.IncidentManageCountQuery; 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; @@ -25,7 +29,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.print.DocFlavor; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -171,14 +175,19 @@ 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(); try{ 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); } } else { throw new BusinessException(ResultCodes.CLIENT_DEP_NOT_EXIST); }catch (Exception e){ throw new AccidentException(AccidentResultCodes.RPC_ERROR); } return dep; } @@ -226,4 +235,327 @@ return new ResultVO<>(ResultCodes.OK, accidentReportCountRespDTOList); } /** * 根据部门以及指定时间统计每月每种事故等级事故数量以及事故后顾相关数据量 * @param query * @return */ //@Override public StatisticsDeptLevelYearAccidentRespDTO getCountByDeptIdAndYear(IncidentManageCountQuery query) { if(null == query.getDeptId()){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"部门不可为空"); } if (null == query.getYear()) { throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"年份不可为空"); } // 通过RPC获取id对应的部门数据 DepInfoRPCRespDTO depInfoRPCRespDTO = getDepInfoByDepId(query.getDeptId()); //填充部门等级数据 StatisticsDeptLevelYearAccidentRespDTO respDTO = new StatisticsDeptLevelYearAccidentRespDTO(); respDTO.setDepLevel(depInfoRPCRespDTO.getDepLevel()); respDTO.setYear(query.getYear()); //开始时间结束时间 String startTime = TimeUtils.getYearFirst(query.getYear()); String endTime = TimeUtils.getYearLast(query.getYear()); //获取指定部门指定时间下事故统计数据 List<AccidentResultCountDO> countDOList = accidentReportInfoService.getAccidentCountByDeptIdAndTime(startTime, endTime, query.getDeptId()); List<StatisticsDepLevelMonthAccidentRespDTO> monthAccidentRespDTOList = new ArrayList<>(); //声明月份 int allMonth = 12; //判断是否是当前年分 // if(query.getYear().equals(TimeUtils.getCurrentYear())){ // allMonth = TimeUtils.getCurrentMonth(); // } //循环月份 for (int i = 1;i <= allMonth;i++) { //填充月数据 StatisticsDepLevelMonthAccidentRespDTO monthAccidentRespDTO = new StatisticsDepLevelMonthAccidentRespDTO(); monthAccidentRespDTO.setMonth(i); monthAccidentRespDTO.setDepLevel(depInfoRPCRespDTO.getDepLevel()); //过滤出该月份的所有数据 int month = i; List<AccidentResultCountDO> selectMonthList = countDOList .stream() .filter(item -> item.getMonth() == month) .collect(Collectors.toList()); List<AccidentLevelResultCountRespDTO> resultCountRespDTOList = new ArrayList<>(); //循环事故等级 for (AccidentReportLevelEnum levelEnum:AccidentReportLevelEnum.values()) { AccidentLevelResultCountRespDTO resultCountRespDTO = new AccidentLevelResultCountRespDTO(); resultCountRespDTO.setAccidentLevel(levelEnum.getCode()); resultCountRespDTO.setAccidentLevelName(levelEnum.getValue()); List<AccidentResultCountDO> levelList = selectMonthList .stream() .filter(item -> item.getAccidentLevel().equals(levelEnum.getCode())) .collect(Collectors.toList()); if(levelList.size()>0){ resultCountRespDTO.setAccidentCount(levelList.get(0).getAccidentCount()); resultCountRespDTO.setDeathCount(levelList.get(0).getDeathCount()); resultCountRespDTO.setMinorInjuryCount(levelList.get(0).getMinorInjuryCount()); resultCountRespDTO.setSeriousInjuryCount(levelList.get(0).getSeriousInjuryCount()); resultCountRespDTO.setEconomicLoss(levelList.get(0).getEconomicLoss()); resultCountRespDTOList.add(resultCountRespDTO); }else{ resultCountRespDTO.setAccidentCount(0); resultCountRespDTO.setDeathCount(0); resultCountRespDTO.setMinorInjuryCount(0); resultCountRespDTO.setSeriousInjuryCount(0); resultCountRespDTO.setEconomicLoss(BigDecimal.valueOf(0)); resultCountRespDTOList.add(resultCountRespDTO); } } monthAccidentRespDTO.setAccidentLevelList(resultCountRespDTOList); monthAccidentRespDTOList.add(monthAccidentRespDTO); } respDTO.setMonthList(monthAccidentRespDTOList); return respDTO; } @Override public StatisticsDepLevelMonthAccidentRespDTO getCountByDeptIdAndMonth(IncidentManageCountQuery query) { if(null == query.getDeptId()){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"部门不可为空"); } if (null == query.getYear()) { throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"年份不可为空"); } if(null == query.getMonth()){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"月份不可为空"); } // 通过RPC获取id对应的部门数据 DepInfoRPCRespDTO depInfoRPCRespDTO = getDepInfoByDepId(query.getDeptId()); //填充数据 StatisticsDepLevelMonthAccidentRespDTO respDTO = new StatisticsDepLevelMonthAccidentRespDTO(); respDTO.setMonth(query.getMonth()); respDTO.setDepLevel(depInfoRPCRespDTO.getDepLevel()); //开始时间结束时间 String startTime = TimeUtils.getMonthFirst(query.getYear(),query.getMonth()); String endTime = TimeUtils.getMonthLast(query.getYear(),query.getMonth()); //获取指定部门指定时间下事故统计数据 List<AccidentResultCountDO> countDOList = accidentReportInfoService.getAccidentCountByDeptIdAndTime(startTime, endTime, query.getDeptId()); List<AccidentLevelResultCountRespDTO> resultCountRespDTOList = new ArrayList<>(); //循环事故等级 for (AccidentReportLevelEnum levelEnum:AccidentReportLevelEnum.values()) { AccidentLevelResultCountRespDTO resultCountRespDTO = new AccidentLevelResultCountRespDTO(); resultCountRespDTO.setAccidentLevel(levelEnum.getCode()); resultCountRespDTO.setAccidentLevelName(levelEnum.getValue()); //过滤事故数据 List<AccidentResultCountDO> selectAccList = countDOList .stream() .filter(ac -> ac.getAccidentLevel().equals(levelEnum.getCode())) .collect(Collectors.toList()); if(selectAccList.size()>0){ resultCountRespDTO.setAccidentCount(selectAccList.get(0).getAccidentCount()); resultCountRespDTO.setDeathCount(selectAccList.get(0).getDeathCount()); resultCountRespDTO.setMinorInjuryCount(selectAccList.get(0).getMinorInjuryCount()); resultCountRespDTO.setSeriousInjuryCount(selectAccList.get(0).getSeriousInjuryCount()); resultCountRespDTO.setEconomicLoss(selectAccList.get(0).getEconomicLoss()); }else{ resultCountRespDTO.setAccidentCount(0); resultCountRespDTO.setDeathCount(0); resultCountRespDTO.setMinorInjuryCount(0); resultCountRespDTO.setSeriousInjuryCount(0); resultCountRespDTO.setEconomicLoss(BigDecimal.valueOf(0)); } resultCountRespDTOList.add(resultCountRespDTO); } respDTO.setAccidentLevelList(resultCountRespDTOList); return respDTO; } public List<StatisticsDeptLevelYearAccidentRespDTO> getCountByDeptIdsAndYear(IncidentManageCountQuery query) { if(null == query.getDeptId()){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"部门不可为空"); } if (null == query.getYear()) { throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"年份不可为空"); } // 通过RPC获取id对应的部门数据 List<DepInfoRPCRespDTO> deptInfoList = getDepListInfoByDepId(query.getDeptId()); //过滤出部门ids List<Long> deptIds = deptInfoList .stream() .map(item -> item.getDepId()) .collect(Collectors.toList()); //开始时间结束时间 String startTime = TimeUtils.getYearFirst(query.getYear()); String endTime = TimeUtils.getYearLast(query.getYear()); //获取指定部门指定时间下事故统计数据 List<AccidentResultCountDO> countDOList = accidentReportInfoService.getAccidentCountByDeptIdsAndTime(startTime, endTime, deptIds); List<StatisticsDeptLevelYearAccidentRespDTO> deptLevelRespDTOList = new ArrayList<>(); //循环部门等级 for(DepartmentLevelEnum departmentLevelEnum : DepartmentLevelEnum.values()) { //填充部门级别数据 StatisticsDeptLevelYearAccidentRespDTO depLevelRespDTO = new StatisticsDeptLevelYearAccidentRespDTO(); depLevelRespDTO.setDepLevel(departmentLevelEnum.getCode()); depLevelRespDTO.setYear(query.getYear()); //获取该部门级别下面的相关部门 List<DepInfoRPCRespDTO> selectDepList = deptInfoList .stream() .filter(dep -> dep.getDepLevel().equals(departmentLevelEnum.getCode())) .collect(Collectors.toList()); //获取该部门级别下相关部门数据 List<AccidentResultCountDO> selectAccList = countDOList .stream() .filter(exe -> selectDepList.stream().map(dep -> dep.getDepId()).collect(Collectors.toList()).contains(exe.getDeptId())) .collect(Collectors.toList()); List<StatisticsDepLevelMonthAccidentRespDTO> monthAccidentRespDTOList = new ArrayList<>(); //声明月份 int allMonth = 12; //判断是否是当前年分 // if(query.getYear().equals(TimeUtils.getCurrentYear())){ // allMonth = TimeUtils.getCurrentMonth(); // } //循环月份 for (int i = 1;i <= allMonth;i++) { //填充月数据 StatisticsDepLevelMonthAccidentRespDTO monthAccidentRespDTO = new StatisticsDepLevelMonthAccidentRespDTO(); monthAccidentRespDTO.setDepLevel(departmentLevelEnum.getCode()); monthAccidentRespDTO.setMonth(i); //过滤出该月份的所有数据 int month = i; List<AccidentResultCountDO> selectMonthList = selectAccList .stream() .filter(item -> item.getMonth() == month) .collect(Collectors.toList()); List<AccidentLevelResultCountRespDTO> resultCountRespDTOList = new ArrayList<>(); //循环事故等级 for (AccidentReportLevelEnum levelEnum:AccidentReportLevelEnum.values()) { //填充事故等级 AccidentLevelResultCountRespDTO resultCountRespDTO = new AccidentLevelResultCountRespDTO(); resultCountRespDTO.setAccidentLevel(levelEnum.getCode()); resultCountRespDTO.setAccidentLevelName(levelEnum.getValue()); //过滤出该事故等级下的数据 List<AccidentResultCountDO> accidentLevelList = selectMonthList .stream() .filter(item -> item.getAccidentLevel().equals(levelEnum.getCode())) .collect(Collectors.toList()); //事故数量 int accidentCount = 0; //死亡数量 int deathCount = 0; //重伤数量 int seriousInjuryCount = 0; //轻伤数量 int minorInjuryCount = 0; //经济损失 BigDecimal economicLoss = BigDecimal.valueOf(0.00); if(accidentLevelList.size()>0){ for(AccidentResultCountDO resultCountDO:accidentLevelList) { accidentCount += resultCountDO.getAccidentCount(); deathCount += resultCountDO.getDeathCount(); seriousInjuryCount += resultCountDO.getSeriousInjuryCount(); minorInjuryCount += resultCountDO.getMinorInjuryCount(); economicLoss = economicLoss.add(resultCountDO.getEconomicLoss()); } } resultCountRespDTO.setAccidentCount(accidentCount); resultCountRespDTO.setDeathCount(deathCount); resultCountRespDTO.setMinorInjuryCount(minorInjuryCount); resultCountRespDTO.setSeriousInjuryCount(seriousInjuryCount); resultCountRespDTO.setEconomicLoss(economicLoss); resultCountRespDTOList.add(resultCountRespDTO); } monthAccidentRespDTO.setAccidentLevelList(resultCountRespDTOList); monthAccidentRespDTOList.add(monthAccidentRespDTO); } depLevelRespDTO.setMonthList(monthAccidentRespDTOList); deptLevelRespDTOList.add(depLevelRespDTO); } return deptLevelRespDTOList; } @Override public List<StatisticsDepLevelMonthAccidentRespDTO> getCountByDeptIdsAndMonth(IncidentManageCountQuery query) { if(null == query.getDeptId()){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"部门不可为空"); } if (null == query.getYear()) { throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"年份不可为空"); } if(null == query.getMonth()){ throw new AccidentException(AccidentResultCodes.SERVE_PARAM_NULL,"月份不可为空"); } // 通过RPC获取id对应的部门数据 List<DepInfoRPCRespDTO> deptInfoList = getDepListInfoByDepId(query.getDeptId()); //过滤出部门ids List<Long> deptIds = deptInfoList .stream() .map(item -> item.getDepId()) .collect(Collectors.toList()); //开始时间结束时间 String startTime = TimeUtils.getMonthFirst(query.getYear(),query.getMonth()); String endTime = TimeUtils.getMonthLast(query.getYear(),query.getMonth()); //获取指定部门指定时间下事故统计数据 List<AccidentResultCountDO> countDOList = accidentReportInfoService.getAccidentCountByDeptIdsAndTime(startTime, endTime, deptIds); List<StatisticsDepLevelMonthAccidentRespDTO> respDTOList = new ArrayList<>(); //循环部门等级 for(DepartmentLevelEnum departmentLevelEnum : DepartmentLevelEnum.values()) { //填充部门级别数据 StatisticsDepLevelMonthAccidentRespDTO depLevelRespDTO = new StatisticsDepLevelMonthAccidentRespDTO(); depLevelRespDTO.setMonth(query.getMonth()); depLevelRespDTO.setDepLevel(departmentLevelEnum.getCode()); //获取该部门级别下面的相关部门 List<DepInfoRPCRespDTO> selectDepList = deptInfoList .stream() .filter(dep -> dep.getDepLevel().equals(departmentLevelEnum.getCode())) .collect(Collectors.toList()); //获取该部门级别下相关部门数据 List<AccidentResultCountDO> selectAccList = countDOList .stream() .filter(exe -> selectDepList.stream().map(dep -> dep.getDepId()).collect(Collectors.toList()).contains(exe.getDeptId())) .collect(Collectors.toList()); List<AccidentLevelResultCountRespDTO> resultCountRespDTOList = new ArrayList<>(); //循环事故等级 for (AccidentReportLevelEnum levelEnum:AccidentReportLevelEnum.values()) { AccidentLevelResultCountRespDTO resultCountRespDTO = new AccidentLevelResultCountRespDTO(); resultCountRespDTO.setAccidentLevel(levelEnum.getCode()); resultCountRespDTO.setAccidentLevelName(levelEnum.getValue()); //过滤出该事故等级下的数据 List<AccidentResultCountDO> accidentLevelList = selectAccList .stream() .filter(item -> item.getAccidentLevel().equals(levelEnum.getCode())) .collect(Collectors.toList()); //事故数量 int accidentCount = 0; //死亡数量 int deathCount = 0; //重伤数量 int seriousInjuryCount = 0; //轻伤数量 int minorInjuryCount = 0; //经济损失 BigDecimal economicLoss = BigDecimal.valueOf(0.00); if(accidentLevelList.size()>0){ for(AccidentResultCountDO resultCountDO:accidentLevelList) { accidentCount += resultCountDO.getAccidentCount(); deathCount += resultCountDO.getDeathCount(); seriousInjuryCount += resultCountDO.getSeriousInjuryCount(); minorInjuryCount += resultCountDO.getMinorInjuryCount(); economicLoss = economicLoss.add(resultCountDO.getEconomicLoss()); } } resultCountRespDTO.setAccidentCount(accidentCount); resultCountRespDTO.setDeathCount(deathCount); resultCountRespDTO.setMinorInjuryCount(minorInjuryCount); resultCountRespDTO.setSeriousInjuryCount(seriousInjuryCount); resultCountRespDTO.setEconomicLoss(economicLoss); resultCountRespDTOList.add(resultCountRespDTO); } depLevelRespDTO.setAccidentLevelList(resultCountRespDTOList); respDTOList.add(depLevelRespDTO); } return respDTOList; } } incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/utils/TimeUtils.java
@@ -70,7 +70,25 @@ return formatDate(currYearLast); } /** * 获取当前年份 * @return */ public static int getCurrentYear() { Calendar date = Calendar.getInstance(); int year = date.get(Calendar.YEAR); return year; } /** * 获取当前月份 * @param */ public static int getCurrentMonth() { Calendar date = Calendar.getInstance(); int month = date.get(Calendar.MONTH) + 1; return month; } public static void main(String[] args) { Calendar date = Calendar.getInstance(); int year = date.get(Calendar.YEAR); incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml
@@ -275,4 +275,56 @@ a.accident_level, DATE_FORMAT( a.gmt_create, '%d' ) </select> <select id="getAccidentCountByDeptIdsAndTime" resultType="com.gkhy.safePlatform.incidentManage.entity.AccidentResultCountDO"> SELECT count( 0 ) AS accidentCount, sum( a.economic_loss ) AS economicLoss, sum( a.minor_injury_num ) AS minorInjuryCount, sum( a.serious_injury_num ) AS seriousInjuryCount, sum( a.death_num ) AS deathCount, a.accident_level AS accidentLevel, DATE_FORMAT( a.gmt_create, '%m' ) AS month, DATE_FORMAT( a.gmt_create, '%Y' ) AS year, b.accident_department_id AS deptId FROM `accident_report` a INNER JOIN `accident_express` b ON a.accident_express_id = b.id WHERE a.del_flag = 0 AND b.accident_department_id IN <foreach collection="deptIds" item="deptId" open="(" close=")" separator=","> #{deptId} </foreach> AND DATE( a.gmt_create ) BETWEEN #{startTime} AND #{endTime} GROUP BY a.accident_level, DATE_FORMAT( a.gmt_create, '%Y-%m' ), DATE_FORMAT( a.gmt_create, '%m' ), DATE_FORMAT( a.gmt_create, '%Y' ), b.accident_department_id </select> <select id="getAccidentCountByDeptIdAndTime" resultType="com.gkhy.safePlatform.incidentManage.entity.AccidentResultCountDO"> SELECT count( 0 ) AS accidentCount, sum( a.economic_loss ) AS economicLoss, sum( a.minor_injury_num ) AS minorInjuryCount, sum( a.serious_injury_num ) AS seriousInjuryCount, sum( a.death_num ) AS deathCount, a.accident_level AS accidentLevel, DATE_FORMAT( a.gmt_create, '%m' ) AS month FROM `accident_report` a INNER JOIN `accident_express` b ON a.accident_express_id = b.id WHERE a.del_flag = 0 AND b.accident_department_id = #{deptId} AND DATE( a.gmt_create ) BETWEEN #{startTime} AND #{endTime} GROUP BY a.accident_level, DATE_FORMAT( a.gmt_create, '%Y-%m' ), DATE_FORMAT( a.gmt_create, '%m' ) </select> </mapper>