From 28aaf2ffa1dbb860a292ba330a7e9362e60e7832 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: Fri, 12 Jul 2024 16:41:03 +0800
Subject: [PATCH] update
---
assess-system/src/main/java/com/gkhy/assess/system/service/impl/AssInvestigationServiceImpl.java | 131 +++++++++++++++++++++++++++++--------------
1 files changed, 88 insertions(+), 43 deletions(-)
diff --git a/assess-system/src/main/java/com/gkhy/assess/system/service/impl/AssInvestigationServiceImpl.java b/assess-system/src/main/java/com/gkhy/assess/system/service/impl/AssInvestigationServiceImpl.java
index 97c7212..bb5661c 100644
--- a/assess-system/src/main/java/com/gkhy/assess/system/service/impl/AssInvestigationServiceImpl.java
+++ b/assess-system/src/main/java/com/gkhy/assess/system/service/impl/AssInvestigationServiceImpl.java
@@ -1,8 +1,14 @@
package com.gkhy.assess.system.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.gkhy.assess.common.enums.DeleteFlagEnum;
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.domain.AssPlanPerson;
import com.gkhy.assess.system.enums.AccessoryFileTypeEnum;
import com.gkhy.assess.system.enums.ReportProgressEnum;
import com.gkhy.assess.system.mapper.AssInvestigationMapper;
@@ -14,6 +20,11 @@
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>
@@ -34,49 +45,44 @@
@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);
+ String location=investigation.getLocation();
+ String[] locationArray = location.split(",");
+ if(locationArray.length!=2){
+ throw new ApiException("现场勘验位置格式不正确");
+ }
+ // 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){
@@ -88,35 +94,74 @@
}
@Override
+ @Transactional(rollbackFor = RuntimeException.class)
public int editInvestigation(AssInvestigation investigation) {
+ if(investigation.getId()==null){
+ throw new ApiException("现场勘验记录id不能为空!");
+ }
projectService.checkUserAllowed(investigation.getProjectId());
+ String location=investigation.getLocation();
+ String[] locationArray = location.split(",");
+ if(locationArray.length!=2){
+ throw new ApiException("现场勘验位置格式不正确");
+ }
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);
- 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);
+
+ LambdaQueryWrapper< AssInvestigation > lambdaQueryWrapper = Wrappers.<AssInvestigation>lambdaQuery()
+ .eq(AssInvestigation::getProjectId, projectId)
+ .eq(AssInvestigation::getDelFlag, DeleteFlagEnum.UN_DELETE);
+
+ Long count= count(lambdaQueryWrapper);
+ if(count<1){
+ throw new ApiException("现场勘验记录不能为空");
+ }
//校验项目状态
projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION);
//更新项目状态
--
Gitblit v1.9.2