Parcourir la source

add offline queue5

xiewj il y a 3 mois
Parent
commit
5c0dad551e

+ 10 - 2
720yun_fd_base/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -2,6 +2,7 @@ package com.gis.common.util;
 
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSON;
+import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 import java.util.regex.Matcher;
@@ -15,11 +16,18 @@ public class FileUtils {
     public static void writeUtf8String(final Object content, final String filePath) {
         String data = JSON.toJSONStringWithDateFormat(content, "yyyy-MM-dd HH:mm:ss");
         //清空所有域名
-        data=data.replaceAll("https://ossxiaoan.4dage.com", "")
+        data = getStringReplaceUrl(data);
+        FileUtil.writeUtf8String(data, filePath.replaceAll("/", Matcher.quoteReplacement(File.separator)));
+    }
+
+    public static @NotNull String getStringReplaceUrl(String data) {
+        data = data.replaceAll("https://ossxiaoan.4dage.com", "")
                 .replaceAll("https://4dkk.4dage.com", "")
                 .replaceAll("https://testeurs3.4dkankan.com", "")
                 .replaceAll("https://eurs3.4dkankan.com", "")
                 .replaceAll("//", "/");
-        FileUtil.writeUtf8String(data, filePath.replaceAll("/", Matcher.quoteReplacement(File.separator)));
+        return data;
     }
+
+
 }

+ 5 - 3
720yun_fd_consumer/src/main/java/com/gis/listener/container/SceneQueueListener.java

@@ -57,6 +57,8 @@ public class SceneQueueListener implements ChannelAwareMessageListener {
     @Value("${domain.4dkk}")
     public  String domain4dKK;
 
+    @Value("${other-bucket.fdkk}")
+    String fdkkBucket;
 
     @Autowired
     WorkCoverTypeService workCoverTypeService;
@@ -145,13 +147,13 @@ public class SceneQueueListener implements ChannelAwareMessageListener {
     private void updateOssStatusJson(String sceneCode, int status) throws Exception {
         //修改OSS,status状态 scene_view_data/场景码/data/status.json
         String statusJson = "scene_view_data/"+sceneCode+"/data/status.json";
-        Boolean exist=ossUtil.doesObjectExist("4dkankan",statusJson);
+        Boolean exist=ossUtil.doesObjectExist(fdkkBucket,statusJson);
         if (exist){
-            String fileContent = ossUtil.getFileContent("4dkankan", statusJson);
+            String fileContent = ossUtil.getFileContent(fdkkBucket, statusJson);
             log.info("statusJson存在: {}",statusJson);
             JSONObject statusJsonObj = JSONObject.parseObject(fileContent);
             statusJsonObj.put("status",status);
-            ossUtil.uploadFileBytes("4dkankan",statusJson,statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8));
+            ossUtil.uploadFileBytes(fdkkBucket,statusJson,statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8));
 
         }
     }

+ 10 - 7
720yun_fd_consumer/src/main/java/com/gis/listener/container/SceneWorkQueueListener.java

