wanghongbo

审片间垫片上传修改

... ... @@ -54,6 +54,19 @@ public class BackupMaterialController {
}
/**
* @description 提交到素材库
* @author W5669
* @date 2025/8/21 11:26
* @param backupChangeDto
* @return ResultBean
*/
@PostMapping("submit")
ResultBean submit(BackupChangeDto backupChangeDto){
//
return ResultBean.ok();
}
/**
* @description 素材删除
* @author W5669
* @date 2025/8/19
... ...
... ... @@ -7,6 +7,7 @@ import com.wondertek.service.RoomOperationSerivice;
import com.wondertek.util.ResultBean;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
... ... @@ -29,7 +30,7 @@ public class RoomOperationController {
* @Version 1.0
*/
@PostMapping("/setDelayTime")
public ResultBean setDelayTime(@RequestBody DelayParam delayParam) {
public ResultBean setDelayTime(@RequestBody @Validated DelayParam delayParam) {
log.info("-->【云审片平台】审片间延时设置,delayParam:{}",delayParam);
return roomOperationSerivice.setDelayTime(delayParam);
... ...
package com.wondertek.dto;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
... ... @@ -10,8 +11,12 @@ import lombok.Data;
*/
@Data
public class DelayParam {
@NotNull(message = "roomId不能为空")
private Long roomId;
@NotNull(message = "delayFirst不能为空")
private Integer delayFirst;
@NotNull(message = "delaySecond不能为空")
private Integer delaySecond;
@NotNull(message = "delayPlay不能为空")
private Integer delayPlay;
}
... ...
... ... @@ -5,8 +5,8 @@ import cn.hutool.core.convert.ConvertException;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
... ... @@ -99,10 +99,6 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
@Override
public ResultBean upload(MultipartFile backupFile, BackupUploadVo backupUploadVo) {
//校验
// if(!"mp4".equalsIgnoreCase(backupUploadVo.getFileType())){
// throw new ServiceException("仅支持上传mp4格式的垫片文件!");
// }
//校验backupFile后缀名
String realName = backupFile.getOriginalFilename();
String suffix = realName.substring(realName.lastIndexOf(".") + 1);
... ... @@ -139,6 +135,33 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
backupMaterial.setFileType(backupUploadVo.getFileType());
backupMaterial.setCreatedTime(LocalDateTime.now());
backupMaterial.setCreatedBy("admin");
backupMaterial.setDel("0");
backupMaterial.setSource(MaterialSourceEnum.UPLOAD.getCode());
//封面图
String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg";
if(extracted(destFilePath, coverPath)){
backupMaterial.setCoverPath(coverPath.replace(realPath, ""));
}else{
backupMaterial.setCoverPath("");
}
//媒体分析获取时长
try {
Media media = mediaInfoService.getMediaInfo(destFilePath, fileId);
String type = media.getType();
Long duration = 0l;//时长
switch (type) {
case MediaType.VIDEO_TYPE:
JSONObject jsonObject = JSONUtil.parseObj(media);
duration = Double.valueOf(jsonObject.get("duration", Double.class) * 1000).longValue();
backupMaterial.setDuration(duration);
}
} catch (NumberFormatException | ConvertException e) {
log.error("媒体分析获取时长报错:e={}", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
backupMaterialMapper.insert(backupMaterial);
//添加审片间垫片配置
LambdaQueryWrapper<BackupConfig> wrapper = new LambdaQueryWrapper<>();
... ... @@ -310,13 +333,41 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
backupMaterial.setDel("0");
backupMaterial.setSource(MaterialSourceEnum.UPLOAD.getCode());
String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg";
if(extracted(destFilePath, coverPath)){
backupMaterial.setCoverPath(coverPath.replace(realPath, ""));
}else{
backupMaterial.setCoverPath("");
}
//媒体分析获取时长
try {
Media media = mediaInfoService.getMediaInfo(destFilePath, fileId);
String type = media.getType();
Long duration = 0l;//时长
switch (type) {
case MediaType.VIDEO_TYPE:
JSONObject jsonObject = JSONUtil.parseObj(media);
duration = Double.valueOf(jsonObject.get("duration", Double.class) * 1000).longValue();
backupMaterial.setDuration(duration);
}
} catch (NumberFormatException | ConvertException e) {
log.error("媒体分析获取时长报错:e={}", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
backupMaterialMapper.insert(backupMaterial);
return ResultBean.ok("新增素材成功");
}
private boolean extracted(String destFilePath, String coverPath) {
//抽封面图,调用定帧抽图接口
ImageVideoReq imageVideoReq = new ImageVideoReq();
imageVideoReq.setInput(destFilePath);
imageVideoReq.setOffset(0L);
OutPut outPut = new OutPut();
outPut.setIndex(0);
String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg";
outPut.setPath(coverPath);
imageVideoReq.setOutput(Arrays.asList(outPut));
try {
... ... @@ -329,8 +380,8 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
AbilityResp response = JSONUtils.jsonToObject(body, new TypeReference<AbilityResp>() {
});
if (response.getRet() == 0) {
backupMaterial.setCoverPath(coverPath.replace(realPath, ""));
log.info("请求能力平台定帧抽图接口成功");
return true;
}else {
log.info("请求能力平台定帧抽图接口响应失败,response:{}",response);
throw new ServiceException("请求能力平台定帧抽图接口响应失败");
... ... @@ -341,27 +392,7 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper,
} catch (Exception e) {
log.error("请求能力平台定帧抽图接口失败,url:{}", switchStreamUrl, e);
}
//媒体分析获取时长
try {
Media media = mediaInfoService.getMediaInfo(destFilePath, fileId);
String type = media.getType();
Long duration = 0l;//时长
switch (type) {
case MediaType.VIDEO_TYPE:
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(media);
duration = Double.valueOf(jsonObject.get("duration", Double.class) * 1000).longValue();
backupMaterial.setDuration(duration);
}
} catch (NumberFormatException | ConvertException e) {
log.error("媒体分析获取时长报错:e={}", e);
} catch (Exception e) {
throw new RuntimeException(e);
}
backupMaterialMapper.insert(backupMaterial);
return ResultBean.ok("新增素材成功");
return false;
}
@Override
... ...
... ... @@ -178,7 +178,7 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice {
opLog.setBusinessId(blockParam.getRoomId().toString());
opLog.setBusinessType("cloudMonitor");
opLog.setOperationType(blockParam.getBlockStatus().equals(0)?
RoomOperationEnum.BLOCK.getCode():RoomOperationEnum.RECOVER.getCode());
RoomOperationEnum.RECOVER.getCode():RoomOperationEnum.BLOCK.getCode());
opLog.setCreatedBy("admin");
opLog.setCreatedTime(LocalDateTime.now());
opLog.setRequestUrl(blockStatusUrl);
... ...