Browse Source

接入springboot-admin

dengsixing 3 years ago
parent
commit
f22046efb1

+ 6 - 0
4dkankan-center-modeling/pom.xml

@@ -93,6 +93,12 @@
 			<version>2.0.0-SNAPSHOT</version>
 		</dependency>
 
+		<dependency>
+			<groupId>de.codecentric</groupId>
+			<artifactId>spring-boot-admin-client</artifactId>
+			<version>2.3.1</version>
+		</dependency>
+
 	</dependencies>
 
 	<build>

+ 12 - 0
4dkankan-center-modeling/src/main/resources/bootstrap.yml

@@ -30,3 +30,15 @@ spring:
       discovery:
         server-addr: 192.168.0.47:8848
         namespace: 4dkankan-dev
+        metadata:
+          management:
+            context-path: ${server.servlet.context-path}/actuator
+
+management:
+  endpoints:
+    web:
+      exposure:
+        include: '*'
+  endpoint:
+    health:
+      show-details: ALWAYS

+ 6 - 0
4dkankan-center-platform/pom.xml

@@ -16,6 +16,12 @@
   <dependencies>
 
       <dependency>
+          <groupId>de.codecentric</groupId>
+          <artifactId>spring-boot-admin-client</artifactId>
+          <version>2.3.1</version>
+      </dependency>
+
+      <dependency>
           <groupId>com.fdkankan</groupId>
           <artifactId>4dkankan-center-scene-api</artifactId>
           <version>2.0.0-SNAPSHOT</version>

+ 13 - 1
4dkankan-center-platform/src/main/resources/bootstrap.yml

@@ -39,7 +39,19 @@ spring:
       discovery:
         server-addr: 192.168.0.47:8848
         namespace: 4dkankan-dev
+        metadata:
+          management:
+            context-path: ${server.servlet.context-path}/actuator
 
 feign:
   httpclient:
-    connection-timeout: 200000
+    connection-timeout: 200000
+
+management:
+  endpoints:
+    web:
+      exposure:
+        include: '*'
+  endpoint:
+    health:
+      show-details: ALWAYS

