zhongdaoyi@wondertek.com.cn

审片间接口初始化

  1 +package com.wondertek.controller;
  2 +
  3 +
  4 +import com.wondertek.dto.LMRoomDto;
  5 +import com.wondertek.service.LiveMonitorRoomService;
  6 +import com.wondertek.util.PageBean;
  7 +import jakarta.annotation.Resource;
  8 +import lombok.extern.slf4j.Slf4j;
  9 +import org.springframework.web.bind.annotation.GetMapping;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +@Slf4j
  14 +@RestController
  15 +@RequestMapping("/monitor/room")
  16 +public class LiveMonitorRoomController {
  17 +
  18 + @Resource
  19 + private LiveMonitorRoomService liveMonitorRoomService;
  20 +
  21 +
  22 + /**
  23 + * 审片间维护-列表页
  24 + * @param lmRoomDto
  25 + * @return
  26 + */
  27 + @GetMapping("queryPage")
  28 + PageBean queryPage(LMRoomDto lmRoomDto){
  29 + return liveMonitorRoomService.queryPage(lmRoomDto);
  30 + }
  31 +
  32 +
  33 + /**
  34 + * 审片间-列表页
  35 + * @param lmRoomDto
  36 + * @return
  37 + */
  38 + @GetMapping("editPage")
  39 + PageBean editPage(LMRoomDto lmRoomDto){
  40 + return liveMonitorRoomService.queryPage(lmRoomDto);
  41 + }
  42 +
  43 +}
  1 +package com.wondertek.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +@Data
  6 +public class CrpDataVo {
  7 +
  8 + /**
  9 + * 频道唯一标识
  10 + * <p>关联转码平台的频道ID</p>
  11 + */
  12 + private String taskId;
  13 +
  14 + /** 转码平台频道ID */
  15 + private Long channelId;
  16 +
  17 + /** 关联的审片间ID */
  18 + private Long roomId;
  19 +
  20 + /**
  21 + * 任务类型
  22 + * <p>取值:</p>
  23 + * <ul>
  24 + * <li>"0" - 主任务</li>
  25 + * <li>"1" - 备任务</li>
  26 + * </ul>
  27 + */
  28 + private String taskType;
  29 +}
  1 +package com.wondertek.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +@Data
  6 +public class LMRoomDto {
  7 +
  8 + /** 审片间名称 */
  9 + private String name;
  10 +
  11 + private Integer page=1;
  12 +
  13 + private Integer size=10;
  14 +}
  1 +package com.wondertek.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.List;
  6 +
  7 +@Data
  8 +public class LMRoomParam {
  9 + private Long id;
  10 +
  11 + private String name;
  12 +
  13 + private String liveName;
  14 +
  15 + private List<CrpDataVo> dataList;
  16 +
  17 +}
@@ -37,5 +37,7 @@ public class LiveMonitorRoom { @@ -37,5 +37,7 @@ public class LiveMonitorRoom {
37 private LocalDateTime updatedTime; 37 private LocalDateTime updatedTime;
38 /** 多画输出流地址 */ 38 /** 多画输出流地址 */
39 private String mixOutputUrl; 39 private String mixOutputUrl;
  40 + /** 直播名称 */
  41 + private String liveName;
40 42
41 } 43 }
1 package com.wondertek.mapper; 1 package com.wondertek.mapper;
2 2
3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.baomidou.mybatisplus.core.metadata.IPage;
  5 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6 +import com.wondertek.dto.LMRoomDto;
4 import com.wondertek.entity.LiveMonitorRoom; 7 import com.wondertek.entity.LiveMonitorRoom;
  8 +import com.wondertek.vo.LMRoomListVo;
  9 +import org.apache.ibatis.annotations.Param;
