Showing
5 changed files
with
131 additions
and
13 deletions
| 1 | package com.wondertek.controller; | 1 | package com.wondertek.controller; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -import com.wondertek.dto.BackupChangeDto; | ||
| 5 | -import com.wondertek.dto.BackupMaterialDto; | ||
| 6 | -import com.wondertek.dto.BackupUploadVo; | ||
| 7 | -import com.wondertek.dto.MaterialUploadVo; | 4 | +import com.wondertek.dto.*; |
| 8 | import com.wondertek.service.BackupMaterialService; | 5 | import com.wondertek.service.BackupMaterialService; |
| 9 | import com.wondertek.util.PageBean; | 6 | import com.wondertek.util.PageBean; |
| 10 | import com.wondertek.util.ResultBean; | 7 | import com.wondertek.util.ResultBean; |
| 11 | import jakarta.annotation.Resource; | 8 | import jakarta.annotation.Resource; |
| 12 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; |
| 10 | +import org.springframework.validation.annotation.Validated; | ||
| 13 | import org.springframework.web.bind.annotation.*; | 11 | import org.springframework.web.bind.annotation.*; |
| 14 | import org.springframework.web.multipart.MultipartFile; | 12 | import org.springframework.web.multipart.MultipartFile; |
| 15 | 13 | ||
| @@ -57,13 +55,13 @@ public class BackupMaterialController { | @@ -57,13 +55,13 @@ public class BackupMaterialController { | ||
| 57 | * @description 提交到素材库 | 55 | * @description 提交到素材库 |
| 58 | * @author W5669 | 56 | * @author W5669 |
| 59 | * @date 2025/8/21 11:26 | 57 | * @date 2025/8/21 11:26 |
| 60 | - * @param backupChangeDto | 58 | + * @param materialSubmitVo |
| 61 | * @return ResultBean | 59 | * @return ResultBean |
| 62 | */ | 60 | */ |
| 63 | @PostMapping("submit") | 61 | @PostMapping("submit") |
| 64 | - ResultBean submit(BackupChangeDto backupChangeDto){ | ||
| 65 | -// | ||
| 66 | - return ResultBean.ok(); | 62 | + ResultBean submit(@RequestBody @Validated MaterialSubmitVo materialSubmitVo){ |
| 63 | + log.info("-->直播剪辑素材提交:{}",materialSubmitVo); | ||
| 64 | + return backupMaterialService.submitOrUpload(materialSubmitVo); | ||
| 67 | } | 65 | } |
| 68 | 66 | ||
| 69 | /** | 67 | /** |
| 1 | +package com.wondertek.dto; | ||
| 2 | + | ||
| 3 | +import jakarta.validation.constraints.NotBlank; | ||
| 4 | +import jakarta.validation.constraints.NotNull; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @Description: 素材提交 | ||
| 9 | + * @Author W5669 | ||
| 10 | + * @Create 2025/7/24 | ||
| 11 | + * @Version 1.0 | ||
| 12 | + */ | ||
| 13 | +@Data | ||
| 14 | +public class MaterialSubmitVo { | ||
| 15 | + //png、jpg、mp4等 | ||
| 16 | + @NotBlank(message = "文件类型不能为空") | ||
| 17 | + private String fileType; | ||
| 18 | + //垫片名 | ||
| 19 | + @NotBlank(message = "垫片名不能为空") | ||
| 20 | + private String backupName; | ||
| 21 | + //审片间id | ||
| 22 | + private Long roomId; | ||
| 23 | + //1:垫片1,2:垫片2 | ||
| 24 | + private Integer backupOrder; | ||
| 25 | + //垫片状态 0-默认 1-当前选中 | ||
| 26 | + private String backupStatus; | ||
| 27 | + // 操作类型 0-提交素材库 1-上传审片间 | ||
| 28 | + @NotBlank(message = "操作类型不能为空") | ||
| 29 | + private String operateType; | ||
| 30 | + //文件路径,绝对路径 | ||
| 31 | + @NotBlank(message = "文件路径不能为空") | ||
| 32 | + private String filePath; | ||
| 33 | + //封面图路径,绝对路径 | ||
| 34 | + private String coverPath; | ||
| 35 | + //时长 | ||
| 36 | + @NotNull(message = "时长不能为空") | ||
| 37 | + private Long duration; | ||
| 38 | + | ||
| 39 | +} |
| @@ -6,7 +6,7 @@ package com.wondertek.enums; | @@ -6,7 +6,7 @@ package com.wondertek.enums; | ||
| 6 | public enum MaterialSourceEnum { | 6 | public enum MaterialSourceEnum { |
| 7 | UPLOAD("upload", "上传"), | 7 | UPLOAD("upload", "上传"), |
| 8 | NAS("nas", "nas"), | 8 | NAS("nas", "nas"), |
| 9 | - clip("clip", "剪辑"); | 9 | + CLIP("clip", "剪辑"); |
| 10 | 10 | ||
| 11 | private final String code; | 11 | private final String code; |
| 12 | private final String name; | 12 | private final String name; |
| 1 | package com.wondertek.service; | 1 | package com.wondertek.service; |
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.extension.service.IService; | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
| 4 | -import com.wondertek.dto.BackupChangeDto; | ||
| 5 | -import com.wondertek.dto.BackupMaterialDto; | ||
| 6 | -import com.wondertek.dto.BackupUploadVo; | ||
| 7 | -import com.wondertek.dto.MaterialUploadVo; | 4 | +import com.wondertek.dto.*; |
| 8 | import com.wondertek.entity.BackupMaterial; | 5 | import com.wondertek.entity.BackupMaterial; |
| 9 | import com.wondertek.util.PageBean; | 6 | import com.wondertek.util.PageBean; |
| 10 | import com.wondertek.util.ResultBean; | 7 | import com.wondertek.util.ResultBean; |
| @@ -23,4 +20,6 @@ public interface BackupMaterialService extends IService<BackupMaterial> { | @@ -23,4 +20,6 @@ public interface BackupMaterialService extends IService<BackupMaterial> { | ||
| 23 | ResultBean uploadToMaterial(MultipartFile backupFile, MaterialUploadVo materialUploadVo); | 20 | ResultBean uploadToMaterial(MultipartFile backupFile, MaterialUploadVo materialUploadVo); |
| 24 | 21 | ||
| 25 | ResultBean batchDelete(Long[] ids); | 22 | ResultBean batchDelete(Long[] ids); |
| 23 | + | ||
| 24 | + ResultBean submitOrUpload(MaterialSubmitVo materialSubmitVo); | ||
| 26 | } | 25 | } |
| @@ -406,4 +406,86 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | @@ -406,4 +406,86 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | ||
| 406 | return rows > 0 ? ResultBean.ok() : ResultBean.error(); | 406 | return rows > 0 ? ResultBean.ok() : ResultBean.error(); |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | + @Override | ||
| 410 | + public ResultBean submitOrUpload(MaterialSubmitVo materialSubmitVo) { | ||
| 411 | + //校验文件类型 | ||
| 412 | + if(!"mp4".equalsIgnoreCase(materialSubmitVo.getFileType())){ | ||
| 413 | + return ResultBean.error("文件类型错误"); | ||
| 414 | + } | ||
| 415 | + | ||
| 416 | + StreamTask streamTask = null; | ||
| 417 | + if(materialSubmitVo.getOperateType().equals("1")){ | ||
| 418 | + if (materialSubmitVo.getRoomId()== null || materialSubmitVo.getBackupOrder() == null){ | ||
| 419 | + return ResultBean.error("请选择审片间和垫片序号"); | ||
| 420 | + } | ||
| 421 | + //找到对应垫片任务 | ||
| 422 | + LambdaQueryWrapper<StreamTask> backupWrapper = new LambdaQueryWrapper<>(); | ||
| 423 | + backupWrapper.eq(StreamTask::getRoomId,materialSubmitVo.getRoomId()); | ||
| 424 | + String palyType = materialSubmitVo.getBackupOrder() == 1? PlayTypeEnum.BACKUP1.getCode() : PlayTypeEnum.BACKUP2.getCode(); | ||
| 425 | + backupWrapper.eq(StreamTask::getPlayType,palyType); | ||
| 426 | + streamTask = streamTaskMapper.selectOne(backupWrapper); | ||
| 427 | + if (streamTask == null){ | ||
| 428 | + return ResultBean.error("未找到该直播间对应的垫片任务"); | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + String fileId = UUIDUtil.randomUUID(); | ||
| 433 | + //保存垫片素材表 | ||
| 434 | + BackupMaterial backupMaterial = new BackupMaterial(); | ||
| 435 | + backupMaterial.setFileId(fileId); | ||
| 436 | + backupMaterial.setBackupName(materialSubmitVo.getBackupName()); | ||
| 437 | + String destFilePath = materialSubmitVo.getFilePath(); | ||
| 438 | + String relativePath = materialSubmitVo.getFilePath().replace(realPath, ""); | ||
| 439 | + backupMaterial.setFilePath(relativePath); | ||
| 440 | + backupMaterial.setFileType(materialSubmitVo.getFileType()); | ||
| 441 | + backupMaterial.setCreatedTime(LocalDateTime.now()); | ||
| 442 | + backupMaterial.setCreatedBy("admin"); | ||
| 443 | + backupMaterial.setDel("0"); | ||
| 444 | + backupMaterial.setSource(MaterialSourceEnum.CLIP.getCode()); | ||
| 445 | + //封面图 | ||
| 446 | + if(StringUtils.isNotEmpty(materialSubmitVo.getCoverPath())){ | ||
| 447 | + backupMaterial.setCoverPath(materialSubmitVo.getCoverPath().replace(realPath, "")); | ||
| 448 | + } | ||
| 449 | + //时长 | ||
| 450 | + backupMaterial.setDuration(materialSubmitVo.getDuration()); | ||
| 451 | + backupMaterialMapper.insert(backupMaterial); | ||
| 452 | + | ||
| 453 | + if(materialSubmitVo.getOperateType().equals("1")){ | ||
| 454 | + | ||
| 455 | + } | ||
| 456 | + //添加审片间垫片配置 | ||
| 457 | + LambdaQueryWrapper<BackupConfig> wrapper = new LambdaQueryWrapper<>(); | ||
| 458 | + wrapper.eq(BackupConfig::getRoomId,materialSubmitVo.getRoomId()); | ||
| 459 | + wrapper.eq(BackupConfig::getBackupOrder,materialSubmitVo.getBackupOrder()); | ||
| 460 | + BackupConfig backupConfig = backupConfigMapper.selectOne(wrapper); | ||
| 461 | + if(ObjectUtil.isNull(backupConfig)){ | ||
| 462 | + backupConfig = new BackupConfig(); | ||
| 463 | + backupConfig.setBackupStatus("0"); | ||
| 464 | + } | ||
| 465 | + backupConfig.setRoomId(materialSubmitVo.getRoomId()); | ||
| 466 | + backupConfig.setBackupId(backupMaterial.getId()); | ||
| 467 | + backupConfig.setBackupOrder(materialSubmitVo.getBackupOrder()); | ||
| 468 | + backupConfig.setBackupPath(relativePath); | ||
| 469 | + backupConfigMapper.insertOrUpdate(backupConfig); | ||
| 470 | + | ||
| 471 | + //对应垫片任务切源(转码平台演示环境已挂载统一存储),请求转码平台修改垫片任务直播源 | ||
| 472 | + changeChannelSource(streamTask.getTaskId(), destFilePath); | ||
| 473 | + //判断是否需要修改当前播出流的垫片 | ||
| 474 | + if("1".equals(backupConfig.getBackupStatus())){ | ||
| 475 | + //切换播出流垫片(主、备) | ||
| 476 | + LambdaQueryWrapper<StreamTask> playWrapper = new LambdaQueryWrapper<>(); | ||
| 477 | + playWrapper.eq(StreamTask::getRoomId,materialSubmitVo.getRoomId()); | ||
| 478 | + playWrapper.eq(StreamTask::getPlayType,"play"); | ||
| 479 | + List<StreamTask> playTasks = streamTaskMapper.selectList(playWrapper); | ||
| 480 | + if(CollectionUtil.isNotEmpty(playTasks)){ | ||
| 481 | + playTasks.forEach(playTask -> { | ||
| 482 | + changeBackup(playTask.getTaskId(), destFilePath); | ||
| 483 | + }); | ||
| 484 | + } | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + return ResultBean.ok("提交成功"); | ||
| 488 | + } | ||
| 489 | + | ||
| 490 | + | ||
| 409 | } | 491 | } |
-
Please register or login to post a comment