瀏覽代碼

1.7.0 fix tour.xml

xiewj 1 年之前
父節點
當前提交
000069cdd8

+ 59 - 3
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneListener.java

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.gis.constant.CmdConstant;
 import com.gis.constant.ConfigConstant;
+import com.gis.entity.FodderEntity;
 import com.gis.entity.ScenePanoEntity;
 import com.gis.entity.SceneQueueDTO;
 import com.gis.entity.WorkEntity;
@@ -120,8 +121,17 @@ public class SceneListener {
                     Map<String,Object> scene=new HashMap<>();
 
                     ScenePanoEntity scenePanoEntity = this.doSlice(traceId ,item, param.getSceneCode(), workEntity.getId(),index+".jpg");
-                    scenePanoEntities.add(scenePanoEntity);
 
+
+
+
+
+
+
+
+
+
+                    scenePanoEntities.add(scenePanoEntity);
                     //  "icon": "https://ossxiaoan.4dage.com/720yun_fd_manage/fd720_8nRkFlzpp/vtour/panos/fd720_8nRkFlzpp.tiles/thumb.jpg",
                     //   "sceneCode": "fd720_8nRkFlzpp",
                     // "sceneTitle": "0",
@@ -142,8 +152,11 @@ public class SceneListener {
 
                 log.info("场景切图完成组装json");
                 //3,修改json文件,并创建work作品表数据,增加作品类型为相机拍摄全景图
-                this.editSomeData(workEntity.getId(),scenes);
+                JSONObject someDataToJson= this.editSomeData(workEntity.getId(),scenes);
+
 
+                // 更新跟目录tour.xml 2022-09-15
+                this.updateTour(someDataToJson, workEntity.getId());
 
                 channel.basicAck(deliveryTag, false);
             }
@@ -245,6 +258,7 @@ public class SceneListener {
             log.info("切图预览图ossUrl: {}",ossUrl);
             entity.setIcon(ossUrl);
             log.info("任务成功返回: " + obj);
+
         } catch (InterruptedException e) {
             e.printStackTrace();
             entity.setStatus(2);
@@ -275,6 +289,47 @@ public class SceneListener {
         log.info("切图流程结束 : ");
         return entity;
     }
+
+    /**
+     * 更新 tour.xml
+     * @param someDataToJson
+     * @param id
+     */
+    private void updateTour(JSONObject someDataToJson, String id) {
+        long startTime = System.currentTimeMillis();
+        String scenes = someDataToJson.getString("scenes");
+        BaseRuntimeException.isBlank(scenes, null, "someData的场景码参数未空");
+        List<ScenePanoEntity> list = scenePanoService.findByWorkId(id);
+
+        // 读取tour.xml模板
+        String baseTour = getBaseTour();
+        StringBuilder builder = new StringBuilder();
+        builder.append(baseTour).append("\r\n");
+        for (ScenePanoEntity entity : list) {
+            String tour = entity.getTour();
+            builder.append(tour).append("\r\n");
+        }
+
+        // 添加结束标签
+        builder.append("</krpano>");
+
+        String tourPath = configConstant.serverBasePath + id + "/tour.xml";
+        FileUtil.writeUtf8String(builder.toString(), tourPath);
+        log.info("作品tour.xml写入完成");
+
+        String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
+        fileAndOssUtil.upload(tourPath, ossKeyPath);
+        log.info("tour.xml上传完成 : {}", ossKeyPath);
+    }
+
+    private String getBaseTour(){
+        String baseTourPath = configConstant.serverBasePath + "baseData/tour.xml";
+        String s = FileUtil.readString(baseTourPath, "utf-8");
+        // 结束标签置空, 方便操作
+        s = s.replace("</krpano>", "");
+        return s;
+    }
+
     // 获取切图后的tour.xml
     private String getTourXmlScene(String code) {
         log.info("处理tour.xml");
@@ -305,7 +360,7 @@ public class SceneListener {
     }
 
 
-    private void editSomeData(String id, List<Map<String, Object>> scenes){
+    private JSONObject editSomeData(String id, List<Map<String, Object>> scenes){
         // 如基someData作出修改,记得把代码里的someData 跟服务器里的someData都修改
         String baseSomeDataPath = configConstant.serverBasePath + "baseData/someData.json";
         String baseSomeDataSceneDataPath = configConstant.serverBasePath + "baseData/someDataSceneData.json";
@@ -365,6 +420,7 @@ public class SceneListener {
         }
         String ossUrl = configConstant.ossDomain + ossKeyPath;
         log.info("ossSomeData:{}", ossUrl);
+        return jsonObject;
     }
 
 

+ 3 - 0
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/service/ScenePanoService.java

@@ -3,6 +3,8 @@ package com.gis.service;
 
 import com.gis.entity.ScenePanoEntity;
 
+import java.util.List;
+
 /**
  * 四维看看场景全景图表 服务类接口
  *
@@ -12,4 +14,5 @@ import com.gis.entity.ScenePanoEntity;
 public interface ScenePanoService extends IBaseService<ScenePanoEntity,Long> {
 
     ScenePanoEntity findByWorkIdAndName(String workId, String imgName);
+    List<ScenePanoEntity> findByWorkId(String workId);
 }

+ 9 - 0
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/service/impl/ScenePanoServiceImpl.java

@@ -8,6 +8,8 @@ import com.gis.service.impl.IBaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 四维看看场景全景图表 服务实现类
  *
@@ -31,4 +33,11 @@ public class ScenePanoServiceImpl extends IBaseServiceImpl<ScenePanoEntity, Long
         one.setName(imgName);
         return getBaseMapper().selectOne(one);
     }
+
+    @Override
+    public List<ScenePanoEntity> findByWorkId(String workId) {
+        ScenePanoEntity one=new ScenePanoEntity();
+        one.setWorkId(workId);
+        return getBaseMapper().select(one);
+    }
 }