浏览代码

las ply 转 bin

lyhzzz 3 年之前
父节点
当前提交
3aa26525ee

+ 39 - 0
src/main/java/com/fdkankan/fusion/common/util/FileWriterUtil.java

@@ -0,0 +1,39 @@
+package com.fdkankan.fusion.common.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+
+public class FileWriterUtil {
+
+    public static void writerJson(String tagPath,String fileName,String msg){
+        try {
+            File file = new File(tagPath);
+            if(!file.exists()){
+                file.mkdirs();
+            }
+            FileWriter fw = new FileWriter(tagPath +File.separator +fileName);
+            fw.write(msg);
+            fw.close();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    public static  String readFile(String file) throws Exception {
+        BufferedReader reader = new BufferedReader(new FileReader(file));
+        String line = null;
+        StringBuilder stringBuilder = new StringBuilder();
+        String ls = System.getProperty("line.separator");
+        try {
+            while((line = reader.readLine()) != null) {
+                stringBuilder.append(line);
+                stringBuilder.append(ls);
+            }
+            return stringBuilder.toString();
+        } finally {
+            reader.close();
+        }
+    }
+}

+ 10 - 3
src/main/java/com/fdkankan/fusion/common/util/OBJToGLBUtil.java

@@ -1,5 +1,6 @@
 package com.fdkankan.fusion.common.util;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.exception.BusinessException;
 import lombok.extern.slf4j.Slf4j;
@@ -108,8 +109,14 @@ public class OBJToGLBUtil {
         return imgName;
     }
 
-
-    public static void main(String[] args) {
-        System.out.println(checkObj("D:\\model"));
+    public static void lasOrPlyToBin(File srcFile) throws IOException {
+        String cmd = ShellUtil.LAS_TO_BIN;
+        cmd =  cmd.replace("@inPath",srcFile.getPath());
+        cmd = cmd.replace("@outPath",srcFile.getParent());
+        ShellUtil.execCmd(cmd);
+        String cloudJs = srcFile.getParent() +"/"+ "cloud.js";
+        JSONObject jsonObject = ShellUtil.fixCloud(cloudJs);
+        FileWriterUtil.writerJson(srcFile.getParent(),"cloud.js",jsonObject.toJSONString());
     }
+
 }

+ 38 - 4
src/main/java/com/fdkankan/fusion/common/util/ShellUtil.java

@@ -1,19 +1,24 @@
 package com.fdkankan.fusion.common.util;
 
+import cn.hutool.core.io.file.FileReader;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.BufferedReader;
 import java.io.Closeable;
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 
 @Slf4j
 public class ShellUtil {
-    /**
-     * 执行系统命令, 返回执行结果
-     * @param cmd 需要执行的命令
-     */
+
+    public final static String LAS_TO_BIN = "bash  /home/ubuntu/bin/PotreeConverter.sh @inPath @outPath ''";
+        /**
+         * 执行系统命令, 返回执行结果
+         * @param cmd 需要执行的命令
+         */
     public static void execCmd(String cmd) {
         StringBuilder result = new StringBuilder();
 
@@ -77,4 +82,33 @@ public class ShellUtil {
         execCmd(command);
         log.info("解压rar完毕:" + command);
     }
+
+    /**
+     * 修改cloud.js 文件
+     *
+     * @param path
+     * @return
+     * @throws IOException
+     */
+    public static JSONObject fixCloud(String path) throws IOException {
+        FileReader fileReader = new FileReader(path);
+        String str = fileReader.readString();
+        JSONObject json = JSONObject.parseObject(str);
+
+        String[] pointAttributes = {
+                "POSITION_CARTESIAN",
+                "COLOR_PACKED",
+                "NORMAL_OCT16"
+        };
+
+//    String[] pointAttributes = {
+//        "POSITION_CARTESIAN",
+//        "COLOR_PACKED",
+//        "NORMAL_OCT16",
+//        "INTENSITY",
+//        "CLASSIFICATION"
+//    };
+        json.put("pointAttributes", pointAttributes);
+        return json;
+    }
 }

+ 46 - 438
src/main/java/com/fdkankan/fusion/common/util/UploadToOssUtil.java

@@ -40,258 +40,82 @@ public class UploadToOssUtil {
 	@Value("${oss.bucket:4dkankan}")
 	private String bucket;
 
-	@Value("${upload.type:oss}")
-	private String type;
 
-	@Value("${local.path:/home/4dkankan}")
-	private String localPath;
 
-	/**
-	 * oss文件上传命令
-	 * 第一个参数是oss路径,要包含bucket名称
-	 * 第二个参数是本地文件路径
-	 */
-	private static final String UPLOAD_SH = "bash /opt/ossutil/upload.sh %s %s";
-
-	//上传的数据是byte[],key是上传后的文件名
-	public void upload(byte[] data,String key1) throws IOException{
-		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , new String(data, "UTF-8"),key1,type);
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				uploadOss(data,key1);
-				break;
-			case AWS:
-				break;
-			case LOCAL:
-				uploadLocal(data,key1);
-				break;
-		}
-	}
-	public void upload(String filePath, String key1) {
-		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , filePath,key1,type);
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				uploadOss(filePath,key1);
-				break;
-			case AWS:
-				uploadAws(filePath,key1);
-				break;
-			case LOCAL:
-				uploadLocal(filePath,key1);
-				break;
-		}
-	}
-
-
-	public void delete(String key1) throws IOException{
-		switch (type){
-			case "oss":deleteOss(key1); break;
-			case "local":FileUtil.del(key1);  break;
-		}
-	}
 
 	/**
-	 * 删除目录或者文件
-	 * @param prefix
+	 * 获取文件内容-阿里云
+	 * @param objectName
 	 * @return
 	 */
