xiewj 2 years ago
parent
commit
f25e7cbf35

+ 1 - 2
src/main/java/com/fdkk/bim/client/BimFaceClient.java

@@ -55,14 +55,13 @@ public interface BimFaceClient {
      * 发送File类型数据
      */
     @Request(
-            url = "/bdfs/data/v1/projects/{projectId}/fileItems/sourceUrl?url={url}&parentId={parentId}&name={name}&length={length}",
+            url = "/bdfs/data/v1/projects/{projectId}/fileItems/sourceUrl?url={url}&parentId={parentId}&name={name}",
             type = "post",
             contentType = "application/octet-stream"
     )
     BimResult<FileBean> fileItems(   @Var("url")String url,
                                   @Var("parentId")String parentId,
                                   @Var("name")String name,
-                                  @Var("length")Long length ,
                                   @Var("projectId") String projectId);
 
 

+ 1 - 1
src/main/java/com/fdkk/bim/constant/HttpStatus.java

@@ -41,7 +41,7 @@ public enum HttpStatus {
 
     e3021(3021, "账号不存在,请核对后重新输入。"),
     e3024(3024, "不能将场景协作给自己"),
-    e3100(3100, "上传文件非法"),
+    e3100(3100, "上传文件非法,请检查文件类型或文件链接"),
     e4001(4001, "验证码返回"),
     e4002(4002, "检测控制点坐标正在被修改,暂时无法操作"),
     e4003(4003, "请输入正确地理坐标"),

+ 2 - 1
src/main/java/com/fdkk/bim/controller/FileController.java

@@ -66,7 +66,8 @@ public class FileController extends BaseController {
         return success(bimFaceVO);
     }
     @PostMapping("/upload")
-    public Result upload(@RequestPart(value="file") MultipartFile file,@RequestPart("dto") BimUploadDTO bimUploadDTO) throws IOException {BimFaceEntity bimFaceEntity = bimFaceService.uploadFile(file, bimUploadDTO);
+    public Result upload(@RequestBody BimUploadDTO bimUploadDTO) throws IOException {
+        BimFaceEntity bimFaceEntity = bimFaceService.uploadFile( bimUploadDTO);
         BimFaceVO bimFaceVO = new BimFaceVO();
         BeanUtil.copyProperties(bimFaceEntity,bimFaceVO);
         return success(bimFaceVO);

+ 4 - 0
src/main/java/com/fdkk/bim/entity/dto/BimFaceBaseDTO.java

@@ -16,4 +16,8 @@ public class BimFaceBaseDTO {
 
    private String source;
 
+   private String fileUrl;
+
+   private String fileName;
+
 }

+ 1 - 1
src/main/java/com/fdkk/bim/service/BimFaceService.java

@@ -25,7 +25,7 @@ public interface BimFaceService extends IService<BimFaceEntity> {
 
     List<BimFaceEntity> getByCallType(String condition ,String... callType);
 
-    BimFaceEntity uploadFile(MultipartFile file, BimUploadDTO bimUploadDTO) throws IOException;
+    BimFaceEntity uploadFile(BimUploadDTO bimUploadDTO) throws IOException;
 
     void translate(BimFaceEntity bimFaceEntity);
 

+ 16 - 7
src/main/java/com/fdkk/bim/service/impl/BimFaceServiceImpl.java

@@ -14,8 +14,10 @@ import com.fdkk.bim.bimEntity.dto.SourceDTO;
 import com.fdkk.bim.bimEntity.dto.TranslateDTO;
 import com.fdkk.bim.bimEntity.vo.DatabagDerivativeBean;
 import com.fdkk.bim.client.BimFaceClient;
+import com.fdkk.bim.constant.HttpStatus;
 import com.fdkk.bim.entity.dto.BimCallBackDTO;
 import com.fdkk.bim.entity.po.BimFaceEntity;
+import com.fdkk.bim.exception.ServiceException;
 import com.fdkk.bim.mapper.BimFaceMapper;
 import com.fdkk.bim.service.BimFaceService;
 import lombok.extern.slf4j.Slf4j;
@@ -104,17 +106,26 @@ public class BimFaceServiceImpl extends ServiceImpl<BimFaceMapper, BimFaceEntity
     }
 
     @Override
-    public BimFaceEntity uploadFile(MultipartFile file, BimUploadDTO bimUploadDTO) throws IOException {
+    public BimFaceEntity uploadFile(BimUploadDTO bimUploadDTO) throws IOException {
+        if (StrUtil.isEmpty(bimUploadDTO.getFileUrl())||StrUtil.isEmpty(bimUploadDTO.getFileName())||!bimUploadDTO.getFileName().endsWith("ifc")){
+            throw new ServiceException(HttpStatus.e3100);
+        }
+
         BimResult<List<ProjectBean>> projectInfo = bimFaceClient.getProjectInfo(bimUploadDTO.getProjectName());
         String projectId="";
+        boolean eq=false;
         if (projectInfo.getCode().equalsIgnoreCase("success")&& ObjectUtil.isNotNull(projectInfo.getData())&& projectInfo.getData().size()>0){
             for (ProjectBean datum : projectInfo.getData()) {
                 if (datum.getName().equals(bimUploadDTO.getProjectName())){
                     projectId=datum.getId();
+                    eq=true;
                     break;
                 }
             }
         }else {
+            eq=false;
+        }
+        if (!eq){
             ProjectDTO projectDTO=new ProjectDTO();
             projectDTO.setName(bimUploadDTO.getProjectName());
             BimResult<ProjectBean> fileBeanBimResult = bimFaceClient.saveProject(projectDTO);
@@ -122,15 +133,12 @@ public class BimFaceServiceImpl extends ServiceImpl<BimFaceMapper, BimFaceEntity
             projectId=fileBeanBimResult.getData().getId();
             }
         }
-        File absFile = FileUploadUtils.uploadAbsPath(bimConfig.getUploadPath(), file);
-        String ossUrl = ossFileService.uploadFile(absFile.getAbsolutePath(), bimConfig.getDefaultFolder() + "/project/"+projectId +"/upload/"+ absFile.getName());
-        absFile.delete();
 
-        BimResult<FileBean> fileBeanBimResult = bimFaceClient.fileItems(ossUrl,projectId,file.getOriginalFilename(), FileUtil.size(absFile), projectId);
+        BimResult<FileBean> fileBeanBimResult = bimFaceClient.fileItems(bimUploadDTO.getFileUrl(),projectId,bimUploadDTO.getFileName(), projectId);
         if (fileBeanBimResult.getCode().equalsIgnoreCase("success")&& ObjectUtil.isNotNull(fileBeanBimResult.getData())) {
             BimFaceEntity bimFaceEntity = new BimFaceEntity();
             bimFaceEntity.setTask(bimUploadDTO.getTask());
-            bimFaceEntity.setFileUrl(ossUrl);
+            bimFaceEntity.setFileUrl(bimUploadDTO.getFileUrl());
             bimFaceEntity.setProjectId(projectId);
             bimFaceEntity.setCallBack(bimUploadDTO.getCallBack());
             bimFaceEntity.setProjectName(bimUploadDTO.getProjectName());
@@ -144,8 +152,9 @@ public class BimFaceServiceImpl extends ServiceImpl<BimFaceMapper, BimFaceEntity
 //            if (save&& fileBeanBimResult.getCode().equalsIgnoreCase("success")){
 //                rabbitSenderTemplate.sender(RabbitQueue.BIM_TOPIC,RabbitQueue.UPLOAD_QUEUE,bimFaceEntity);
 //            }
+        }else {
+            throw new ServiceException(fileBeanBimResult.getMessage(),500);
         }
-        return null;
     }
 
     @Override

+ 2 - 2
src/main/java/com/fdkk/bim/task/task.java

@@ -44,7 +44,7 @@ public class task {
                       bimFace.setCallType(BusinessStatus.TRANSLATE.getInfo());
                       bimFaceService.updateById(bimFace);
                       bimFaceService.callBack(BusinessStatus.UPLOAD,bimFace);
-//                      bimFaceService.translate(bimFace);
+                      bimFaceService.translate(bimFace);
                   } else if (fileStatusInfo.getData().getStatus().equalsIgnoreCase("failed")) {
                       bimFace.setCallType(BusinessStatus.ERROR.getInfo());
                       bimFace.setUploadStatus(fileStatusInfo.getData().getStatus());
@@ -67,7 +67,7 @@ public class task {
                       bimFace.setCallType(BusinessStatus.OFFLINE.getInfo());
                       bimFaceService.updateById(bimFace);
                       bimFaceService.callBack(BusinessStatus.TRANSLATE,bimFace);
-//                      bimFaceService.offlineDatabag(bimFace);
+                      bimFaceService.offlineDatabag(bimFace);
                   } else if (translateInfo.getData().getStatus().equalsIgnoreCase("failed")) {
                       bimFace.setCallType(BusinessStatus.ERROR.getInfo());
                       bimFace.setTranslateStatus(translateInfo.getData().getStatus());