Parcourir la source

http://192.168.0.21/index.php?m=bug&f=view&bugID=28690

dengsixing il y a 3 ans
Parent
commit
b5b862cb8e

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

@@ -6,9 +6,11 @@ import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.fdkankan.common.bean.DownLoadProgressBean;
 import com.fdkankan.common.bean.DownLoadTaskBean;
 import com.fdkankan.common.constant.SceneDownloadProgressStatus;
+import com.fdkankan.common.constant.SceneFrom;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.constant.UploadFilePath;
 import com.fdkankan.common.response.ResultData;
@@ -96,6 +98,9 @@ public class SceneDownloadHandlerServiceImpl {
     @Value("${zip.nThreads}")
     private int zipNthreads;
 
+    @Value("${oss.bucket:4dkankan}")
+    private String bucket;
+
     @Value("${upload.type:oss}")
     private String uploadType;
     @Value("${download.config.resource-url}")
@@ -170,19 +175,22 @@ public class SceneDownloadHandlerServiceImpl {
             }
             ZipOutputStream out = new ZipOutputStream(zipFile);
 
-            JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
-            String resolution = "2k";
-            if(getInfoJson.getInt("sceneSource") != null &&
-                (getInfoJson.getInt("sceneSource") == 3 || getInfoJson.getInt("sceneSource") == 4)){
-                resolution = "4k";
+//            JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
+            String sceneJsonData = uploadToOssUtil.getObjectContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
+            JSONObject sceneJson = JSONUtil.parseObj(sceneJsonData);
+            String resolution = "4k";
+            String sceneForm = sceneJson.getStr("sceneFrom");
+            if(StrUtil.isNotEmpty(sceneForm) && SceneFrom.PRO.code().equals(sceneForm)){
+                resolution = "2k";
             }
             int imagesVersion = -1;
             // TODO: 2022/3/29  V4版本目前没有imagesVersion字段,暂时用version字段替代
 //            if(getInfoJson.getInt("imagesVersion") != null){
 //                imagesVersion = getInfoJson.getInt("imagesVersion");
 //            }
-            if(getInfoJson.getInt("version") != null){
-                imagesVersion = getInfoJson.getInt("version");
+            Integer version = sceneJson.getInt("version");
+            if(Objects.nonNull(version)){
+                imagesVersion = version;
             }
 
 
@@ -198,6 +206,8 @@ public class SceneDownloadHandlerServiceImpl {
             long end2 = Calendar.getInstance().getTimeInMillis();
             log.info("打包oss文件耗时, num:{}, time:{}", num, end2 - end1);
 
+            //重新写入scene.json(去掉密码访问设置)
+            this.zipSceneJson(out, this.wwwroot, num, sceneJson);
 
             //写入启动命令
             this.zipBat(out, num);
@@ -361,6 +371,16 @@ public class SceneDownloadHandlerServiceImpl {
         return getInfoJson;
     }
 
+    private void zipSceneJson(ZipOutputStream out, String root, String num, JSONObject sceneJson) throws Exception{
+
+        //访问密码置0
+        JSONObject controls = sceneJson.getJSONObject("controls");
+        controls.set("showLock", 0);
+
+        String sceneJsonPath = root + String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
+        this.zipBytes(out, sceneJsonPath, sceneJson.toString().getBytes());
+    }
+
     private void processImage(String key, ZipOutputStream out, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
 
         String fileName = key.substring(key.lastIndexOf("/")+1, key.indexOf("."));