|
@@ -432,11 +432,42 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneInfoVO.setVideos(scenePlusExt.getVideos());
|
|
|
sceneInfoVO.setMosaicList(this.getMosaicList(num));
|
|
|
|
|
|
+ this.SortBoxVideos(sceneInfoVO);
|
|
|
+
|
|
|
this.setExtData(sceneInfoVO, scenePlus.getCameraId());
|
|
|
|
|
|
return sceneInfoVO;
|
|
|
}
|
|
|
|
|
|
+ private void SortBoxVideos(SceneInfoVO sceneInfoVO){
|
|
|
+ String boxVideos = sceneInfoVO.getBoxVideos();
|
|
|
+ if(StrUtil.isEmpty(boxVideos)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray boxVideoArr = JSON.parseArray(boxVideos);
|
|
|
+ if(CollUtil.isEmpty(boxVideoArr)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<TagBean> tagBeanList = boxVideoArr.stream().map(o -> {
|
|
|
+ JSONObject item = (JSONObject) o;
|
|
|
+ return TagBean.builder()
|
|
|
+ .createTime(item.getLong("createTime"))
|
|
|
+ .tag(item).build();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //按创建时间倒叙排序
|
|
|
+ tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
|
|
|
+
|
|
|
+ //移除createTime字段
|
|
|
+ List<JSONObject> boxVideoList = tagBeanList.stream().map(tagBean -> {
|
|
|
+ JSONObject tag = tagBean.getTag();
|
|
|
+ tag.remove("createTime");
|
|
|
+ return tag;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ sceneInfoVO.setBoxVideos(JSON.toJSONString(boxVideoList));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
getInfo接口返回字段扩展
|
|
@@ -2246,11 +2277,23 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}else {
|
|
|
boxVideosJson = new JSONArray();
|
|
|
}
|
|
|
+ if(boxVideosJson.size() > 0){
|
|
|
+ int i = 1;
|
|
|
+ long timeInMillis = Calendar.getInstance().getTimeInMillis();
|
|
|
+ for (Object o : boxVideosJson) {
|
|
|
+ JSONObject item = (JSONObject)o;
|
|
|
+ if(Objects.nonNull(item.getLong("createTime"))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.put("createTime", timeInMillis - (i++));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
String result = null;
|
|
|
//删除
|
|
|
if(type == OperationType.DELETE.code()){
|
|
|
- Set<String> deleteFile = new HashSet<>();
|
|
|
+ Set<String> deleteVidoeFile = new HashSet<>();
|
|
|
+ Set<String> deletePicFile = new HashSet<>();
|
|
|
if(boxVideosJson.size() == 0)
|
|
|
return null;
|
|
|
for(int i=0;i<boxVideosJson.size();++i){
|
|
@@ -2259,11 +2302,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
String poster = ele.getString("poster");
|
|
|
if(StrUtil.isNotEmpty(poster))
|
|
|
- deleteFile.add(poster);
|
|
|
+ deletePicFile.add(poster);
|
|
|
String url = ele.getString("url");
|
|
|
if(StrUtil.isNotEmpty(url)){
|
|
|
- deleteFile.add(url);
|
|
|
- deleteFile.add(url.replace(".mp4",".flv"));
|
|
|
+ deleteVidoeFile.add(url);
|
|
|
+ deleteVidoeFile.add(url.replace(".mp4",".flv"));
|
|
|
}
|
|
|
|
|
|
boxVideosJson.remove(i);
|
|
@@ -2271,27 +2314,34 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
//删除资源文件
|
|
|
- if(CollUtil.isNotEmpty(deleteFile))
|
|
|
+ if(CollUtil.isNotEmpty(deleteVidoeFile))
|
|
|
sceneUploadService.delete(
|
|
|
DeleteFileParamVO.builder().num(num)
|
|
|
.bizType(FileBizType.BOX_VIDEO.code())
|
|
|
- .fileNames(new ArrayList<>(deleteFile)).build());
|
|
|
+ .fileNames(new ArrayList<>(deleteVidoeFile)).build());
|
|
|
+ //删除资源文件
|
|
|
+ if(CollUtil.isNotEmpty(deleteVidoeFile))
|
|
|
+ sceneUploadService.delete(
|
|
|
+ DeleteFileParamVO.builder().num(num)
|
|
|
+ .bizType(FileBizType.BOX_POSTER.code())
|
|
|
+ .fileNames(new ArrayList<>(deletePicFile)).build());
|
|
|
}else{
|
|
|
|
|
|
- // TODO: 2022/3/1 目前需求只保留一个,所以这里先注释掉,sid不同时,不追加
|
|
|
+ boxVideo.put("createTime", Calendar.getInstance().getTimeInMillis());
|
|
|
+
|
|
|
//更新
|
|
|
-// boolean exist = false;
|
|
|
-// for(int i=0;i<boxVideosJson.size();++i){
|
|
|
-// JSONObject ele = boxVideosJson.getJSONObject(i);
|
|
|
-// if(ele.getString("sid").equals(sid)){
|
|
|
-// boxVideosJson.set(i, boxVideo);
|
|
|
-// exist = true;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //新增
|
|
|
-// if(!exist){
|
|
|
-// boxVideosJson.add(boxVideo);
|
|
|
-// }
|
|
|
+ boolean exist = false;
|
|
|
+ for(int i=0;i<boxVideosJson.size();++i){
|
|
|
+ JSONObject ele = boxVideosJson.getJSONObject(i);
|
|
|
+ if(ele.getString("sid").equals(sid)){
|
|
|
+ boxVideosJson.set(i, boxVideo);
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //新增
|
|
|
+ if(!exist){
|
|
|
+ boxVideosJson.add(boxVideo);
|
|
|
+ }
|
|
|
|
|
|
boxVideosJson.clear();
|
|
|
boxVideosJson.add(boxVideo);
|