lyhzzz 3 ay önce
ebeveyn
işleme
4b84ef1903

+ 1 - 0
src/main/java/com/fdkankan/fusion/common/ResultCode.java

@@ -81,6 +81,7 @@ public enum ResultCode {
     UPLOAD_FILE_ERROR(8030, "上传失败,请检查文件格式。"),
 
     FILE_TYPE_ERROR23(8031, "文件名不得含有中文"),
+    MEDIO_NOT_EXIT(8032, "模型不存在"),
 
     ;
 

+ 36 - 0
src/main/java/com/fdkankan/fusion/controller/ModelController.java

@@ -2,15 +2,19 @@ package com.fdkankan.fusion.controller;
 
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.json.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.ResultData;
 import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.FileWriterUtil;
 import com.fdkankan.fusion.common.util.MD5Checksum;
 import com.fdkankan.fusion.common.util.UploadToOssUtil;
+import com.fdkankan.fusion.entity.CommonUpload;
 import com.fdkankan.fusion.entity.Model;
 import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.request.AddByMediaLibraryParam;
 import com.fdkankan.fusion.request.ModelPram;
 import com.fdkankan.fusion.request.ScenePram;
 import com.fdkankan.fusion.response.FileInfoVo;
@@ -45,6 +49,12 @@ public class ModelController extends BaseController{
     IModelService modelService;
     @Autowired
     IFusionNumService fusionNumService;
+    @Autowired
+    ICommonUploadService commonUploadService;
+    @Autowired
+    ICaseService caseService;
+    @Autowired
+    ICaseNumService caseNumService;
 
 
     @PostMapping("/uploadObj")
@@ -52,6 +62,32 @@ public class ModelController extends BaseController{
         return ResultData.ok(modelService.uploadObj(file,getUserName()));
     }
 
+    @PostMapping("/addByMediaLibrary")
+    public ResultData addByMediaLibrary(@RequestBody AddByMediaLibraryParam param)  {
+        if(param.getCaseId() == null || param.getUploadId() == null ){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        CommonUpload commonUpload = commonUploadService.getById(param.getUploadId());
+        if(commonUpload == null || StringUtils.isBlank(commonUpload.getFileUrl())){
+            throw new BusinessException(ResultCode.MEDIO_NOT_EXIT);
+        }
+        Model model = new Model();
+        model.setModelTitle(commonUpload.getFileName());
+        model.setModelSize(FileWriterUtil.setFileSize(Long.valueOf(commonUpload.getFileSize())));
+        model.setModelDateType(commonUpload.getFileFormat());
+        model.setModelType(commonUpload.getResultFileFormat());
+        model.setWgs84(commonUpload.getWgs84());
+        model.setGcj02(commonUpload.getGcj02());
+
+        JSONArray jsonArray = new JSONArray();
+        jsonArray.add(commonUpload.getFileUrl());
+        model.setModelGlbUrl(jsonArray.toJSONString());
+        modelService.save(model);
+
+        //caseNumService.addModeByCaseId(param.getCaseId(),model.getModelId());
+        return ResultData.ok(model);
+    }
+
     @GetMapping("/uploadObjProgress")
     public ResultData uploadAddVideoProgress(@RequestParam(required = false) Integer modelId) throws Exception {
         String code = modelService.uploadObjProgress(modelId);

+ 6 - 0
src/main/java/com/fdkankan/fusion/entity/Model.java

@@ -95,4 +95,10 @@ public class Model implements Serializable {
 
     @TableField("render_type")
     private String renderType;
+
+    @TableField("wgs84")
+    private String wgs84;
+
+    @TableField("gcj02")
+    private String gcj02;
 }