wanghongbo

审片间垫片上传修改

@@ -54,6 +54,19 @@ public class BackupMaterialController { @@ -54,6 +54,19 @@ public class BackupMaterialController {
54 } 54 }
55 55
56 /** 56 /**
  57 + * @description 提交到素材库
  58 + * @author W5669
  59 + * @date 2025/8/21 11:26
  60 + * @param backupChangeDto
  61 + * @return ResultBean
  62 + */
  63 + @PostMapping("submit")
  64 + ResultBean submit(BackupChangeDto backupChangeDto){
  65 +//
  66 + return ResultBean.ok();
  67 + }
  68 +
  69 + /**
57 * @description 素材删除 70 * @description 素材删除
58 * @author W5669 71 * @author W5669
59 * @date 2025/8/19 72 * @date 2025/8/19
@@ -7,6 +7,7 @@ import com.wondertek.service.RoomOperationSerivice; @@ -7,6 +7,7 @@ import com.wondertek.service.RoomOperationSerivice;
7 import com.wondertek.util.ResultBean; 7 import com.wondertek.util.ResultBean;
8 import jakarta.annotation.Resource; 8 import jakarta.annotation.Resource;
9 import lombok.extern.slf4j.Slf4j; 9 import lombok.extern.slf4j.Slf4j;
  10 +import org.springframework.validation.annotation.Validated;
10 import org.springframework.web.bind.annotation.*; 11 import org.springframework.web.bind.annotation.*;
11 12
12 /** 13 /**
@@ -29,7 +30,7 @@ public class RoomOperationController { @@ -29,7 +30,7 @@ public class RoomOperationController {
29 * @Version 1.0 30 * @Version 1.0
30 */ 31 */
31 @PostMapping("/setDelayTime") 32 @PostMapping("/setDelayTime")
32 - public ResultBean setDelayTime(@RequestBody DelayParam delayParam) { 33 + public ResultBean setDelayTime(@RequestBody @Validated DelayParam delayParam) {
33 log.info("-->【云审片平台】审片间延时设置,delayParam:{}",delayParam); 34 log.info("-->【云审片平台】审片间延时设置,delayParam:{}",delayParam);
34 return roomOperationSerivice.setDelayTime(delayParam); 35 return roomOperationSerivice.setDelayTime(delayParam);
35 36
1 package com.wondertek.dto; 1 package com.wondertek.dto;
2 2
  3 +import jakarta.validation.constraints.NotNull;
3 import lombok.Data; 4 import lombok.Data;
4 5
5 /** 6 /**
@@ -10,8 +11,12 @@ import lombok.Data; @@ -10,8 +11,12 @@ import lombok.Data;
10 */ 11 */
11 @Data 12 @Data
12 public class DelayParam { 13 public class DelayParam {
  14 + @NotNull(message = "roomId不能为空")
13 private Long roomId; 15 private Long roomId;
  16 + @NotNull(message = "delayFirst不能为空")
14 private Integer delayFirst; 17 private Integer delayFirst;
  18 + @NotNull(message = "delaySecond不能为空")
15 private Integer delaySecond; 19 private Integer delaySecond;
  20 + @NotNull(message = "delayPlay不能为空")
16 private Integer delayPlay; 21 private Integer delayPlay;
17 } 22 }
@@ -5,8 +5,8 @@ import cn.hutool.core.convert.ConvertException; @@ -5,8 +5,8 @@ import cn.hutool.core.convert.ConvertException;
5 import cn.hutool.core.util.ObjectUtil; 5 import cn.hutool.core.util.ObjectUtil;
6 import cn.hutool.http.HttpRequest; 6 import cn.hutool.http.HttpRequest;
7 import cn.hutool.http.HttpResponse; 7 import cn.hutool.http.HttpResponse;
  8 +import cn.hutool.json.JSONObject;
8 import cn.hutool.json.JSONUtil; 9 import cn.hutool.json.JSONUtil;
9 -import com.alibaba.fastjson.JSON;  
10 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 10 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
11 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 11 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
12 import com.baomidou.mybatisplus.core.metadata.IPage; 12 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -99,10 +99,6 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, @@ -99,10 +99,6 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
99 99
100 @Override 100 @Override
101 public ResultBean upload(MultipartFile backupFile, BackupUploadVo backupUploadVo) { 101 public ResultBean upload(MultipartFile backupFile, BackupUploadVo backupUploadVo) {
102 - //校验  
103 -// if(!"mp4".equalsIgnoreCase(backupUploadVo.getFileType())){  
104 -// throw new ServiceException("仅支持上传mp4格式的垫片文件!");  
105 -// }  
106 //校验backupFile后缀名 102 //校验backupFile后缀名
107 String realName = backupFile.getOriginalFilename(); 103 String realName = backupFile.getOriginalFilename();
108 String suffix = realName.substring(realName.lastIndexOf(".") + 1); 104 String suffix = realName.substring(realName.lastIndexOf(".") + 1);
@@ -139,6 +135,33 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, @@ -139,6 +135,33 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
139 backupMaterial.setFileType(backupUploadVo.getFileType()); 135 backupMaterial.setFileType(backupUploadVo.getFileType());
140 backupMaterial.setCreatedTime(LocalDateTime.now()); 136 backupMaterial.setCreatedTime(LocalDateTime.now());
141 backupMaterial.setCreatedBy("admin"); 137 backupMaterial.setCreatedBy("admin");
  138 + backupMaterial.setDel("0");
  139 + backupMaterial.setSource(MaterialSourceEnum.UPLOAD.getCode());
  140 + //封面图
  141 + String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg";
  142 + if(extracted(destFilePath, coverPath)){
  143 + backupMaterial.setCoverPath(coverPath.replace(realPath, ""));
  144 + }else{
  145 + backupMaterial.setCoverPath("");
  146 + }
  147 + //媒体分析获取时长
  148 + try {
  149 + Media media = mediaInfoService.getMediaInfo(destFilePath, fileId);
  150 + String type = media.getType();
  151 + Long duration = 0l;//时长
  152 + switch (type) {
  153 + case MediaType.VIDEO_TYPE:
  154 + JSONObject jsonObject = JSONUtil.parseObj(media);
  155 + duration = Double.valueOf(jsonObject.get("duration", Double.class) * 1000).longValue();
  156 + backupMaterial.setDuration(duration);
  157 + }
  158 + } catch (NumberFormatException | ConvertException e) {
  159 + log.error("媒体分析获取时长报错:e={}", e);
  160 + } catch (Exception e) {
  161 + throw new RuntimeException(e);
  162 + }
  163 +
  164 +
142 backupMaterialMapper.insert(backupMaterial); 165 backupMaterialMapper.insert(backupMaterial);
143 //添加审片间垫片配置 166 //添加审片间垫片配置
144 LambdaQueryWrapper<BackupConfig> wrapper = new LambdaQueryWrapper<>(); 167 LambdaQueryWrapper<BackupConfig> wrapper = new LambdaQueryWrapper<>();
@@ -310,13 +333,41 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, @@ -310,13 +333,41 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
310 backupMaterial.setDel("0"); 333 backupMaterial.setDel("0");
311 backupMaterial.setSource(MaterialSourceEnum.UPLOAD.getCode()); 334 backupMaterial.setSource(MaterialSourceEnum.UPLOAD.getCode());
312 335
  336 + String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg";
  337 + if(extracted(destFilePath, coverPath)){
  338 + backupMaterial.setCoverPath(coverPath.replace(realPath, ""));
  339 + }else{
  340 + backupMaterial.setCoverPath("");
  341 + }
  342 + //媒体分析获取时长
  343 + try {
  344 + Media media = mediaInfoService.getMediaInfo(destFilePath, fileId);
  345 + String type = media.getType();
  346 + Long duration = 0l;//时长
  347 + switch (type) {
  348 + case MediaType.VIDEO_TYPE:
  349 + JSONObject jsonObject = JSONUtil.parseObj(media);
  350 + duration = Double.valueOf(jsonObject.get("duration", Double.class) * 1000).longValue();
  351 + backupMaterial.setDuration(duration);
  352 + }
  353 + } catch (NumberFormatException | ConvertException e) {
  354 + log.error("媒体分析获取时长报错:e={}", e);
  355 + } catch (Exception e) {
  356 + throw new RuntimeException(e);
  357 + }
  358 +
  359 + backupMaterialMapper.insert(backupMaterial);
  360 +
  361 + return ResultBean.ok("新增素材成功");
  362 + }
  363 +
  364 + private boolean extracted(String destFilePath, String coverPath) {
313 //抽封面图,调用定帧抽图接口 365 //抽封面图,调用定帧抽图接口
314 ImageVideoReq imageVideoReq = new ImageVideoReq(); 366 ImageVideoReq imageVideoReq = new ImageVideoReq();
315 imageVideoReq.setInput(destFilePath); 367 imageVideoReq.setInput(destFilePath);
316 imageVideoReq.setOffset(0L); 368 imageVideoReq.setOffset(0L);
317 OutPut outPut = new OutPut(); 369 OutPut outPut = new OutPut();
318 outPut.setIndex(0); 370 outPut.setIndex(0);
319 - String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg";  
320 outPut.setPath(coverPath); 371 outPut.setPath(coverPath);
321 imageVideoReq.setOutput(Arrays.asList(outPut)); 372 imageVideoReq.setOutput(Arrays.asList(outPut));
322 try { 373 try {
@@ -329,8 +380,8 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, @@ -329,8 +380,8 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
329 AbilityResp response = JSONUtils.jsonToObject(body, new TypeReference<AbilityResp>() { 380 AbilityResp response = JSONUtils.jsonToObject(body, new TypeReference<AbilityResp>() {
330 }); 381 });
331 if (response.getRet() == 0) { 382 if (response.getRet() == 0) {
332 - backupMaterial.setCoverPath(coverPath.replace(realPath, ""));  
333 log.info("请求能力平台定帧抽图接口成功"); 383 log.info("请求能力平台定帧抽图接口成功");
  384 + return true;
334 }else { 385 }else {
335 log.info("请求能力平台定帧抽图接口响应失败,response:{}",response); 386 log.info("请求能力平台定帧抽图接口响应失败,response:{}",response);
336 throw new ServiceException("请求能力平台定帧抽图接口响应失败"); 387 throw new ServiceException("请求能力平台定帧抽图接口响应失败");
@@ -341,27 +392,7 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, @@ -341,27 +392,7 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
341 } catch (Exception e) { 392 } catch (Exception e) {
342 log.error("请求能力平台定帧抽图接口失败,url:{}", switchStreamUrl, e); 393 log.error("请求能力平台定帧抽图接口失败,url:{}", switchStreamUrl, e);
343 } 394 }
344 -  
345 - //媒体分析获取时长  
346 - try {  
347 - Media media = mediaInfoService.getMediaInfo(destFilePath, fileId);  
348 - String type = media.getType();  
349 - Long duration = 0l;//时长  
350 - switch (type) {  
351 - case MediaType.VIDEO_TYPE:  
352 - cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(media);  
353 - duration = Double.valueOf(jsonObject.get("duration", Double.class) * 1000).longValue();  
354 - backupMaterial.setDuration(duration);  
355 - }  
356 - } catch (NumberFormatException | ConvertException e) {  
357 - log.error("媒体分析获取时长报错:e={}", e);  
358 - } catch (Exception e) {  
359 - throw new RuntimeException(e);  
360 - }  
361 -  
362 - backupMaterialMapper.insert(backupMaterial);  
363 -  
364 - return ResultBean.ok("新增素材成功"); 395 + return false;
365 } 396 }
366 397
367 @Override 398 @Override
@@ -178,7 +178,7 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { @@ -178,7 +178,7 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice {
178 opLog.setBusinessId(blockParam.getRoomId().toString()); 178 opLog.setBusinessId(blockParam.getRoomId().toString());
179 opLog.setBusinessType("cloudMonitor"); 179 opLog.setBusinessType("cloudMonitor");
180 opLog.setOperationType(blockParam.getBlockStatus().equals(0)? 180 opLog.setOperationType(blockParam.getBlockStatus().equals(0)?
181 - RoomOperationEnum.BLOCK.getCode():RoomOperationEnum.RECOVER.getCode()); 181 + RoomOperationEnum.RECOVER.getCode():RoomOperationEnum.BLOCK.getCode());
182 opLog.setCreatedBy("admin"); 182 opLog.setCreatedBy("admin");
183 opLog.setCreatedTime(LocalDateTime.now()); 183 opLog.setCreatedTime(LocalDateTime.now());
184 opLog.setRequestUrl(blockStatusUrl); 184 opLog.setRequestUrl(blockStatusUrl);