lyhzzz 2 years ago
parent
commit
9c987214bd

+ 6 - 3
src/main/java/com/fdkankan/site/controller/UploadController.java

@@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.util.List;
 import java.util.Objects;
 
 @Slf4j
@@ -70,9 +71,11 @@ public class UploadController extends BaseController {
         if(!uploadToOssUtil.existKey(ossKey)){
             throw new BusinessException(ResultCode.UPLOAD_BIM_ERROR);
         }
-        ProjectBim bim = projectBimService.getByProjectId(projectId);
-        if(bim != null && !bim.getBimStatus().equals(BusinessStatus.ERROR.getInfo())){
-            throw new BusinessException(ResultCode.UPLOAD_BIM_EXIST);
+        List<ProjectBim> bims = projectBimService.getByProjectId(projectId);
+        for (ProjectBim bim : bims) {
+            if(bim.getBimStatus().equals(BusinessStatus.DONE.getInfo())){
+                throw new BusinessException(ResultCode.UPLOAD_BIM_EXIST);
+            }
         }
         ProjectBim projectBim = new ProjectBim();
         projectBim.setBimName(Objects.requireNonNull(file.getOriginalFilename()).split("\\.")[0]);

+ 3 - 1
src/main/java/com/fdkankan/site/service/IProjectBimService.java

@@ -3,6 +3,8 @@ package com.fdkankan.site.service;
 import com.fdkankan.site.entity.ProjectBim;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -13,7 +15,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IProjectBimService extends IService<ProjectBim> {
 
-    ProjectBim getByProjectId(Integer projectId);
+    List<ProjectBim> getByProjectId(Integer projectId);
 
     void updateBimName(ProjectBim projectBim);
 }

+ 4 - 2
src/main/java/com/fdkankan/site/service/impl/ProjectBimServiceImpl.java

@@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -24,10 +26,10 @@ import org.springframework.stereotype.Service;
 public class ProjectBimServiceImpl extends ServiceImpl<IProjectBimMapper, ProjectBim> implements IProjectBimService {
 
     @Override
-    public ProjectBim getByProjectId(Integer projectId) {
+    public List<ProjectBim> getByProjectId(Integer projectId) {
         LambdaQueryWrapper<ProjectBim> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(ProjectBim::getProjectId,projectId);
-        return this.getOne(wrapper);
+        return this.list(wrapper);
     }
 
     @Override