From 0414ddb0b2b3a7199ae6181a770f97ac140dbd73 Mon Sep 17 00:00:00 2001 From: zhangf <1603559716@qq.com> Date: 星期三, 08 五月 2024 16:46:22 +0800 Subject: [PATCH] spi统计 --- incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/WorkInjuryDeclarationServiceImpl.java | 172 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 100 insertions(+), 72 deletions(-) diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/WorkInjuryDeclarationServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/WorkInjuryDeclarationServiceImpl.java index 80b673f..7429f08 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/WorkInjuryDeclarationServiceImpl.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/WorkInjuryDeclarationServiceImpl.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; @@ -9,6 +11,7 @@ import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.incidentManage.entity.*; import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes; +import com.gkhy.safePlatform.incidentManage.enums.WorkInjuryTypeEnum; import com.gkhy.safePlatform.incidentManage.exception.AccidentException; import com.gkhy.safePlatform.incidentManage.model.dto.req.WorkInjuryDeclarationFileReqDTO; import com.gkhy.safePlatform.incidentManage.model.dto.req.WorkInjuryDeclarationReqDTO; @@ -18,16 +21,16 @@ import com.gkhy.safePlatform.incidentManage.query.WorkInjuryDeclarationQuery; import com.gkhy.safePlatform.incidentManage.query.db.WorkInjuryDeclarationDBQuery; import com.gkhy.safePlatform.incidentManage.service.WorkInjuryDeclarationService; +import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressInfoService; import com.gkhy.safePlatform.incidentManage.service.baseService.WorkInjuryDeclarationFileInfoService; import com.gkhy.safePlatform.incidentManage.service.baseService.WorkInjuryDeclarationInfoService; +import org.apache.dubbo.config.annotation.DubboReference; 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("workInjuryDeclarationService") @@ -38,6 +41,12 @@ @Autowired private WorkInjuryDeclarationFileInfoService workInjuryDeclarationFileInfoService; + + @DubboReference(check = false) + private AccountDepartmentService accountDepartmentService; + + @Autowired + private AccidentExpressInfoService accidentExpressInfoService; @Override @@ -55,10 +64,30 @@ List<WorkInjuryDeclarationInfoPageDO> WorkInjuryDeclarationInfoPageDOList = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationList(page, WorkInjuryDeclarationDBQuery); List<WorkInjuryDeclarationPageRespDTO> respList = BeanCopyUtils.copyBeanList(WorkInjuryDeclarationInfoPageDOList, WorkInjuryDeclarationPageRespDTO.class); + + Map<Long, String> depPool = new HashMap<>(); + + respList.forEach(WorkInjuryDeclarationPageRespDTO -> { + // 设置部门名称 + if (!depPool.containsKey(WorkInjuryDeclarationPageRespDTO.getDeclareDepartmentId())) { + ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(WorkInjuryDeclarationPageRespDTO.getDeclareDepartmentId()); + 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(WorkInjuryDeclarationPageRespDTO.getDeclareDepartmentId()); + WorkInjuryDeclarationPageRespDTO.setDeptName(depName); + }); + return new SearchResultVO<>( true, pageIndex, - pageSize, + pageSize, page.getPages(), page.getTotal(), respList, ResultCodes.OK @@ -79,13 +108,13 @@ WorkInjuryDeclarationInfo.setGmtCreate(nowDate); workInjuryDeclarationInfoService.addWorkInjuryDeclaration(WorkInjuryDeclarationInfo); //2.新增工伤申报附件 - if (!CollectionUtils.isEmpty(WorkInjuryDeclarationReqDTO.getFileList())){ - addWorkInjuryDeclarationFile(WorkInjuryDeclarationInfo.getId(),uid,nowDate,WorkInjuryDeclarationReqDTO.getFileList()); + if (!CollectionUtils.isEmpty(WorkInjuryDeclarationReqDTO.getFileList())) { + addWorkInjuryDeclarationFile(WorkInjuryDeclarationInfo.getId(), uid, nowDate, WorkInjuryDeclarationReqDTO.getFileList()); } return new ResultVO(ResultCodes.OK); } - private void addWorkInjuryDeclarationFile(Long WorkInjuryDeclarationId ,Long uid , Date nowDate , List<WorkInjuryDeclarationFileReqDTO> WorkInjuryDeclarationFileReqDTOList){ + private void addWorkInjuryDeclarationFile(Long WorkInjuryDeclarationId, Long uid, Date nowDate, List<WorkInjuryDeclarationFileReqDTO> WorkInjuryDeclarationFileReqDTOList) { List<WorkInjuryDeclarationFileInfo> fileInfoList = BeanCopyUtils.copyBeanList(WorkInjuryDeclarationFileReqDTOList, WorkInjuryDeclarationFileInfo.class); fileInfoList.forEach(WorkInjuryDeclarationFileInfo -> { WorkInjuryDeclarationFileInfo.setWorkInjuryDeclarationId(WorkInjuryDeclarationId); @@ -93,7 +122,7 @@ WorkInjuryDeclarationFileInfo.setCreateUid(uid); WorkInjuryDeclarationFileInfo.setGmtCreate(nowDate); }); - for (WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo :fileInfoList){ + for (WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo : fileInfoList) { workInjuryDeclarationFileInfoService.addWorkInjuryDeclarationFile(WorkInjuryDeclarationFileInfo); } } @@ -103,17 +132,17 @@ WorkInjuryDeclarationDetailRespDTO WorkInjuryDeclarationDetailRespDTO = new WorkInjuryDeclarationDetailRespDTO(); //查询是否存在 WorkInjuryDeclarationInfoDetailDO WorkInjuryDeclarationInfoDetailDO = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationById(id); - if (WorkInjuryDeclarationInfoDetailDO==null){ - throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); - }else{ - BeanUtils.copyProperties(WorkInjuryDeclarationInfoDetailDO,WorkInjuryDeclarationDetailRespDTO); + if (WorkInjuryDeclarationInfoDetailDO == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NOT_EXIST); + } else { + BeanUtils.copyProperties(WorkInjuryDeclarationInfoDetailDO, WorkInjuryDeclarationDetailRespDTO); //查找对应的附件 List<WorkInjuryDeclarationFileInfoDO> WorkInjuryDeclarationFileInfoDOList = workInjuryDeclarationFileInfoService.selectByWorkInjuryDeclarationId(id); - if (!CollectionUtils.isEmpty(WorkInjuryDeclarationFileInfoDOList)){ - List<WorkInjuryDeclarationFileRespDTO> WorkInjuryDeclarationFileRespDTOList = BeanCopyUtils.copyBeanList(WorkInjuryDeclarationFileInfoDOList , WorkInjuryDeclarationFileRespDTO.class); + if (!CollectionUtils.isEmpty(WorkInjuryDeclarationFileInfoDOList)) { + List<WorkInjuryDeclarationFileRespDTO> WorkInjuryDeclarationFileRespDTOList = BeanCopyUtils.copyBeanList(WorkInjuryDeclarationFileInfoDOList, WorkInjuryDeclarationFileRespDTO.class); WorkInjuryDeclarationDetailRespDTO.setFileList(WorkInjuryDeclarationFileRespDTOList); } - return new ResultVO<>(ResultCodes.OK ,WorkInjuryDeclarationDetailRespDTO); + return new ResultVO<>(ResultCodes.OK, WorkInjuryDeclarationDetailRespDTO); } } @@ -122,21 +151,21 @@ Date nowDate = new Date(); //查询是否存在 WorkInjuryDeclarationInfoDetailDO WorkInjuryDeclarationInfoDetailDO = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationById(WorkInjuryDeclarationReqDTO.getId()); - if (WorkInjuryDeclarationInfoDetailDO==null){ - throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); - }else{ + if (WorkInjuryDeclarationInfoDetailDO == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NOT_EXIST); + } else { WorkInjuryDeclarationInfo WorkInjuryDeclarationInfo = new WorkInjuryDeclarationInfo(); - BeanUtils.copyProperties(WorkInjuryDeclarationReqDTO,WorkInjuryDeclarationInfo); + BeanUtils.copyProperties(WorkInjuryDeclarationReqDTO, WorkInjuryDeclarationInfo); WorkInjuryDeclarationInfo.setUpdateUid(uid); WorkInjuryDeclarationInfo.setGmtModitify(nowDate); workInjuryDeclarationInfoService.updateWorkInjuryDeclaration(WorkInjuryDeclarationInfo); //修改工伤申报附件 - updateWorkInjuryDeclarationFile(uid,WorkInjuryDeclarationReqDTO.getId(),nowDate,WorkInjuryDeclarationReqDTO.getFileList()); + updateWorkInjuryDeclarationFile(uid, WorkInjuryDeclarationReqDTO.getId(), nowDate, WorkInjuryDeclarationReqDTO.getFileList()); return new ResultVO(ResultCodes.OK); } } - private void updateWorkInjuryDeclarationFile(Long uid ,Long WorkInjuryDeclarationId ,Date nowDate,List<WorkInjuryDeclarationFileReqDTO> WorkInjuryDeclarationFileReqDTOList){ + private void updateWorkInjuryDeclarationFile(Long uid, Long WorkInjuryDeclarationId, Date nowDate, List<WorkInjuryDeclarationFileReqDTO> WorkInjuryDeclarationFileReqDTOList) { List<WorkInjuryDeclarationFileInfoDO> WorkInjuryDeclarationFileInfoDOList = workInjuryDeclarationFileInfoService.selectByWorkInjuryDeclarationId(WorkInjuryDeclarationId); List<Long> oldIdsList = WorkInjuryDeclarationFileInfoDOList.stream().map(WorkInjuryDeclarationFileInfoDO::getId).collect(Collectors.toList()); @@ -146,11 +175,11 @@ List<WorkInjuryDeclarationFileInfo> addList = new ArrayList<>(); //删除的附件集合(id) List<Long> deleteList = new ArrayList<>(); - for (WorkInjuryDeclarationFileReqDTO WorkInjuryDeclarationFileReqDTO : WorkInjuryDeclarationFileReqDTOList){ + for (WorkInjuryDeclarationFileReqDTO WorkInjuryDeclarationFileReqDTO : WorkInjuryDeclarationFileReqDTOList) { //如果不存在id则表示页面新增的附件 - if (WorkInjuryDeclarationFileReqDTO.getId() == null){ + if (WorkInjuryDeclarationFileReqDTO.getId() == null) { WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo = new WorkInjuryDeclarationFileInfo(); - BeanUtils.copyProperties(WorkInjuryDeclarationFileReqDTO,WorkInjuryDeclarationFileInfo); + BeanUtils.copyProperties(WorkInjuryDeclarationFileReqDTO, WorkInjuryDeclarationFileInfo); WorkInjuryDeclarationFileInfo.setDelFlag(false); WorkInjuryDeclarationFileInfo.setGmtCreate(nowDate); WorkInjuryDeclarationFileInfo.setCreateUid(uid); @@ -158,34 +187,34 @@ addList.add(WorkInjuryDeclarationFileInfo); } //如果存在id则判断页面是否删除 - else{ + else { newIdsList.add(WorkInjuryDeclarationFileReqDTO.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 (WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo : addList){ + if (!CollectionUtils.isEmpty(addList)) { + for (WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo : addList) { workInjuryDeclarationFileInfoService.addWorkInjuryDeclarationFile(WorkInjuryDeclarationFileInfo); } } - if (!CollectionUtils.isEmpty(deleteList)){ + if (!CollectionUtils.isEmpty(deleteList)) { workInjuryDeclarationFileInfoService.deleteWorkInjuryDeclarationFileByIds(deleteList); } } @Override - public ResultVO batchDeleteWorkInjuryDeclaration(String ids) { - if (StringUtils.isBlank(ids)){ - throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NULL); - }else{ - String[] idArr = ids.split(","); - for (String id : idArr) { - deleteWorkInjuryDeclaration(Long.valueOf(id)); + public ResultVO batchDeleteWorkInjuryDeclaration(Long[] ids) { + + if (ids == null || ids.length == 0) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NULL); + } else { + for (Long id : ids) { + deleteWorkInjuryDeclaration(id); } return new ResultVO(ResultCodes.OK); } @@ -194,9 +223,9 @@ private void deleteWorkInjuryDeclaration(Long id) { //查询是否存在 WorkInjuryDeclarationInfoDetailDO WorkInjuryDeclarationInfoDetailDO = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationById(id); - if (WorkInjuryDeclarationInfoDetailDO==null){ - throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); - }else{ + if (WorkInjuryDeclarationInfoDetailDO == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NOT_EXIST); + } else { workInjuryDeclarationInfoService.deleteWorkInjuryDeclarationById(id); //删除附件 workInjuryDeclarationFileInfoService.deleteWorkInjuryDeclarationFileByWorkInjuryDeclarationId(id); @@ -204,49 +233,48 @@ } - - /** * 验证必填项 + * * @return */ - private void checkRequired(WorkInjuryDeclarationReqDTO WorkInjuryDeclarationReqDTO) { - /* //名称 - if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getAccidentName())) { - throw new AccidentException(AccidentResultCodes.Report_NAME_NULL); + private void checkRequired(WorkInjuryDeclarationReqDTO workInjuryDeclarationReqDTO) { + //申报人姓名 + if (StringUtils.isBlank(workInjuryDeclarationReqDTO.getDeclareUserName())) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_USERNAME_NULL); } - //部门 - if (WorkInjuryDeclarationReqDTO.getAccidentDepartmentId()==null) { - throw new AccidentException(AccidentResultCodes.Report_DEPARTMENT_NULL); + //事故性别 + if (workInjuryDeclarationReqDTO.getDeclareUserGender() == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_GENDER_NULL); } - //发生时间 - if (WorkInjuryDeclarationReqDTO.getOccurrenceTime() == null ) { - throw new AccidentException(AccidentResultCodes.Report_TIME_NULL); + //申报人部门 + if (workInjuryDeclarationReqDTO.getDeclareDepartmentId() == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_USERNAME_NOT_EXIST); } - //发生地点 - if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getOccurrencePlace())) { - throw new AccidentException(AccidentResultCodes.Report_PLACE_NULL); + //事故名称 + if (workInjuryDeclarationReqDTO.getAccidentExpressId() == null) { + throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL); } - //事故原因 - if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getAccidentCause())) { - throw new AccidentException(AccidentResultCodes.Report_CAUSE_NULL); + AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(workInjuryDeclarationReqDTO.getAccidentExpressId()); + if (accidentExpressInfo == null) { + throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NOT_EXIST); } - //是否有伤亡 - if (WorkInjuryDeclarationReqDTO.getCasualties()==null) { - throw new AccidentException(AccidentResultCodes.Report_CASUALTIES_NULL); + //工伤类型 + if (workInjuryDeclarationReqDTO.getWorkInjuryType() == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_TYPE_NULL); } - //简要经过 - if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getAccidentBriefProcess())) { - throw new AccidentException(AccidentResultCodes.Report_BRIEF_PROCESS_NULL); + //申报日期 + if (workInjuryDeclarationReqDTO.getDeclareDate() == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_DATA_NULL); } - //初步分析 - if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getAccidentCausesPreliminaryAnalysis())) { - throw new AccidentException(AccidentResultCodes.Report_CASE_PRELIMINARY_ANALYSIS_NULL); - } - //应急防范措施 - if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getEmergencyPrecautions())) { - throw new AccidentException(AccidentResultCodes.Report_EMERGENCY_PRECAUTIONS_NULL); - }*/ } + /** + * 枚举验证 + */ + private void checkEnum(WorkInjuryDeclarationReqDTO workInjuryDeclarationReqDTO) { + if (WorkInjuryTypeEnum.getByCode(workInjuryDeclarationReqDTO.getWorkInjuryType()) == null) { + throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_ENUMS_TYPE_NOT_EXIST); + } + } } -- Gitblit v1.9.2