-	public int deleteFile(String prefix){
-		switch (type){
-			case "oss":deleteOssFile(prefix); break;
-			case "local":FileUtil.del(prefix);  break;
-		}
-		return 1;
-	}
-
-	public void deleteOss(String objectName){
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		try {
-			ossClient.deleteObject(bucket, objectName);
-		} catch (Exception e) {
-			log.error("OSS删除文件失败,key=" + objectName);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
-		}
-	}
-
-	public void deleteOssFile(String prefix){
-		int maxKeys = 200;
+	public boolean existKey(String objectName){
+		//创建oss客户端
 		OSSClient ossClient = new OSSClient(point, key, secrey);
-		try {
-
-			String nextMarker = null;
-			ObjectListing objectListing;
-
-			do {
-				objectListing = ossClient.listObjects(new ListObjectsRequest(this.bucket).withPrefix(prefix).withMarker(nextMarker).withMaxKeys(maxKeys));
-				List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
-				if (CollUtil.isEmpty(sums)) {
-					return;
-				}
-				List<String> keys = new ArrayList<>();
-				for (OSSObjectSummary sum : sums) {
-					keys.add(sum.getKey());
-				}
-				DeleteObjectsRequest deleteObjectsRequest =
-					new DeleteObjectsRequest(bucket).withKeys(keys).withEncodingType("url");
-				DeleteObjectsResult deleteObjectsResult = ossClient
-					.deleteObjects(deleteObjectsRequest);
-				List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
-				try {
-					for (String deletedObject : deletedObjects) {
-						String decode = URLDecoder.decode(deletedObject, "UTF-8");
-						log.info("删除oss文件:{}", decode);
-					}
-				} catch (UnsupportedEncodingException e) {
-					e.printStackTrace();
-				}
-
-//				ListUtil.page(keys, 100, subKeys -> {
-//					DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket)
-//						.withKeys(
-//							subKeys).withEncodingType("url");
-//					DeleteObjectsResult deleteObjectsResult = ossClient
-//						.deleteObjects(deleteObjectsRequest);
-//					List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
-//					try {
-//						for (String deletedObject : deletedObjects) {
-//							String decode = URLDecoder.decode(deletedObject, "UTF-8");
-//							log.info("删除oss文件:{}", decode);
-//						}
-//					} catch (UnsupportedEncodingException e) {
-//						e.printStackTrace();
-//					}
-//				});
-			}while (objectListing.isTruncated());
-		}catch (Exception  e){
-			e.printStackTrace();
+		// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
+		try{
+			boolean exist = ossClient.doesObjectExist(bucket, objectName);
+			return exist;
+		}catch (Exception e){
+			log.error("s4判断是否存在key异常,key=" + objectName, e);
 		}finally {
 			if(ossClient != null){
 				ossClient.shutdown();
 			}
 		}
+		return false;
 	}
 
-
-	public void uploadOss(byte[] data,String objectName){
+	/**
+	 * 从阿里云oss下载文件到本地
+	 * @param objectName 云端文件k地址
+	 * @param localPath 本地文件地址
+	 * @return
+	 */
+	public boolean downFormAli(String objectName, String localPath){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
-			ossClient.putObject(bucket, objectName, new ByteArrayInputStream(data));
-		} catch (Exception e) {
-			log.error("oss上传文件失败", e);
+			com.aliyun.oss.model.GetObjectRequest request  = new com.aliyun.oss.model.GetObjectRequest(bucket,objectName);
+			ossClient.getObject(request, new File(localPath));
+			return true;
+		}catch (Exception e){
+			log.error("阿里云oss文件下载失败,key=" + objectName, e);
 		}finally {
 			if(ossClient != null){
 				ossClient.shutdown();
 			}
 		}
-	}
-	public void uploadLocal(byte[] data,String key1){
-		InputStream in = new ByteArrayInputStream(data);
-		File file = new File(key1);
-		String path = key1.substring(0, key1.lastIndexOf("/"));
-		if (!file.exists()) {
-			new File(path).mkdir();
-		}
-		FileOutputStream fos = null;
-		try {
-			fos = new FileOutputStream(file);
-			int len = 0;
-			byte[] buf = new byte[1024];
-			while ((len = in.read(buf)) != -1) {
-				fos.write(buf, 0, len);
-			}
-			fos.flush();
-		} catch (Exception e) {
-			e.printStackTrace();
-		} finally {
-			if (null != fos) {
-				try {
-					fos.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-		}
+		return false;
 	}
 
 
-	public void uploadOss(String filePath, String key1){
+	public  void uploadOss(String filePath, String key1){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
+			System.out.println("oss-path:"+key1);
 			File file = new File(filePath);
 			if (!file.exists()) {
-				log.error("要上传的文件不存在:" + filePath);
 				return;
 			}
 			ObjectMetadata metadata = new ObjectMetadata();
-			if(filePath.contains(".jpg")){
-				metadata.setContentType("image/jpeg");
-			}
 			ossClient.putObject(bucket, key1, new File(filePath), metadata);
 
 		} catch (Exception e) {
-			log.error(e.toString() + filePath);
+			e.printStackTrace();
 		} finally {
 			ossClient.shutdown();
 		}
 	}
-
-	public void uploadAws(String filePath, String key1){
-		try{
-		}catch (Exception e){
-			e.printStackTrace();
-		}
-	}
-	public void uploadLocal(String filePath, String key1){
+	public void delete(String objectName){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
-			File srcFile = new File(filePath);
-			File file = new File(localPath + key1);
-			FileUtils.copyFile(srcFile,file);
-		}catch (Exception e){
-			e.printStackTrace();
-		}
-	}
-
-
-	/**
-	 * 获取文件类型
-	 */
-	public static String getContentType(String filePath){
-		FileNameMap fileNameMap = URLConnection.getFileNameMap();
-		String contentType = fileNameMap.getContentTypeFor(filePath);
-		System.out.println(contentType);
-		return contentType;
-
-	}
-
-	/**
-	 * 检查文件是否为空
-	 *
-	 * @param imageFile
-	 * @return
-	 */
-	private static boolean isEmpty(MultipartFile imageFile) {
-		if (imageFile == null || imageFile.getSize() <= 0) {
-			return true;
-		}
-		return false;
-	}
-
-	public List<String> listKeys(String sourcePath){
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				return this.listKeysFromAli(sourcePath);
-			case AWS:
-				return this.listKeysFromAws(sourcePath);
-			case LOCAL:
-				return this.listKeysFromLocal(sourcePath);
+			ossClient.deleteObject(bucket, objectName);
+		} catch (Exception e) {
+			log.error("OSS删除文件失败,key=" + objectName);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
 		}
-		return null;
 	}
 
 	/**
@@ -340,153 +164,12 @@ public class UploadToOssUtil {
 	}
 
 	/**
-	 * 获得文件列表-亚马逊
-	 * @return
-	 */
-	public List<String> listKeysFromAws(String sourcePath) {
-		return null;
-	}
-
-	/**
-	 * 获得文件列表-阿里云
-	 * @return
-	 */
-	public List<String> listKeysFromLocal(String sourcePath) {
-		List<String> keyList = new ArrayList<>();
-		return keyList;
-	}
-
-	/**
-	 * <p>
-	        拷贝目录
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 * @param sourcePath
-	 * @param targetPath
-	 **/
-	public void copyFiles(String sourcePath, String targetPath) throws IOException {
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				this.copyFilesFromAli(sourcePath, targetPath);
-				break;
-			case AWS:
-				break;
-			case LOCAL: this.copyFilesFromLocal(sourcePath, targetPath);
-		}
-	}
-
-	/**
-	 * <p>
-	 拷贝文件
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 * @param sourceKey
-	 * @param targetKey
-	 **/
-	public void copyObject(String sourceKey, String targetKey) throws IOException {
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				this.copyObjectFromAli(sourceKey, targetKey);
-				break;
-			case AWS:
-				break;
-		}
-	}
-
-	/**
-	 * <p>
-	 拷贝-阿里云
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 * @param sourcePath
-	 * @param targetPath
-	 **/
-	public void copyObjectFromAli(String sourcePath, String targetPath) throws IOException {
-
-		// 创建OSSClient实例。
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		// 复制文件
-		log.info("开始复制:" + sourcePath);
-		ossClient.copyObject(this.bucket, sourcePath, this.bucket, targetPath);
-		log.info("复制成功:" + sourcePath);
-		ossClient.shutdown();
-	}
-
-
-
-	/**
-	 * <p>
-	 拷贝-阿里云
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 * @param sourcePath
-	 * @param targetPath
-	 **/
-	public void copyFilesFromAli(String sourcePath, String targetPath) throws IOException {
-
-		//获取源文件列表
-		List<String> sourceKeyList = this.listKeysFromAli(sourcePath);
-		if(CollUtil.isEmpty(sourceKeyList)){
-			return;
-		}
-		// 创建OSSClient实例。
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		// 复制文件
-		sourceKeyList.parallelStream().forEach(key -> {
-			log.info("开始复制:" + key);
-			ossClient.copyObject(this.bucket, key, this.bucket, key.replace(sourcePath, targetPath));
-			log.info("复制成功:" + key);
-		});
-
-		ossClient.shutdown();
-	}
-
-
-	/**
-	 * <p>
-	 拷贝-本地
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 * @param sourcePath
-	 * @param targetPath
-	 **/
-	public void copyFilesFromLocal(String sourcePath, String targetPath) throws IOException {
-		// TODO: 2022/1/21
-
-	}
-
-	/**
-	 * 获取文件内容
-	 * @param bucketName
-	 * @param objectName
-	 * @return
-	 */
-	public String getObjectContent(String bucketName, String objectName){
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				return this.getObjectContentFromAli(bucketName, objectName);
-			case AWS:
-			case LOCAL:
-				return this.getObjectContentFromLocal(objectName);
-		}
-		return null;
-	}
-
-	/**
 	 * 获取文件内容-阿里云
 	 * @param bucketName
 	 * @param objectName
 	 * @return
 	 */
