| | |
| | | |
| | | import com.gkhy.assess.common.enums.RequestSourceEnum; |
| | | import com.gkhy.assess.common.exception.ApiException; |
| | | import com.gkhy.assess.system.domain.AssAccessoryFile; |
| | | import com.gkhy.assess.system.domain.AssInvestigation; |
| | | import com.gkhy.assess.system.enums.AccessoryFileTypeEnum; |
| | | import com.gkhy.assess.system.enums.ReportProgressEnum; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public int addInvestigation(AssInvestigation investigation,String requestSourceType) { |
| | | public Long addInvestigation(AssInvestigation investigation) { |
| | | Long projectId=investigation.getProjectId(); |
| | | projectService.checkUserAllowed(projectId); |
| | | checkInvestigationCount(projectId); |
| | | // checkInvestigationCount(projectId); |
| | | investigation.setCreateBy(ShiroUtils.getSysUser().getUsername()); |
| | | if(investigation.getIsSafetyCheck()!=null&&investigation.getIsSafetyCheck()==1){ |
| | | Integer fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_ATTACHMENT.getCode()); |
| | | Integer fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId,null, AccessoryFileTypeEnum.INVESTINGATION_ATTACHMENT.getCode()); |
| | | if(fileCount==0){ |
| | | throw new ApiException("未上传现场安全检查表"); |
| | | } |
| | | } |
| | | //校验图片数量 |
| | | Integer fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.DEVICE_IMAGE.getCode()); |
| | | if(fileCount==0){ |
| | | throw new ApiException("主要装置前的合影照片不能为空"); |
| | | List<AssAccessoryFile> accessFiles=new ArrayList<>(); |
| | | accessFiles.addAll(investigation.getCompanyImages()); |
| | | accessFiles.addAll(investigation.getDeviceImages()); |
| | | accessFiles.addAll(investigation.getInvestingationImages()); |
| | | if(investigation.getInvestingationVideos()!=null&& !investigation.getInvestingationVideos().isEmpty()){ |
| | | accessFiles.addAll(investigation.getInvestingationVideos()); |
| | | } |
| | | fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_IMAGE.getCode()); |
| | | if(fileCount==0){ |
| | | throw new ApiException("现场勘验照片照片不能为空"); |
| | | if(investigation.getAssAccessoryFiles()!=null&&!investigation.getAssAccessoryFiles().isEmpty()){ |
| | | accessFiles.addAll(investigation.getAssAccessoryFiles()); |
| | | } |
| | | fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.COMPANY_IMAGE.getCode()); |
| | | if(fileCount==0){ |
| | | throw new ApiException("现场勘验人员与企业陪同人员图片不能为空"); |
| | | List<Long> fileIds=new ArrayList<>(); |
| | | for(AssAccessoryFile accessoryFile:accessFiles){ |
| | | if(accessoryFile.getId()==null){ |
| | | throw new ApiException("附件或图片id不能为空"); |
| | | } |
| | | fileIds.add(accessoryFile.getId()); |
| | | } |
| | | // fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_VIDEO.getCode()); |
| | | // if(fileCount==0){ |
| | | // throw new ApiException("现场勘验视频不能为空"); |
| | | // } |
| | | int row=baseMapper.insert(investigation); |
| | | if(requestSourceType== RequestSourceEnum.WEB.getCode()){ |
| | | //校验项目状态 |
| | | projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION); |
| | | //更新项目状态 |
| | | projectService.changeReportProgress(projectId,ReportProgressEnum.INVESTINGATION); |
| | | } |
| | | //校验项目状态 |
| | | // projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION); |
| | | // int row=baseMapper.insert(investigation); |
| | | // if(row>0 && (investigation.getState()==null||!investigation.getState().equals(ApproveStatusEnum.TEMPORARY.getCode()))) { |
| | | // //更新项目状态 |
| | | // projectService.changeReportProgress(projectId,ReportProgressEnum.INVESTINGATION); |
| | | // } |
| | | return row; |
| | | baseMapper.insert(investigation); |
| | | //更新图片过程id |
| | | accessoryFileService.batchUpdateAccessoryFileProcessId(fileIds,investigation.getId()); |
| | | return investigation.getId(); |
| | | } |
| | | |
| | | public void checkInvestigationCount(Long projectId){ |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public int editInvestigation(AssInvestigation investigation) { |
| | | if(investigation.getId()==null){ |
| | | throw new ApiException("现场勘验记录id不能为空!"); |
| | | } |
| | | projectService.checkUserAllowed(investigation.getProjectId()); |
| | | investigation.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | List<AssAccessoryFile> accessFiles=new ArrayList<>(); |
| | | accessFiles.addAll(investigation.getCompanyImages()); |
| | | accessFiles.addAll(investigation.getDeviceImages()); |
| | | accessFiles.addAll(investigation.getInvestingationImages()); |
| | | if(investigation.getInvestingationVideos()!=null&& !investigation.getInvestingationVideos().isEmpty()){ |
| | | accessFiles.addAll(investigation.getInvestingationVideos()); |
| | | } |
| | | if(investigation.getAssAccessoryFiles()!=null&&!investigation.getAssAccessoryFiles().isEmpty()){ |
| | | accessFiles.addAll(investigation.getAssAccessoryFiles()); |
| | | } |
| | | List<Long> fileIds=new ArrayList<>(); |
| | | for(AssAccessoryFile accessoryFile:accessFiles){ |
| | | if(accessoryFile.getId()==null){ |
| | | throw new ApiException("附件或图片id不能为空"); |
| | | } |
| | | fileIds.add(accessoryFile.getId()); |
| | | } |
| | | accessoryFileService.batchUpdateAccessoryFileProcessId(fileIds,investigation.getId()); |
| | | int row=baseMapper.updateById(investigation); |
| | | return row; |
| | | } |
| | | |
| | | @Override |
| | | public AssInvestigation getInvestigationByProjectId(Long projectId) { |
| | | public List<AssInvestigation> getInvestigationByProjectId(Long projectId) { |
| | | projectService.checkUserAllowed(projectId); |
| | | AssInvestigation investigation= baseMapper.getInvestigationByProjectId(projectId); |
| | | if(investigation!=null) { |
| | | investigation.setAssAccessoryFiles(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_ATTACHMENT.getCode())); |
| | | investigation.setCcompanyImages(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.COMPANY_IMAGE.getCode())); |
| | | investigation.setDeviceImages(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.DEVICE_IMAGE.getCode())); |
| | | investigation.setInvestingationImages(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_IMAGE.getCode())); |
| | | investigation.setInvestingationVideos(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_VIDEO.getCode())); |
| | | } |
| | | return investigation; |
| | | List<AssInvestigation> investigations= baseMapper.getInvestigationByProjectId(projectId); |
| | | return investigations; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public AssInvestigation getInvestigationById(Long investigationId) { |
| | | return baseMapper.getInvestigationById(investigationId); |
| | | AssInvestigation investigation= baseMapper.getInvestigationById(investigationId); |
| | | if(investigation!=null) { |
| | | investigation.setAssAccessoryFiles(accessoryFileService.getAccessoryFileByProjectId(investigation.getProjectId(),investigation.getId(), AccessoryFileTypeEnum.INVESTINGATION_ATTACHMENT.getCode())); |
| | | investigation.setCompanyImages(accessoryFileService.getAccessoryFileByProjectId(investigation.getProjectId(),investigation.getId(), AccessoryFileTypeEnum.COMPANY_IMAGE.getCode())); |
| | | investigation.setDeviceImages(accessoryFileService.getAccessoryFileByProjectId(investigation.getProjectId(),investigation.getId(), AccessoryFileTypeEnum.DEVICE_IMAGE.getCode())); |
| | | investigation.setInvestingationImages(accessoryFileService.getAccessoryFileByProjectId(investigation.getProjectId(),investigation.getId(), AccessoryFileTypeEnum.INVESTINGATION_IMAGE.getCode())); |
| | | investigation.setInvestingationVideos(accessoryFileService.getAccessoryFileByProjectId(investigation.getProjectId(),investigation.getId(), AccessoryFileTypeEnum.INVESTINGATION_VIDEO.getCode())); |
| | | } |
| | | return investigation; |
| | | } |
| | | |
| | | @Override |
| | | public void doInvestigationProcess(Long projectId) { |
| | | public void doInvestigationProcess(Map map) { |
| | | Long projectId= Long.parseLong(map.get("projectId").toString()); |
| | | projectService.checkUserAllowed(projectId); |
| | | |
| | | //校验项目状态 |
| | | projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION); |
| | | //更新项目状态 |