فهرست منبع

dev-1.1.2-20240311

xiewj 1 سال پیش
والد
کامیت
252fefbb93

+ 5 - 8
pom.xml

@@ -110,13 +110,6 @@
             <version>1.18.20</version>
         </dependency>
 
-
-        <dependency>
-            <groupId>com.aliyun.oss</groupId>
-            <artifactId>aliyun-sdk-oss</artifactId>
-            <version>2.8.3</version>
-        </dependency>
-
         <dependency>
             <groupId>io.jsonwebtoken</groupId>
             <artifactId>jjwt</artifactId>
@@ -143,7 +136,11 @@
             <version>1.34.0</version>
         </dependency>
 
-
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-filestorage</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 17 - 116
src/main/java/com/fdkankan/site/common/util/UploadToOssUtil.java

@@ -1,35 +1,20 @@
 package com.fdkankan.site.common.util;
 
-import cn.hutool.core.collection.CollUtil;
-import com.aliyun.oss.OSSClient;
-import com.aliyun.oss.model.*;
+import com.fdkankan.filestorage.FileStorageTemplate;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.io.*;
-import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Slf4j
 @Component
 public class UploadToOssUtil {
 
 
-	@Value("${oss.point:http://oss-cn-shenzhen-internal.aliyuncs.com}")
-	private String point;
-
-	@Value("${oss.key:LTAIUrvuHqj8pvry}")
-	private String key;
-
-	@Value("${oss.secrey:JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4}")
-	private String secrey;
-
-	@Value("${oss.bucket:4dkankan}")
-	private String bucket;
-
-
+	@Resource()
+	FileStorageTemplate fileStorageTemplate;
 
 
 	/**
@@ -38,18 +23,12 @@ public class UploadToOssUtil {
 	 * @return
 	 */
 	public boolean existKey(String objectName){
-		//创建oss客户端
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
+
 		try{
-			boolean exist = ossClient.doesObjectExist(bucket, objectName);
+			boolean exist = fileStorageTemplate.doesObjectExist(objectName);
 			return exist;
 		}catch (Exception e){
 			log.error("s4判断是否存在key异常,key=" + objectName, e);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
 		}
 		return false;
 	}
@@ -61,29 +40,17 @@ public class UploadToOssUtil {
 	 * @return
 	 */
 	public boolean downFormAli(String objectName, String localPath){
-		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
-			GetObjectRequest request  = new GetObjectRequest(bucket,objectName);
-			File file = new File(localPath);
-			if(!file.getParentFile().exists()){
-				file.getParentFile().mkdirs();
-				file = new File(localPath);
-			}
-			ossClient.getObject(request, file);
+			fileStorageTemplate.downloadFile(objectName,localPath);
 			return true;
 		}catch (Exception e){
 			log.error("阿里云oss文件下载失败,key=" + objectName, e);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
 		}
 		return false;
 	}
 
 
 	public  void uploadOss(String filePath, String key1){
-		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			log.info("upload-to-oss:file-path:{},oss-path:{}",filePath,key1);
 			File file = new File(filePath);
@@ -91,24 +58,16 @@ public class UploadToOssUtil {
 				log.info("upload-to-oss:file-path:{},oss-path:{},filePath不存在!",filePath,key1);
 				return;
 			}
-			ObjectMetadata metadata = new ObjectMetadata();
-			ossClient.putObject(bucket, key1, new File(filePath), metadata);
+			fileStorageTemplate.uploadFile(filePath,key1);
 		} catch (Exception e) {
 			e.printStackTrace();
-		} finally {
-			ossClient.shutdown();
 		}
 	}
 	public void delete(String objectName){
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		try {
-			ossClient.deleteObject(bucket, objectName);
+ 		try {
+			fileStorageTemplate.deleteObject( objectName);
 		} catch (Exception e) {
 			log.error("OSS删除文件失败,key=" + objectName);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
 		}
 	}
 
@@ -117,44 +76,7 @@ public class UploadToOssUtil {
 	 * @return
 	 */
 	public List<String> listKeysFromAli(String sourcePath) {
-		List<String> keyList = new ArrayList<>();
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		try {
-			boolean flag = true;
-			String nextMaker = null;
-			ListObjectsRequest listObjectsRequest = new ListObjectsRequest(this.bucket);
-			//指定下一级文件
-			listObjectsRequest.setPrefix(sourcePath);
-			//设置分页的页容量
-			listObjectsRequest.setMaxKeys(200);
-			do
-			{
-				//获取下一页的起始点,它的下一项
-				listObjectsRequest.setMarker(nextMaker);
-				ObjectListing objectListing = ossClient.listObjects(listObjectsRequest);
-				List<OSSObjectSummary> objectSummaries = objectListing.getObjectSummaries();
-				List<String> collect = objectSummaries.stream().map(summary -> {
-					return summary.getKey();
-				}).collect(Collectors.toList());
-				if(CollUtil.isNotEmpty(collect)){
-					keyList.addAll(collect);
-				}
-				nextMaker = objectListing.getNextMarker();
-				//全部执行完后,为false
-				flag = objectListing.isTruncated();
-			} while (flag);
-		}catch (Exception e){
-			log.error("获取文件列表失败,path="+sourcePath, e);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
-		}
-
-
-		ossClient.shutdown();
-
-		return keyList;
+		return fileStorageTemplate.getFileFolder(sourcePath);
 	}
 
 	/**
@@ -164,33 +86,12 @@ public class UploadToOssUtil {
 	 * @return
 	 */
 	public String getObjectContent(String bucketName, String objectName){
-		//创建oss客户端
-		OSSClient ossClient = new OSSClient(point, key, secrey);
-		InputStream objectContent = null;
-		StringBuilder contentJson = new StringBuilder();
-		try {
-			// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
-			OSSObject ossObject = ossClient.getObject(bucketName, objectName);
-			objectContent = ossObject.getObjectContent();
-			try(BufferedReader reader = new BufferedReader(new InputStreamReader(objectContent))){
-				while (true) {
-					String line = reader.readLine();
-					if (line == null) break;
-					contentJson.append(line);
-				}
-			} catch (IOException e) {
-				log.error("读取scene.json文件流失败", e);
-			}
-		}catch (Exception e){
-			log.error("s3获取文件内容失败,key="+objectName, e);
-		}finally {
-			if(ossClient != null){
-				ossClient.shutdown();
-			}
-		}
-
-		return contentJson.toString();
-	}
+        try {
+            return fileStorageTemplate.getFileContent(bucketName,objectName);
+        } catch (Exception e) {
+			throw new RuntimeException(e);
+        }
+    }
 
 	public  void uploadFileOss(File file) {
 		if(file.isFile()){

+ 2 - 0
src/main/java/com/fdkankan/site/httpClient/request/LaserSceneParam.java

@@ -12,4 +12,6 @@ public class LaserSceneParam {
     private List<String> sceneCodes;
     private String title;
     private Integer status;
+    //4深市 5 深光
+    private Integer sceneSource;
 }

+ 3 - 0
src/main/java/com/fdkankan/site/response/SceneVo.java

@@ -21,4 +21,7 @@ public class SceneVo {
 
     private String phone;
     private Boolean bind = false;
+
+    private int shootCount ;
+
 }

+ 8 - 1
src/main/java/com/fdkankan/site/service/impl/SceneServiceImpl.java

@@ -145,7 +145,7 @@ public class SceneServiceImpl implements ISceneService {
             JSONArray list = JSONArray.parseArray(JSONObject.toJSONString(pageInfo.getList()));
             sceneVoList = overSceneVo(list,0);
         }
-        if(param.getType() == 2) {       //深时
+        if(param.getType() == 2|| param.getType() == 3) {       //深时  深光
             //获取激光(深时)场景数据
             LaserSceneParam laserSceneParam = new LaserSceneParam();
             laserSceneParam.setPageNum(param.getPageNum());
@@ -154,6 +154,12 @@ public class SceneServiceImpl implements ISceneService {
             if (StringUtils.isNotBlank(param.getSceneName())) {
                 laserSceneParam.setTitle(param.getSceneName());
             }
+            if(param.getType()==2){
+                laserSceneParam.setSceneSource(4);    //4深时
+            }else {
+                laserSceneParam.setSceneSource(5);    //5深光
+            }
+
             if (param.getNumList() != null && param.getNumList().size() > 0) {
                 laserSceneParam.setSceneCodes(param.getNumList());
             }
@@ -228,6 +234,7 @@ public class SceneServiceImpl implements ISceneService {
                 sceneVo.setIsLaser(false);
                 sceneVo.setPhone(fdkkScenePlusVo.getPhone());
                 sceneVo.setType(fdkkScenePlusVo.getSceneType());
+                sceneVo.setShootCount(fdkkScenePlusVo.getShootCount());
 //                if (fdkkScenePlusVo.getUserId() == null) {
 //                    sceneVo.setBind(false);
 //                }

+ 11 - 1
src/main/resources/application-local-prod.yaml

@@ -44,4 +44,14 @@ logging:
   file:
     path: /home/backend/smart-site/logs
   level:
-    com.fdkankan: DEBUG
+    com.fdkankan: DEBUG
+filestorage:
+  active: oss
+  oss:
+    endpoint: https://oss-cn-shenzhen.aliyuncs.com
+    internal-endpoint: https://oss-cn-shenzhen-internal.aliyuncs.com
+    access-key: LTAIUrvuHqj8pvry
+    access-key-secret: JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4
+    bucket: 4dkankan
+    bucket-custom-domain:
+      4dkankan: https://4dkk.4dage.com/

+ 11 - 1
src/main/resources/application-local.yaml

@@ -46,4 +46,14 @@ logging:
   file:
     path: /logs
   level:
-    com.fdkankan: DEBUG
+    com.fdkankan: DEBUG
+filestorage:
+  active: oss
+  oss:
+    endpoint: https://oss-cn-shenzhen.aliyuncs.com
+    internal-endpoint: https://oss-cn-shenzhen-internal.aliyuncs.com
+    access-key: LTAIUrvuHqj8pvry
+    access-key-secret: JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4
+    bucket: 4dkankan
+    bucket-custom-domain:
+      4dkankan: https://4dkk.4dage.com/

+ 11 - 1
src/main/resources/application-prod.yaml

@@ -44,4 +44,14 @@ logging:
   file:
     path: /home/backend/smart-site/logs
   level:
-    com.fdkankan: DEBUG
+    com.fdkankan: DEBUG
+filestorage:
+  active: oss
+  oss:
+    endpoint: https://oss-cn-shenzhen.aliyuncs.com
+    internal-endpoint: https://oss-cn-shenzhen-internal.aliyuncs.com
+    access-key: LTAIUrvuHqj8pvry
+    access-key-secret: JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4
+    bucket: 4dkankan
+    bucket-custom-domain:
+      4dkankan: https://4dkk.4dage.com/

+ 11 - 1
src/main/resources/application-test.yaml

@@ -49,4 +49,14 @@ logging:
   file:
     path: /home/smart-site/logs
   level:
-    com.fdkankan: DEBUG
+    com.fdkankan: DEBUG
+filestorage:
+  active: oss
+  oss:
+    endpoint: https://oss-cn-shenzhen.aliyuncs.com
+    internal-endpoint: https://oss-cn-shenzhen-internal.aliyuncs.com
+    access-key: LTAIUrvuHqj8pvry
+    access-key-secret: JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4
+    bucket: 4dkankan
+    bucket-custom-domain:
+      4dkankan: https://4dkk.4dage.com/