xiewj 6 tháng trước cách đây
mục cha
commit
6f6e8cc952

+ 14 - 17
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneListener.java

@@ -57,12 +57,11 @@ import java.util.regex.Pattern;
 @Component
 @Slf4j
 public class SceneListener {
-
-    @Autowired
-    ConfigConstant configConstant;
     @Autowired
     FileAndOssUtil fileAndOssUtil;
     @Autowired
+    ConfigConstant configConstant;
+    @Autowired
     WorkService workService;
     @Autowired
     QrCodeUtils qrCodeUtils;
@@ -99,7 +98,7 @@ public class SceneListener {
     @RabbitListener(
             queuesToDeclare = @Queue("${queue.scene-queue}"),concurrency = "2"
     )
-    public void sceneQueue(Channel channel, Message message) throws IOException {
+    public void sceneQueue(Channel channel, Message message) throws Exception {
             if (ObjectUtils.isEmpty(message.getBody())) {
                 log.error("消息内容为空,退出构建,当前服务器id:{}" );
                 return;
@@ -167,7 +166,7 @@ public class SceneListener {
     @RabbitListener(
             queuesToDeclare = @Queue("${queue.scene-queue-work}"),concurrency = "1"
     )
-    public void sceneQueueWork(Channel channel, Message message) throws IOException {
+    public void sceneQueueWork(Channel channel, Message message) throws Exception {
         if (ObjectUtils.isEmpty(message.getBody())) {
             log.error("消息内容为空,退出构建,当前服务器id:{}" );
             return;
@@ -213,7 +212,7 @@ public class SceneListener {
                     scenePanoService.updateById(scenePanoEntity);
                 }
 
-                String visionUrl = domain4dKK+"/scene_view_data/"+param.getSceneCode()+"/images/vision.txt";
+                String visionUrl =  ossUtil.calculateUrl("")+"/scene_view_data/"+param.getSceneCode()+"/images/vision.txt";
 
                 HttpResponse execute = HttpRequest.get(visionUrl+"?m="+System.currentTimeMillis()).execute();
                 JSONArray sweepLocations = new JSONArray();
@@ -347,19 +346,17 @@ public class SceneListener {
         }
     }
 
-    private void updateOssStatusJson(String sceneCode, int status) throws IOException {
+    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=fileAndOssUtil.existKey("4dkankan",statusJson);
+        Boolean exist=ossUtil.doesObjectExist("4dkankan",statusJson);
         if (exist){
-            String statusJsonUrl = domain4dKK+"/"+statusJson;
-            HttpResponse execute = HttpRequest.get(statusJsonUrl+"?m="+System.currentTimeMillis()).execute();
-            if (execute.getStatus()==200){
+            String fileContent = ossUtil.getFileContent("4dkankan", statusJson);
                 log.info("statusJson存在: {}");
-                JSONObject statusJsonObj = JSONObject.parseObject(execute.body());
+                JSONObject statusJsonObj = JSONObject.parseObject(fileContent);
                 statusJsonObj.put("status",status);
-                fileAndOssUtil.upload("4dkankan",statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8), statusJson);
-            }
+                ossUtil.uploadFileBytes("4dkankan",statusJson,statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8));
+
         }
     }
 
@@ -420,7 +417,7 @@ public class SceneListener {
             sceneCode = RandomUtils.getSceneCode("fd720_");
             newName = sceneCode + ".jpg";
             filePath = configConstant.serverBasePath + sceneCode+ "/" + newName;
-            fileAndOssUtil.downloadFile("4dkankan",item,filePath );
+            ossUtil.downloadFile("4dkankan",item,filePath );
 
             entity = new ScenePanoEntity();
             entity.setFilePath(filePath);
@@ -454,7 +451,7 @@ public class SceneListener {
 
 
             log.info("生成过,重新下载");
-            fileAndOssUtil.downloadBySh(item, filePath,"4dkankan","local");
+            ossUtil.downloadFile("4dkankan",item,filePath );
             log.info("下载完成重新切图");
             long size = FileUtil.size(new File(filePath));
             size = size / 1024;
@@ -549,7 +546,7 @@ public class SceneListener {
         log.info("作品tour.xml写入完成");
 
         String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
-        fileAndOssUtil.upload(tourPath, ossKeyPath);
+        ossUtil.uploadFile( ossKeyPath,tourPath);
         log.info("tour.xml上传完成 : {}", ossKeyPath);
     }