xiewj 1 год назад
Родитель
Сommit
71d6949cc7

+ 28 - 2
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneListener.java

@@ -8,6 +8,7 @@ import cn.hutool.http.HttpResponse;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.amazonaws.services.dynamodbv2.xspec.S;
 import com.gis.constant.CmdConstant;
 import com.gis.constant.ConfigConstant;
 import com.gis.entity.RelicsSceneInitQueueDTO;
@@ -89,7 +90,7 @@ public class SceneListener {
             }
         String traceId = System.currentTimeMillis()+"";
         MDC.put("TRACE_ID", traceId);
-
+        String sceneCode="";
         long deliveryTag = message.getMessageProperties().getDeliveryTag();
         try {
             String msg = new String(message.getBody(), StandardCharsets.UTF_8);
@@ -100,6 +101,7 @@ public class SceneListener {
                 log.error("参数列表错误(缺少),格式不匹配,{}",param);
                 channel.basicAck(deliveryTag, false);
             }
+            sceneCode=param.getSceneCode();
             WorkEntity workEntity=workService.findByNum(param.getSceneCode());
             if (ObjectUtil.isEmpty(workEntity)&&param.getStatus()==0){
                 //初始化创建work表数据
@@ -117,6 +119,8 @@ public class SceneListener {
                 sendStartMq(param);
                 channel.basicAck(deliveryTag, false);
             }else if (ObjectUtil.isNotEmpty(param.getSceneCode())&&param.getStatus()==1){
+                updateOssStatusJson(param.getSceneCode(),0);
+
                 //计算完成处理
                 //1,下载场景的全景图 默认 。scene_view_data/panorama/目录下的全景图图片
                 workEntity.setAlgorithmTime(param.getAlgorithmTime());
@@ -190,16 +194,38 @@ public class SceneListener {
                 workEntity.setCalcStatus(1);
                 workService.update(workEntity);
                 sendEndMq(param);
+                updateOssStatusJson(param.getSceneCode(),0);
                 channel.basicAck(deliveryTag, false);
             }
 
 
         }catch (Exception e){
-            e.printStackTrace();
+            if (StrUtil.isNotEmpty(sceneCode)){
+                updateOssStatusJson(sceneCode,0);
+            }
             channel.basicAck(deliveryTag, false);
             log.error("场景sceneQueue报错{}",e.getMessage());
+            e.printStackTrace();
+
         }
     }
+
+    private void updateOssStatusJson(String sceneCode, int status) throws IOException {
+        //修改OSS,status状态 scene_view_data/场景码/data/status.json
+        String statusJson = "scene_view_data/"+sceneCode+"/data/status.json";
+        Boolean exist=aliyunOssUtil.existKey("4dkankan",statusJson);
+        if (exist){
+            String statusJsonUrl = "http://4dkk.4dage.com/"+statusJson;
+            HttpResponse execute = HttpRequest.get(statusJsonUrl+"?m="+System.currentTimeMillis()).execute();
+            if (execute.getStatus()==200){
+                log.info("vision.txt存在: {}");
+                JSONObject statusJsonObj = JSONObject.parseObject(execute.body());
+                statusJsonObj.put("status",status);
+                fileAndOssUtil.upload(statusJsonObj.toJSONString().getBytes(StandardCharsets.UTF_8), statusJson);
+            }
+        }
+    }
+
     private void sendStartMq(SceneQueueDTO param) {
             RelicsSceneInitQueueDTO relicsSceneInitQueueDTO = new RelicsSceneInitQueueDTO();
             relicsSceneInitQueueDTO.setSceneCode(param.getSceneCode());

+ 21 - 1
720yun_fd_consumer/gis_consumer_oss/src/main/java/com/gis/oss/util/AliYunOssUtil.java

@@ -72,7 +72,27 @@ public class AliYunOssUtil {
             log.error(e.toString() + key);
         }
     }
-
+    /**
+     * 获取文件内容-阿里云
+     * @param objectName
+     * @return
+     */
+    public boolean existKey(String bucket,String objectName){
+        //创建oss客户端
+        OSSClient ossClient = init();
+        // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
+        try{
+            boolean exist = ossClient.doesObjectExist(bucket, objectName);
+            return exist;
+        }catch (Exception e){
+            log.error("s4判断是否存在key异常,key=" + objectName, e);
+        }finally {
+            if(ossClient != null){
+                ossClient.shutdown();
+            }
+        }
+        return false;
+    }
     /**
      *
      * @param data