lyhzzz 2 年 前
コミット
0b44bb25f8

+ 12 - 11
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -119,25 +119,26 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
         }
     }
 
-    public void runThread(MultipartFile file,Model model,IModelService modelService){
+    public void runThread(MultipartFile file,Model model,IModelService modelService) throws IOException {
+        String fileName = UUID.randomUUID().toString().replace("-","") +".zip";
+        String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "modelId_"+model.getModelId()) ;
+        log.info("uploadObj--ThreadStart-fileName:{},modeId:{}",fileName,model.getModelId());
+
+        File newObjFile = new File(objPath +"/" + fileName);
+        if(!newObjFile.getParentFile().exists()){
+            newObjFile.getParentFile().mkdirs();
+        }
+        // file.transferTo(newObjFile); 异步会出现 FileNotFoundException temp.
+        FileUtils.copyInputStreamToFile(file.getInputStream(), newObjFile);
+
         ExecutorService executor = ThreadUtil.newSingleExecutor();
         try {
             CompletableFuture.runAsync(() -> {
-                File newObjFile = null;
                 File objPathFile = null;
                 File mntFile = null;
                 File b3dmFile = null;
                 File osgbFile = null;
                 try {
-                    String fileName = UUID.randomUUID().toString().replace("-","") +".zip";
-                    String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "modelId_"+model.getModelId()) ;
-                    log.info("uploadObj--ThreadStart-fileName:{},modeId:{}",fileName,model.getModelId());
-
-                    newObjFile = new File(objPath +"/" + fileName);
-                    if(!newObjFile.getParentFile().exists()){
-                        newObjFile.getParentFile().mkdirs();
-                    }
-
                     // file.transferTo(newObjFile); 异步会出现 FileNotFoundException temp.
                     FileUtils.copyInputStreamToFile(file.getInputStream(), newObjFile);