| | |
| | | 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; |
| | |
| | | return new SearchResultVO<>( |
| | | true, |
| | | pageIndex, |
| | | pageSize,page.getPages(), |
| | | pageSize, page.getPages(), |
| | | page.getTotal(), |
| | | respList, |
| | | ResultCodes.OK |
| | |
| | | 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); |
| | |
| | | WorkInjuryDeclarationFileInfo.setCreateUid(uid); |
| | | WorkInjuryDeclarationFileInfo.setGmtCreate(nowDate); |
| | | }); |
| | | for (WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo :fileInfoList){ |
| | | for (WorkInjuryDeclarationFileInfo WorkInjuryDeclarationFileInfo : fileInfoList) { |
| | | workInjuryDeclarationFileInfoService.addWorkInjuryDeclarationFile(WorkInjuryDeclarationFileInfo); |
| | | } |
| | | } |
| | |
| | | WorkInjuryDeclarationDetailRespDTO WorkInjuryDeclarationDetailRespDTO = new WorkInjuryDeclarationDetailRespDTO(); |
| | | //查询是否存在 |
| | | WorkInjuryDeclarationInfoDetailDO WorkInjuryDeclarationInfoDetailDO = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationById(id); |
| | | if (WorkInjuryDeclarationInfoDetailDO==null){ |
| | | if (WorkInjuryDeclarationInfoDetailDO == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NOT_EXIST); |
| | | }else{ |
| | | BeanUtils.copyProperties(WorkInjuryDeclarationInfoDetailDO,WorkInjuryDeclarationDetailRespDTO); |
| | | } 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); |
| | | } |
| | | } |
| | | |
| | |
| | | Date nowDate = new Date(); |
| | | //查询是否存在 |
| | | WorkInjuryDeclarationInfoDetailDO WorkInjuryDeclarationInfoDetailDO = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationById(WorkInjuryDeclarationReqDTO.getId()); |
| | | if (WorkInjuryDeclarationInfoDetailDO==null){ |
| | | if (WorkInjuryDeclarationInfoDetailDO == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NOT_EXIST); |
| | | }else{ |
| | | } 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()); |
| | |
| | | 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); |
| | |
| | | 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(Long[] ids) { |
| | | |
| | | if (ids == null || ids.length==0){ |
| | | if (ids == null || ids.length == 0) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NULL); |
| | | }else{ |
| | | for (Long id : ids){ |
| | | } else { |
| | | for (Long id : ids) { |
| | | deleteWorkInjuryDeclaration(id); |
| | | } |
| | | return new ResultVO(ResultCodes.OK); |
| | |
| | | private void deleteWorkInjuryDeclaration(Long id) { |
| | | //查询是否存在 |
| | | WorkInjuryDeclarationInfoDetailDO WorkInjuryDeclarationInfoDetailDO = workInjuryDeclarationInfoService.selectWorkInjuryDeclarationById(id); |
| | | if (WorkInjuryDeclarationInfoDetailDO==null){ |
| | | if (WorkInjuryDeclarationInfoDetailDO == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_NOT_EXIST); |
| | | }else{ |
| | | } else { |
| | | workInjuryDeclarationInfoService.deleteWorkInjuryDeclarationById(id); |
| | | //删除附件 |
| | | workInjuryDeclarationFileInfoService.deleteWorkInjuryDeclarationFileByWorkInjuryDeclarationId(id); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 验证必填项 |
| | | * |
| | | * @return |
| | | */ |
| | | private void checkRequired(WorkInjuryDeclarationReqDTO WorkInjuryDeclarationReqDTO) { |
| | | private void checkRequired(WorkInjuryDeclarationReqDTO workInjuryDeclarationReqDTO) { |
| | | //申报人姓名 |
| | | if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getDeclareUserName())) { |
| | | if (StringUtils.isBlank(workInjuryDeclarationReqDTO.getDeclareUserName())) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_USERNAME_NULL); |
| | | } |
| | | //事故性别 |
| | | if (WorkInjuryDeclarationReqDTO.getDeclareUserGender() == null ) { |
| | | if (workInjuryDeclarationReqDTO.getDeclareUserGender() == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_GENDER_NULL); |
| | | } |
| | | //申报人部门 |
| | | if (WorkInjuryDeclarationReqDTO.getDeclareDepartmentId()==null) { |
| | | if (workInjuryDeclarationReqDTO.getDeclareDepartmentId() == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_USERNAME_NOT_EXIST); |
| | | } |
| | | //事故名称 |
| | | if (WorkInjuryDeclarationReqDTO.getAccidentExpressId() == null ) { |
| | | if (workInjuryDeclarationReqDTO.getAccidentExpressId() == null) { |
| | | throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL); |
| | | } |
| | | AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(WorkInjuryDeclarationReqDTO.getAccidentExpressId()); |
| | | AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(workInjuryDeclarationReqDTO.getAccidentExpressId()); |
| | | if (accidentExpressInfo == null) { |
| | | throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NOT_EXIST); |
| | | } |
| | | //工伤类型 |
| | | if (StringUtils.isBlank(WorkInjuryDeclarationReqDTO.getWorkInjuryType())) { |
| | | if (workInjuryDeclarationReqDTO.getWorkInjuryType() == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_TYPE_NULL); |
| | | } |
| | | //申报日期 |
| | | if (WorkInjuryDeclarationReqDTO.getDeclareDate()==null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_Date_NULL); |
| | | if (workInjuryDeclarationReqDTO.getDeclareDate() == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_DATA_NULL); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 枚举验证 |
| | | */ |
| | | private void checkEnum(WorkInjuryDeclarationReqDTO workInjuryDeclarationReqDTO) { |
| | | if (WorkInjuryTypeEnum.getByCode(workInjuryDeclarationReqDTO.getWorkInjuryType()) == null) { |
| | | throw new AccidentException(AccidentResultCodes.WORK_INJURY_DECLARATION_ENUMS_TYPE_NOT_EXIST); |
| | | } |
| | | } |
| | | } |