From c9529bd19a8d61666b71824dd751682c1e9dc288 Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期一, 15 八月 2022 10:39:31 +0800 Subject: [PATCH] Merge branches 'genchuang' and 'master' of https://sinanoaq.cn:8888/r/safePlatform-out into master --- incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java | 229 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 158 insertions(+), 71 deletions(-) diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java index 0df3f3c..72b5683 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java @@ -1,6 +1,8 @@ package com.gkhy.safePlatform.incidentManage.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService; +import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; @@ -12,22 +14,25 @@ import com.gkhy.safePlatform.incidentManage.exception.AccidentException; import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportFileReqDTO; import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportReqDTO; -import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportDetailRespDTO; -import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportFileRespDTO; -import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportPageRespDTO; +import com.gkhy.safePlatform.incidentManage.model.dto.resp.*; import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery; +import com.gkhy.safePlatform.incidentManage.query.AccidentReportRPCQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery; +import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery; import com.gkhy.safePlatform.incidentManage.service.AccidentReportService; +import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressFileInfoService; +import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressInfoService; import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportFileInfoService; import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportInfoService; +import com.gkhy.safePlatform.incidentManage.utils.TimeUtils; +import org.apache.dubbo.config.annotation.DubboReference; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Service("accidentReportService") @@ -38,6 +43,15 @@ @Autowired private AccidentReportFileInfoService accidentReportFileInfoService; + + @DubboReference(check = false) + private AccountDepartmentService accountDepartmentService; + + @Autowired + private AccidentExpressInfoService accidentExpressInfoService; + + @Autowired + private AccidentExpressFileInfoService accidentExpressFileInfoService; @Override @@ -55,10 +69,30 @@ List<AccidentReportInfoPageDO> accidentReportInfoPageDOList = accidentReportInfoService.selectAccidentReportList(page, accidentReportDBQuery); List<AccidentReportPageRespDTO> respList = BeanCopyUtils.copyBeanList(accidentReportInfoPageDOList, AccidentReportPageRespDTO.class); + Map<Long, String> depPool = new HashMap<>(); + + respList.forEach(AccidentReportPageRespDTO -> { + // 设置部门名称 + if (!depPool.containsKey(AccidentReportPageRespDTO.getAccidentDepartmentId())) { + ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(AccidentReportPageRespDTO.getAccidentDepartmentId()); + if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) { + if (rpcResult.getData() != null) { + DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData(); + + depPool.put(dep.getDepId(), dep.getDepName()); + } + } + } + + String depName = depPool.get(AccidentReportPageRespDTO.getAccidentDepartmentId()); + AccidentReportPageRespDTO.setDeptName(depName); + }); + + return new SearchResultVO<>( true, pageIndex, - pageSize, + pageSize, page.getPages(), page.getTotal(), respList, ResultCodes.OK @@ -77,16 +111,15 @@ accidentReportInfo.setDelFlag(false); accidentReportInfo.setCreateUid(uid); accidentReportInfo.setGmtCreate(nowDate); - accidentReportInfo.setStatus(false); accidentReportInfoService.addAccidentReport(accidentReportInfo); //2.新增事故报告附件 - if (!CollectionUtils.isEmpty(accidentReportReqDTO.getFileList())){ - addAccidentReportFile(accidentReportInfo.getId(),uid,nowDate,accidentReportReqDTO.getFileList()); + if (!CollectionUtils.isEmpty(accidentReportReqDTO.getFileList())) { + addAccidentReportFile(accidentReportInfo.getId(), uid, nowDate, accidentReportReqDTO.getFileList()); } return new ResultVO(ResultCodes.OK); } - private void addAccidentReportFile(Long accidentReportId ,Long uid , Date nowDate , List<AccidentReportFileReqDTO> AccidentReportFileReqDTOList){ + private void addAccidentReportFile(Long accidentReportId, Long uid, Date nowDate, List<AccidentReportFileReqDTO> AccidentReportFileReqDTOList) { List<AccidentReportFileInfo> fileInfoList = BeanCopyUtils.copyBeanList(AccidentReportFileReqDTOList, AccidentReportFileInfo.class); fileInfoList.forEach(AccidentReportFileInfo -> { AccidentReportFileInfo.setAccidentReportId(accidentReportId); @@ -94,7 +127,7 @@ AccidentReportFileInfo.setCreateUid(uid); AccidentReportFileInfo.setGmtCreate(nowDate); }); - for (AccidentReportFileInfo AccidentReportFileInfo :fileInfoList){ + for (AccidentReportFileInfo AccidentReportFileInfo : fileInfoList) { accidentReportFileInfoService.addAccidentReportFile(AccidentReportFileInfo); } } @@ -104,17 +137,25 @@ AccidentReportDetailRespDTO AccidentReportDetailRespDTO = new AccidentReportDetailRespDTO(); //查询是否存在 AccidentReportInfoDetailDO AccidentReportInfoDetailDO = accidentReportInfoService.selectAccidentReportById(id); - if (AccidentReportInfoDetailDO==null){ + if (AccidentReportInfoDetailDO == null) { throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); - }else{ - BeanUtils.copyProperties(AccidentReportInfoDetailDO,AccidentReportDetailRespDTO); - //查找对应的附件 + } else { + BeanUtils.copyProperties(AccidentReportInfoDetailDO, AccidentReportDetailRespDTO); + //查找事故报告对应的附件 List<AccidentReportFileInfoDO> AccidentReportFileInfoDOList = accidentReportFileInfoService.selectByAccidentReportId(id); - if (!CollectionUtils.isEmpty(AccidentReportFileInfoDOList)){ - List<AccidentReportFileRespDTO> accidentReportFileRespDTOList = BeanCopyUtils.copyBeanList(AccidentReportFileInfoDOList , AccidentReportFileRespDTO.class); + if (!CollectionUtils.isEmpty(AccidentReportFileInfoDOList)) { + List<AccidentReportFileRespDTO> accidentReportFileRespDTOList = BeanCopyUtils.copyBeanList(AccidentReportFileInfoDOList, AccidentReportFileRespDTO.class); AccidentReportDetailRespDTO.setFileList(accidentReportFileRespDTOList); } - return new ResultVO<>(ResultCodes.OK ,AccidentReportDetailRespDTO); + // 查找事故快报对应的附件 + List<AccidentExpressFileInfoDO> AccidentExpressFileInfoDOList = accidentExpressFileInfoService.selectByAccidentExpressId(AccidentReportDetailRespDTO.getAccidentExpressId()); + if (!CollectionUtils.isEmpty(AccidentExpressFileInfoDOList)) { + List<AccidentExpressFileRespDTO> accidentExpressFileRespDTOList = BeanCopyUtils.copyBeanList(AccidentExpressFileInfoDOList, AccidentExpressFileRespDTO.class); + AccidentReportDetailRespDTO.setExpressFileList(accidentExpressFileRespDTOList); + } + + + return new ResultVO<>(ResultCodes.OK, AccidentReportDetailRespDTO); } } @@ -123,21 +164,21 @@ Date nowDate = new Date(); //查询是否存在 AccidentReportInfoDetailDO AccidentReportInfoDetailDO = accidentReportInfoService.selectAccidentReportById(accidentReportReqDTO.getId()); - if (AccidentReportInfoDetailDO==null){ + if (AccidentReportInfoDetailDO == null) { throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); - }else{ + } else { AccidentReportInfo accidentReportInfo = new AccidentReportInfo(); - BeanUtils.copyProperties(accidentReportReqDTO,accidentReportInfo); + BeanUtils.copyProperties(accidentReportReqDTO, accidentReportInfo); accidentReportInfo.setUpdateUid(uid); accidentReportInfo.setGmtModitify(nowDate); accidentReportInfoService.updateAccidentReport(accidentReportInfo); //修改事故报告附件 - updateAccidentReportFile(uid,accidentReportReqDTO.getId(),nowDate,accidentReportReqDTO.getFileList()); + updateAccidentReportFile(uid, accidentReportReqDTO.getId(), nowDate, accidentReportReqDTO.getFileList()); return new ResultVO(ResultCodes.OK); } } - private void updateAccidentReportFile(Long uid ,Long accidentReportId ,Date nowDate,List<AccidentReportFileReqDTO> AccidentReportFileReqDTOList){ + private void updateAccidentReportFile(Long uid, Long accidentReportId, Date nowDate, List<AccidentReportFileReqDTO> AccidentReportFileReqDTOList) { List<AccidentReportFileInfoDO> accidentReportFileInfoDOList = accidentReportFileInfoService.selectByAccidentReportId(accidentReportId); List<Long> oldIdsList = accidentReportFileInfoDOList.stream().map(AccidentReportFileInfoDO::getId).collect(Collectors.toList()); @@ -147,11 +188,11 @@ List<AccidentReportFileInfo> addList = new ArrayList<>(); //删除的附件集合(id) List<Long> deleteList = new ArrayList<>(); - for (AccidentReportFileReqDTO AccidentReportFileReqDTO : AccidentReportFileReqDTOList){ + for (AccidentReportFileReqDTO AccidentReportFileReqDTO : AccidentReportFileReqDTOList) { //如果不存在id则表示页面新增的附件 - if (AccidentReportFileReqDTO.getId() == null){ + if (AccidentReportFileReqDTO.getId() == null) { AccidentReportFileInfo AccidentReportFileInfo = new AccidentReportFileInfo(); - BeanUtils.copyProperties(AccidentReportFileReqDTO,AccidentReportFileInfo); + BeanUtils.copyProperties(AccidentReportFileReqDTO, AccidentReportFileInfo); AccidentReportFileInfo.setDelFlag(false); AccidentReportFileInfo.setGmtCreate(nowDate); AccidentReportFileInfo.setCreateUid(uid); @@ -159,45 +200,46 @@ addList.add(AccidentReportFileInfo); } //如果存在id则判断页面是否删除 - else{ + else { newIdsList.add(AccidentReportFileReqDTO.getId()); } } - for (Long oldId : oldIdsList){ - if (!newIdsList.contains(oldId)){ + for (Long oldId : oldIdsList) { + if (!newIdsList.contains(oldId)) { deleteList.add(oldId); } } - if (!CollectionUtils.isEmpty(addList)){ - for (AccidentReportFileInfo AccidentReportFileInfo : addList){ + if (!CollectionUtils.isEmpty(addList)) { + for (AccidentReportFileInfo AccidentReportFileInfo : addList) { accidentReportFileInfoService.addAccidentReportFile(AccidentReportFileInfo); } } - if (!CollectionUtils.isEmpty(deleteList)){ + if (!CollectionUtils.isEmpty(deleteList)) { accidentReportFileInfoService.deleteAccidentReportFileByIds(deleteList); } } @Override - public ResultVO batchDeleteAccidentReport(String ids) { - if (StringUtils.isBlank(ids)){ + public ResultVO batchDeleteAccidentReport(Long[] ids) { + if (ids == null || ids.length==0){ throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NULL); - }else{ - String[] idArr = ids.split(","); - for (String id : idArr) { - deleteAccidentReport(Long.valueOf(id)); + } else { + + for (Long id : ids){ + deleteAccidentReport(id); } return new ResultVO(ResultCodes.OK); } } + private void deleteAccidentReport(Long id) { //查询是否存在 AccidentReportInfoDetailDO AccidentReportInfoDetailDO = accidentReportInfoService.selectAccidentReportById(id); - if (AccidentReportInfoDetailDO==null){ + if (AccidentReportInfoDetailDO == null) { throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); - }else{ + } else { accidentReportInfoService.deleteAccidentReportById(id); //删除附件 accidentReportFileInfoService.deleteAccidentReportFileByAccidentReportId(id); @@ -205,49 +247,94 @@ } - - /** * 验证必填项 + * * @return */ private void checkRequired(AccidentReportReqDTO AccidentReportReqDTO) { - /* //名称 - if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentName())) { - throw new AccidentException(AccidentResultCodes.Report_NAME_NULL); + //事故快报 + if (AccidentReportReqDTO.getAccidentExpressId() == null) { + throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL); } - //部门 - if (AccidentReportReqDTO.getAccidentDepartmentId()==null) { - throw new AccidentException(AccidentResultCodes.Report_DEPARTMENT_NULL); + AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(AccidentReportReqDTO.getAccidentExpressId()); + if (accidentExpressInfo == null) { + throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NOT_EXIST); } - //发生时间 - if (AccidentReportReqDTO.getOccurrenceTime() == null ) { - throw new AccidentException(AccidentResultCodes.Report_TIME_NULL); + + //事故类型 + if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentType())) { + throw new AccidentException(AccidentResultCodes.REPORT_TYPE_NULL); } - //发生地点 - if (StringUtils.isBlank(AccidentReportReqDTO.getOccurrencePlace())) { - throw new AccidentException(AccidentResultCodes.Report_PLACE_NULL); + //事故等级 + if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentGrade())) { + throw new AccidentException(AccidentResultCodes.REPORT_GRADE_NULL); } - //事故原因 - if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentCause())) { - throw new AccidentException(AccidentResultCodes.Report_CAUSE_NULL); + //经济损失 + if (AccidentReportReqDTO.getEconomicLoss() == null) { + throw new AccidentException(AccidentResultCodes.REPORT_ECONOMIC_LOSS_NULL); } - //是否有伤亡 - if (AccidentReportReqDTO.getCasualties()==null) { - throw new AccidentException(AccidentResultCodes.Report_CASUALTIES_NULL); + //要求报告完成期限 + if (AccidentReportReqDTO.getReportDeadline() == null) { + throw new AccidentException(AccidentResultCodes.REPORT_REPORT_DEADLINE_NULL); } - //简要经过 - if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentBriefProcess())) { - throw new AccidentException(AccidentResultCodes.Report_BRIEF_PROCESS_NULL); + //事故级别 + if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentLevel())) { + throw new AccidentException(AccidentResultCodes.REPORT_LEVEL_NULL); } - //初步分析 - if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentCausesPreliminaryAnalysis())) { - throw new AccidentException(AccidentResultCodes.Report_CASE_PRELIMINARY_ANALYSIS_NULL); + //原因综合分析(直接) + if (StringUtils.isBlank(AccidentReportReqDTO.getComprehensiveAnalysisDirect())) { + throw new AccidentException(AccidentResultCodes.REPORT_COMPREHENSIVE_ANALYSIS_DIRECT_NULL); } - //应急防范措施 - if (StringUtils.isBlank(AccidentReportReqDTO.getEmergencyPrecautions())) { - throw new AccidentException(AccidentResultCodes.Report_EMERGENCY_PRECAUTIONS_NULL); - }*/ + //原因综合分析(直接) + if (StringUtils.isBlank(AccidentReportReqDTO.getComprehensiveAnalysisDirect())) { + throw new AccidentException(AccidentResultCodes.REPORT_COMPREHENSIVE_ANALYSIS_DIRECT_NULL); + } + //原因综合分析(间接) + if (StringUtils.isBlank(AccidentReportReqDTO.getComprehensiveAnalysisIndirect())) { + throw new AccidentException(AccidentResultCodes.REPORT_COMPREHENSIVE_ANALYSIS_INDIRECT_NULL); + } + //整改措施 + if (StringUtils.isBlank(AccidentReportReqDTO.getRectificationMeasures())) { + throw new AccidentException(AccidentResultCodes.REPORT_RECTIFICATION_MEASURES_NULL); + } + //事故处理 + if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentHandling())) { + throw new AccidentException(AccidentResultCodes.REPORT_ACCIDENT_HANDLING_NULL); + } + //填写人 + if (AccidentReportReqDTO.getFillInUserUid() == null) { + throw new AccidentException(AccidentResultCodes.REPORT_FILL_IN_USER_UID_NULL); + } + //填写日期 + if (AccidentReportReqDTO.getFillInTime() == null) { + throw new AccidentException(AccidentResultCodes.REPORT_FILL_IN_TIME_NULL); + } + } + + @Override + public ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportRPCQuery query) { + + List<AccidentReportCount> list = new ArrayList<>(); + AccidentReportRPCDBQuery dbQuery = new AccidentReportRPCDBQuery(); + if (query.getType()==1){ + // 月 + int year = query.getYear(); + int month = query.getMonth(); + dbQuery.setStartTime(TimeUtils.getMonthFirst(year,month)); + dbQuery.setEndTime(TimeUtils.getMonthLast(year,month)); + list = accidentReportInfoService.selectByTimeAndType(dbQuery); + } + if (query.getType()==2){ + // 年 + int year = query.getYear(); + dbQuery.setStartTime(TimeUtils.getYearFirst(year)); + dbQuery.setEndTime(TimeUtils.getYearLast(year)); + list = accidentReportInfoService.selectByTimeAndType(dbQuery); + } + + List<AccidentReportCountRespDTO> accidentReportCountRespDTOList = BeanCopyUtils.copyBeanList(list,AccidentReportCountRespDTO.class); + return new ResultVO<>(ResultCodes.OK,accidentReportCountRespDTOList); } } -- Gitblit v1.9.2