+ 18 - 7
4dkankan-center-scene-download/src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -65,7 +65,17 @@ public class SceneDownloadHandlerServiceImpl {
     @Autowired
     private SceneUserSceneClient sceneUserSceneClient;
 
-    private static final String wwwroot = "wwwroot/";
+    @Value("${path.v3school}")
+    private String v3localPath;
+
+    @Value("${path.zip-local}")
+    private String zipLocalFormat;
+
+    @Value("${path.zip-oss}")
+    private String zipOssFormat;
+
+    @Value("${path.zip-root}")
+    private String wwwroot;
 //    private static final String[] prefixArr = new String[]{
 //        "data/data%s/",
 //        "voice/voice%s/",
@@ -149,7 +159,7 @@ public class SceneDownloadHandlerServiceImpl {
 
         //代码文件路径
         //String v3localPath = "/downloads/v3local/";
-        String v3localPath = "F:\\downloads\\v3local\\";
+//        String v3localPath = "F:\\downloads\\v3local\\";
 
         try {
             Set<String> cacheKeys = new HashSet<>();
@@ -163,11 +173,12 @@ public class SceneDownloadHandlerServiceImpl {
             int count = 0;
             //定义压缩包
             //            zipPath = "/downloads/scenes/" + num + ".zip";
-            zipPath = "F:\\downloads\\scenes\\" + num + ".zip";
+//            zipPath = "F:\\downloads\\scenes\\" + num + ".zip";
+            zipPath = String.format(this.zipLocalFormat, num);
             File zipFile = new File(zipPath);
             ZipOutputStream out = new ZipOutputStream(zipFile);
 
-            JSONObject getInfoJson = this.zipGetInfoJson(out, num);
+            JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
             String resolution = "2k";
             if(getInfoJson.getInt("sceneSource") != null &&
                 (getInfoJson.getInt("sceneSource") == 3 || getInfoJson.getInt("sceneSource") == 4)){
@@ -195,7 +206,7 @@ public class SceneDownloadHandlerServiceImpl {
             out.close();
 
             //上传压缩包
-            String uploadPath = "downloads/scenes/" + num + ".zip";
+            String uploadPath = String.format(this.zipOssFormat, num);
             uploadToOssUtil.upload(zipPath, uploadPath);
 
             //更新进度100
@@ -300,7 +311,7 @@ public class SceneDownloadHandlerServiceImpl {
         return map;
     }
 
-    private JSONObject zipGetInfoJson(ZipOutputStream out, String num) throws Exception{
+    private JSONObject zipGetInfoJson(ZipOutputStream out, String root, String num) throws Exception{
 
         ResultData<SceneInfoDTO> sceneViewInfo = sceneUserSceneClient.getSceneViewInfo(num);
         if(!sceneViewInfo.getSuccess()){
@@ -318,7 +329,7 @@ public class SceneDownloadHandlerServiceImpl {
         getInfoJson.set("needKey", 0);
         getInfoJson.set("sceneKey","");
         //写入getInfo.json
-        String getInfoJsonPath = "wwwroot/data/data"+num + "/getInfo.json";
+        String getInfoJsonPath = root + "data/data"+ num + "/getInfo.json";
         this.zipBytes(out, getInfoJsonPath, getInfoJson.toString().getBytes());
         return getInfoJson;
     }

+ 5 - 0
4dkankan-center-scene-download/src/main/resources/bootstrap.yml

@@ -31,6 +31,11 @@ spring:
       discovery:
         server-addr: 192.168.0.47:8848
         namespace: 4dkankan-dev
+path:
+  v3school: /downloads/v3local/
+  zip-root: wwwroot/
+  zip-local: /downloads/scenes/%s.zip
+  zip-oss: downloads/scenes/%s.zip
 
 download:
   config:

+ 6 - 0
4dkankan-center-scene/pom.xml

@@ -103,6 +103,12 @@
             <version>1.3.6</version>
         </dependency>
 
+        <dependency>
+            <groupId>de.codecentric</groupId>
+            <artifactId>spring-boot-admin-client</artifactId>
+            <version>2.3.1</version>
+        </dependency>
+
 
     </dependencies>
 

+ 14 - 2
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/TestController.java

@@ -14,8 +14,10 @@ import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.service.IFolderService;
 import com.fdkankan.scene.service.IScene3dNumService;
 import com.fdkankan.scene.service.ISceneService;
+import com.fdkankan.scene.vo.SceneEditInfoVO;
 import com.fdkankan.scene.vo.SceneVO;
 import com.google.common.collect.Lists;
+import java.util.ArrayList;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -71,7 +73,7 @@ public class TestController {
     RedisLockUtil redisLockUtil;
 
 
-    @PostMapping("/test")
+    @GetMapping("/test")
     public String test(String path, String buildType) throws Exception {
 
 //        JSONObject dataJson = new JSONObject();
@@ -88,7 +90,17 @@ public class TestController {
 //            CreateObjUtil.build3dModel(path , "1");
 //        }
 
-        platformGoodsClient.getCameraById(1L);
+//        folderService.list();
+
+        List<SceneEditInfoVO> list = new ArrayList<>();
+        for (int i = 0; i < 10000000; i++){
+            list.add(SceneEditInfoVO.builder().num("aaa" + i)
+                .description("123adfffffffffffffffffffffffffffffffffasdfadhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhsfvhbsfghsdfgdfgrdg").build());
+        }
+
+
+        Thread.sleep(50000000);
+
 
 
         return "123";

+ 7 - 4
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -855,7 +855,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     @Override
     public ResultData saveInitialPage(FileNameAndDataParamVO param) throws Exception{
 
-//        ScenePro scenePro = this.findBySceneNum(param.getNum());
+        ScenePro scenePro = this.findBySceneNum(param.getNum());
         ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
         if(scenePlus == null){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
@@ -867,6 +867,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         scenePlusExt.setThumb(thumbUrl);
         scenePlusExtService.updateById(scenePlusExt);
 
+        scenePro.setThumb(thumbUrl);
+        sceneProService.updateById(scenePro);
+
         SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
         if(sceneEditInfo == null){
             sceneEditInfo = new SceneEditInfo();
@@ -2993,8 +2996,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if (!directory.exists()) {
             directory.mkdirs();
         }
-        String editImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, param.getNum());
-        String modeldataUrl = ossUrlPrefix + editImagesPath + "vision.modeldata?t=" + System.currentTimeMillis();
+        String viewImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, param.getNum());
+        String modeldataUrl = ossUrlPrefix + viewImagesPath + "vision.modeldata?t=" + System.currentTimeMillis();
 
         //如果是云存储,将vision.modeldata下载到本地,如果是本地存储,场景计算完就已经将这个文件拷贝到编辑目录了存在这个文件了,不需要再下载
         if(!StorageType.LOCAL.code().equals(this.type)){
@@ -3029,7 +3032,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         FileUtils.deleteFile(localDataPath + "vision.modeldata");
         FileUtils.writeFile(localDataPath + "vision.json", json.toString());
         ConvertUtils.convertTxtToVisionModelData(localDataPath + "vision.json", localDataPath + "vision.modeldata");
-        uploadToOssUtil.upload(localDataPath + "vision.modeldata", editImagesPath + "vision.modeldata");
+        uploadToOssUtil.upload(localDataPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
 
         //更新版本号
         SceneEditInfo editInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());

+ 13 - 0
4dkankan-center-scene/src/main/resources/bootstrap.yml

@@ -48,6 +48,9 @@ spring:
       discovery:
         server-addr: 192.168.0.47:8848
         namespace: 4dkankan-dev
+        metadata:
+          management:
+            context-path: ${server.servlet.context-path}/actuator
     sentinel:
       transport:
         dashboard: 192.168.0.47:8888
@@ -86,6 +89,16 @@ feign:
   httpclient:
     connection-timeout: 200000
 
+management:
+  endpoints:
+    web:
+      exposure:
+        include: '*'
+  endpoint:
+    health:
+      show-details: ALWAYS
+
+
 
 
 

+ 5 - 0
4dkankan-common/src/main/java/com/fdkankan/common/response/BaseResponseAdvice.java

@@ -33,6 +33,11 @@ public class BaseResponseAdvice implements ResponseBodyAdvice<Object> {
 //        List<String> strings = serverHttpRequest.getHeaders().get("Accept-Language");
 //        System.out.println(strings.get(0));
 
+        //admin监控请求,直接返回
+        if(serverHttpRequest.getURI().getPath().contains("actuator")){
+            return body;
+        }
+
         if(body instanceof String){
             return JSONObject.toJSONString(ResultData.ok(body));
         }