-	public String getObjectContentFromAli(String bucketName, String objectName){
+	public String getObjectContent(String bucketName, String objectName){
 		//创建oss客户端
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		InputStream objectContent = null;
@@ -515,91 +198,16 @@ public class UploadToOssUtil {
 		return contentJson.toString();
 	}
 
-	/**
-	 * 获取文件内容-阿里云
-	 * @param objectName
-	 * @return
-	 */
-	public boolean existOnAli(String objectName){
-		//创建oss客户端
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
-		try{
-			boolean exist = ossClient.doesObjectExist(bucket, objectName);
-			return exist;
-		}catch (Exception e){
-			log.error("s4判断是否存在key异常,key=" + objectName, e);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
+	public  void uploadFileOss(File file,String filePath) {
+		if(file.isFile()){
+			String ossPath = file.getPath().replace(filePath,"");
+			ossPath =  ossPath.replace("\\","/");
+			this.uploadOss(file.getPath(),ossPath);
+		}else {
+			File[] files = file.listFiles();
+			for (File file1 : files) {
+				uploadFileOss(file1,filePath);
 			}
 		}
-		return false;
 	}
-
-
-	/**
-	 * 判断key是否存在
-	 * @param key
-	 * @return
-	 */
-	public boolean existKey(String key){
-		StorageType storageType = StorageType.get(type);
-		switch (storageType){
-			case OSS:
-				return this.existOnAli(key);
-			case AWS:
-			default:
-				return false;
-		}
-	}
-
-	/**
-	 * 获取文件内容-本地
-	 * @param objectName
-	 * @return
-	 */
-	public String getObjectContentFromLocal(String objectName){
-		// TODO: 2022/1/21
-		return null;
-	}
-
-	/**
-	 * oss下载文件到本地
-	 * @param objectName
-	 * @param localPath
-	 */
-	public boolean download(String objectName, String localPath){
-		StorageType storageType = StorageType.get(this.type);
-		switch (storageType){
-			case OSS:
-				return this.downFormAli(objectName, localPath);
-			case AWS:
-		}
-		return false;
-	}
-
-	/**
-	 * 从阿里云oss下载文件到本地
-	 * @param objectName 云端文件k地址
-	 * @param localPath 本地文件地址
-	 * @return
-	 */
-	public boolean downFormAli(String objectName, String localPath){
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		try {
-			GetObjectRequest request  = new GetObjectRequest(bucket,objectName);
-			ossClient.getObject(request, new File(localPath));
-			return true;
-		}catch (Exception e){
-			log.error("阿里云oss文件下载失败,key=" + objectName, e);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
-		}
-		return false;
-	}
-
-
 }

+ 1 - 1
src/main/java/com/fdkankan/fusion/service/impl/CaseNumServiceImpl.java

@@ -121,7 +121,7 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
                 uploadToOssUtil.downFormAli(fileName,localPath);
             }
             OBJToGLBUtil.objToGlb(objPath,glbPath );
-            uploadToOssUtil.upload(glbPath,glbOssPath);
+            uploadToOssUtil.uploadOss(glbPath,glbOssPath);
             FileUtil.del(objPath);
             return queryPath + "/"+glbOssPath;
         }

+ 2 - 2
src/main/java/com/fdkankan/fusion/service/impl/CaseVideoServiceImpl.java

@@ -145,8 +145,8 @@ public class CaseVideoServiceImpl extends ServiceImpl<ICaseVideoMapper, CaseVide
 
                 String mergeLocalPathImg =  FilePath.VIDEO_LOCAL_PATH +"/"+mergeLocalName.replace(".mp4",".jpg");
                 String ossKeyImg =  String.format(FilePath.VIDEO_OSS_PATH,videoFolder.getVideoFolderId()) +"/"+mergeLocalName.replace(".mp4",".jpg");
-                uploadToOssUtil.upload(mergeLocalPath,ossKey);
-                uploadToOssUtil.upload(mergeLocalPathImg,ossKeyImg);
+                uploadToOssUtil.uploadOss(mergeLocalPath,ossKey);
+                uploadToOssUtil.uploadOss(mergeLocalPathImg,ossKeyImg);
                 if(!uploadToOssUtil.existKey(ossKey)&& !uploadToOssUtil.existKey(ossKeyImg)){
                     updateCaseVideoStatus(videoFolder.getVideoFolderId(),-1);
                     redisUtil.set(RedisKeyUtil.mergerVideoKey+videoFolder.getVideoFolderId(),"-1");

+ 13 - 22
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -89,7 +89,6 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
         File newObjFile = null;
         try {
             String objPath = String.format(OBJ_PATH , "modelId_"+model.getModelId()) ;
-            StringBuilder glbPath = new StringBuilder(String.format(GLB_PATH, "modelId_" + model.getModelId()));
             String glbOssPath = String.format(FilePath.GLB_OSS_PATH, model.getModelId());
 
             newObjFile = new File(objPath +"/" + fileName);
@@ -111,40 +110,32 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
             for (File file1 : files) {
                 String name = file1.getName();
                 if(name.contains("obj") || name.contains("OBJ")){
-                    String glbName = "";
-                    if(glbPath.toString().contains(".obj")){
-                        glbName = name.replace(".obj",".glb");
-                    }
-                    if(glbPath.toString().contains(".OBJ")){
-                        glbName = name.replace(".OBJ",".glb");
-                    }
-                    OBJToGLBUtil.objToGlb(objPath,name,  glbPath+"/"+glbName);
-                    glbOssPath = glbOssPath.replace("mesh.glb",glbName);
-                    glbPath.append("/").append(glbName);
+                    glbOssPath = glbOssPath.replace("mesh.glb",file1.getName().replace("obj","glb"));
+                    model.setModelDateType("obj");
+                    model.setModelType("glb");
+                    OBJToGLBUtil.objToGlb(objPath,name,  file1.getPath().replace("obj","glb"));
+                    uploadToOssUtil.uploadOss(file1.getPath(),glbOssPath);
+
                 }
                 if(name.contains(".ply")){
-                    glbOssPath = glbOssPath.replace("mesh.glb",name);
-                    glbPath.append("/").append(name);
+                    glbOssPath = glbOssPath.replace("mesh.glb","webcloud");
                     model.setModelDateType("ply");
                     model.setModelType("ply");
+                    OBJToGLBUtil.lasOrPlyToBin(file1);
+                    uploadToOssUtil.uploadFileOss(file1 ,glbOssPath);
                 }
                 if(name.contains(".las")){
-                    glbOssPath = glbOssPath.replace("mesh.glb",name);
-                    glbPath.append("/").append(name);
+                    glbOssPath = glbOssPath.replace("mesh.glb","webcloud");
                     model.setModelDateType("las");
                     model.setModelType("las");
+                    OBJToGLBUtil.lasOrPlyToBin(file1);
+                    uploadToOssUtil.uploadFileOss(file1 ,glbOssPath);
+
                 }
             }
-            uploadToOssUtil.upload(glbPath.toString(),glbOssPath);
             model.setModelObjUrl(objPath);
             model.setModelGlbUrl(queryPath + glbOssPath);
             model.setCreateStatus(1);  //上传成功
-            if(StringUtils.isEmpty(model.getModelDateType())){
-                model.setModelDateType("obj");
-            }
-            if(StringUtils.isEmpty(model.getModelType())){
-                model.setModelType("glb");
-            }
             this.saveOrUpdate(model);
         }catch (Exception e){
             model.setCreateStatus(-1);

+ 2 - 2
src/main/java/com/fdkankan/fusion/service/impl/UploadService.java

@@ -56,12 +56,12 @@ public class UploadService {
             }
             if(file.getOriginalFilename().toLowerCase().endsWith(".mp4")){
                 VideoUtil.ffmpegVideo(path,path.replace(suffixName,".jpg"),"200","200");
-                uploadToOssUtil.upload(path.replace(suffixName,".jpg"),filePathAdd+ fileName + ".jpg");
+                uploadToOssUtil.uploadOss(path.replace(suffixName,".jpg"),filePathAdd+ fileName + ".jpg");
                 if(!uploadToOssUtil.existKey(filePathAdd+ fileName + ".jpg")){
                     throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
                 }
             }
-            uploadToOssUtil.upload(path,filePathAdd+ fileName + suffixName);
+            uploadToOssUtil.uploadOss(path,filePathAdd+ fileName + suffixName);
             if(!uploadToOssUtil.existKey(filePathAdd + fileName + suffixName)){
                 throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
             }