瀏覽代碼

prod 配置

lyhzzz 2 年之前
父節點
當前提交
e922943454

+ 8 - 6
src/main/java/com/fdkankan/fusion/common/FilePath.java

@@ -2,16 +2,18 @@ package com.fdkankan.fusion.common;
 
 public class FilePath {
 
-    public final static String hotPath = "scene_view_data/%s/user/hot.json";
-    public final static String hotIconDefaultPath = "fusion/default/tag_icon_default.svg";
 
     public final static String OBJ_OSS_PATH = "scene_view_data/%s/data/mesh";
-    public final static String GLB_OSS_PATH = "fusion/model/glb/%s/mesh.glb";
-
-    public final static String VIDEO_OSS_PATH = "fusion/video/%s";
+    public final static String GLB_OSS_PATH = "fusion/%s/model/glb/%s/mesh.glb";
+    public final static String VIDEO_OSS_PATH = "fusion/%s/video/%s";
+    public final static String File_OSS_PATH = "fusion/%s/file/%s";
+    public final static String ICON_OSS_PATH = "fusion/%s/icon/%s";
+    public final static String DEFAULT_OSS_PATH = "fusion/default/%s";
 
    // public final static String VIDEO_LOCAL_PATH = "D:\\video\\merge";
-   public final static String VIDEO_LOCAL_PATH = "/home/fusion/video/merge";
+   public final static String VIDEO_LOCAL_PATH = "/home/fusion/%s/video/merge";
+   public final static String OBJ_LOCAL_PATH = "/home/fusion/%s/model/%s";
+   public final static String GLB_LOCAL_PATH = "/home/fusion/%s/model/%s";
 
 
 }

+ 5 - 1
src/main/java/com/fdkankan/fusion/controller/CaseFilesController.java

