lyhzzz 1 سال پیش
والد
کامیت
160bd6d4e9

+ 24 - 0
src/main/java/com/fdkankan/fusion/common/util/UploadToOssUtil.java

@@ -9,6 +9,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
@@ -213,4 +214,27 @@ public class UploadToOssUtil {
 			}
 		}
 	}
+	public Long getSize(String filePath){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		Long total = 0L;
+		try {
+			List<String> files = listKeysFromAli( filePath);
+			if (ObjectUtils.isEmpty(files)) {
+				return 0L;
+			}
+			for (String file : files) {
+				GetObjectRequest getObjectMetadataRequest = new GetObjectRequest(bucket, file);
+				Long size = ossClient.getObjectMetadata(getObjectMetadataRequest).getContentLength();
+				total += size;
+			}
+
+		}catch (Exception e){
+			log.info("oss-getFileInfo-error:{}",e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+		return total;
+	}
 }

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

@@ -91,6 +91,7 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
                     continue;
                 }
                 Model model = modelService.getIsNullNewByNum(num,param.getType());
+                model.setUpdateTime(null);
                 model.setModelDateType("obj");
                 model.setType(param.getType());
                 model.setModelType("pointcloud");    //深时点云类型
@@ -134,17 +135,11 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
                     if(ossGlbPath.contains("lod_")){
                         if(ossGlbPath.contains("lod_0")){
                             ossGlbPaths.add(queryPath  +ossGlbPath);
-                            File file = new File(localGlbPath);
-                            if(file!=null){
-                                modelSize += file.length();
-                            }
+                            modelSize +=  uploadToOssUtil.getSize(ossGlbPath);
                         }
                         continue;
                     }
-                    File file = new File(localGlbPath);
-                    if(file!=null){
-                        modelSize += file.length();
-                    }
+                    modelSize +=  uploadToOssUtil.getSize(ossGlbPath);
                     ossGlbPaths.add(queryPath +ossGlbPath);
                 }
                 return JSONArray.toJSONString(ossGlbPaths);