|
@@ -71,32 +71,23 @@ public class CsjResourceServiceImpl implements ICsjResourceService {
|
|
|
seqList.removeIf(seq -> seq.getSeq() == null);
|
|
seqList.removeIf(seq -> seq.getSeq() == null);
|
|
|
}
|
|
}
|
|
|
Map<Integer, CsjAlbumSeqResourceInfo> seqMap = seqList.stream().collect(Collectors.toMap(CsjAlbumSeqResourceInfo::getSeq, seq -> seq));
|
|
Map<Integer, CsjAlbumSeqResourceInfo> seqMap = seqList.stream().collect(Collectors.toMap(CsjAlbumSeqResourceInfo::getSeq, seq -> seq));
|
|
|
- if (videoList != null && !videoList.isEmpty()){
|
|
|
|
|
- for (int i = 0; i < videoList.size(); i++) {
|
|
|
|
|
- JSONObject videoInfo = videoList.getJSONObject(i);
|
|
|
|
|
- Integer seqNum = videoInfo.getInteger("seq");
|
|
|
|
|
- String videoUrl = videoInfo.getString("url");
|
|
|
|
|
- if (Check.isNull(videoUrl)) {
|
|
|
|
|
- log.error("第" + seqNum + "集视频链接为空");
|
|
|
|
|
- }
|
|
|
|
|
- CsjAlbumSeqResourceInfo seq = seqMap.get(seqNum);
|
|
|
|
|
- if (seq == null){
|
|
|
|
|
- seq = new CsjAlbumSeqResourceInfo(albumId, seqNum);
|
|
|
|
|
- seqList.add(seq);
|
|
|
|
|
- seqMap.put(seqNum, seq);
|
|
|
|
|
- }
|
|
|
|
|
- if (StringUtils.isEmpty(seq.getOssSeqVideo())){
|
|
|
|
|
- String fileName = albumId + "_" + seqNum + "_video.mp4";
|
|
|
|
|
- String ossVideoUrl = uploadToOss(videoUrl, fileName);
|
|
|
|
|
- if (StringUtils.isNotEmpty(ossVideoUrl)){
|
|
|
|
|
- seq.setOssSeqVideo(ossVideoUrl);
|
|
|
|
|
- }
|
|
|
|
|
- csjResourceMapper.updateSeq(seq);
|
|
|
|
|
|
|
|
|
|
|
|
+ //先存图
|
|
|
|
|
+ //获取一个最大的seq值,来判断上传是否完成
|
|
|
|
|
+ if (coverList != null && !coverList.isEmpty()){
|
|
|
|
|
+ int maxSeq = 0;
|
|
|
|
|
+ for (int i = 0; i < coverList.size(); i++) {
|
|
|
|
|
+ JSONObject coverInfo = coverList.getJSONObject(i);
|
|
|
|
|
+ Integer seqNum = coverInfo.getInteger("seq");
|
|
|
|
|
+ if (seqNum == null || seqNum == 0){
|
|
|
|
|
+ maxSeq = 0;
|
|
|
|
|
+ break; //封面图不需要seq
|
|
|
|
|
+ } else {
|
|
|
|
|
+ maxSeq = Math.max(maxSeq, seqNum);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- if (coverList != null && !coverList.isEmpty()){
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
for (int i = 0; i < coverList.size(); i++) {
|
|
for (int i = 0; i < coverList.size(); i++) {
|
|
|
JSONObject coverInfo = coverList.getJSONObject(i);
|
|
JSONObject coverInfo = coverList.getJSONObject(i);
|
|
|
Integer seqNum = coverInfo.getInteger("seq");
|
|
Integer seqNum = coverInfo.getInteger("seq");
|
|
@@ -129,12 +120,32 @@ public class CsjResourceServiceImpl implements ICsjResourceService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (videoList != null && !videoList.isEmpty()){
|
|
|
|
|
+ for (int i = 0; i < videoList.size(); i++) {
|
|
|
|
|
+ JSONObject videoInfo = videoList.getJSONObject(i);
|
|
|
|
|
+ Integer seqNum = videoInfo.getInteger("seq");
|
|
|
|
|
+ String videoUrl = videoInfo.getString("url");
|
|
|
|
|
+ if (Check.isNull(videoUrl)) {
|
|
|
|
|
+ log.error("第" + seqNum + "集视频链接为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ CsjAlbumSeqResourceInfo seq = seqMap.get(seqNum);
|
|
|
|
|
+ if (seq == null){
|
|
|
|
|
+ seq = new CsjAlbumSeqResourceInfo(albumId, seqNum);
|
|
|
|
|
+ seqList.add(seq);
|
|
|
|
|
+ seqMap.put(seqNum, seq);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(seq.getOssSeqVideo())){
|
|
|
|
|
+ String fileName = albumId + "_" + seqNum + "_video.mp4";
|
|
|
|
|
+ String ossVideoUrl = uploadToOss(videoUrl, fileName);
|
|
|
|
|
+ if (StringUtils.isNotEmpty(ossVideoUrl)){
|
|
|
|
|
+ seq.setOssSeqVideo(ossVideoUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+ csjResourceMapper.updateSeq(seq);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-// //update album, update seq
|
|
|
|
|
-// csjResourceMapper.updateAlbum(album);
|
|
|
|
|
-// if (album.getSeqList() != null && !album.getSeqList().isEmpty()){
|
|
|
|
|
-// csjResourceMapper.batchUpdateAlbumSeq(album.getSeqList());
|
|
|
|
|
-// }
|
|
|
|
|
log.info("处理资源成功: " + album.getAlbumId() + ", 共处理分集: " + seqList.size());
|
|
log.info("处理资源成功: " + album.getAlbumId() + ", 共处理分集: " + seqList.size());
|
|
|
|
|
|
|
|
return "";
|
|
return "";
|