zhujinghui 4 år sedan
förälder
incheckning
d8f1a4d8eb

+ 22 - 16
4dkankan-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -40,7 +40,7 @@ import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.util.StringUtil;
-import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import net.coobird.thumbnailator.Thumbnails;
 import org.apache.commons.lang3.StringUtils;
@@ -54,9 +54,7 @@ import org.springframework.web.multipart.MultipartFile;
 import tk.mybatis.mapper.entity.Condition;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * Created by Hb_zzZ on 2019/7/23.
@@ -3843,7 +3841,7 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
             scenejson = JSONObject.parseObject(strsceneInfos);
         }
         log.info("转换前-scene.json文件转换json-{}", scenejson);
-        JSONObject object = putVideoDataToSceneJson(operaVideoDTO, scenejson);
+        putVideoDataToAllSceneJson(operaVideoDTO, scenejson);
         log.info("转换后-scene.json文件转换json-{}", scenejson);
         FileUtils.writeFile(dataBuffer + "scene.json", scenejson.toString());
 
@@ -3851,7 +3849,7 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
         uploadMap.put(dataBuffer + "scene.json", dataBuf + "scene.json");
         uploadToOssUtil.uploadMulFiles(uploadMap);
 
-        sceneProEntity.setVideos(object.toString());
+        sceneProEntity.setVideos(scenejson.get("videos").toString());
         update(sceneProEntity);
     }
 
@@ -3871,43 +3869,51 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
         }
 
         log.info("转换前-scene.json文件转换json-{}", scenejson);
-        JSONArray newSceneJson = putVideoDataToAllSceneJson(operaVideoDTO, scenejson);
+        putVideoDataToSceneJson(operaVideoDTO, scenejson);
         log.info("转换后-scene.json文件转换json-{}", scenejson);
-        FileUtils.writeFile(dataBuffer + "scene.json", newSceneJson.toString());
+        FileUtils.writeFile(dataBuffer + "scene.json", scenejson.toString());
 
         Map<String, String> uploadMap = new HashMap<>();
         uploadMap.put(dataBuffer + "scene.json", dataBuf + "scene.json");
         uploadToOssUtil.uploadMulFiles(uploadMap);
 
-        sceneProEntity.setVideos(newSceneJson.toString());
+        sceneProEntity.setVideos(scenejson.get("videos").toString());
         update(sceneProEntity);
     }
 
-    private JSONArray putVideoDataToAllSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
-        Object data = scenejson.get("data");
+    private void putVideoDataToAllSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
+        Object videos = scenejson.get("videos");
+        Object data;
+        if (videos == null) {
+            throw new BaseRuntimeException("json数据异常");
+        }
+        data = ((JsonObject)videos).get("data");
         if (data == null || data instanceof JSONArray == false) {
-            throw new BaseRuntimeException("json数据data异常");
+            throw new BaseRuntimeException("json-data数据异常");
         }
         JSONArray jsonArray = (JSONArray) data;
         for (Object o : jsonArray) {
             ((JSONObject)o).put("show", operaVideoDTO.getShow());
         }
-        return jsonArray;
     }
 
 
     // todo
-    private JSONObject putVideoDataToSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
-        Object data = scenejson.get("data");
+    private void putVideoDataToSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
+        Object videos = scenejson.get("videos");
+        Object data;
+        if (videos == null) {
+            throw new BaseRuntimeException("json数据异常");
+        }
+        data = ((JsonObject)videos).get("data");
         if (data == null || data instanceof JSONArray == false) {
-            throw new BaseRuntimeException("json数据data异常");
+            throw new BaseRuntimeException("json-data数据异常");
         }
         JSONArray jsonArray = (JSONArray) data;
         Object jsonObj = jsonArray.stream().filter(j -> operaVideoDTO.getId().equals(((JSONObject)j).get("id")))
                 .findAny().orElseThrow(() -> new BaseRuntimeException("json数据data里找不到对应记录"));
 
         ((JSONObject)jsonObj).put("show", operaVideoDTO.getShow());
-        return ((JSONObject)jsonObj);
     }
 
 }

+ 1 - 1
4dkankan-scene/src/main/java/com/fdkankan/scene/util/CreateObjUtil.java

@@ -49,7 +49,7 @@ public class CreateObjUtil{
 		String fileName = videoPath.substring(videoPath.lastIndexOf("/") + 1, videoPath.lastIndexOf("."));
 		String suffix = videoPath.substring(videoPath.lastIndexOf("."));
 		String fileFolderPath = videoPath.substring(0, videoPath.lastIndexOf("/") + 1);
-		String command = "ssh root@" + ffmpegEnv +  "'4dage-ffmpeg-rotVwatermark -s " + videoPath
+		String command = "ssh root@" + ffmpegEnv +  " '4dage-ffmpeg-rotVwatermark -s " + videoPath
 				+ " -w " + Constant.WATER_MARK_PATH
 				+ " -n " + fileName + Constant.SCENE_VIDEO_SHARE_SUFFIX + suffix
 				+ " -o " + fileFolderPath + "'";