5 10
6 /** 11 /**
7 * @Description: 12 * @Description:
@@ -10,4 +15,6 @@ import com.wondertek.entity.LiveMonitorRoom; @@ -10,4 +15,6 @@ import com.wondertek.entity.LiveMonitorRoom;
10 * @Version 1.0 15 * @Version 1.0
11 */ 16 */
12 public interface LiveMonitorRoomMapper extends BaseMapper<LiveMonitorRoom> { 17 public interface LiveMonitorRoomMapper extends BaseMapper<LiveMonitorRoom> {
  18 +
  19 + IPage<LMRoomListVo> findPageList(Page<LMRoomListVo> page, @Param("dto") LMRoomDto dto);
13 } 20 }
  1 +package com.wondertek.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.wondertek.dto.BackupMaterialDto;
  5 +import com.wondertek.dto.LMRoomDto;
  6 +import com.wondertek.dto.LMRoomParam;
  7 +import com.wondertek.entity.LiveMonitorRoom;
  8 +import com.wondertek.util.PageBean;
  9 +import com.wondertek.util.ResultBean;
  10 +
  11 +public interface LiveMonitorRoomService extends IService<LiveMonitorRoom> {
  12 + PageBean queryPage(LMRoomDto lmRoomDto);
  13 +
  14 + PageBean editPage(LMRoomDto lmRoomDto);
  15 +
  16 +
  17 + ResultBean create(LMRoomParam lmRoomParam);
  18 +
  19 +}
  1 +package com.wondertek.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.wondertek.entity.StreamTask;
  5 +
  6 +public interface StreamTaskService extends IService<StreamTask> {
  7 +}
  1 +package com.wondertek.service.impl;
  2 +import java.time.LocalDateTime;
  3 +import java.util.List;
  4 +
  5 +import com.baomidou.mybatisplus.core.metadata.IPage;
  6 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  8 +import com.wondertek.dto.CrpDataVo;
  9 +import com.wondertek.dto.LMRoomDto;
  10 +import com.wondertek.dto.LMRoomParam;
  11 +import com.wondertek.entity.LiveMonitorRoom;
  12 +import com.wondertek.entity.StreamTask;
  13 +import com.wondertek.mapper.LiveMonitorRoomMapper;
  14 +import com.wondertek.service.LiveMonitorRoomService;
  15 +import com.wondertek.service.StreamTaskService;
  16 +import com.wondertek.util.PageBean;
  17 +import com.wondertek.util.ResultBean;
  18 +import com.wondertek.vo.LMRoomListVo;
  19 +import jakarta.annotation.Resource;
  20 +import org.springframework.stereotype.Service;
  21 +import org.springframework.util.CollectionUtils;
  22 +
  23 +@Service
  24 +public class LiveMonitorRoomServiceImpl extends ServiceImpl<LiveMonitorRoomMapper, LiveMonitorRoom> implements LiveMonitorRoomService {
  25 +
  26 + @Resource
  27 + private LiveMonitorRoomMapper liveMonitorRoomMapper;
  28 +
  29 + @Resource
  30 + private StreamTaskService monitorMarkService;
  31 +
  32 + @Override
  33 + public PageBean queryPage(LMRoomDto lmRoomDto) {
  34 + Page<LMRoomListVo> page = new Page<>(lmRoomDto.getPage(), lmRoomDto.getSize());
  35 + IPage<LMRoomListVo> resultPage = liveMonitorRoomMapper.findPageList(page, lmRoomDto);
  36 + return new PageBean(Integer.parseInt(String.valueOf(resultPage.getPages())),resultPage.getTotal(),resultPage.getRecords());
  37 + }
  38 +
  39 + @Override
  40 + public PageBean editPage(LMRoomDto lmRoomDto) {
  41 + return null;
  42 + }
  43 +
  44 +
  45 + @Override
  46 + public ResultBean create(LMRoomParam lmRoomParam) {
  47 +
  48 +
  49 + //审片间信息
  50 + LiveMonitorRoom liveMonitorRoom = new LiveMonitorRoom();
  51 + liveMonitorRoom.setName(lmRoomParam.getName());
  52 + liveMonitorRoom.setRoomStatus("0");
  53 + liveMonitorRoom.setCreatedBy("");
  54 + liveMonitorRoom.setCreatedTime(LocalDateTime.now());
  55 + liveMonitorRoom.setLiveName(lmRoomParam.getLiveName());
  56 + boolean b = saveOrUpdate(liveMonitorRoom);
  57 + Long roomId = liveMonitorRoom.getId();
  58 +
  59 +
  60 + List<CrpDataVo> dataList = lmRoomParam.getDataList();
  61 +
  62 + //初始化子任务信息
  63 + if(!CollectionUtils.isEmpty(dataList)){
  64 + List<StreamTask> taskList = dataList.stream().map(crpDataVo -> {
  65 + StreamTask streamTask = new StreamTask();
  66 + streamTask.setTaskId(crpDataVo.getTaskId());
  67 + streamTask.setChannelId(crpDataVo.getChannelId());
  68 + streamTask.setRoomId(roomId);
  69 + streamTask.setTaskType(crpDataVo.getTaskType());
  70 + streamTask.setCreatedBy("");
  71 + streamTask.setCreatedTime(LocalDateTime.now());
  72 + return streamTask;
  73 + }).toList();
  74 + monitorMarkService.saveOrUpdateBatch(taskList);
  75 + }
  76 +
  77 + return ResultBean.ok("创建成功");
  78 + }
  79 +}
  1 +package com.wondertek.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.wondertek.entity.StreamTask;
  5 +import com.wondertek.mapper.StreamTaskMapper;
  6 +import com.wondertek.service.StreamTaskService;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +@Service
  10 +public class StreamTaskServiceImpl extends ServiceImpl<StreamTaskMapper, StreamTask> implements StreamTaskService {
  11 +}
  1 +package com.wondertek.vo;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import lombok.Data;
  5 +
  6 +import java.time.LocalDateTime;
  7 +
  8 +@Data
  9 +public class LMRoomListVo {
  10 +
  11 + private Long id;
  12 + /** 审片间名称 */
  13 + private String name;
  14 +
  15 + private String brocStatus;
  16 + /** 审片间状态 0-启用 1-禁用 */
  17 + private String roomStatus;
  18 +
  19 + /** 创建人 */
  20 + private String createdBy;
  21 + /** 创建时间 */
  22 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  23 + private LocalDateTime createdTime;
  24 + /** 更新人 */
  25 + private String updatedBy;
  26 + /** 更新时间 */
  27 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  28 + private LocalDateTime updatedTime;
  29 +
  30 +
  31 + /** 多画输出流地址 */
  32 + private String mixOutputUrl;
  33 + /** 直播名称 */
  34 + private String liveName;
  35 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.wondertek.mapper.LiveMonitorRoomMapper">
  4 +
  5 + <select id="findPageList" resultType="com.wondertek.vo.LMRoomListVo">
  6 + SELECT
  7 + `id`,
  8 + `name`,
  9 + `broc_status`,
  10 + `room_status`,
  11 + `created_by`,
  12 + `created_time`,
  13 + `updated_by`,
  14 + `updated_time`,
  15 + `mix_output_url`,
  16 + `live_name`
  17 + FROM
  18 + crp_live_monitor_room`
  19 + <where>
  20 + <if test="dto.name != null and dto.name != ''">
  21 + and `name` like CONCAT('%',#{dto.name},'%')
  22 + </if>
  23 + </where>
  24 + order by created_time desc,updated_time DESC
  25 + </select>
  26 +
  27 +</mapper>