Toggle navigation
Toggle navigation
This project
Loading...
Sign in
crp
/
crp-operation
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wanghongbo
2025-07-22 16:03:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bdba71e6bb75d9cb62616051ac95d4e990025b40
bdba71e6
1 parent
65b09d8a
审片间延时
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
410 additions
and
0 deletions
pom.xml
src/main/java/com/wondertek/controller/RoomOperationController.java
src/main/java/com/wondertek/dto/DelayParam.java
src/main/java/com/wondertek/service/RoomOperationSerivice.java
src/main/java/com/wondertek/service/impl/RoomOperationServiceImpl.java
src/main/java/com/wondertek/util/JSONUtils.java
src/main/java/com/wondertek/util/ResponseData.java
src/main/resources/application-dev.yml
pom.xml
View file @
bdba71e
...
...
@@ -128,6 +128,12 @@
<artifactId>
janino
</artifactId>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.8.32
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/wondertek/controller/RoomOperationController.java
0 → 100644
View file @
bdba71e
package
com
.
wondertek
.
controller
;
import
com.wondertek.dto.DelayParam
;
import
com.wondertek.service.RoomOperationSerivice
;
import
com.wondertek.util.ResultBean
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Description: 审片间控制
* @Author W5669
* @Create 2025/7/22
* @Version 1.0
*/
@Slf4j
@RestController
@RequestMapping
(
"/monitor/room"
)
public
class
RoomOperationController
{
@Resource
private
RoomOperationSerivice
roomOperationSerivice
;
@RequestMapping
(
"/setDelayTime"
)
public
ResultBean
setDelayTime
(
DelayParam
delayParam
)
{
return
roomOperationSerivice
.
setDelayTime
(
delayParam
);
}
}
...
...
src/main/java/com/wondertek/dto/DelayParam.java
0 → 100644
View file @
bdba71e
package
com
.
wondertek
.
dto
;
import
lombok.Data
;
/**
* @Description: 延迟设置参数
* @Author W5669
* @Create 2025/7/22
* @Version 1.0
*/
@Data
public
class
DelayParam
{
private
Long
roomId
;
private
Integer
delayFirst
;
private
Integer
delaySecond
;
private
Integer
delayPlay
;
}
...
...
src/main/java/com/wondertek/service/RoomOperationSerivice.java
0 → 100644
View file @
bdba71e
package
com
.
wondertek
.
service
;
import
com.wondertek.dto.DelayParam
;
import
com.wondertek.util.ResultBean
;
/**
* @Description:
* @Author W5669
* @Create 2025/7/22
* @Version 1.0
*/
public
interface
RoomOperationSerivice
{
/**
* 设置延迟时间
* @param delayParam
* @return
*/
ResultBean
setDelayTime
(
DelayParam
delayParam
);
}
...
...
src/main/java/com/wondertek/service/impl/RoomOperationServiceImpl.java
0 → 100644
View file @
bdba71e
package
com
.
wondertek
.
service
.
impl
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.wondertek.dto.DelayParam
;
import
com.wondertek.entity.LiveMonitorRoom
;
import
com.wondertek.entity.StreamTask
;
import
com.wondertek.mapper.LiveMonitorRoomMapper
;
import
com.wondertek.mapper.StreamTaskMapper
;
import
com.wondertek.service.RoomOperationSerivice
;
import
com.wondertek.util.JSONUtils
;
import
com.wondertek.util.ResponseData
;
import
com.wondertek.util.ResultBean
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Description:
* @Author W5669
* @Create 2025/7/22
* @Version 1.0
*/
@Service
@Slf4j
public
class
RoomOperationServiceImpl
implements
RoomOperationSerivice
{
@Resource
private
LiveMonitorRoomMapper
liveMonitorRoomMapper
;
@Resource
private
StreamTaskMapper
streamTaskMapper
;
@Value
(
"${transcode.delayTimeUrl}"
)
private
String
delayTimeUrl
;
@Override
public
ResultBean
setDelayTime
(
DelayParam
delayParam
)
{
log
.
info
(
"-->【云审片平台】审片间延时设置,delayParam:{}"
,
delayParam
);
LiveMonitorRoom
liveMonitorRoom
=
liveMonitorRoomMapper
.
selectById
(
delayParam
.
getRoomId
());
LambdaQueryWrapper
<
StreamTask
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
StreamTask:
:
getRoomId
,
delayParam
.
getRoomId
());
List
<
StreamTask
>
streamTasks
=
streamTaskMapper
.
selectList
(
wrapper
);
//1.依次取出延时1、延时2、播出任务,设置转码平台相应的延时时间
streamTasks
.
forEach
(
streamTask
->
{
if
(
streamTask
.
getPlayType
().
equals
(
"delay1"
)){
delayTask
(
streamTask
.
getTaskId
(),
delayParam
.
getDelayFirst
());
//更新任务
streamTask
.
setDelayTime
(
delayParam
.
getDelayFirst
());
streamTaskMapper
.
updateById
(
streamTask
);
}
});
//2.更新多画
return
ResultBean
.
ok
(
"设置成功"
);
}
public
void
delayTask
(
String
taskId
,
int
delayTime
){
Map
<
String
,
Object
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"taskId"
,
taskId
);
paramsMap
.
put
(
"delayTime"
,
delayTime
);
HttpResponse
execute
=
null
;
try
{
execute
=
HttpRequest
.
post
(
delayTimeUrl
)
.
header
(
"Content-Type"
,
"application/json"
)
.
body
(
JSONUtils
.
obj2json
(
paramsMap
)).
timeout
(
30000
).
execute
();
if
(
execute
.
isOk
())
{
log
.
info
(
"-->请求转码系统延时接口,url:{},paramsMap:{}"
,
delayTimeUrl
,
paramsMap
);
String
body
=
execute
.
body
();
ResponseData
response
=
JSONUtils
.
jsonToObject
(
body
,
new
TypeReference
<
ResponseData
>()
{
});
if
(
response
.
getResultCode
().
equals
(
"0"
))
{
log
.
info
(
"请求转码系统延时接口成功"
);
}
else
{
log
.
info
(
"请求转码系统延时接口响应失败,response:{}"
,
response
);
}
}
else
{
log
.
error
(
"请求转码系统延时接口失败,url:{},body:{}"
,
delayTimeUrl
,
execute
.
body
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"请求转码系统延时接口失败,url:{}"
,
delayTimeUrl
,
e
);
}
}
}
...
...
src/main/java/com/wondertek/util/JSONUtils.java
0 → 100644
View file @
bdba71e
package
com
.
wondertek
.
util
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.datatype.jdk8.Jdk8Module
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
com.fasterxml.jackson.module.paramnames.ParameterNamesModule
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.List
;
@Slf4j
public
class
JSONUtils
{
private
static
final
ObjectMapper
objectMapper
=
new
ObjectMapper
().
registerModule
(
new
ParameterNamesModule
())
.
registerModule
(
new
Jdk8Module
())
// 使jackson识别被@JsonFormat标识的字段
.
registerModule
(
new
JavaTimeModule
())
// 设置jackson反序列化时遇到类中不存在的字段时不抛出异常
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
private
JSONUtils
()
{
}
public
static
ObjectMapper
getInstance
()
{
return
objectMapper
;
}
/**
* javaBean,list,array convert to json string
*/
public
static
String
obj2json
(
Object
obj
)
{
try
{
return
objectMapper
.
writeValueAsString
(
obj
);
}
catch
(
JsonProcessingException
e
)
{
log
.
error
(
"获取异常信息:{}"
,
e
.
getMessage
());
}
return
null
;
}
public
static
JsonNode
parseJsonNode
(
String
jsonChar
)
{
return
jsonToObject
(
jsonChar
,
JsonNode
.
class
);
}
public
static
<
T
>
T
obj2T
(
Object
obj
,
Class
<
T
>
t
)
{
return
objectMapper
.
convertValue
(
obj
,
new
TypeReference
<
T
>()
{
});
}
public
static
<
T
>
T
jsonToObject
(
String
jsonChar
,
TypeReference
<
T
>
t
)
{
try
{
return
objectMapper
.
readValue
(
jsonChar
,
t
);
}
catch
(
Exception
e
)
{
log
.
error
(
"json字符串反序列化失败,json字符串:{},类型:{}"
,
jsonChar
,
t
.
getType
().
getTypeName
());
}
return
null
;
}
public
static
<
T
>
List
<
T
>
jsonToList
(
String
jsonChar
,
Class
<
T
>
t
)
{
return
jsonToObject
(
jsonChar
,
new
TypeReference
<
List
<
T
>>()
{
});
}
public
static
<
T
>
T
jsonToObject
(
String
jsonChar
,
Class
<
T
>
t
)
{
try
{
return
objectMapper
.
readValue
(
jsonChar
,
t
);
}
catch
(
Exception
e
)
{
log
.
error
(
"json字符串反序列化失败,json字符串:{},类型:{}"
,
jsonChar
,
t
.
getName
());
}
return
null
;
}
/**
* 获取节点指定字段的值
* <p><b>Title:</b> getString</p>
* <p><b>Description:</b> </p>
*
* @author Zewei.Zhou
* @param jsonNode 节点
* @param fieldName 字段名称
* @return
*/
public
static
String
getString
(
JsonNode
jsonNode
,
String
fieldName
)
{
if
(
jsonNode
==
null
)
{
return
null
;
}
JsonNode
node
=
jsonNode
.
get
(
fieldName
);
return
(
node
==
null
||
node
.
isNull
())
?
null
:
node
.
asText
();
}
/**
* 获取节点指定字段的值
* <p><b>Title:</b> nodeToString</p>
* <p><b>Description:</b> </p>
*
* @author Zewei.Zhou
* @param jsonNode 节点
* @param fieldName 字段名称
* @return
*/
public
static
String
nodeToString
(
JsonNode
jsonNode
,
String
fieldName
)
{
if
(
jsonNode
==
null
)
{
return
null
;
}
JsonNode
node
=
jsonNode
.
get
(
fieldName
);
return
(
node
==
null
||
node
.
isNull
())
?
null
:
node
.
toString
();
}
/**
* 获取节点指定字段的int值,默认为0
* <p><b>Title:</b> getInt</p>
* <p><b>Description:</b> </p>
*
* @author Zewei.Zhou
* @param jsonNode 节点
* @param fieldName 字段名称
* @return
*/
public
static
int
getInt
(
JsonNode
jsonNode
,
String
fieldName
)
{
if
(
jsonNode
==
null
)
{
return
0
;
}
JsonNode
node
=
jsonNode
.
get
(
fieldName
);
return
node
==
null
||
!
node
.
canConvertToInt
()
?
0
:
node
.
asInt
();
}
/**
* 获取节点指定字段的值
* <p><b>Title:</b> getInteger</p>
* <p><b>Description:</b> </p>
*
* @author Zewei.Zhou
* @param jsonNode 节点
* @param fieldName 字段名称
* @return
*/
public
static
Integer
getInteger
(
JsonNode
jsonNode
,
String
fieldName
)
{
if
(
jsonNode
==
null
)
{
return
null
;
}
JsonNode
node
=
jsonNode
.
get
(
fieldName
);
return
node
==
null
||
!
node
.
canConvertToInt
()
?
null
:
node
.
asInt
();
}
/**
* 获取节点指定字段的值
* <p><b>Title:</b> getLong</p>
* <p><b>Description:</b> </p>
*
* @author Zewei.Zhou
* @param jsonNode 节点
* @param fieldName 字段名称
* @return
*/
public
static
Long
getLong
(
JsonNode
jsonNode
,
String
fieldName
)
{
if
(
jsonNode
==
null
)
{
return
null
;
}
JsonNode
node
=
jsonNode
.
get
(
fieldName
);
return
node
==
null
||
!
node
.
canConvertToLong
()
?
null
:
node
.
asLong
();
}
}
\ No newline at end of file
...
...
src/main/java/com/wondertek/util/ResponseData.java
0 → 100644
View file @
bdba71e
package
com
.
wondertek
.
util
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.wondertek.enums.GlobalCodeEnum
;
import
lombok.Data
;
import
lombok.ToString
;
@Data
@ToString
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ResponseData
<
T
>
{
/**
* 返回代码
*/
private
String
resultCode
;
/**
* 返回信息
*/
private
String
returnMessage
;
/**
* 返回结果
*/
private
T
data
;
public
<
K
>
ResponseData
()
{
}
public
ResponseData
(
String
code
,
String
msg
)
{
this
.
resultCode
=
code
;
this
.
returnMessage
=
msg
;
}
public
ResponseData
(
String
code
,
String
msg
,
T
result
)
{
this
.
resultCode
=
code
;
this
.
returnMessage
=
msg
;
this
.
data
=
result
;
}
public
static
<
T
>
ResponseData
<
T
>
ok
()
{
return
new
ResponseData
<>(
GlobalCodeEnum
.
SUCCESS
.
getCode
(),
GlobalCodeEnum
.
SUCCESS
.
getMsg
());
}
public
static
<
T
>
ResponseData
<
T
>
ok
(
String
msg
)
{
return
new
ResponseData
<
T
>(
GlobalCodeEnum
.
SUCCESS
.
getCode
(),
msg
);
}
public
static
<
T
>
ResponseData
<
T
>
ok
(
T
result
)
{
return
new
ResponseData
<
T
>(
GlobalCodeEnum
.
SUCCESS
.
getCode
(),
GlobalCodeEnum
.
SUCCESS
.
getMsg
(),
result
);
}
public
Boolean
isSuccess
()
{
return
GlobalCodeEnum
.
SUCCESS
.
getCode
().
equals
(
this
.
resultCode
);
}
public
static
<
T
>
ResponseData
<
T
>
error
()
{
return
new
ResponseData
<
T
>(
GlobalCodeEnum
.
FAILURE
.
getCode
(),
GlobalCodeEnum
.
FAILURE
.
getMsg
());
}
public
static
<
T
>
ResponseData
<
T
>
error
(
String
msg
)
{
return
new
ResponseData
<
T
>(
GlobalCodeEnum
.
FAILURE
.
getCode
(),
msg
);
}
public
static
<
T
>
ResponseData
<
T
>
error
(
String
code
,
String
msg
)
{
return
new
ResponseData
<
T
>(
code
,
msg
);
}
public
static
<
K
>
ResponseData
<
K
>
error
(
String
code
,
String
msg
,
K
k
)
{
return
new
ResponseData
<
K
>(
code
,
msg
,
k
);
}
public
void
setCodeAndMsg
(
GlobalCodeEnum
globalCodeEnum
)
{
setCodeAndMsg
(
globalCodeEnum
.
getCode
(),
globalCodeEnum
.
getMsg
());
}
public
void
setCodeAndMsg
(
String
code
,
String
msg
)
{
this
.
resultCode
=
code
;
this
.
returnMessage
=
msg
;
}
}
...
...
src/main/resources/application-dev.yml
View file @
bdba71e
...
...
@@ -59,6 +59,8 @@ mybatis-plus:
logic-not-delete-value
:
1
logic-delete-value
:
0
transcode
:
delayTimeUrl
:
http://192.168.1.41:8080/transcode/delayTime
# 延迟接口
crp
:
log
:
...
...
Please
register
or
login
to post a comment