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