@@ -2,6 +2,7 @@ package com.fdkankan.fusion.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.ResultData;
@@ -10,6 +11,7 @@ import com.fdkankan.fusion.service.ICaseFilesService;
 import com.fdkankan.fusion.service.impl.UploadService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -29,6 +31,8 @@ public class CaseFilesController {
     ICaseFilesService caseFilesService;
     @Autowired
     UploadService uploadService;
+    @Value("${spring.profiles.active}")
+    private String environment;
 
     @GetMapping("/allList")
     public ResultData allList(@RequestParam(required = false) Integer caseId,
@@ -50,7 +54,7 @@ public class CaseFilesController {
         caseFiles.setFilesTypeId(filesTypeId);
         caseFiles.setFilesTitle(filesTitle);
         caseFilesService.save(caseFiles);
-        String url = uploadService.uploadFile(file, false, "fusion/file/" + caseFiles.getFilesId() + "/");
+        String url = uploadService.uploadFile(file, false, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
         caseFiles.setFilesUrl(url);
         caseFilesService.saveOrUpdate(caseFiles);
         return ResultData.ok();

+ 5 - 1
src/main/java/com/fdkankan/fusion/controller/HotIconController.java

@@ -1,6 +1,7 @@
 package com.fdkankan.fusion.controller;
 
 
+import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.util.JwtUtil;
 import com.fdkankan.fusion.exception.BusinessException;
@@ -11,6 +12,7 @@ import com.fdkankan.fusion.service.IHotIconService;
 import com.fdkankan.fusion.service.impl.UploadService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -35,6 +37,8 @@ public class HotIconController extends BaseController{
     ICaseTagService caseTagService;
     @Autowired
     UploadService uploadService;
+    @Value("${spring.profiles.active}")
+    private String environment;
 
     @GetMapping("/list")
     public ResultData list(@RequestParam(required = false) Integer caseId){
@@ -52,7 +56,7 @@ public class HotIconController extends BaseController{
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
 
-        String iconUrl = uploadService.uploadFile(file, true, "fusion/icon/");
+        String iconUrl = uploadService.uploadFile(file, true, String.format(FilePath.ICON_OSS_PATH,environment,""));
 
         String username = JwtUtil.getUsername(getToken());
         HotIcon hotIcon = new HotIcon();

+ 4 - 2
src/main/java/com/fdkankan/fusion/controller/UploadController.java

@@ -1,5 +1,6 @@
 package com.fdkankan.fusion.controller;
 
+import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.ResultData;
@@ -24,11 +25,12 @@ public class UploadController {
 
     @Autowired
     UploadService uploadService;
-
+    @Value("${spring.profiles.active}")
+    private String environment;
 
     @PostMapping("/file")
     public ResultData file(@RequestParam(required = false) MultipartFile file) throws Exception {
 
-        return ResultData.ok( uploadService.uploadFile(file,true,"fusion/file/"));
+        return ResultData.ok( uploadService.uploadFile(file,true,String.format(FilePath.File_OSS_PATH,environment,"")));
     }
 }

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

@@ -33,12 +33,10 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
 
     @Autowired
     UploadToOssUtil uploadToOssUtil;
-    @Value("${local.obj_path}")
-    private String OBJ_PATH;
-    @Value("${local.glb_path}")
-    private String GLB_PATH;
     @Value("${upload.query-path}")
     private String queryPath;
+    @Value("${spring.profiles.active}")
+    private String environment;
     @Autowired
     IModelService modelService;
     @Autowired
@@ -93,7 +91,7 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
                 model.setType(param.getType());
                 model.setModelType("pointcloud");    //深时点云类型
                 if(param.getType() != 2){           //不为深时
-                    model.setModelObjUrl(String.format(OBJ_PATH ,num) +"/mesh.obj");
+                    model.setModelObjUrl(String.format(FilePath.OBJ_LOCAL_PATH,environment ,num) +"/mesh.obj");
                     model.setModelGlbUrl(getGlbUrl(param.getType(),num,model));
                     model.setModelType("glb");
                 }
@@ -114,9 +112,9 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
 
     private String getGlbUrl(Integer type, String num,Model model) {
         if(type == 0 || type == 1){ //看看,看见
-            String objPath = String.format(OBJ_PATH ,num);
-            String glbPath = String.format(GLB_PATH,num) +"/mesh.glb";
-            String glbOssPath = String.format(FilePath.GLB_OSS_PATH , num);
+            String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
+            String glbPath = String.format(FilePath.GLB_LOCAL_PATH,environment,num) +"/mesh.glb";
+            String glbOssPath = String.format(FilePath.GLB_OSS_PATH ,environment, num);
 //            if(uploadToOssUtil.existKey(glbOssPath)){
 //                return queryPath + "/"+glbOssPath;
 //            }

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

@@ -57,6 +57,8 @@ public class CaseVideoServiceImpl extends ServiceImpl<ICaseVideoMapper, CaseVide
     UploadService uploadService;
     @Value("${upload.query-path}")
     private String queryPath;
+    @Value("${spring.profiles.active}")
+    private String environment;
     @Autowired
     RedisUtil redisUtil;
 
@@ -145,7 +147,7 @@ public class CaseVideoServiceImpl extends ServiceImpl<ICaseVideoMapper, CaseVide
                         return;
                     }
                     String mergeLocalPath = FilePath.VIDEO_LOCAL_PATH + "/" + mergeLocalName;
-                    String ossKey = String.format(FilePath.VIDEO_OSS_PATH, videoFolder.getVideoFolderId()) + "/" + mergeLocalName;
+                    String ossKey = String.format(FilePath.VIDEO_OSS_PATH,environment, videoFolder.getVideoFolderId()) + "/" + mergeLocalName;
                     uploadToOssUtil.uploadOss(mergeLocalPath, ossKey);
                     if (!uploadToOssUtil.existKey(ossKey)) {
                         updateCaseVideoStatus(videoFolder.getVideoFolderId(), -1);
@@ -154,7 +156,7 @@ public class CaseVideoServiceImpl extends ServiceImpl<ICaseVideoMapper, CaseVide
                     }
                     if(newCover){
                         String mergeLocalPathImg = FilePath.VIDEO_LOCAL_PATH + "/" + mergeLocalName.replace(".mp4", ".jpg");
-                        String ossKeyImg = String.format(FilePath.VIDEO_OSS_PATH, videoFolder.getVideoFolderId()) + "/" + mergeLocalName.replace(".mp4", ".jpg");
+                        String ossKeyImg = String.format(FilePath.VIDEO_OSS_PATH, environment,videoFolder.getVideoFolderId()) + "/" + mergeLocalName.replace(".mp4", ".jpg");
                         uploadToOssUtil.uploadOss(mergeLocalPathImg, ossKeyImg);
                         if (!uploadToOssUtil.existKey(ossKeyImg)) {
                             updateCaseVideoStatus(videoFolder.getVideoFolderId(), -1);

+ 4 - 6
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -56,12 +56,10 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
     @Autowired
     RedisUtil redisUtil;
 
-    @Value("${local.obj_path}")
-    private String OBJ_PATH;
-    @Value("${local.glb_path}")
-    private String GLB_PATH;
     @Value("${upload.query-path}")
     private String queryPath;
+    @Value("${spring.profiles.active}")
+    private String environment;
 
     @Override
     public Model uploadObj(MultipartFile file, String username) throws Exception {
@@ -97,7 +95,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
         fileName = UUID.randomUUID().toString().replace("-","") +".zip";
         File newObjFile = null;
         File objPathFile = null;
-        String objPath = String.format(OBJ_PATH , "modelId_"+model.getModelId()) ;
+        String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "modelId_"+model.getModelId()) ;
 
         newObjFile = new File(objPath +"/" + fileName);
         if(!newObjFile.getParentFile().exists()){
@@ -153,7 +151,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
             public void run() {
                 File mntFile = null;
                 try {
-                    String glbOssPath = String.format(FilePath.GLB_OSS_PATH, model.getModelId());
+                    String glbOssPath = String.format(FilePath.GLB_OSS_PATH,environment, model.getModelId());
 
                     String name = file1.getName();
                     if(name.contains("obj") || name.contains("OBJ")){

+ 0 - 4
src/main/resources/application-dev.yaml

@@ -27,7 +27,3 @@ spring:
         max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
     lettuce:
       shutdown-timeout: 0ms
-
-local:
-  obj_path: /home/fusion/model/%s
-  glb_path: /home/fusion/model/%s

+ 0 - 3
src/main/resources/application-local.yaml

@@ -28,6 +28,3 @@ spring:
     lettuce:
       shutdown-timeout: 0ms
 
-local:
-  obj_path: D:\fusion\model\%s
-  glb_path: D:\fusion\model\%s

+ 31 - 0
src/main/resources/application-prod.yaml

@@ -0,0 +1,31 @@
+spring:
+  datasource:
+    type: com.zaxxer.hikari.HikariDataSource          # 数据源类型:HikariCP
+    driver-class-name: com.mysql.jdbc.Driver          # mysql驱动
+    url: jdbc:mysql://172.20.0.5:3306/fd_fusion?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
+    username: fusion
+    password: 3oo19bgh0cae2406
+    hikari:
+      connection-timeout: 30000         # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 默认:30秒
+      minimum-idle: 5                   # 最小连接数
+      maximum-pool-size: 20             # 最大连接数
+      auto-commit: true                 # 事务自动提交
+      idle-timeout: 600000              # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟
+      pool-name: DateSourceHikariCP     # 连接池名字
+      max-lifetime: 1800000             # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 1800000ms
+      connection-test-query: SELECT 1   # 连接测试语句
+  redis:
+    host: 172.18.157.42
+    port: 6379
+    timeout: 6000ms
+    password:
+    jedis:
+      pool:
+        max-active: 10  #连接池最大连接数(使用负值表示没有限制)
+        max-idle: 10 # 连接池中的最大空闲连接
+        min-idle: 5 # 连接池中的最小空闲连接
+        max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
+    lettuce:
+      shutdown-timeout: 0ms
+
+

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

@@ -59,10 +59,8 @@ forest:
   ## 连接超时时间,单位为毫秒, 默认值为2000
   connect-timeout: 3000000
 
-
 upload:
   type: oss
-  file-path : fusion/
   query-path: https://4dkk.4dage.com/
 oss:
   #point: http://oss-cn-shenzhen-internal.aliyuncs.com
@@ -70,12 +68,4 @@ oss:
   key: LTAIUrvuHqj8pvry
   secrey: JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4
   bucket: 4dkankan
-  sdk: 4dscene
-  small: ?x-oss-process=image/resize,m_fill,h_%s,w_%s
-  prefix:
-    ali: https://4dkk.4dage.com/
-    sdk: https://4dscene.4dage.com/
-    url: https://4dkk.4dage.com/
-
-local:
-  path: /home/4dkankan/
+  small: ?x-oss-process=image/resize,m_fill,h_%s,w_%s