@@ -105,6 +105,9 @@ public class SceneWorkQueueListener implements ChannelAwareMessageListener {
     @Autowired
     private WorkNavigationService workNavigationService;
 
+    @Value("${other-bucket.fdkk}")
+    String fdkkBucket;
+
     private String queueName;
 
     public void setQueueName(String queueName) {
@@ -181,9 +184,9 @@ public class SceneWorkQueueListener implements ChannelAwareMessageListener {
                 String visionOssKey="scene_view_data/"+param.getSceneCode()+"/images/vision.txt";
 
                 JSONArray sweepLocations = new JSONArray();
-                if (ossUtil.doesObjectExist("4dkankan",visionOssKey)){
+                if (ossUtil.doesObjectExist(fdkkBucket,visionOssKey)){
                     log.info("vision.txt存在: {}",visionOssKey);
-                    JSONObject visJson = JSONObject.parseObject(ossUtil.getFileContent("4dkankan",visionOssKey));
+                    JSONObject visJson = JSONObject.parseObject(ossUtil.getFileContent(fdkkBucket,visionOssKey));
                     if(visJson.containsKey("sweepLocations")){
                         sweepLocations = visJson.getJSONArray("sweepLocations");
                     }
@@ -274,13 +277,13 @@ public class SceneWorkQueueListener implements ChannelAwareMessageListener {
     private void updateOssStatusJson(String sceneCode, int status) throws Exception {
         //修改OSS,status状态 scene_view_data/场景码/data/status.json
         String statusJson = "scene_view_data/"+sceneCode+"/data/status.json";
-        Boolean exist=ossUtil.doesObjectExist("4dkankan",statusJson);
+        Boolean exist=ossUtil.doesObjectExist(fdkkBucket,statusJson);
         if (exist){
-            String fileContent = ossUtil.getFileContent("4dkankan", statusJson);
+            String fileContent = ossUtil.getFileContent(fdkkBucket, statusJson);
             log.info("statusJson存在: {}",statusJson);
             JSONObject statusJsonObj = JSONObject.parseObject(fileContent);
             statusJsonObj.put("status",status);
-            ossUtil.uploadFileBytes("4dkankan",statusJson,statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8));
+            ossUtil.uploadFileBytes(fdkkBucket,statusJson,statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8));
 
         }
     }
@@ -421,7 +424,7 @@ public class SceneWorkQueueListener implements ChannelAwareMessageListener {
             sceneCode = RandomUtils.getSceneCode("fd720_");
             newName = sceneCode + ".jpg";
             filePath = configConstant.serverBasePath + sceneCode+ "/" + newName;
-            ossUtil.downloadFile("4dkankan",item,filePath );
+            ossUtil.downloadFile(fdkkBucket,item,filePath );
 
             entity = new ScenePanoEntity();
             entity.setFilePath(filePath);
@@ -455,7 +458,7 @@ public class SceneWorkQueueListener implements ChannelAwareMessageListener {
 
 
             log.info("生成过,重新下载");
-            ossUtil.downloadFile("4dkankan",item,filePath );
+            ossUtil.downloadFile(fdkkBucket,item,filePath );
             log.info("下载完成重新切图");
             long size = FileUtil.size(new File(filePath));
             size = size / 1024;

+ 13 - 4
720yun_fd_consumer/src/main/java/com/gis/listener/container/WorkOfflineListener.java

@@ -3,7 +3,6 @@ package com.gis.listener.container;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.lang.tree.Tree;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.StrUtil;
@@ -16,7 +15,6 @@ import com.gis.common.mq.RabbitMqProducerUtil;
 import com.gis.common.util.FileUtils;
 import com.gis.common.util.RedisUtil;
 import com.gis.common.util.Result;
-import com.gis.constant.SysConstants;
 import com.gis.domain.dto.WorkOfflineDTO;
 import com.gis.domain.dto.WorkOfflineDoneDTO;
 import com.gis.domain.entity.WorkEntity;
@@ -30,7 +28,6 @@ import com.gis.oss.util.OssShUtil;
 import com.gis.service.*;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;
-import org.slf4j.MDC;
 import org.springframework.amqp.core.Message;
 import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -81,7 +78,8 @@ public class WorkOfflineListener implements ChannelAwareMessageListener {
     @Autowired
     RedisUtil redisUtil;
 
-
+    @Value("${other-bucket.fdkk}")
+    String fdkkBucket;
     @Override
     @LogAnnotation
     public void onMessage(Message message, Channel channel) throws Exception {
@@ -156,6 +154,17 @@ public class WorkOfflineListener implements ChannelAwareMessageListener {
                             if (FileUtil.exist(zipPath)) {
                                 String cmd = String.format(CmdConstant.UNZIP_MESH_ZIP, zipPath, param.getPath());
                                 CmdUtils.callLineSh(cmd);
+                                //下载icon
+                                String iconOssKey = FileUtils.getStringReplaceUrl(workNavigationEntity.getIcon());
+                                log.info("下载icon:{}", iconOssKey);
+                                fileStorageTemplate.downloadFile(fdkkBucket,
+                                        iconOssKey,
+                                        param.getPath() + File.separator + iconOssKey
+                                );
+
+
+
+
                             }else {
                                 log.info("mesh离线包不存在,{}---{}", workNavigationEntity.getSceneCode(),zipPath);
                             }

+ 3 - 1
720yun_fd_consumer/src/main/resources/application-pro.yml

@@ -84,4 +84,6 @@ mq:
     listener:
         dynamic: ${Dynamic}
 hostName:
-    filePath: /opt/hosts/hosts.txt
+    filePath: /opt/hosts/hosts.txt
+other-bucket:
+    fdkk: "4dkankan"

+ 3 - 1
720yun_fd_consumer/src/main/resources/application-sit.yml

@@ -87,4 +87,6 @@ mq:
  listener:
     dynamic: ${Dynamic}
 hostName:
-    filePath: /opt/hosts/hosts.txt
+    filePath: /opt/hosts/hosts.txt
+other-bucket:
+    fdkk: "4dkankan"

+ 3 - 1
720yun_fd_manage/src/main/resources/application-pro.yml

@@ -101,4 +101,6 @@ queue:
     do-slice-queue: queue-do-slice
     relics-update-name-queue: relics-update-name-queue
 config:
-    bashPath: ${project.name}/
+    bashPath: ${project.name}/
+other-bucket:
+    fdkk: "4dkankan"

+ 3 - 1
720yun_fd_manage/src/main/resources/application-sit.yml

@@ -95,4 +95,6 @@ queue:
     qjkk-work-offline: qjkk-work-offline
     qjkk-work-offline-done: qjkk-work-offline-done
 config:
-    bashPath: ${project.name}/
+    bashPath: ${project.name}/
+other-bucket:
+    fdkk: "4dkankan"