dsx 2 年 前
コミット
4b9c1f29bd

+ 2 - 1
src/main/java/com/fdkankan/scene/controller/inner/InnerController.java

@@ -37,8 +37,9 @@ public class InnerController extends BaseController {
         @RequestParam(value = "userName",required = false) String userName,
         @RequestParam(value = "floor",required = false) String floor,
         @RequestParam(value = "sceneKind",defaultValue = "tiles") String sceneKind,
+        @RequestParam(value = "packagePath", required = false) String packagePath,
         @RequestParam(value = "file",required = false) MultipartFile file) throws Exception {
-        return innerApiService.uploadMatterproData(sceneName,userName,floor,sceneKind,file);
+        return innerApiService.uploadMatterproData(sceneName,userName,floor,sceneKind,packagePath, file);
     }
 
     /**

+ 1 - 1
src/main/java/com/fdkankan/scene/service/IInnerApiService.java

@@ -14,7 +14,7 @@ import org.springframework.web.multipart.MultipartFile;
  **/
 public interface IInnerApiService {
 
-    ResultData uploadMatterproData(String sceneName,String userName,String floor,String sceneKind, MultipartFile file) throws Exception;
+    ResultData uploadMatterproData(String sceneName,String userName,String floor,String sceneKind, String packagePath, MultipartFile file) throws Exception;
 
     ResultData getUploadMatterproDataStatus(String num);
 

+ 21 - 12
src/main/java/com/fdkankan/scene/service/impl/InnerApiServiceImpl.java

@@ -76,8 +76,8 @@ public class InnerApiServiceImpl implements IInnerApiService {
     private RedisLockUtil redisLockUtil;
 
     @Override
-    public ResultData uploadMatterproData(String sceneName, String userName, String floor, String sceneKind, MultipartFile file) throws Exception {
-        if(file == null || file.getSize() <=0){
+    public ResultData uploadMatterproData(String sceneName, String userName, String floor, String sceneKind, String packagePath, MultipartFile file) throws Exception {
+        if((file == null || file.getSize() <=0) && (StrUtil.isEmpty(packagePath) || !fYunFileService.fileExist(packagePath))){
             throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
         }
 
@@ -95,7 +95,7 @@ public class InnerApiServiceImpl implements IInnerApiService {
         scene3dNumMatterProService.updateById(numEntity);
         redisLockUtil.unlockLua(RedisLockKey.LOCK_GET_MATTERPRO_NUM);
 
-        String dataSource = ConstantFilePath.BUILD_MODEL_PATH + UUID.randomUUID() + File.separator ;
+        String dataSource = ConstantFilePath.BUILD_MODEL_PATH + UUID.randomUUID() + File.separator;
         JSONObject result = new JSONObject();
         result.put("num", sceneNum);
         result.put("dataSource", dataSource);
@@ -103,19 +103,28 @@ public class InnerApiServiceImpl implements IInnerApiService {
         String key = String.format(RedisKey.SCENE_UPLOAD_MATTERPRO_NUM, sceneNum);
         redisUtil.set(key, result.toJSONString(), RedisKey.CAMERA_EXPIRE_7_TIME);
 
-        File data = new File(dataSource + file.getOriginalFilename());
-        if(!data.getParentFile().exists()){
-            data.getParentFile().mkdirs();
+        String fileName = null;
+        if(StrUtil.isNotEmpty(packagePath)){
+            fileName = packagePath.substring(packagePath.lastIndexOf("/"));
+            fYunFileService.downloadFile(packagePath, dataSource.concat(fileName));
+        }else{
+            fileName = file.getOriginalFilename();
+            File data = new File(dataSource + fileName);
+            if(!data.getParentFile().exists()){
+                data.getParentFile().mkdirs();
+            }
+            file.transferTo(data);
         }
-        file.transferTo(data);
 
+        String finalFileName = fileName;
         CompletableFuture.runAsync(() -> {
             try {
-                if(file.getOriginalFilename().toLowerCase().endsWith(".zip")){
-                    CreateObjUtil.unZip(dataSource + file.getOriginalFilename(), dataSource);
+                String ext = FileUtil.extName(finalFileName);
+                if(ext.toLowerCase().endsWith("zip")){
+                    CreateObjUtil.unZip(dataSource + finalFileName, dataSource);
                 }
-                if(file.getOriginalFilename().toLowerCase().endsWith(".rar")){
-                    CreateObjUtil.unRarWithPath(dataSource + file.getOriginalFilename(), dataSource);
+                if(ext.toLowerCase().endsWith("rar")){
+                    CreateObjUtil.unRarWithPath(dataSource + finalFileName, dataSource);
 //            log.info("解压rar开始");
 //            String command = "unrar x " + dataSource + file.getOriginalFilename() + " " + dataSource;
 //            RuntimeUtil.exec(command);
@@ -125,7 +134,7 @@ public class InnerApiServiceImpl implements IInnerApiService {
                 Thread.sleep(2000L);
 
                 //删除压缩包
-                new File(dataSource + file.getOriginalFilename()).delete();
+//                new File(dataSource + file.getOriginalFilename()).delete();
 
                 List<String> fileList = new ArrayList<>();
                 FileUtils.readfilePath(dataSource, fileList);