Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-live
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
cloud-live
Commits
ad8c4089
Commit
ad8c4089
authored
Feb 26, 2021
by
liangkaiping
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hutao-替换保利威视配置' into 'master'
打日志 直播状态 See merge request fairylandcloudschool/cloud-live!2
parents
99652083
d446c542
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
307 additions
and
316 deletions
+307
-316
cloud-live-service/src/main/java/com/yizhi/live/application/service/impl/LiveActivityServiceImpl.java
+293
-304
cloud-live-service/src/main/java/com/yizhi/live/application/util/LiveUtil.java
+8
-12
cloud-live-service/src/main/java/com/yizhi/live/application/util/PolyvUtils.java
+6
-0
No files found.
cloud-live-service/src/main/java/com/yizhi/live/application/service/impl/LiveActivityServiceImpl.java
View file @
ad8c4089
...
@@ -17,19 +17,16 @@ import com.yizhi.application.orm.util.QueryUtil;
...
@@ -17,19 +17,16 @@ import com.yizhi.application.orm.util.QueryUtil;
import
com.yizhi.core.application.cache.RedisCache
;
import
com.yizhi.core.application.cache.RedisCache
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.RequestContext
;
import
com.yizhi.core.application.context.RequestContext
;
import
com.yizhi.core.application.enums.InternationalEnums
;
import
com.yizhi.core.application.enums.TaskParamsEnums
;
import
com.yizhi.core.application.enums.TaskParamsEnums
;
import
com.yizhi.core.application.task.AbstractTaskHandler
;
import
com.yizhi.core.application.task.AbstractTaskHandler
;
import
com.yizhi.core.application.task.TaskExecutor
;
import
com.yizhi.core.application.task.TaskExecutor
;
import
com.yizhi.core.application.vo.DroolsVo
;
import
com.yizhi.core.application.vo.DroolsVo
;
import
com.yizhi.live.application.constant.LiveStatusEnum
;
import
com.yizhi.live.application.constant.LiveStatusEnum
;
import
com.yizhi.live.application.constant.PolyvResponseVO
;
import
com.yizhi.live.application.constant.PolyvUpdatePO
;
import
com.yizhi.live.application.constant.PolyvUpdatePO
;
import
com.yizhi.live.application.constant.UtilConstants
;
import
com.yizhi.live.application.constant.UtilConstants
;
import
com.yizhi.live.application.domain.LiveActivity
;
import
com.yizhi.live.application.domain.LiveActivity
;
import
com.yizhi.live.application.domain.LiveReplay
;
import
com.yizhi.live.application.domain.LiveReplay
;
import
com.yizhi.live.application.domain.ScopeAuthorization
;
import
com.yizhi.live.application.domain.ScopeAuthorization
;
import
com.yizhi.live.application.enums.LiveStatus
;
import
com.yizhi.live.application.enums.LiveStatusV2
;
import
com.yizhi.live.application.enums.LiveStatusV2
;
import
com.yizhi.live.application.enums.PolyvReqEnum
;
import
com.yizhi.live.application.enums.PolyvReqEnum
;
import
com.yizhi.live.application.mapper.LiveActivityMapper
;
import
com.yizhi.live.application.mapper.LiveActivityMapper
;
...
@@ -46,7 +43,6 @@ import com.yizhi.util.application.date.DateUtil;
...
@@ -46,7 +43,6 @@ import com.yizhi.util.application.date.DateUtil;
import
com.yizhi.util.application.domain.BizResponse
;
import
com.yizhi.util.application.domain.BizResponse
;
import
com.yizhi.util.application.page.PageInfo
;
import
com.yizhi.util.application.page.PageInfo
;
import
com.yizhi.util.application.page.PageParam
;
import
com.yizhi.util.application.page.PageParam
;
import
jdk.nashorn.internal.codegen.ObjectClassGenerator
;
import
org.apache.ibatis.session.RowBounds
;
import
org.apache.ibatis.session.RowBounds
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -80,8 +76,6 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -80,8 +76,6 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Value
(
"${ACTIVE}"
)
@Value
(
"${ACTIVE}"
)
public
String
active
;
public
String
active
;
@Autowired
@Autowired
LiveUtil
liveUtil
;
@Autowired
ScopeAuthorizationMapper
scopeAuthorizationMapper
;
ScopeAuthorizationMapper
scopeAuthorizationMapper
;
@Autowired
@Autowired
IdGenerator
idGenerator
;
IdGenerator
idGenerator
;
...
@@ -91,10 +85,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -91,10 +85,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
private
LiveEvenSendMessage
liveEvenSendMessage
;
private
LiveEvenSendMessage
liveEvenSendMessage
;
@Autowired
@Autowired
private
TaskExecutor
taskExecutor
;
private
TaskExecutor
taskExecutor
;
@Autowired
@Autowired
private
IScopeAuthorizationService
scopeAuthorizationService
;
private
IScopeAuthorizationService
scopeAuthorizationService
;
@Autowired
@Autowired
RedisCache
redisCache
;
RedisCache
redisCache
;
@Autowired
@Autowired
...
@@ -104,9 +96,9 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -104,9 +96,9 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
String
createChanel
(
Map
<
String
,
String
>
params
)
{
public
String
createChanel
(
Map
<
String
,
String
>
params
)
{
String
sign
=
l
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
String
sign
=
L
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"sign"
,
sign
);
String
result
=
l
iveUtil
.
sendHttpPost
(
UtilConstants
.
CREATE_CHANNEL_URL
,
params
);
String
result
=
L
iveUtil
.
sendHttpPost
(
UtilConstants
.
CREATE_CHANNEL_URL
,
params
);
return
result
;
return
result
;
}
}
...
@@ -114,18 +106,18 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -114,18 +106,18 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
public
List
<
LiveActivity
>
findWithinSevenDaysLive
(
Long
companyId
,
Long
siteId
,
Long
accountId
)
{
public
List
<
LiveActivity
>
findWithinSevenDaysLive
(
Long
companyId
,
Long
siteId
,
Long
accountId
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
DATE
,
-
6
);
calendar
.
add
(
Calendar
.
DATE
,
-
6
);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
// 分级授权修改
// 分级授权修改
// LOG.info("分级授权开始 ------------------------------------------");
// LOG.info("分级授权开始 ------------------------------------------");
//HQueryUtil.startHQ(LiveActivity.class);
//HQueryUtil.startHQ(LiveActivity.class);
// 基础查询条件
// 基础查询条件
EntityWrapper
<
LiveActivity
>
ew
=
QueryUtil
.
condition
(
new
LiveActivity
());
EntityWrapper
<
LiveActivity
>
ew
=
QueryUtil
.
condition
(
new
LiveActivity
());
ew
.
eq
(
"company_id"
,
companyId
).
eq
(
"site_id"
,
siteId
)
ew
.
eq
(
"company_id"
,
companyId
).
eq
(
"site_id"
,
siteId
)
.
eq
(
"create_by_id"
,
accountId
)
.
eq
(
"create_by_id"
,
accountId
)
.
eq
(
"shelves"
,
1
)
.
eq
(
"shelves"
,
1
)
.
between
(
"end_time"
,
calendar
.
getTime
(),
Calendar
.
getInstance
().
getTime
());
.
between
(
"end_time"
,
calendar
.
getTime
(),
Calendar
.
getInstance
().
getTime
());
...
@@ -136,29 +128,29 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -136,29 +128,29 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
public
Page
<
PageLiveVo
>
searchPage
(
String
title
,
String
startTimeString
,
public
Page
<
PageLiveVo
>
searchPage
(
String
title
,
String
startTimeString
,
String
endTimeString
,
Long
companyId
,
Long
siteId
,
String
endTimeString
,
Long
companyId
,
Long
siteId
,
List
<
Long
>
orgIds
,
int
pageNo
,
int
pageSize
,
List
<
Long
>
orgIds
,
int
pageNo
,
int
pageSize
,
String
expTimeString
,
Integer
status
,
Integer
viewType
,
Boolean
startTimeAsc
,
Boolean
endTimeAsc
)
{
String
expTimeString
,
Integer
status
,
Integer
viewType
,
Boolean
startTimeAsc
,
Boolean
endTimeAsc
)
{
LOG
.
info
(
"转换前直播列表 查询参数:startTimeString={},endTimeString={},expTimeString"
,
startTimeString
,
endTimeString
,
expTimeString
);
LOG
.
info
(
"转换前直播列表 查询参数:startTimeString={},endTimeString={},expTimeString"
,
startTimeString
,
endTimeString
,
expTimeString
);
SimpleDateFormat
sim
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
SimpleDateFormat
sim
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
Date
startTime
=
null
;
Date
startTime
=
null
;
Date
endTime
=
null
;
Date
endTime
=
null
;
Date
expTime
=
null
;
Date
expTime
=
null
;
try
{
try
{
if
(!
StringUtils
.
isEmpty
(
startTimeString
))
{
if
(!
StringUtils
.
isEmpty
(
startTimeString
))
{
startTime
=
sim
.
parse
(
startTimeString
);
startTime
=
sim
.
parse
(
startTimeString
);
}
}
if
(!
StringUtils
.
isEmpty
(
endTimeString
))
{
if
(!
StringUtils
.
isEmpty
(
endTimeString
))
{
endTime
=
sim
.
parse
(
endTimeString
);
endTime
=
sim
.
parse
(
endTimeString
);
}
}
if
(!
StringUtils
.
isEmpty
(
expTimeString
))
{
if
(!
StringUtils
.
isEmpty
(
expTimeString
))
{
expTime
=
sim
.
parse
(
expTimeString
);
expTime
=
sim
.
parse
(
expTimeString
);
}
}
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
LOG
.
info
(
"直播列表日期转换错误"
,
e
);
LOG
.
info
(
"直播列表日期转换错误"
,
e
);
}
}
LOG
.
info
(
"转换后直播列表 查询参数:startTime={},endTime={},expTime"
,
startTime
,
endTime
,
expTime
);
LOG
.
info
(
"转换后直播列表 查询参数:startTime={},endTime={},expTime"
,
startTime
,
endTime
,
expTime
);
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
// 分页信息
// 分页信息
...
@@ -175,48 +167,48 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -175,48 +167,48 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
LOG
.
info
(
"分级授权开始 ------------------------------------------"
);
LOG
.
info
(
"分级授权开始 ------------------------------------------"
);
HQueryUtil
.
startHQ
(
LiveActivity
.
class
);
HQueryUtil
.
startHQ
(
LiveActivity
.
class
);
LOG
.
info
(
"直播列表 查询参数:startTime={},endTime={}"
,
startTime
,
endTime
);
LOG
.
info
(
"直播列表 查询参数:startTime={},endTime={}"
,
startTime
,
endTime
);
if
(
null
!=
startTime
&&
null
!=
endTime
&&
(
endTime
.
getTime
()
>
startTime
.
getTime
()))
{
if
(
null
!=
startTime
&&
null
!=
endTime
&&
(
endTime
.
getTime
()
>
startTime
.
getTime
()))
{
ew
.
ge
(
"start_time"
,
startTime
).
and
().
le
(
"end_time"
,
endTime
);
ew
.
ge
(
"start_time"
,
startTime
).
and
().
le
(
"end_time"
,
endTime
);
}
else
{
}
else
{
if
(
expTime
!=
null
)
{
if
(
expTime
!=
null
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LOG
.
info
(
"开始时间={},结束时间={}"
,
simpleDateFormat
.
format
(
expTime
),
simpleDateFormat
.
format
(
calendar
.
getTime
()));
LOG
.
info
(
"开始时间={},结束时间={}"
,
simpleDateFormat
.
format
(
expTime
),
simpleDateFormat
.
format
(
calendar
.
getTime
()));
ew
.
le
(
"start_time"
,
expTime
).
ge
(
"end_time"
,
calendar
.
getTime
());
ew
.
le
(
"start_time"
,
expTime
).
ge
(
"end_time"
,
calendar
.
getTime
());
}
}
}
}
if
(
Objects
.
nonNull
(
viewType
))
{
if
(
Objects
.
nonNull
(
viewType
))
{
ew
.
eq
(
"view_type"
,
viewType
);
ew
.
eq
(
"view_type"
,
viewType
);
}
}
if
(
Objects
.
nonNull
(
status
))
{
if
(
Objects
.
nonNull
(
status
))
{
ew
.
eq
(
"shelves"
,
status
);
ew
.
eq
(
"shelves"
,
status
);
}
}
if
(!
StringUtils
.
isEmpty
(
title
))
{
if
(!
StringUtils
.
isEmpty
(
title
))
{
ew
.
andNew
().
ew
.
andNew
().
like
(
"title"
,
title
,
SqlLike
.
DEFAULT
)
like
(
"title"
,
title
,
SqlLike
.
DEFAULT
)
.
or
().
like
(
"channel"
,
title
,
SqlLike
.
DEFAULT
)
.
or
().
like
(
"channel"
,
title
,
SqlLike
.
DEFAULT
)
.
or
().
like
(
"keywords"
,
title
);
.
or
().
like
(
"keywords"
,
title
);
}
}
if
(
null
==
startTimeAsc
&&
null
==
endTimeAsc
){
if
(
null
==
startTimeAsc
&&
null
==
endTimeAsc
)
{
//当开始和结束时间排序都不传递的时候;默认按照创建时间倒叙;
//当开始和结束时间排序都不传递的时候;默认按照创建时间倒叙;
ew
.
orderBy
(
"create_time"
,
false
);
ew
.
orderBy
(
"create_time"
,
false
);
}
else
{
}
else
{
if
(
null
!=
startTimeAsc
){
if
(
null
!=
startTimeAsc
)
{
ew
.
orderBy
(
"start_time"
,
startTimeAsc
);
ew
.
orderBy
(
"start_time"
,
startTimeAsc
);
}
else
if
(
null
!=
endTimeAsc
)
{
}
else
if
(
null
!=
endTimeAsc
)
{
ew
.
orderBy
(
"end_time"
,
endTimeAsc
);
ew
.
orderBy
(
"end_time"
,
endTimeAsc
);
}
}
}
}
Page
<
LiveActivity
>
retList
=
this
.
selectPage
(
PageUtil
.
vice
(
pageParam
),
ew
);
Page
<
LiveActivity
>
retList
=
this
.
selectPage
(
PageUtil
.
vice
(
pageParam
),
ew
);
// 复制结果到返回变量
// 复制结果到返回变量
BeanUtils
.
copyProperties
(
retList
,
page
,
"records"
);
BeanUtils
.
copyProperties
(
retList
,
page
,
"records"
);
List
<
LiveActivity
>
data
=
retList
.
getRecords
();
List
<
LiveActivity
>
data
=
retList
.
getRecords
();
if
(
CollectionUtils
.
isEmpty
(
data
))
{
if
(
CollectionUtils
.
isEmpty
(
data
))
{
return
page
;
return
page
;
}
}
// 获取全部的房间号
// 获取全部的房间号
...
@@ -226,7 +218,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -226,7 +218,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
List
<
PageLiveVo
>
retData
=
new
ArrayList
<>();
List
<
PageLiveVo
>
retData
=
new
ArrayList
<>();
data
.
stream
().
forEach
(
obj
->
{
data
.
stream
().
forEach
(
obj
->
{
PageLiveVo
vo
=
new
PageLiveVo
();
PageLiveVo
vo
=
new
PageLiveVo
();
BeanUtils
.
copyProperties
(
obj
,
vo
);
BeanUtils
.
copyProperties
(
obj
,
vo
);
retData
.
add
(
vo
);
retData
.
add
(
vo
);
});
});
page
.
setRecords
(
retData
);
page
.
setRecords
(
retData
);
...
@@ -239,10 +231,10 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -239,10 +231,10 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"userId"
,
UtilConstants
.
APP_USER_ID
);
params
.
put
(
"userId"
,
UtilConstants
.
APP_USER_ID
);
String
sign
=
l
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
String
sign
=
L
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"sign"
,
sign
);
try
{
try
{
String
result
=
l
iveUtil
.
sendHttpPost
(
UtilConstants
.
CREATE_CHANNEL_URL
+
"/"
+
chanel
+
"/delete"
,
params
);
String
result
=
L
iveUtil
.
sendHttpPost
(
UtilConstants
.
CREATE_CHANNEL_URL
+
"/"
+
chanel
+
"/delete"
,
params
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
String
code
=
obj
.
getString
(
"code"
);
String
code
=
obj
.
getString
(
"code"
);
if
(
"200"
.
equals
(
code
))
{
if
(
"200"
.
equals
(
code
))
{
...
@@ -262,11 +254,11 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -262,11 +254,11 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"token"
,
token
);
params
.
put
(
"token"
,
token
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
String
sign
=
l
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
String
sign
=
L
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"sign"
,
sign
);
try
{
try
{
String
result
=
l
iveUtil
.
sendHttpPost
(
UtilConstants
.
CREATE_CHANNEL_URL
+
"/"
+
chanel
+
"/set-token"
,
params
);
String
result
=
L
iveUtil
.
sendHttpPost
(
UtilConstants
.
CREATE_CHANNEL_URL
+
"/"
+
chanel
+
"/set-token"
,
params
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
String
code
=
obj
.
getString
(
"code"
);
String
code
=
obj
.
getString
(
"code"
);
if
(
"200"
.
equals
(
code
))
{
if
(
"200"
.
equals
(
code
))
{
...
@@ -311,7 +303,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -311,7 +303,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
public
Page
<
PageLiveVo
>
apiSearchPageList
(
List
<
Long
>
relationIds
,
String
title
,
Long
companyId
,
Long
siteId
,
int
pageNo
,
int
pageSize
)
{
public
Page
<
PageLiveVo
>
apiSearchPageList
(
List
<
Long
>
relationIds
,
String
title
,
Long
companyId
,
Long
siteId
,
int
pageNo
,
int
pageSize
)
{
List
<
Long
>
ids
=
null
;
List
<
Long
>
ids
=
null
;
if
(!
StringUtils
.
isEmpty
(
relationIds
))
{
if
(!
StringUtils
.
isEmpty
(
relationIds
))
{
Long
accountId
=
ContextHolder
.
get
().
getAccountId
();
Long
accountId
=
ContextHolder
.
get
().
getAccountId
();
relationIds
.
add
(
accountId
);
relationIds
.
add
(
accountId
);
ids
=
scopeAuthorizationMapper
.
selectLiveIdByRelationId
(
relationIds
);
ids
=
scopeAuthorizationMapper
.
selectLiveIdByRelationId
(
relationIds
);
}
}
...
@@ -330,28 +322,33 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -330,28 +322,33 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Map
<
String
,
String
>
statusMap
=
getStringStringMap
(
channelIds
);
Map
<
String
,
String
>
statusMap
=
getStringStringMap
(
channelIds
);
liveActivities
.
parallelStream
().
forEach
(
liveActivity
->
{
LOG
.
info
(
"保利威视返回信息:"
+
(
statusMap
!=
null
?
statusMap
.
toString
()
:
statusMap
));
liveActivities
.
parallelStream
().
forEach
(
liveActivity
->
{
if
(
statusMap
.
containsKey
(
liveActivity
.
getChannel
()))
{
if
(
statusMap
.
containsKey
(
liveActivity
.
getChannel
()))
{
// 直播回放
// 直播回放
LiveStatusV2
status
=
PolyvUtils
.
getLiveStatus
(
liveActivity
.
getChannel
(),
liveActivity
.
getStartTime
(),
liveActivity
.
getEndTime
(),
null
);
LiveStatusV2
status
=
PolyvUtils
.
getLiveStatus
(
liveActivity
.
getChannel
(),
liveActivity
.
getStartTime
(),
liveActivity
.
getEndTime
(),
null
);
LOG
.
info
(
"直播 channel:"
+
liveActivity
.
getChannel
()
+
"名称:"
+
liveActivity
.
getTitle
()
+
"查询到直播状态为"
+
status
.
toString
());
liveActivity
.
setStatus
(
String
.
valueOf
(
status
.
getCode
()));
liveActivity
.
setStatus
(
String
.
valueOf
(
status
.
getCode
()));
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
status
.
getCode
())){
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
status
.
getCode
()))
{
//添加直播在学人数
//添加直播在学人数
String
channel
=
liveActivity
.
getChannel
();
String
channel
=
liveActivity
.
getChannel
();
liveActivity
.
setOnlineCount
(
0
);
liveActivity
.
setOnlineCount
(
0
);
try
{
try
{
List
<
LiveOnlineCountVo
>
channelOnlineCountRealTime
=
getChannelOnlineCountRealTime
(
channel
);
List
<
LiveOnlineCountVo
>
channelOnlineCountRealTime
=
getChannelOnlineCountRealTime
(
channel
);
if
(
null
!=
channelOnlineCountRealTime
&&
channelOnlineCountRealTime
.
size
()
>
0
){
if
(
null
!=
channelOnlineCountRealTime
&&
channelOnlineCountRealTime
.
size
()
>
0
)
{
LiveOnlineCountVo
liveOnlineCountVo
=
channelOnlineCountRealTime
.
get
(
0
);
LiveOnlineCountVo
liveOnlineCountVo
=
channelOnlineCountRealTime
.
get
(
0
);
Integer
onlineCountVoCount
=
liveOnlineCountVo
.
getCount
();
Integer
onlineCountVoCount
=
liveOnlineCountVo
.
getCount
();
liveActivity
.
setOnlineCount
(
onlineCountVoCount
);
liveActivity
.
setOnlineCount
(
onlineCountVoCount
);
}
}
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
LOG
.
error
(
"查询直播在学人数异常: channel = {} ,companyId ={} ,siteId = {}"
,
channel
,
companyId
,
siteId
,
e
);
LOG
.
error
(
"查询直播在学人数异常: channel = {} ,companyId ={} ,siteId = {}"
,
channel
,
companyId
,
siteId
,
e
);
}
}
}
}
}
else
{
LOG
.
error
(
"直播 channel:"
+
liveActivity
.
getChannel
()
+
"名称:"
+
liveActivity
.
getTitle
()
+
"未在保利威视查询到!!!"
);
}
}
});
});
page
.
setRecords
(
liveActivities
);
page
.
setRecords
(
liveActivities
);
Integer
count
=
this
.
baseMapper
.
apiSearchPageCount
(
ids
,
title
,
siteId
,
companyId
);
Integer
count
=
this
.
baseMapper
.
apiSearchPageCount
(
ids
,
title
,
siteId
,
companyId
);
...
@@ -361,7 +358,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -361,7 +358,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
Boolean
saveLive
(
LiveActivityResultVO
liveActivityResultVO
)
{
public
Boolean
saveLive
(
LiveActivityResultVO
liveActivityResultVO
)
{
LOG
.
info
(
"后台直播创建,携带活动那个参数{},可见范围信息{}"
,
liveActivityResultVO
.
getLiveActivity
(),
liveActivityResultVO
.
getScopeAuthorizations
());
LOG
.
info
(
"后台直播创建,携带活动那个参数{},可见范围信息{}"
,
liveActivityResultVO
.
getLiveActivity
(),
liveActivityResultVO
.
getScopeAuthorizations
());
if
(
liveActivityResultVO
.
getLiveActivity
()
==
null
)
{
if
(
liveActivityResultVO
.
getLiveActivity
()
==
null
)
{
LOG
.
info
(
"LiveActivity直播活动表为空"
);
LOG
.
info
(
"LiveActivity直播活动表为空"
);
return
false
;
return
false
;
...
@@ -379,22 +376,22 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -379,22 +376,22 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
params
.
put
(
"channelPasswd"
,
liveActivity
.
getPassword
());
params
.
put
(
"channelPasswd"
,
liveActivity
.
getPassword
());
params
.
put
(
"name"
,
liveActivity
.
getTitle
());
params
.
put
(
"name"
,
liveActivity
.
getTitle
());
String
scene
=
liveActivity
.
getScene
();
String
scene
=
liveActivity
.
getScene
();
if
(
"ppt"
.
equals
(
scene
)
||
"topclass"
.
equals
(
scene
))
{
if
(
"ppt"
.
equals
(
scene
)
||
"topclass"
.
equals
(
scene
))
{
}
else
{
}
else
{
scene
=
"alone"
;
scene
=
"alone"
;
}
}
params
.
put
(
"scene"
,
scene
);
params
.
put
(
"scene"
,
scene
);
LOG
.
info
(
"进入方法之前:参数params{},第二个参数{}"
,
params
,
UtilConstants
.
CREATE_CHANNEL_URL
);
LOG
.
info
(
"进入方法之前:参数params{},第二个参数{}"
,
params
,
UtilConstants
.
CREATE_CHANNEL_URL
);
String
result
=
execPolyvApi
(
params
,
UtilConstants
.
CREATE_CHANNEL_URL
);
String
result
=
execPolyvApi
(
params
,
UtilConstants
.
CREATE_CHANNEL_URL
);
LOG
.
info
(
"进入方法之后:{}"
,
result
);
LOG
.
info
(
"进入方法之后:{}"
,
result
);
Map
<
String
,
Object
>
maps
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
maps
=
new
HashMap
<
String
,
Object
>();
try
{
try
{
maps
=
JsonUtil
.
parseJSON2Map
(
result
);
maps
=
JsonUtil
.
parseJSON2Map
(
result
);
if
(
maps
.
containsKey
(
"data"
))
{
if
(
maps
.
containsKey
(
"data"
))
{
LOG
.
info
(
"获取保利威直播频道号的结果={},请求参数={}"
,
JSON
.
toJSONString
(
maps
),
JSON
.
toJSONString
(
params
));
LOG
.
info
(
"获取保利威直播频道号的结果={},请求参数={}"
,
JSON
.
toJSONString
(
maps
),
JSON
.
toJSONString
(
params
));
JSONObject
jsonObject
=
(
JSONObject
)
maps
.
get
(
"data"
);
JSONObject
jsonObject
=
(
JSONObject
)
maps
.
get
(
"data"
);
if
(
jsonObject
.
containsKey
(
"channelId"
))
{
if
(
jsonObject
.
containsKey
(
"channelId"
))
{
String
channelId
=
jsonObject
.
get
(
"channelId"
).
toString
();
String
channelId
=
jsonObject
.
get
(
"channelId"
).
toString
();
...
@@ -403,7 +400,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -403,7 +400,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
//进行 自定义授权的配置 channelSetting(设置成授权观看)
//进行 自定义授权的配置 channelSetting(设置成授权观看)
String
secretKey
=
channelSetting
(
jsonObject
.
get
(
"channelId"
).
toString
());
String
secretKey
=
channelSetting
(
jsonObject
.
get
(
"channelId"
).
toString
());
if
(
StringUtils
.
isEmpty
(
secretKey
))
{
if
(
StringUtils
.
isEmpty
(
secretKey
))
{
LOG
.
info
(
"secretKey 为空:{}"
,
secretKey
);
LOG
.
info
(
"secretKey 为空:{}"
,
secretKey
);
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
liveActivity
.
setSecretKey
(
secretKey
);
liveActivity
.
setSecretKey
(
secretKey
);
...
@@ -412,37 +409,37 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -412,37 +409,37 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
try
{
try
{
Map
<
String
,
String
>
params1
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params1
=
new
HashMap
<
String
,
String
>();
params1
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params1
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params1
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params1
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
// 之前未设置倒计时直播提示和直播时间的频道号,在开启倒计时开关时,必须提交countTips和startTime
// 之前未设置倒计时直播提示和直播时间的频道号,在开启倒计时开关时,必须提交countTips和startTime
//params1.put("countEnabled", "N");
//params1.put("countEnabled", "N");
params1
.
put
(
"startTime"
,
DateUtil
.
toSeconds
(
startTime
));
params1
.
put
(
"startTime"
,
DateUtil
.
toSeconds
(
startTime
));
String
result1
=
execPolyvApi
(
params1
,
String
.
format
(
UtilConstants
.
CHANNEL_STARTDATE_UPDATE
,
channelId
));
String
result1
=
execPolyvApi
(
params1
,
String
.
format
(
UtilConstants
.
CHANNEL_STARTDATE_UPDATE
,
channelId
));
Map
<
String
,
String
>
params2
=
new
HashMap
<>();
Map
<
String
,
String
>
params2
=
new
HashMap
<>();
params2
.
put
(
"channelId"
,
channelId
);
params2
.
put
(
"channelId"
,
channelId
);
//String body = "{\"authSettings\": [ {\"rank\":1,\"enabled\":\"Y\",\"authType\":\"custom\"} ] }";
//String body = "{\"authSettings\": [ {\"rank\":1,\"enabled\":\"Y\",\"authType\":\"custom\"} ] }";
if
(
liveActivity
.
getViewType
()
==
0
)
{
if
(
liveActivity
.
getViewType
()
==
0
)
{
String
body
=
"{\"authSettings\":[{\"rank\":1,\"enabled\":\"N\"}]}"
;
String
body
=
"{\"authSettings\":[{\"rank\":1,\"enabled\":\"N\"}]}"
;
String
result2
=
LiveUtilPostUrlParam
.
sendPost
(
UtilConstants
.
LIVE_AUTH_UPDATE_URL
,
body
,
params2
);
String
result2
=
LiveUtilPostUrlParam
.
sendPost
(
UtilConstants
.
LIVE_AUTH_UPDATE_URL
,
body
,
params2
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
info
(
"新增直播 更新时间异常={}"
,
e
);
LOG
.
info
(
"新增直播 更新时间异常={}"
,
e
);
}
}
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
info
(
"插入更新时间 异常:{}"
,
e
);
LOG
.
info
(
"插入更新时间 异常:{}"
,
e
);
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
LiveActivity
lt
=
new
LiveActivity
();
LiveActivity
lt
=
new
LiveActivity
();
BeanUtils
.
copyProperties
(
liveActivity
,
lt
);
BeanUtils
.
copyProperties
(
liveActivity
,
lt
);
if
(
setOptions
(
lt
,
lt
,
true
))
{
if
(
setOptions
(
lt
,
lt
,
true
))
{
LOG
.
info
(
"设在参数异常"
);
LOG
.
info
(
"设在参数异常"
);
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
...
@@ -471,7 +468,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -471,7 +468,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
}
}
});
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
info
(
"直播发消息异常:{}"
,
e
);
LOG
.
info
(
"直播发消息异常:{}"
,
e
);
}
}
}
}
...
@@ -482,15 +479,16 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -482,15 +479,16 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
/**
/**
* 调用保利威接口
* 调用保利威接口
*
* @param params
* @param params
* @return
* @return
*/
*/
private
String
execPolyvApi
(
Map
<
String
,
String
>
params
,
String
apiUrl
)
{
private
String
execPolyvApi
(
Map
<
String
,
String
>
params
,
String
apiUrl
)
{
String
sign
=
getSign
(
params
);
String
sign
=
getSign
(
params
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"sign"
,
sign
);
//调用地三方接口创建直播 获得直播频道号
//调用地三方接口创建直播 获得直播频道号
String
result
=
l
iveUtil
.
sendHttpPost
(
apiUrl
,
params
);
String
result
=
L
iveUtil
.
sendHttpPost
(
apiUrl
,
params
);
LOG
.
info
(
"保利威返回 {};URL IS {}"
,
result
,
apiUrl
,
params
);
LOG
.
info
(
"保利威返回 {};URL IS {}"
,
result
,
apiUrl
,
params
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
result
);
return
result
;
return
result
;
}
}
...
@@ -503,10 +501,10 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -503,10 +501,10 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
}
}
LiveActivityVO
liveActivity
=
liveActivityResultVO
.
getLiveActivity
();
LiveActivityVO
liveActivity
=
liveActivityResultVO
.
getLiveActivity
();
LiveActivity
updateLiveActivity
=
this
.
baseMapper
.
selectById
(
liveActivity
.
getId
());
LiveActivity
updateLiveActivity
=
this
.
baseMapper
.
selectById
(
liveActivity
.
getId
());
if
(
updateLiveActivity
==
null
)
{
if
(
updateLiveActivity
==
null
)
{
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
if
(
liveActivity
!=
null
)
{
if
(
liveActivity
!=
null
)
{
updateLiveActivity
.
setEnableTask
(
liveActivity
.
getEnableTask
());
updateLiveActivity
.
setEnableTask
(
liveActivity
.
getEnableTask
());
}
}
...
@@ -525,12 +523,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -525,12 +523,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
updateLiveActivity
.
setReplayStatus
(
liveActivity
.
getReplayStatus
());
updateLiveActivity
.
setReplayStatus
(
liveActivity
.
getReplayStatus
());
Integer
updateCount
=
this
.
baseMapper
.
updateById
(
updateLiveActivity
);
Integer
updateCount
=
this
.
baseMapper
.
updateById
(
updateLiveActivity
);
if
(
updateCount
==
null
||
updateCount
==
0
)
{
if
(
updateCount
==
null
||
updateCount
==
0
)
{
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
}
}
Integer
scope
=
liveActivity
.
getScope
();
Integer
scope
=
liveActivity
.
getScope
();
if
(
scope
!=
null
)
{
if
(
scope
!=
null
)
{
if
(
1
==
updateLiveActivity
.
getScope
()
&&
liveActivityResultVO
.
getScopeAuthorizations
().
size
()
>
0
)
{
if
(
1
==
updateLiveActivity
.
getScope
()
&&
liveActivityResultVO
.
getScopeAuthorizations
().
size
()
>
0
)
{
ScopeAuthorization
scopeAuthorization
=
new
ScopeAuthorization
();
ScopeAuthorization
scopeAuthorization
=
new
ScopeAuthorization
();
scopeAuthorization
.
setLiveId
(
updateLiveActivity
.
getId
());
scopeAuthorization
.
setLiveId
(
updateLiveActivity
.
getId
());
...
@@ -570,22 +568,14 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -570,22 +568,14 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
po
.
setPublisher
(
liveActivity
.
getAnchor
());
po
.
setPublisher
(
liveActivity
.
getAnchor
());
po
.
setDesc
(
liveActivity
.
getDescription
());
po
.
setDesc
(
liveActivity
.
getDescription
());
po
.
setStartTime
(
liveActivity
.
getStartTime
().
getTime
());
po
.
setStartTime
(
liveActivity
.
getStartTime
().
getTime
());
PolyvUtils
.
updateChannelParams
(
updateLiveActivity
.
getChannel
(),
po
,
true
,
updateLiveActivity
.
getSecretKey
(),
getRedirectUrl
());
PolyvUtils
.
updateChannelParams
(
updateLiveActivity
.
getChannel
(),
po
,
true
,
updateLiveActivity
.
getSecretKey
(),
getRedirectUrl
());
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
}
}
public
static
void
main
(
String
[]
args
)
{
//String secretKey = channelSetting(jsonObject.get("channelId").toString());
Map
<
String
,
String
>
params2
=
new
HashMap
<>();
params2
.
put
(
"channelId"
,
"1077706"
);
params2
.
put
(
"customUri"
,
UtilConstants
.
UAT_LIVE_CUSTOM_URI
);
//LiveUtilPostUrlNotParam.sendPost()
String
result2
=
LiveUtilPostUrlParam
.
sendPost
(
String
.
format
(
UtilConstants
.
LIVE_CHANNEL_SETTING_URL
,
UtilConstants
.
APP_USER_ID
),
null
,
params2
);
System
.
out
.
println
(
result2
);
}
private
boolean
setOptions
(
final
LiveActivity
liveActivity
,
LiveActivity
updateLiveActivity
,
boolean
addFlg
)
{
private
boolean
setOptions
(
final
LiveActivity
liveActivity
,
LiveActivity
updateLiveActivity
,
boolean
addFlg
)
{
String
title
=
liveActivity
.
getTitle
();
String
title
=
liveActivity
.
getTitle
();
if
(
title
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
title
,
updateLiveActivity
.
getTitle
()))
{
if
(
title
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
title
,
updateLiveActivity
.
getTitle
()))
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
...
@@ -593,49 +583,49 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -593,49 +583,49 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
params
.
put
(
"name"
,
title
);
params
.
put
(
"name"
,
title
);
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_TITLE_NAME_UPDATE
,
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_TITLE_NAME_UPDATE
,
updateLiveActivity
.
getChannel
()));
updateLiveActivity
.
getChannel
()));
LOG
.
info
(
"直播频道更新名称结果result={}"
,
result
);
LOG
.
info
(
"直播频道更新名称结果result={}"
,
result
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)>=
0
)
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)
>=
0
)
{
updateLiveActivity
.
setTitle
(
title
);
//直播主题
updateLiveActivity
.
setTitle
(
title
);
//直播主题
}
else
{
}
else
{
LOG
.
info
(
"直播频道更新名称 失败"
);
LOG
.
info
(
"直播频道更新名称 失败"
);
return
true
;
return
true
;
}
}
}
}
String
pwd
=
liveActivity
.
getPassword
();
String
pwd
=
liveActivity
.
getPassword
();
if
(
pwd
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
pwd
,
updateLiveActivity
.
getPassword
()))
{
if
(
pwd
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
pwd
,
updateLiveActivity
.
getPassword
()))
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"channelId"
,
updateLiveActivity
.
getChannel
());
params
.
put
(
"channelId"
,
updateLiveActivity
.
getChannel
());
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"passwd"
,
pwd
);
params
.
put
(
"passwd"
,
pwd
);
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_PASSWD_UPDATE
,
UtilConstants
.
APP_USER_ID
));
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_PASSWD_UPDATE
,
UtilConstants
.
APP_USER_ID
));
LOG
.
info
(
"直播频道更新名称结果result={}"
,
result
);
LOG
.
info
(
"直播频道更新名称结果result={}"
,
result
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)>=
0
)
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)
>=
0
)
{
updateLiveActivity
.
setPassword
(
pwd
);
//直播密码
updateLiveActivity
.
setPassword
(
pwd
);
//直播密码
}
else
{
}
else
{
LOG
.
info
(
"直播频道更新密码 失败"
);
LOG
.
info
(
"直播频道更新密码 失败"
);
return
true
;
return
true
;
}
}
}
}
String
logo
=
liveActivity
.
getLogoImage
();
String
logo
=
liveActivity
.
getLogoImage
();
if
(
addFlg
||
(
logo
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
logo
,
updateLiveActivity
.
getLogoImage
())))
{
if
(
addFlg
||
(
logo
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
logo
,
updateLiveActivity
.
getLogoImage
())))
{
updateLiveActivity
.
setLogoImage
(
logo
);
// 直播logo
updateLiveActivity
.
setLogoImage
(
logo
);
// 直播logo
}
}
String
anchor
=
liveActivity
.
getAnchor
();
String
anchor
=
liveActivity
.
getAnchor
();
if
(
addFlg
||
(
anchor
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
anchor
,
updateLiveActivity
.
getAnchor
())))
{
if
(
addFlg
||
(
anchor
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
anchor
,
updateLiveActivity
.
getAnchor
())))
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"channelId"
,
updateLiveActivity
.
getChannel
());
params
.
put
(
"channelId"
,
updateLiveActivity
.
getChannel
());
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"publisher"
,
anchor
);
//主持人姓名,不超过20个字符
params
.
put
(
"publisher"
,
anchor
);
//主持人姓名,不超过20个字符
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_ANCHOR_UPDATE
,
UtilConstants
.
APP_USER_ID
));
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_ANCHOR_UPDATE
,
UtilConstants
.
APP_USER_ID
));
LOG
.
info
(
"直播频道更新主播名字结果result={}"
,
result
);
LOG
.
info
(
"直播频道更新主播名字结果result={}"
,
result
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)>=
0
)
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)
>=
0
)
{
updateLiveActivity
.
setAnchor
(
anchor
);
// 主播名称
updateLiveActivity
.
setAnchor
(
anchor
);
// 主播名称
}
else
{
}
else
{
LOG
.
info
(
"直播频道更新主持人姓名 失败"
);
LOG
.
info
(
"直播频道更新主持人姓名 失败"
);
return
true
;
return
true
;
}
}
...
@@ -643,53 +633,53 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -643,53 +633,53 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Date
startTime
=
liveActivity
.
getStartTime
();
Date
startTime
=
liveActivity
.
getStartTime
();
Date
dbStartTime
=
updateLiveActivity
.
getStartTime
();
Date
dbStartTime
=
updateLiveActivity
.
getStartTime
();
dbStartTime
=
dbStartTime
==
null
?(
new
Date
()):
dbStartTime
;
dbStartTime
=
dbStartTime
==
null
?
(
new
Date
())
:
dbStartTime
;
Date
endTime
=
liveActivity
.
getEndTime
();
Date
endTime
=
liveActivity
.
getEndTime
();
if
(
addFlg
||
(
startTime
!=
null
&&
startTime
.
compareTo
(
dbStartTime
)!=
0
))
{
if
(
addFlg
||
(
startTime
!=
null
&&
startTime
.
compareTo
(
dbStartTime
)
!=
0
))
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
// 之前未设置倒计时直播提示和直播时间的频道号,在开启倒计时开关时,必须提交countTips和startTime
// 之前未设置倒计时直播提示和直播时间的频道号,在开启倒计时开关时,必须提交countTips和startTime
//params.put("countEnabled", "N");
//params.put("countEnabled", "N");
params
.
put
(
"startTime"
,
DateUtil
.
toSeconds
(
startTime
));
params
.
put
(
"startTime"
,
DateUtil
.
toSeconds
(
startTime
));
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_STARTDATE_UPDATE
,
updateLiveActivity
.
getChannel
()));
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_STARTDATE_UPDATE
,
updateLiveActivity
.
getChannel
()));
LOG
.
info
(
"直播频道更新开始时间结果result={}"
,
result
);
LOG
.
info
(
"直播频道更新开始时间结果result={}"
,
result
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)>=
0
)
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)
>=
0
)
{
updateLiveActivity
.
setStartTime
(
startTime
);
//直播开始时间
updateLiveActivity
.
setStartTime
(
startTime
);
//直播开始时间
}
else
{
}
else
{
LOG
.
info
(
"直播频道更新开始时间 失败"
);
LOG
.
info
(
"直播频道更新开始时间 失败"
);
return
true
;
return
true
;
}
}
}
}
if
(
addFlg
||
endTime
!=
null
)
{
if
(
addFlg
||
endTime
!=
null
)
{
updateLiveActivity
.
setEndTime
(
endTime
);
//直播结束时间
updateLiveActivity
.
setEndTime
(
endTime
);
//直播结束时间
}
}
String
desc
=
liveActivity
.
getDescription
();
String
desc
=
liveActivity
.
getDescription
();
if
(
addFlg
||
(
desc
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
desc
,
updateLiveActivity
.
getDescription
())))
{
if
(
addFlg
||
(
desc
!=
null
&&
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
desc
,
updateLiveActivity
.
getDescription
())))
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"content"
,
desc
);
params
.
put
(
"content"
,
desc
);
params
.
put
(
"menuType"
,
"desc"
);
params
.
put
(
"menuType"
,
"desc"
);
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_DESC_UPDATE
,
String
result
=
execPolyvApi
(
params
,
String
.
format
(
UtilConstants
.
CHANNEL_DESC_UPDATE
,
UtilConstants
.
APP_USER_ID
,
updateLiveActivity
.
getChannel
()));
UtilConstants
.
APP_USER_ID
,
updateLiveActivity
.
getChannel
()));
LOG
.
info
(
"直播频道更新说明信息结果result={}"
,
result
);
LOG
.
info
(
"直播频道更新说明信息结果result={}"
,
result
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)>=
0
)
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
result
)
&&
org
.
apache
.
commons
.
lang3
.
StringUtils
.
indexOf
(
result
,
"success"
)
>=
0
)
{
updateLiveActivity
.
setDescription
(
desc
);
//直播介绍
updateLiveActivity
.
setDescription
(
desc
);
//直播介绍
}
else
{
}
else
{
LOG
.
info
(
"直播频道更新说明信息 失败"
);
LOG
.
info
(
"直播频道更新说明信息 失败"
);
return
true
;
return
true
;
}
}
}
}
Integer
scope
=
liveActivity
.
getScope
();
Integer
scope
=
liveActivity
.
getScope
();
if
(
scope
!=
null
)
{
if
(
scope
!=
null
)
{
updateLiveActivity
.
setScope
(
scope
);
updateLiveActivity
.
setScope
(
scope
);
}
}
if
(
liveActivity
.
getEnableRemind
()
!=
null
)
{
if
(
liveActivity
.
getEnableRemind
()
!=
null
)
{
updateLiveActivity
.
setEnableRemind
(
liveActivity
.
getEnableRemind
());
updateLiveActivity
.
setEnableRemind
(
liveActivity
.
getEnableRemind
());
}
}
...
@@ -708,7 +698,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -708,7 +698,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
// 分级授权修改
// 分级授权修改
HQueryUtil
.
startHQ
(
LiveActivity
.
class
);
HQueryUtil
.
startHQ
(
LiveActivity
.
class
);
List
<
PageLiveVo
>
pageLiveVos
=
this
.
baseMapper
.
portalList2
(
title
,
startTime
,
endTime
,
companyId
,
siteId
,
orgId
,
page
);
List
<
PageLiveVo
>
pageLiveVos
=
this
.
baseMapper
.
portalList2
(
title
,
startTime
,
endTime
,
companyId
,
siteId
,
orgId
,
page
);
page
.
setRecords
(
pageLiveVos
);
page
.
setRecords
(
pageLiveVos
);
return
page
;
return
page
;
}
}
...
@@ -723,18 +713,18 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -723,18 +713,18 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
return
this
.
baseMapper
.
portalList
(
title
,
startTime
,
endTime
,
companyId
,
siteId
,
orgId
,
new
RowBounds
(
page
.
getOffset
(),
page
.
getLimit
()));
return
this
.
baseMapper
.
portalList
(
title
,
startTime
,
endTime
,
companyId
,
siteId
,
orgId
,
new
RowBounds
(
page
.
getOffset
(),
page
.
getLimit
()));
}
}
private
Map
<
String
,
String
>
getStringStringMap
(
String
channelIds
)
{
private
static
Map
<
String
,
String
>
getStringStringMap
(
String
channelIds
)
{
Map
<
String
,
String
>
statusMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
statusMap
=
new
HashMap
<
String
,
String
>();
try
{
try
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"appId"
,
UtilConstants
.
APP_ID
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
"channelIds"
,
channelIds
);
params
.
put
(
"channelIds"
,
channelIds
);
String
sign
=
l
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
String
sign
=
L
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"sign"
,
sign
);
String
result
=
l
iveUtil
.
sendHttpPost
(
UtilConstants
.
LIVE_STATUS_URL
,
params
);
String
result
=
L
iveUtil
.
sendHttpPost
(
UtilConstants
.
LIVE_STATUS_URL
,
params
);
if
(
StringUtils
.
isEmpty
(
result
)){
if
(
StringUtils
.
isEmpty
(
result
))
{
LOG
.
warn
(
"获取频道直播状态异常;channelIds ={}"
,
channelIds
);
LOG
.
warn
(
"获取频道直播状态异常;channelIds ={}"
,
channelIds
);
return
statusMap
;
return
statusMap
;
}
}
JSONObject
obj
=
JSON
.
parseObject
(
result
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
...
@@ -752,7 +742,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -752,7 +742,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
return
statusMap
;
return
statusMap
;
}
}
public
String
getRedirectUrl
(){
public
String
getRedirectUrl
()
{
if
(
"dev"
.
equals
(
active
))
{
if
(
"dev"
.
equals
(
active
))
{
return
UtilConstants
.
DEV_LIVE_CUSTOM_URI
;
return
UtilConstants
.
DEV_LIVE_CUSTOM_URI
;
}
else
if
(
"sit"
.
equals
(
active
))
{
}
else
if
(
"sit"
.
equals
(
active
))
{
...
@@ -784,7 +774,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -784,7 +774,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
url
.
append
(
UtilConstants
.
LIVE_CHANNELSETTING_URL
);
url
.
append
(
UtilConstants
.
LIVE_CHANNELSETTING_URL
);
url
.
append
(
UtilConstants
.
APP_USER_ID
);
url
.
append
(
UtilConstants
.
APP_USER_ID
);
url
.
append
(
"/oauth-custom"
);
url
.
append
(
"/oauth-custom"
);
String
result
=
l
iveUtil
.
sendHttpPost
(
url
.
toString
(),
map
);
String
result
=
L
iveUtil
.
sendHttpPost
(
url
.
toString
(),
map
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
JSONObject
obj
=
JSON
.
parseObject
(
result
);
LOG
.
info
(
"channelSetting:"
+
result
);
LOG
.
info
(
"channelSetting:"
+
result
);
...
@@ -825,34 +815,31 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -825,34 +815,31 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
}
}
@Override
@Override
public
VisibleRangeExport
vsibleRangeExport
(
Long
liveId
)
{
public
VisibleRangeExport
vsibleRangeExport
(
Long
liveId
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
VisibleRangeExport
visibleRangeExport
=
new
VisibleRangeExport
();
VisibleRangeExport
visibleRangeExport
=
new
VisibleRangeExport
();
List
<
Long
>
accountIds
=
new
ArrayList
<
Long
>();
List
<
Long
>
accountIds
=
new
ArrayList
<
Long
>();
List
<
Long
>
orgIds
=
new
ArrayList
<
Long
>();
List
<
Long
>
orgIds
=
new
ArrayList
<
Long
>();
LiveActivity
liveActivity
=
liveActivityMapper
.
selectById
(
liveId
);
LiveActivity
liveActivity
=
liveActivityMapper
.
selectById
(
liveId
);
if
(
liveActivity
!=
null
)
{
if
(
liveActivity
!=
null
)
{
visibleRangeExport
.
setBizId
(
liveActivity
.
getId
());
visibleRangeExport
.
setBizId
(
liveActivity
.
getId
());
visibleRangeExport
.
setBizName
(
liveActivity
.
getTitle
());
visibleRangeExport
.
setBizName
(
liveActivity
.
getTitle
());
}
}
List
<
ScopeAuthorization
>
listStudent
=
scopeAuthorizationService
.
listScopeAuthorization
(
liveId
);
List
<
ScopeAuthorization
>
listStudent
=
scopeAuthorizationService
.
listScopeAuthorization
(
liveId
);
if
(
listStudent
!=
null
&&
listStudent
.
size
()>
0
)
{
if
(
listStudent
!=
null
&&
listStudent
.
size
()
>
0
)
{
ScopeAuthorization
scopeAuthorization
=
null
;
ScopeAuthorization
scopeAuthorization
=
null
;
for
(
int
i
=
0
;
i
<
listStudent
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
listStudent
.
size
();
i
++)
{
scopeAuthorization
=
listStudent
.
get
(
i
);
scopeAuthorization
=
listStudent
.
get
(
i
);
if
(
scopeAuthorization
!=
null
&&
scopeAuthorization
.
getType
()!=
null
)
{
if
(
scopeAuthorization
!=
null
&&
scopeAuthorization
.
getType
()
!=
null
)
{
if
(
scopeAuthorization
.
getType
()==
2
)
{
//用户
if
(
scopeAuthorization
.
getType
()
==
2
)
{
//用户
accountIds
.
add
(
scopeAuthorization
.
getAccountId
());
accountIds
.
add
(
scopeAuthorization
.
getAccountId
());
}
}
if
(
scopeAuthorization
.
getType
()==
1
)
{
//部门
if
(
scopeAuthorization
.
getType
()
==
1
)
{
//部门
orgIds
.
add
(
scopeAuthorization
.
getAccountId
());
orgIds
.
add
(
scopeAuthorization
.
getAccountId
());
}
}
}
}
...
@@ -862,11 +849,9 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -862,11 +849,9 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
}
}
LOG
.
info
(
"直播ID:{},直播名字:{}"
,
visibleRangeExport
.
getBizId
(),
visibleRangeExport
.
getBizName
());
LOG
.
info
(
"账号Id:{}"
,
visibleRangeExport
.
getAccountIds
());
LOG
.
info
(
"直播ID:{},直播名字:{}"
,
visibleRangeExport
.
getBizId
(),
visibleRangeExport
.
getBizName
());
LOG
.
info
(
"部门Id:{}"
,
visibleRangeExport
.
getOrgIds
());
LOG
.
info
(
"账号Id:{}"
,
visibleRangeExport
.
getAccountIds
());
LOG
.
info
(
"部门Id:{}"
,
visibleRangeExport
.
getOrgIds
());
return
visibleRangeExport
;
return
visibleRangeExport
;
}
}
...
@@ -912,12 +897,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -912,12 +897,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
public
Page
<
LiveActivity
>
getPageLiveVoListNotIds
(
List
<
Long
>
ids
,
Long
siteId
,
Integer
pageNo
,
Integer
pageSize
)
{
public
Page
<
LiveActivity
>
getPageLiveVoListNotIds
(
List
<
Long
>
ids
,
Long
siteId
,
Integer
pageNo
,
Integer
pageSize
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Page
<
LiveActivity
>
page
=
new
Page
<
LiveActivity
>(
pageNo
,
pageSize
);
Page
<
LiveActivity
>
page
=
new
Page
<
LiveActivity
>(
pageNo
,
pageSize
);
LiveActivity
liveActivity
=
new
LiveActivity
();
LiveActivity
liveActivity
=
new
LiveActivity
();
liveActivity
.
setSiteId
(
siteId
);
liveActivity
.
setSiteId
(
siteId
);
liveActivity
.
setShelves
(
1
);
liveActivity
.
setShelves
(
1
);
EntityWrapper
<
LiveActivity
>
wrapper
=
new
EntityWrapper
<
LiveActivity
>(
liveActivity
);
EntityWrapper
<
LiveActivity
>
wrapper
=
new
EntityWrapper
<
LiveActivity
>(
liveActivity
);
if
(!
CollectionUtils
.
isEmpty
(
ids
))
{
if
(!
CollectionUtils
.
isEmpty
(
ids
))
{
wrapper
.
notIn
(
"id"
,
ids
);
wrapper
.
notIn
(
"id"
,
ids
);
}
}
wrapper
.
orderBy
(
"create_time"
,
false
);
wrapper
.
orderBy
(
"create_time"
,
false
);
...
@@ -928,12 +913,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -928,12 +913,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
Page
<
LiveActivity
>
LiveActivityByIds
(
List
<
Long
>
listIds
,
Integer
pageNo
,
Integer
pageSize
)
{
public
Page
<
LiveActivity
>
LiveActivityByIds
(
List
<
Long
>
listIds
,
Integer
pageNo
,
Integer
pageSize
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Page
<
LiveActivity
>
page
=
new
Page
<
LiveActivity
>(
pageNo
,
pageSize
);
Page
<
LiveActivity
>
page
=
new
Page
<
LiveActivity
>(
pageNo
,
pageSize
);
LiveActivity
liveActivity
=
new
LiveActivity
();
LiveActivity
liveActivity
=
new
LiveActivity
();
liveActivity
.
setShelves
(
1
);
liveActivity
.
setShelves
(
1
);
EntityWrapper
<
LiveActivity
>
wrapper
=
new
EntityWrapper
<
LiveActivity
>(
liveActivity
);
EntityWrapper
<
LiveActivity
>
wrapper
=
new
EntityWrapper
<
LiveActivity
>(
liveActivity
);
wrapper
.
orderBy
(
"create_time"
,
false
);
wrapper
.
orderBy
(
"create_time"
,
false
);
if
(!
CollectionUtils
.
isEmpty
(
listIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
listIds
))
{
wrapper
.
in
(
"id"
,
listIds
);
wrapper
.
in
(
"id"
,
listIds
);
}
}
return
this
.
selectPage
(
page
,
wrapper
);
return
this
.
selectPage
(
page
,
wrapper
);
...
@@ -956,7 +941,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -956,7 +941,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
RequestContext
context
=
ContextHolder
.
get
();
RequestContext
context
=
ContextHolder
.
get
();
Set
<
PageLiveVo
>
set
=
liveActivityMapper
.
queryLiveListByRelationIds
(
relationIds
,
context
.
getSiteId
(),
new
RowBounds
(
page
.
getOffset
(),
page
.
getLimit
()));
Set
<
PageLiveVo
>
set
=
liveActivityMapper
.
queryLiveListByRelationIds
(
relationIds
,
context
.
getSiteId
(),
new
RowBounds
(
page
.
getOffset
(),
page
.
getLimit
()));
List
<
PageLiveVo
>
list
=
new
ArrayList
<>();
List
<
PageLiveVo
>
list
=
new
ArrayList
<>();
list
.
addAll
(
set
);
list
.
addAll
(
set
);
return
list
;
return
list
;
...
@@ -965,21 +950,21 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -965,21 +950,21 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
List
<
Map
<
String
,
Object
>>
getServerByCompanyIdAndIds
(
Long
companyId
,
List
<
Long
>
ids
)
{
public
List
<
Map
<
String
,
Object
>>
getServerByCompanyIdAndIds
(
Long
companyId
,
List
<
Long
>
ids
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
List
<
Map
<
String
,
Object
>>
listMap
=
null
;
List
<
Map
<
String
,
Object
>>
listMap
=
null
;
//查询
//查询
LiveActivity
live
=
new
LiveActivity
();
LiveActivity
live
=
new
LiveActivity
();
live
.
setCompanyId
(
companyId
);
live
.
setCompanyId
(
companyId
);
EntityWrapper
<
LiveActivity
>
wrapper
=
new
EntityWrapper
<
LiveActivity
>(
live
);
EntityWrapper
<
LiveActivity
>
wrapper
=
new
EntityWrapper
<
LiveActivity
>(
live
);
if
(!
CollectionUtils
.
isEmpty
(
ids
))
{
if
(!
CollectionUtils
.
isEmpty
(
ids
))
{
wrapper
.
in
(
"id"
,
ids
);
wrapper
.
in
(
"id"
,
ids
);
}
}
List
<
LiveActivity
>
listLive
=
this
.
selectList
(
wrapper
);
List
<
LiveActivity
>
listLive
=
this
.
selectList
(
wrapper
);
//循环组装到输出对象
//循环组装到输出对象
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
listLive
))
{
if
(!
CollectionUtils
.
isEmpty
(
listLive
))
{
listMap
=
new
ArrayList
<
Map
<
String
,
Object
>>();
listMap
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
LiveActivity
c:
listLive
)
{
for
(
LiveActivity
c
:
listLive
)
{
map
=
new
HashMap
<
String
,
Object
>();
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"catalog"
,
3
);
map
.
put
(
"catalog"
,
3
);
map
.
put
(
"id"
,
c
.
getId
());
map
.
put
(
"id"
,
c
.
getId
());
map
.
put
(
"name"
,
c
.
getTitle
());
map
.
put
(
"name"
,
c
.
getTitle
());
...
@@ -995,8 +980,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -995,8 +980,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Set
<
Long
>
ids
=
null
;
Set
<
Long
>
ids
=
null
;
List
<
Long
>
idList
=
new
ArrayList
<>();
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(!
StringUtils
.
isEmpty
(
relationIds
))
{
if
(!
StringUtils
.
isEmpty
(
relationIds
))
{
ids
=
scopeAuthorizationMapper
.
selectLiveId
(
relationIds
,
siteId
);
//去重
ids
=
scopeAuthorizationMapper
.
selectLiveId
(
relationIds
,
siteId
);
//去重
for
(
Long
a
:
ids
)
{
for
(
Long
a
:
ids
)
{
idList
.
add
(
a
);
idList
.
add
(
a
);
}
}
}
}
...
@@ -1004,7 +989,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1004,7 +989,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
Page
<
PageLiveVo
>
page
=
new
Page
<
PageLiveVo
>(
pageNo
,
pageSize
);
List
<
PageLiveVo
>
liveActivities
=
this
.
baseMapper
.
apiSearchPage
(
idList
,
title
,
siteId
,
companyId
,
page
);
List
<
PageLiveVo
>
liveActivities
=
this
.
baseMapper
.
apiSearchPage
(
idList
,
title
,
siteId
,
companyId
,
page
);
String
channelIds
=
""
;
String
channelIds
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
liveActivities
))
{
if
(!
CollectionUtils
.
isEmpty
(
liveActivities
))
{
for
(
PageLiveVo
liveActivity
:
liveActivities
)
{
for
(
PageLiveVo
liveActivity
:
liveActivities
)
{
if
(
""
.
equals
(
channelIds
))
{
if
(
""
.
equals
(
channelIds
))
{
channelIds
=
liveActivity
.
getChannel
();
channelIds
=
liveActivity
.
getChannel
();
...
@@ -1014,25 +999,25 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1014,25 +999,25 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
}
}
Map
<
String
,
String
>
statusMap
=
getStringStringMap
(
channelIds
);
Map
<
String
,
String
>
statusMap
=
getStringStringMap
(
channelIds
);
liveActivities
.
parallelStream
().
forEach
(
liveActivity
->
{
liveActivities
.
parallelStream
().
forEach
(
liveActivity
->
{
if
(
statusMap
.
containsKey
(
liveActivity
.
getChannel
()))
{
if
(
statusMap
.
containsKey
(
liveActivity
.
getChannel
()))
{
// 直播回放
// 直播回放
LiveStatusV2
status
=
PolyvUtils
.
getLiveStatus
(
liveActivity
.
getChannel
(),
liveActivity
.
getStartTime
(),
liveActivity
.
getEndTime
(),
null
);
LiveStatusV2
status
=
PolyvUtils
.
getLiveStatus
(
liveActivity
.
getChannel
(),
liveActivity
.
getStartTime
(),
liveActivity
.
getEndTime
(),
null
);
liveActivity
.
setStatus
(
String
.
valueOf
(
status
.
getCode
()));
liveActivity
.
setStatus
(
String
.
valueOf
(
status
.
getCode
()));
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
status
.
getCode
())){
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
status
.
getCode
()))
{
//添加直播在学人数
//添加直播在学人数
String
channel
=
liveActivity
.
getChannel
();
String
channel
=
liveActivity
.
getChannel
();
liveActivity
.
setOnlineCount
(
0
);
liveActivity
.
setOnlineCount
(
0
);
try
{
try
{
List
<
LiveOnlineCountVo
>
channelOnlineCountRealTime
=
getChannelOnlineCountRealTime
(
channel
);
List
<
LiveOnlineCountVo
>
channelOnlineCountRealTime
=
getChannelOnlineCountRealTime
(
channel
);
if
(
null
!=
channelOnlineCountRealTime
&&
channelOnlineCountRealTime
.
size
()
>
0
){
if
(
null
!=
channelOnlineCountRealTime
&&
channelOnlineCountRealTime
.
size
()
>
0
)
{
LiveOnlineCountVo
liveOnlineCountVo
=
channelOnlineCountRealTime
.
get
(
0
);
LiveOnlineCountVo
liveOnlineCountVo
=
channelOnlineCountRealTime
.
get
(
0
);
Integer
onlineCountVoCount
=
liveOnlineCountVo
.
getCount
();
Integer
onlineCountVoCount
=
liveOnlineCountVo
.
getCount
();
liveActivity
.
setOnlineCount
(
onlineCountVoCount
);
liveActivity
.
setOnlineCount
(
onlineCountVoCount
);
}
}
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
LOG
.
error
(
"查询直播在学人数异常: channel = {} ,companyId ={} ,siteId = {}"
,
channel
,
companyId
,
siteId
,
e
);
LOG
.
error
(
"查询直播在学人数异常: channel = {} ,companyId ={} ,siteId = {}"
,
channel
,
companyId
,
siteId
,
e
);
}
}
}
}
}
}
...
@@ -1054,12 +1039,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1054,12 +1039,12 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
//根据可见范围获取直播ids
//根据可见范围获取直播ids
List
<
Long
>
trIds
=
new
ArrayList
<>();
List
<
Long
>
trIds
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
context
.
getRelationIds
())){
if
(!
CollectionUtils
.
isEmpty
(
context
.
getRelationIds
()))
{
trIds
=
scopeAuthorizationMapper
.
getUsefulIds
(
ids
,
context
.
getRelationIds
(),
context
.
getSiteId
());
trIds
=
scopeAuthorizationMapper
.
getUsefulIds
(
ids
,
context
.
getRelationIds
(),
context
.
getSiteId
());
}
}
List
<
PageLiveVo
>
liveActivities
=
liveActivityMapper
.
getPageToCalendar
(
null
,
trIds
,
date
,
context
.
getSiteId
(),
page
);
List
<
PageLiveVo
>
liveActivities
=
liveActivityMapper
.
getPageToCalendar
(
null
,
trIds
,
date
,
context
.
getSiteId
(),
page
);
if
(!
CollectionUtils
.
isEmpty
(
liveActivities
)){
if
(!
CollectionUtils
.
isEmpty
(
liveActivities
))
{
liveActivities
=
buildLiveStatus
(
liveActivities
);
liveActivities
=
buildLiveStatus
(
liveActivities
);
}
}
...
@@ -1071,10 +1056,11 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1071,10 +1056,11 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
/**
/**
* 获取直播状态
* 获取直播状态
*
* @param liveActivities
* @param liveActivities
* @return
* @return
*/
*/
public
List
<
PageLiveVo
>
buildLiveStatus
(
List
<
PageLiveVo
>
liveActivities
){
public
List
<
PageLiveVo
>
buildLiveStatus
(
List
<
PageLiveVo
>
liveActivities
)
{
String
channelIds
=
""
;
String
channelIds
=
""
;
for
(
PageLiveVo
liveActivity
:
liveActivities
)
{
for
(
PageLiveVo
liveActivity
:
liveActivities
)
{
...
@@ -1124,19 +1110,19 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1124,19 +1110,19 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
public
List
<
LiveOnlineCountVo
>
getChannelOnlineCountRealTime
(
String
channelIds
)
throws
JsonProcessingException
{
public
List
<
LiveOnlineCountVo
>
getChannelOnlineCountRealTime
(
String
channelIds
)
throws
JsonProcessingException
{
List
<
LiveOnlineCountVo
>
countVoList
=
new
ArrayList
<>();
List
<
LiveOnlineCountVo
>
countVoList
=
new
ArrayList
<>();
if
(
StringUtils
.
isEmpty
(
channelIds
)){
if
(
StringUtils
.
isEmpty
(
channelIds
))
{
LOG
.
warn
(
"查询直播实时在线人数;参数频道id为空"
);
LOG
.
warn
(
"查询直播实时在线人数;参数频道id为空"
);
return
countVoList
;
return
countVoList
;
}
}
//存储获取到的频道-频道在学人数的map
//存储获取到的频道-频道在学人数的map
Map
<
String
,
LiveOnlineCountVo
>
map
=
new
HashMap
<>();
Map
<
String
,
LiveOnlineCountVo
>
map
=
new
HashMap
<>();
//缓存数据到redis 接口请求有限制
//缓存数据到redis 接口请求有限制
String
hKey
=
"live_online_"
;
String
hKey
=
"live_online_"
;
List
<
String
>
noCacheChannelIds
=
new
ArrayList
<>();
List
<
String
>
noCacheChannelIds
=
new
ArrayList
<>();
getRedisCache
(
channelIds
,
map
,
hKey
,
noCacheChannelIds
);
getRedisCache
(
channelIds
,
map
,
hKey
,
noCacheChannelIds
);
if
(
noCacheChannelIds
.
isEmpty
()){
if
(
noCacheChannelIds
.
isEmpty
())
{
//全部命中缓存
//全部命中缓存
map
.
forEach
((
k
,
v
)
->
{
map
.
forEach
((
k
,
v
)
->
{
countVoList
.
add
(
v
);
countVoList
.
add
(
v
);
});
});
LOG
.
info
(
"全部命中缓存"
);
LOG
.
info
(
"全部命中缓存"
);
...
@@ -1146,9 +1132,9 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1146,9 +1132,9 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
String
noCacheChannelIdsStr
=
noCacheChannelIds
.
stream
().
collect
(
Collectors
.
joining
(
","
));
String
noCacheChannelIdsStr
=
noCacheChannelIds
.
stream
().
collect
(
Collectors
.
joining
(
","
));
//组装参数
//组装参数
String
result
=
getOnlineResult
(
noCacheChannelIdsStr
);
String
result
=
getOnlineResult
(
noCacheChannelIdsStr
);
LOG
.
info
(
"批量获取频道实时在线人数;返回结果: {}"
,
result
);
LOG
.
info
(
"批量获取频道实时在线人数;返回结果: {}"
,
result
);
//解析返回结果
//解析返回结果
if
(
StringUtils
.
isEmpty
(
result
)){
if
(
StringUtils
.
isEmpty
(
result
))
{
LOG
.
error
(
"批量获取频道实时在线人数相应值为空!"
);
LOG
.
error
(
"批量获取频道实时在线人数相应值为空!"
);
return
countVoList
;
return
countVoList
;
}
}
...
@@ -1156,30 +1142,30 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1156,30 +1142,30 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
PolyvResponseVo
<
List
<
LiveOnlineCountVo
>>
responseVo
=
mapper
.
readValue
(
result
,
new
TypeReference
<
PolyvResponseVo
<
List
<
LiveOnlineCountVo
>>>()
{});
PolyvResponseVo
<
List
<
LiveOnlineCountVo
>>
responseVo
=
mapper
.
readValue
(
result
,
new
TypeReference
<
PolyvResponseVo
<
List
<
LiveOnlineCountVo
>>>()
{});
int
code
=
responseVo
.
getCode
();
int
code
=
responseVo
.
getCode
();
List
<
LiveOnlineCountVo
>
data
=
responseVo
.
getData
();
List
<
LiveOnlineCountVo
>
data
=
responseVo
.
getData
();
if
(
200
!=
code
||
null
==
data
||
data
.
isEmpty
()){
if
(
200
!=
code
||
null
==
data
||
data
.
isEmpty
())
{
LOG
.
error
(
"批量获取频道实时在线人数失败;结果: {}"
,
result
);
LOG
.
error
(
"批量获取频道实时在线人数失败;结果: {}"
,
result
);
return
countVoList
;
return
countVoList
;
}
}
data
.
forEach
(
liveOnlineCountVo
->
{
data
.
forEach
(
liveOnlineCountVo
->
{
String
channelId
=
liveOnlineCountVo
.
getChannelId
();
String
channelId
=
liveOnlineCountVo
.
getChannelId
();
Integer
onlineCount
=
liveOnlineCountVo
.
getCount
();
Integer
onlineCount
=
liveOnlineCountVo
.
getCount
();
if
(
map
.
containsKey
(
channelId
)){
if
(
map
.
containsKey
(
channelId
))
{
LiveOnlineCountVo
oldVo
=
map
.
get
(
channelId
);
LiveOnlineCountVo
oldVo
=
map
.
get
(
channelId
);
Integer
oldCount
=
oldVo
.
getCount
();
Integer
oldCount
=
oldVo
.
getCount
();
if
(
null
!=
oldCount
&&
oldCount
.
compareTo
(
onlineCount
)
<
0
)
{
if
(
null
!=
oldCount
&&
oldCount
.
compareTo
(
onlineCount
)
<
0
)
{
map
.
put
(
channelId
,
liveOnlineCountVo
);
map
.
put
(
channelId
,
liveOnlineCountVo
);
redisCache
.
set
(
hKey
+
channelId
,
JSONObject
.
toJSONString
(
liveOnlineCountVo
),
20
);
redisCache
.
set
(
hKey
+
channelId
,
JSONObject
.
toJSONString
(
liveOnlineCountVo
),
20
);
//LOG.info("放入缓存");
//LOG.info("放入缓存");
}
}
}
else
{
}
else
{
map
.
put
(
channelId
,
liveOnlineCountVo
);
map
.
put
(
channelId
,
liveOnlineCountVo
);
//放入缓存
//放入缓存
redisCache
.
set
(
hKey
+
channelId
,
JSONObject
.
toJSONString
(
liveOnlineCountVo
),
20
);
redisCache
.
set
(
hKey
+
channelId
,
JSONObject
.
toJSONString
(
liveOnlineCountVo
),
20
);
//LOG.info("放入缓存");
//LOG.info("放入缓存");
}
}
});
});
map
.
forEach
((
k
,
v
)
->
{
map
.
forEach
((
k
,
v
)
->
{
countVoList
.
add
(
v
);
countVoList
.
add
(
v
);
});
});
return
countVoList
;
return
countVoList
;
...
@@ -1187,6 +1173,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1187,6 +1173,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
/**
/**
* 获取在线人数请求
* 获取在线人数请求
*
* @param channelIds 频道id;多个用逗号隔开
* @param channelIds 频道id;多个用逗号隔开
* @return 返回结果
* @return 返回结果
*/
*/
...
@@ -1195,14 +1182,15 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1195,14 +1182,15 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
params
.
put
(
PolyvReqEnum
.
APP_ID
.
getName
(),
UtilConstants
.
APP_ID
);
params
.
put
(
PolyvReqEnum
.
APP_ID
.
getName
(),
UtilConstants
.
APP_ID
);
params
.
put
(
PolyvReqEnum
.
TIMESTAMP
.
getName
(),
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
PolyvReqEnum
.
TIMESTAMP
.
getName
(),
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
PolyvReqEnum
.
CHANNEL_IDS
.
getName
(),
channelIds
);
params
.
put
(
PolyvReqEnum
.
CHANNEL_IDS
.
getName
(),
channelIds
);
String
sign
=
l
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
String
sign
=
L
iveUtil
.
generateSign
(
params
,
UtilConstants
.
APP_SECRET
);
params
.
put
(
PolyvReqEnum
.
SIGN
.
getName
(),
sign
);
params
.
put
(
PolyvReqEnum
.
SIGN
.
getName
(),
sign
);
LOG
.
info
(
"批量获取频道实时在线人数;请求入参: {}"
,
params
);
LOG
.
info
(
"批量获取频道实时在线人数;请求入参: {}"
,
params
);
return
l
iveUtil
.
sendHttpPost
(
UtilConstants
.
LIVE_STATISTICS_BATCH_COUNT
,
params
);
return
L
iveUtil
.
sendHttpPost
(
UtilConstants
.
LIVE_STATISTICS_BATCH_COUNT
,
params
);
}
}
/**
/**
* 获取缓存中的频道在学人数
* 获取缓存中的频道在学人数
*
* @param channelIds 通道ids
* @param channelIds 通道ids
* @param map 频道-LiveOnlineCountVo
* @param map 频道-LiveOnlineCountVo
* @param hKey redis key
* @param hKey redis key
...
@@ -1211,17 +1199,17 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1211,17 +1199,17 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
private
void
getRedisCache
(
String
channelIds
,
Map
<
String
,
LiveOnlineCountVo
>
map
,
String
hKey
,
List
<
String
>
noCacheChannelIds
)
{
private
void
getRedisCache
(
String
channelIds
,
Map
<
String
,
LiveOnlineCountVo
>
map
,
String
hKey
,
List
<
String
>
noCacheChannelIds
)
{
String
[]
split
=
channelIds
.
split
(
","
);
String
[]
split
=
channelIds
.
split
(
","
);
for
(
String
channel
:
split
)
{
for
(
String
channel
:
split
)
{
if
(
StringUtils
.
isEmpty
(
channel
)){
if
(
StringUtils
.
isEmpty
(
channel
))
{
continue
;
continue
;
}
}
String
strValue
=
(
String
)
redisCache
.
get
(
hKey
+
channel
);
String
strValue
=
(
String
)
redisCache
.
get
(
hKey
+
channel
);
if
(
StringUtils
.
isEmpty
(
strValue
)){
if
(
StringUtils
.
isEmpty
(
strValue
))
{
noCacheChannelIds
.
add
(
channel
);
noCacheChannelIds
.
add
(
channel
);
continue
;
continue
;
}
}
LiveOnlineCountVo
liveOnlineCountVo
=
JSONObject
.
parseObject
(
strValue
,
LiveOnlineCountVo
.
class
);
LiveOnlineCountVo
liveOnlineCountVo
=
JSONObject
.
parseObject
(
strValue
,
LiveOnlineCountVo
.
class
);
if
(
null
!=
liveOnlineCountVo
){
if
(
null
!=
liveOnlineCountVo
)
{
map
.
put
(
channel
,
liveOnlineCountVo
);
map
.
put
(
channel
,
liveOnlineCountVo
);
continue
;
continue
;
}
}
noCacheChannelIds
.
add
(
channel
);
noCacheChannelIds
.
add
(
channel
);
...
@@ -1234,21 +1222,21 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1234,21 +1222,21 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
//校验验签sign
//校验验签sign
String
signSource
=
new
StringBuffer
().
append
(
secret
).
append
(
timestamp
).
toString
();
String
signSource
=
new
StringBuffer
().
append
(
secret
).
append
(
timestamp
).
toString
();
String
ourSign
=
org
.
apache
.
commons
.
codec
.
digest
.
DigestUtils
.
md5Hex
(
signSource
);
String
ourSign
=
org
.
apache
.
commons
.
codec
.
digest
.
DigestUtils
.
md5Hex
(
signSource
);
LOG
.
info
(
"直播状态修改回调参数:channelId = {} ,sign = {},timestamp={}, 校验的生成规则为md5(AppSecret+timestamp):ourSign={}"
,
channelId
,
sign
,
timestamp
,
ourSign
);
LOG
.
info
(
"直播状态修改回调参数:channelId = {} ,sign = {},timestamp={}, 校验的生成规则为md5(AppSecret+timestamp):ourSign={}"
,
channelId
,
sign
,
timestamp
,
ourSign
);
if
(!
sign
.
equalsIgnoreCase
(
ourSign
)){
if
(!
sign
.
equalsIgnoreCase
(
ourSign
))
{
LOG
.
warn
(
"直播状态修改回调验签不通过!"
);
LOG
.
warn
(
"直播状态修改回调验签不通过!"
);
return
BizResponse
.
fail
(
"直播状态修改回调验签不通过"
);
return
BizResponse
.
fail
(
"直播状态修改回调验签不通过"
);
}
}
LiveActivity
select
=
new
LiveActivity
();
LiveActivity
select
=
new
LiveActivity
();
select
.
setChannel
(
channelId
);
select
.
setChannel
(
channelId
);
LiveActivity
activity
=
baseMapper
.
selectOne
(
select
);
LiveActivity
activity
=
baseMapper
.
selectOne
(
select
);
if
(
null
==
activity
)
{
if
(
null
==
activity
)
{
LOG
.
error
(
"保利威直播状态回调,根据频道号没有查询到对应的直播channelId={}"
,
channelId
);
LOG
.
error
(
"保利威直播状态回调,根据频道号没有查询到对应的直播channelId={}"
,
channelId
);
return
BizResponse
.
fail
(
"没有找到频道"
);
return
BizResponse
.
fail
(
"没有找到频道"
);
}
}
if
(
PolyvReqEnum
.
LIVE
.
getName
().
equals
(
status
)){
if
(
PolyvReqEnum
.
LIVE
.
getName
().
equals
(
status
))
{
activity
.
setStatus
(
LiveStatusEnum
.
LIVE
.
getCode
());
activity
.
setStatus
(
LiveStatusEnum
.
LIVE
.
getCode
());
}
else
if
(
PolyvReqEnum
.
END
.
getName
().
equals
(
status
))
{
}
else
if
(
PolyvReqEnum
.
END
.
getName
().
equals
(
status
))
{
activity
.
setStatus
(
LiveStatusEnum
.
END
.
getCode
());
activity
.
setStatus
(
LiveStatusEnum
.
END
.
getCode
());
}
}
//修改直播状态
//修改直播状态
...
@@ -1259,7 +1247,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1259,7 +1247,7 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
BizResponse
livebackCallback
(
PolyvLiveBackCallbackVo
liveBackCallbackVo
)
{
public
BizResponse
livebackCallback
(
PolyvLiveBackCallbackVo
liveBackCallbackVo
)
{
String
channelId
=
liveBackCallbackVo
.
getChannelId
();
String
channelId
=
liveBackCallbackVo
.
getChannelId
();
if
(
StringUtils
.
isEmpty
(
channelId
)){
if
(
StringUtils
.
isEmpty
(
channelId
))
{
LOG
.
error
(
"保利威直播回放完成回调接口:通道channelId 为空;"
);
LOG
.
error
(
"保利威直播回放完成回调接口:通道channelId 为空;"
);
return
BizResponse
.
fail
(
"保利威直播回放完成回调接口:通道channelId 为空;"
);
return
BizResponse
.
fail
(
"保利威直播回放完成回调接口:通道channelId 为空;"
);
}
}
...
@@ -1267,8 +1255,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1267,8 +1255,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
liveActivity
.
setChannel
(
channelId
);
liveActivity
.
setChannel
(
channelId
);
EntityWrapper
wrapper
=
new
EntityWrapper
(
liveActivity
);
EntityWrapper
wrapper
=
new
EntityWrapper
(
liveActivity
);
List
<
LiveActivity
>
list
=
baseMapper
.
selectList
(
wrapper
);
List
<
LiveActivity
>
list
=
baseMapper
.
selectList
(
wrapper
);
if
(
null
==
list
||
list
.
isEmpty
()){
if
(
null
==
list
||
list
.
isEmpty
())
{
LOG
.
error
(
"保利威直播回放完成回调接口,根据频道号没有查询到对应的直播channelId={}"
,
channelId
);
LOG
.
error
(
"保利威直播回放完成回调接口,根据频道号没有查询到对应的直播channelId={}"
,
channelId
);
return
BizResponse
.
fail
(
"没有找到频道"
);
return
BizResponse
.
fail
(
"没有找到频道"
);
}
}
for
(
LiveActivity
activity
:
list
)
{
for
(
LiveActivity
activity
:
list
)
{
...
@@ -1278,19 +1266,19 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1278,19 +1266,19 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
params
.
put
(
PolyvReqEnum
.
APP_ID
.
getName
(),
UtilConstants
.
APP_ID
);
params
.
put
(
PolyvReqEnum
.
APP_ID
.
getName
(),
UtilConstants
.
APP_ID
);
params
.
put
(
PolyvReqEnum
.
TIMESTAMP
.
getName
(),
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
PolyvReqEnum
.
TIMESTAMP
.
getName
(),
System
.
currentTimeMillis
()
+
""
);
params
.
put
(
PolyvReqEnum
.
CHANNEL_ID
.
getName
(),
channelId
);
params
.
put
(
PolyvReqEnum
.
CHANNEL_ID
.
getName
(),
channelId
);
PolyvResponseVo
<
String
>
polyvResponseVO
=
PolyvUtils
.
execPolyvApi
(
null
,
params
,
UtilConstants
.
LIVE_BACK_SWITCH_GET
,
RequestMethod
.
GET
);
PolyvResponseVo
<
String
>
polyvResponseVO
=
PolyvUtils
.
execPolyvApi
(
null
,
params
,
UtilConstants
.
LIVE_BACK_SWITCH_GET
,
RequestMethod
.
GET
);
LOG
.
info
(
"保利威直播回放完成回调接口,获取直播回放开关状态结果:{}"
,
JSONObject
.
toJSONString
(
polyvResponseVO
));
LOG
.
info
(
"保利威直播回放完成回调接口,获取直播回放开关状态结果:{}"
,
JSONObject
.
toJSONString
(
polyvResponseVO
));
if
(
null
==
polyvResponseVO
||
200
!=
polyvResponseVO
.
getCode
()){
if
(
null
==
polyvResponseVO
||
200
!=
polyvResponseVO
.
getCode
())
{
LOG
.
error
(
"保利威直播回放完成回调接口,获取直播回放开关状态失败"
,
channelId
);
LOG
.
error
(
"保利威直播回放完成回调接口,获取直播回放开关状态失败"
,
channelId
);
return
BizResponse
.
fail
(
"获取直播回放开关状态失败"
);
return
BizResponse
.
fail
(
"获取直播回放开关状态失败"
);
}
}
String
data
=
polyvResponseVO
.
getData
();
String
data
=
polyvResponseVO
.
getData
();
if
(
StringUtils
.
isEmpty
(
data
)
||
"N"
.
equals
(
data
)){
if
(
StringUtils
.
isEmpty
(
data
)
||
"N"
.
equals
(
data
))
{
continue
;
continue
;
}
}
//查询保利威直播回放;
//查询保利威直播回放;
List
<
LiveReplay
>
channelReplay
=
PolyvUtils
.
getChannelReplay
(
channelId
);
List
<
LiveReplay
>
channelReplay
=
PolyvUtils
.
getChannelReplay
(
channelId
);
if
(
null
==
channelReplay
||
channelReplay
.
isEmpty
()){
if
(
null
==
channelReplay
||
channelReplay
.
isEmpty
())
{
continue
;
continue
;
}
}
//新增回放
//新增回放
...
@@ -1300,14 +1288,14 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1300,14 +1288,14 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
query
.
setVideoPoolId
(
videoPoolId
);
query
.
setVideoPoolId
(
videoPoolId
);
EntityWrapper
<
LiveReplay
>
ew
=
new
EntityWrapper
<>(
query
);
EntityWrapper
<
LiveReplay
>
ew
=
new
EntityWrapper
<>(
query
);
List
<
LiveReplay
>
replayList
=
liveReplayMapper
.
selectList
(
ew
);
List
<
LiveReplay
>
replayList
=
liveReplayMapper
.
selectList
(
ew
);
if
(
null
!=
replayList
&&
replayList
.
size
()
>
0
){
if
(
null
!=
replayList
&&
replayList
.
size
()
>
0
)
{
for
(
LiveReplay
replay
:
replayList
)
{
for
(
LiveReplay
replay
:
replayList
)
{
Long
id
=
replay
.
getId
();
Long
id
=
replay
.
getId
();
copyLiveProperties
(
liveReplay
,
replay
,
activity
);
copyLiveProperties
(
liveReplay
,
replay
,
activity
);
replay
.
setId
(
id
);
replay
.
setId
(
id
);
liveReplayMapper
.
updateById
(
replay
);
liveReplayMapper
.
updateById
(
replay
);
}
}
}
else
{
}
else
{
liveReplay
.
setCompanyId
(
activity
.
getCompanyId
());
liveReplay
.
setCompanyId
(
activity
.
getCompanyId
());
liveReplay
.
setSiteId
(
activity
.
getSiteId
());
liveReplay
.
setSiteId
(
activity
.
getSiteId
());
liveReplay
.
setLivePlanStartAt
(
activity
.
getStartTime
());
liveReplay
.
setLivePlanStartAt
(
activity
.
getStartTime
());
...
@@ -1368,24 +1356,24 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1368,24 +1356,24 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
RequestContext
context
=
replayLivesReq
.
getRequestContext
();
RequestContext
context
=
replayLivesReq
.
getRequestContext
();
int
pageNo
=
replayLivesReq
.
getPageNo
();
int
pageNo
=
replayLivesReq
.
getPageNo
();
int
pageSize
=
replayLivesReq
.
getPageSize
();
int
pageSize
=
replayLivesReq
.
getPageSize
();
if
(
pageNo
==
0
||
pageSize
==
0
){
if
(
pageNo
==
0
||
pageSize
==
0
)
{
pageNo
=
1
;
pageNo
=
1
;
pageSize
=
Integer
.
MAX_VALUE
;
pageSize
=
Integer
.
MAX_VALUE
;
}
}
Page
<
LiveTitleVo
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
Page
<
LiveTitleVo
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
try
{
try
{
//获取开启直播回放开关的直播间id
//获取开启直播回放开关的直播间id
List
<
Long
>
liveIds
=
getReplayOnLiveIds
(
context
);
List
<
Long
>
liveIds
=
getReplayOnLiveIds
(
context
);
if
(
null
==
liveIds
||
liveIds
.
isEmpty
()){
if
(
null
==
liveIds
||
liveIds
.
isEmpty
())
{
LOG
.
error
(
"获取全部可见的回放开关开启上架直播列表id为空. companyId = {} , siteId = {} , accountId = {} ."
LOG
.
error
(
"获取全部可见的回放开关开启上架直播列表id为空. companyId = {} , siteId = {} , accountId = {} ."
,
context
.
getCompanyCode
(),
context
.
getSiteId
(),
context
.
getAccountId
());
,
context
.
getCompanyCode
(),
context
.
getSiteId
(),
context
.
getAccountId
());
return
page
;
return
page
;
}
}
List
<
LiveTitleVo
>
liveTitleVos
=
liveReplayMapper
.
selectHashReviewLiveList
(
liveIds
,
context
.
getCompanyId
(),
context
.
getSiteId
(),
page
);
List
<
LiveTitleVo
>
liveTitleVos
=
liveReplayMapper
.
selectHashReviewLiveList
(
liveIds
,
context
.
getCompanyId
(),
context
.
getSiteId
(),
page
);
page
.
setRecords
(
liveTitleVos
);
page
.
setRecords
(
liveTitleVos
);
return
page
;
return
page
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"获取直播回放的直播间异常,companyId = {} , siteId = {} , accountId = {} . 错误信息如下:"
,
context
.
getCompanyCode
(),
context
.
getSiteId
(),
context
.
getAccountId
(),
e
);
LOG
.
error
(
"获取直播回放的直播间异常,companyId = {} , siteId = {} , accountId = {} . 错误信息如下:"
,
context
.
getCompanyCode
(),
context
.
getSiteId
(),
context
.
getAccountId
(),
e
);
}
}
return
page
;
return
page
;
}
}
...
@@ -1393,14 +1381,14 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1393,14 +1381,14 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
List
<
Long
>
getReplayOnLiveIds
(
RequestContext
context
)
{
public
List
<
Long
>
getReplayOnLiveIds
(
RequestContext
context
)
{
List
<
Long
>
relationIds
=
context
.
getRelationIds
();
List
<
Long
>
relationIds
=
context
.
getRelationIds
();
if
(
null
==
relationIds
){
if
(
null
==
relationIds
)
{
relationIds
=
new
ArrayList
<>();
relationIds
=
new
ArrayList
<>();
}
}
relationIds
.
add
(
context
.
getAccountId
());
relationIds
.
add
(
context
.
getAccountId
());
//获取指定用户可见的直播id
//获取指定用户可见的直播id
List
<
Long
>
authLiveIds
=
scopeAuthorizationMapper
.
selectLiveIdByRelationId
(
relationIds
);
List
<
Long
>
authLiveIds
=
scopeAuthorizationMapper
.
selectLiveIdByRelationId
(
relationIds
);
//获取全部可见的回放开关开启上架直播
//获取全部可见的回放开关开启上架直播
return
scopeAuthorizationMapper
.
selectReplayOnLiveIds
(
authLiveIds
,
context
.
getCompanyId
(),
context
.
getSiteId
());
return
scopeAuthorizationMapper
.
selectReplayOnLiveIds
(
authLiveIds
,
context
.
getCompanyId
(),
context
.
getSiteId
());
}
}
@Override
@Override
...
@@ -1408,30 +1396,30 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1408,30 +1396,30 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
int
pageNo
=
liveReviewsVo
.
getPageNo
();
int
pageNo
=
liveReviewsVo
.
getPageNo
();
int
pageSize
=
liveReviewsVo
.
getPageSize
();
int
pageSize
=
liveReviewsVo
.
getPageSize
();
Page
<
LiveReplayVo
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
Page
<
LiveReplayVo
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
Long
liveId
=
liveReviewsVo
.
getLiveId
();
Long
liveId
=
liveReviewsVo
.
getLiveId
();
RequestContext
context
=
liveReviewsVo
.
getRequestContext
();
RequestContext
context
=
liveReviewsVo
.
getRequestContext
();
if
(
null
==
liveId
){
if
(
null
==
liveId
)
{
LOG
.
error
(
"获取直播下所有直播回放列表,liveId is null ;accountId = {} , siteId = {}"
,
context
.
getAccountId
(),
context
.
getSiteId
());
LOG
.
error
(
"获取直播下所有直播回放列表,liveId is null ;accountId = {} , siteId = {}"
,
context
.
getAccountId
(),
context
.
getSiteId
());
return
page
;
return
page
;
}
}
LiveActivity
activity
=
liveActivityMapper
.
selectById
(
liveId
);
LiveActivity
activity
=
liveActivityMapper
.
selectById
(
liveId
);
if
(
null
==
activity
){
if
(
null
==
activity
)
{
LOG
.
error
(
"获取直播下所有直播回放列表;根据liveId = {} 未查询到直播信息;accountId = {} , siteId = {}"
,
liveId
,
context
.
getAccountId
(),
context
.
getSiteId
());
LOG
.
error
(
"获取直播下所有直播回放列表;根据liveId = {} 未查询到直播信息;accountId = {} , siteId = {}"
,
liveId
,
context
.
getAccountId
(),
context
.
getSiteId
());
return
page
;
return
page
;
}
}
String
logoImage
=
activity
.
getLogoImage
();
String
logoImage
=
activity
.
getLogoImage
();
List
<
LiveReplayVo
>
replayVoList
=
liveReplayMapper
.
selectReplayListByLiveId
(
liveId
,
page
);
List
<
LiveReplayVo
>
replayVoList
=
liveReplayMapper
.
selectReplayListByLiveId
(
liveId
,
page
);
if
(
null
==
replayVoList
||
replayVoList
.
isEmpty
()){
if
(
null
==
replayVoList
||
replayVoList
.
isEmpty
())
{
return
page
;
return
page
;
}
}
replayVoList
.
parallelStream
().
forEach
(
replayVo
->
{
replayVoList
.
parallelStream
().
forEach
(
replayVo
->
{
String
liveLogoUrl
=
replayVo
.
getLiveLogoUrl
();
String
liveLogoUrl
=
replayVo
.
getLiveLogoUrl
();
replayVo
.
setLiveTitle
(
activity
.
getTitle
());
replayVo
.
setLiveTitle
(
activity
.
getTitle
());
replayVo
.
setLiveDefaultLogoUrl
(
logoImage
);
replayVo
.
setLiveDefaultLogoUrl
(
logoImage
);
if
(!
StringUtils
.
isEmpty
(
logoImage
)
&&
logoImage
.
equals
(
liveLogoUrl
)){
if
(!
StringUtils
.
isEmpty
(
logoImage
)
&&
logoImage
.
equals
(
liveLogoUrl
))
{
replayVo
.
setDefaultLogo
(
true
);
replayVo
.
setDefaultLogo
(
true
);
}
else
{
}
else
{
replayVo
.
setDefaultLogo
(
false
);
replayVo
.
setDefaultLogo
(
false
);
}
}
});
});
...
@@ -1441,20 +1429,20 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1441,20 +1429,20 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
Boolean
updateReplayStatus
(
Long
replayId
,
Boolean
operation
)
{
public
Boolean
updateReplayStatus
(
Long
replayId
,
Boolean
operation
)
{
if
(
null
==
replayId
||
null
==
operation
){
if
(
null
==
replayId
||
null
==
operation
)
{
LOG
.
error
(
"直播回放上架、下架失败. replayId = {} ,top ={}"
,
replayId
,
operation
);
LOG
.
error
(
"直播回放上架、下架失败. replayId = {} ,top ={}"
,
replayId
,
operation
);
return
false
;
return
false
;
}
}
LiveReplay
liveReplay
=
liveReplayMapper
.
selectById
(
replayId
);
LiveReplay
liveReplay
=
liveReplayMapper
.
selectById
(
replayId
);
if
(
null
==
liveReplay
){
if
(
null
==
liveReplay
)
{
LOG
.
error
(
"直播回放上架、下架失败. 未查询到replayId = {} 的直播回放"
,
replayId
);
LOG
.
error
(
"直播回放上架、下架失败. 未查询到replayId = {} 的直播回放"
,
replayId
);
return
false
;
return
false
;
}
}
liveReplay
.
setLiveReplayStatus
(
operation
);
liveReplay
.
setLiveReplayStatus
(
operation
);
try
{
try
{
liveReplayMapper
.
updateById
(
liveReplay
);
liveReplayMapper
.
updateById
(
liveReplay
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"直播回放上架、下架异常: "
,
e
);
LOG
.
error
(
"直播回放上架、下架异常: "
,
e
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -1462,24 +1450,24 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1462,24 +1450,24 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
Boolean
updateReplayTop
(
Long
replayId
,
Boolean
top
)
{
public
Boolean
updateReplayTop
(
Long
replayId
,
Boolean
top
)
{
if
(
null
==
replayId
||
null
==
top
){
if
(
null
==
replayId
||
null
==
top
)
{
LOG
.
error
(
"直播回放置顶、取消置顶失败. replayId = {} ,top ={}"
,
replayId
,
top
);
LOG
.
error
(
"直播回放置顶、取消置顶失败. replayId = {} ,top ={}"
,
replayId
,
top
);
return
false
;
return
false
;
}
}
LiveReplay
liveReplay
=
liveReplayMapper
.
selectById
(
replayId
);
LiveReplay
liveReplay
=
liveReplayMapper
.
selectById
(
replayId
);
if
(
null
==
liveReplay
){
if
(
null
==
liveReplay
)
{
LOG
.
error
(
"直播回放置顶、取消置顶失败. 未查询到replayId = {} 的直播回放"
,
replayId
);
LOG
.
error
(
"直播回放置顶、取消置顶失败. 未查询到replayId = {} 的直播回放"
,
replayId
);
return
false
;
return
false
;
}
}
if
(
top
){
if
(
top
)
{
liveReplay
.
setTopTime
(
new
Date
());
liveReplay
.
setTopTime
(
new
Date
());
}
else
{
}
else
{
liveReplay
.
setTopTime
(
null
);
liveReplay
.
setTopTime
(
null
);
}
}
try
{
try
{
liveReplayMapper
.
updateTopTime
(
liveReplay
.
getId
(),
liveReplay
.
getTopTime
());
liveReplayMapper
.
updateTopTime
(
liveReplay
.
getId
(),
liveReplay
.
getTopTime
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"直播回放置顶、取消置顶异常: "
,
e
);
LOG
.
error
(
"直播回放置顶、取消置顶异常: "
,
e
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -1488,44 +1476,44 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1488,44 +1476,44 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
@Override
@Override
public
Boolean
updateReplayInfos
(
LiveReplayInfoVo
infoVo
)
{
public
Boolean
updateReplayInfos
(
LiveReplayInfoVo
infoVo
)
{
Long
replayId
=
infoVo
.
getReplayId
();
Long
replayId
=
infoVo
.
getReplayId
();
if
(
null
==
replayId
){
if
(
null
==
replayId
)
{
LOG
.
error
(
"直播回放编辑信息失败,回放id为空.infoVo = {} "
,
JSONObject
.
toJSONString
(
infoVo
));
LOG
.
error
(
"直播回放编辑信息失败,回放id为空.infoVo = {} "
,
JSONObject
.
toJSONString
(
infoVo
));
return
false
;
return
false
;
}
}
try
{
try
{
LiveReplay
liveReplay
=
liveReplayMapper
.
selectById
(
replayId
);
LiveReplay
liveReplay
=
liveReplayMapper
.
selectById
(
replayId
);
if
(
null
==
liveReplay
){
if
(
null
==
liveReplay
)
{
LOG
.
error
(
"直播回放编辑信息失败失败. 未查询到replayId = {} 的直播回放"
,
replayId
);
LOG
.
error
(
"直播回放编辑信息失败失败. 未查询到replayId = {} 的直播回放"
,
replayId
);
return
false
;
return
false
;
}
}
Boolean
defaultLogo
=
infoVo
.
getDefaultLogo
();
Boolean
defaultLogo
=
infoVo
.
getDefaultLogo
();
if
(
null
!=
defaultLogo
&&
defaultLogo
){
if
(
null
!=
defaultLogo
&&
defaultLogo
)
{
//使用本身图片
//使用本身图片
Long
liveId
=
liveReplay
.
getLiveId
();
Long
liveId
=
liveReplay
.
getLiveId
();
LiveActivity
activity
=
liveActivityMapper
.
selectById
(
liveId
);
LiveActivity
activity
=
liveActivityMapper
.
selectById
(
liveId
);
if
(
null
==
activity
){
if
(
null
==
activity
)
{
LOG
.
error
(
"直播回放编辑信息失败失败. 未查询到replayId = {} ,liveId = {} 的直播"
,
replayId
,
liveId
);
LOG
.
error
(
"直播回放编辑信息失败失败. 未查询到replayId = {} ,liveId = {} 的直播"
,
replayId
,
liveId
);
return
false
;
return
false
;
}
}
liveReplay
.
setLiveLogoUrl
(
activity
.
getLogoImage
());
liveReplay
.
setLiveLogoUrl
(
activity
.
getLogoImage
());
}
else
{
}
else
{
String
replayLogoUrl
=
infoVo
.
getReplayLogoUrl
();
String
replayLogoUrl
=
infoVo
.
getReplayLogoUrl
();
if
(
StringUtils
.
isEmpty
(
replayLogoUrl
)){
if
(
StringUtils
.
isEmpty
(
replayLogoUrl
))
{
LOG
.
error
(
"直播回放编辑信息失败失败. replayId = {} 的直播回放,上传图片路径为空"
,
JSONObject
.
toJSONString
(
infoVo
));
LOG
.
error
(
"直播回放编辑信息失败失败. replayId = {} 的直播回放,上传图片路径为空"
,
JSONObject
.
toJSONString
(
infoVo
));
return
false
;
return
false
;
}
}
liveReplay
.
setLiveLogoUrl
(
replayLogoUrl
);
liveReplay
.
setLiveLogoUrl
(
replayLogoUrl
);
}
}
String
anchor
=
infoVo
.
getAnchor
();
String
anchor
=
infoVo
.
getAnchor
();
if
(
StringUtils
.
isEmpty
(
anchor
)){
if
(
StringUtils
.
isEmpty
(
anchor
))
{
LOG
.
error
(
"直播回放编辑信息失败失败. replayId = {} 的直播回放,主播名为空"
,
JSONObject
.
toJSONString
(
infoVo
));
LOG
.
error
(
"直播回放编辑信息失败失败. replayId = {} 的直播回放,主播名为空"
,
JSONObject
.
toJSONString
(
infoVo
));
return
false
;
return
false
;
}
}
liveReplay
.
setLiveAnchor
(
anchor
);
liveReplay
.
setLiveAnchor
(
anchor
);
liveReplay
.
setImageDesc
(
infoVo
.
getImageDesc
());
liveReplay
.
setImageDesc
(
infoVo
.
getImageDesc
());
liveReplayMapper
.
updateById
(
liveReplay
);
liveReplayMapper
.
updateById
(
liveReplay
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"直播回放编辑信息异常: "
,
e
);
LOG
.
error
(
"直播回放编辑信息异常: "
,
e
);
return
false
;
return
false
;
}
}
...
@@ -1537,30 +1525,30 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1537,30 +1525,30 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
Long
liveId
=
liveReviewsVo
.
getLiveId
();
Long
liveId
=
liveReviewsVo
.
getLiveId
();
RequestContext
context
=
liveReviewsVo
.
getRequestContext
();
RequestContext
context
=
liveReviewsVo
.
getRequestContext
();
List
<
LiveReplayVo
>
replayVoList
=
new
ArrayList
<>();
List
<
LiveReplayVo
>
replayVoList
=
new
ArrayList
<>();
if
(
null
==
liveId
){
if
(
null
==
liveId
)
{
LOG
.
error
(
"查询直播间下的直播回放列表;直播id为空!accountId = {},companyId ={},siteId={}"
,
context
.
getAccountId
(),
context
.
getCompanyId
(),
context
.
getSiteId
());
LOG
.
error
(
"查询直播间下的直播回放列表;直播id为空!accountId = {},companyId ={},siteId={}"
,
context
.
getAccountId
(),
context
.
getCompanyId
(),
context
.
getSiteId
());
return
BizResponse
.
ok
(
replayVoList
);
return
BizResponse
.
ok
(
replayVoList
);
}
}
LiveActivity
activity
=
liveActivityMapper
.
selectById
(
liveId
);
LiveActivity
activity
=
liveActivityMapper
.
selectById
(
liveId
);
if
(
null
==
activity
){
if
(
null
==
activity
)
{
LOG
.
error
(
"查询直播间回放列表;未查询到直播信息: liveId = {},siteId = {}"
,
liveId
,
context
.
getSiteId
());
LOG
.
error
(
"查询直播间回放列表;未查询到直播信息: liveId = {},siteId = {}"
,
liveId
,
context
.
getSiteId
());
return
BizResponse
.
ok
(
replayVoList
);
return
BizResponse
.
ok
(
replayVoList
);
}
}
LiveReplay
liveReplay
=
new
LiveReplay
();
LiveReplay
liveReplay
=
new
LiveReplay
();
liveReplay
.
setLiveId
(
liveId
);
liveReplay
.
setLiveId
(
liveId
);
liveReplay
.
setLiveReplayStatus
(
true
);
liveReplay
.
setLiveReplayStatus
(
true
);
EntityWrapper
<
LiveReplay
>
wrapper
=
new
EntityWrapper
<>(
liveReplay
);
EntityWrapper
<
LiveReplay
>
wrapper
=
new
EntityWrapper
<>(
liveReplay
);
wrapper
.
orderBy
(
"top_time"
,
false
);
wrapper
.
orderBy
(
"top_time"
,
false
);
wrapper
.
orderBy
(
"start_time"
,
false
);
wrapper
.
orderBy
(
"start_time"
,
false
);
List
<
LiveReplay
>
liveReplays
=
liveReplayMapper
.
selectList
(
wrapper
);
List
<
LiveReplay
>
liveReplays
=
liveReplayMapper
.
selectList
(
wrapper
);
if
(
null
==
liveReplays
||
liveReplays
.
isEmpty
()){
if
(
null
==
liveReplays
||
liveReplays
.
isEmpty
())
{
LOG
.
info
(
"查询直播间liveId ={}的直播回放列表为空;accountId = {},companyId ={},siteId={}"
,
liveId
,
context
.
getAccountId
(),
context
.
getCompanyId
(),
context
.
getSiteId
());
LOG
.
info
(
"查询直播间liveId ={}的直播回放列表为空;accountId = {},companyId ={},siteId={}"
,
liveId
,
context
.
getAccountId
(),
context
.
getCompanyId
(),
context
.
getSiteId
());
return
BizResponse
.
ok
(
replayVoList
);
return
BizResponse
.
ok
(
replayVoList
);
}
}
liveReplays
.
forEach
(
replay
->
{
liveReplays
.
forEach
(
replay
->
{
LiveReplayVo
replayVo
=
new
LiveReplayVo
();
LiveReplayVo
replayVo
=
new
LiveReplayVo
();
BeanUtils
.
copyProperties
(
replay
,
replayVo
);
BeanUtils
.
copyProperties
(
replay
,
replayVo
);
replayVo
.
setViewType
(
activity
.
getViewType
());
replayVo
.
setViewType
(
activity
.
getViewType
());
replayVoList
.
add
(
replayVo
);
replayVoList
.
add
(
replayVo
);
});
});
...
@@ -1572,8 +1560,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1572,8 +1560,8 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
String
channelId
=
liveBackCallbackVo
.
getChannelId
();
String
channelId
=
liveBackCallbackVo
.
getChannelId
();
String
sign
=
liveBackCallbackVo
.
getSign
();
String
sign
=
liveBackCallbackVo
.
getSign
();
long
timestamp
=
liveBackCallbackVo
.
getTimestamp
();
long
timestamp
=
liveBackCallbackVo
.
getTimestamp
();
LOG
.
info
(
"转播回放成功;保利威回调参数: channelId = {},sign= {},timestamp={}"
,
channelId
,
sign
,
timestamp
);
LOG
.
info
(
"转播回放成功;保利威回调参数: channelId = {},sign= {},timestamp={}"
,
channelId
,
sign
,
timestamp
);
if
(
StringUtils
.
isEmpty
(
channelId
)
||
StringUtils
.
isEmpty
(
sign
)){
if
(
StringUtils
.
isEmpty
(
channelId
)
||
StringUtils
.
isEmpty
(
sign
))
{
LOG
.
error
(
"视频转存回调接口,保利威回调入参;频道号为空;验签为空"
);
LOG
.
error
(
"视频转存回调接口,保利威回调入参;频道号为空;验签为空"
);
return
BizResponse
.
fail
(
"channelId is null"
);
return
BizResponse
.
fail
(
"channelId is null"
);
}
}
...
@@ -1581,22 +1569,22 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1581,22 +1569,22 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
//校验验签sign
//校验验签sign
String
signSource
=
new
StringBuffer
().
append
(
secret
).
append
(
timestamp
).
toString
();
String
signSource
=
new
StringBuffer
().
append
(
secret
).
append
(
timestamp
).
toString
();
String
ourSign
=
org
.
apache
.
commons
.
codec
.
digest
.
DigestUtils
.
md5Hex
(
signSource
);
String
ourSign
=
org
.
apache
.
commons
.
codec
.
digest
.
DigestUtils
.
md5Hex
(
signSource
);
LOG
.
info
(
"转播回放成功;保利威回调参数:sign = {},timestamp={}, 校验的生成规则为md5(AppSecret+timestamp):ourSign={}"
,
sign
,
timestamp
,
ourSign
);
LOG
.
info
(
"转播回放成功;保利威回调参数:sign = {},timestamp={}, 校验的生成规则为md5(AppSecret+timestamp):ourSign={}"
,
sign
,
timestamp
,
ourSign
);
if
(!
sign
.
equalsIgnoreCase
(
ourSign
)){
if
(!
sign
.
equalsIgnoreCase
(
ourSign
))
{
LOG
.
warn
(
"转播回放成功回调验签不通过!"
);
LOG
.
warn
(
"转播回放成功回调验签不通过!"
);
return
BizResponse
.
fail
(
"转播回放成功回调验签不通过"
);
return
BizResponse
.
fail
(
"转播回放成功回调验签不通过"
);
}
}
LiveActivity
select
=
new
LiveActivity
();
LiveActivity
select
=
new
LiveActivity
();
select
.
setChannel
(
channelId
);
select
.
setChannel
(
channelId
);
LiveActivity
activity
=
baseMapper
.
selectOne
(
select
);
LiveActivity
activity
=
baseMapper
.
selectOne
(
select
);
if
(
null
==
activity
){
if
(
null
==
activity
)
{
LOG
.
error
(
"保利威视频转存回调接口,根据频道号没有查询到对应的直播channelId={}"
,
channelId
);
LOG
.
error
(
"保利威视频转存回调接口,根据频道号没有查询到对应的直播channelId={}"
,
channelId
);
return
BizResponse
.
fail
(
"没有找到频道"
);
return
BizResponse
.
fail
(
"没有找到频道"
);
}
}
activity
.
setReplayCallbackStatus
(
true
);
activity
.
setReplayCallbackStatus
(
true
);
//查询保利威直播回放;
//查询保利威直播回放;
List
<
LiveReplay
>
channelReplay
=
PolyvUtils
.
getChannelReplay
(
channelId
);
List
<
LiveReplay
>
channelReplay
=
PolyvUtils
.
getChannelReplay
(
channelId
);
if
(
null
==
channelReplay
||
channelReplay
.
isEmpty
()){
if
(
null
==
channelReplay
||
channelReplay
.
isEmpty
())
{
return
BizResponse
.
ok
();
return
BizResponse
.
ok
();
}
}
// 查询本地数据库的channel下的回放列表 alist
// 查询本地数据库的channel下的回放列表 alist
...
@@ -1611,13 +1599,13 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1611,13 +1599,13 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
for
(
LiveReplay
liveReplay
:
channelReplay
)
{
for
(
LiveReplay
liveReplay
:
channelReplay
)
{
String
videoPoolId
=
liveReplay
.
getVideoPoolId
();
String
videoPoolId
=
liveReplay
.
getVideoPoolId
();
LiveReplay
oldReplay
=
replayService
.
getByVideoPoolId
(
videoPoolId
);
LiveReplay
oldReplay
=
replayService
.
getByVideoPoolId
(
videoPoolId
);
if
(
null
!=
oldReplay
)
{
if
(
null
!=
oldReplay
)
{
//修改
//修改
Long
id
=
oldReplay
.
getId
();
Long
id
=
oldReplay
.
getId
();
copyLiveProperties
(
liveReplay
,
oldReplay
,
activity
);
copyLiveProperties
(
liveReplay
,
oldReplay
,
activity
);
oldReplay
.
setId
(
id
);
oldReplay
.
setId
(
id
);
liveReplayMapper
.
updateById
(
oldReplay
);
liveReplayMapper
.
updateById
(
oldReplay
);
}
else
{
}
else
{
//新增
//新增
liveReplay
.
setId
(
idGenerator
.
generate
());
liveReplay
.
setId
(
idGenerator
.
generate
());
liveReplay
.
setCompanyId
(
activity
.
getCompanyId
());
liveReplay
.
setCompanyId
(
activity
.
getCompanyId
());
...
@@ -1631,18 +1619,18 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1631,18 +1619,18 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
liveReplay
.
setLiveLogoUrl
(
activity
.
getLogoImage
());
liveReplay
.
setLiveLogoUrl
(
activity
.
getLogoImage
());
try
{
try
{
liveReplayMapper
.
insert
(
liveReplay
);
liveReplayMapper
.
insert
(
liveReplay
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
warn
(
"新增直播回放异常;channelId = "
+
channelId
+
" ,videoPoolId = "
+
videoPoolId
+
" ;"
,
e
);
LOG
.
warn
(
"新增直播回放异常;channelId = "
+
channelId
+
" ,videoPoolId = "
+
videoPoolId
+
" ;"
,
e
);
}
}
}
}
}
}
//删除保利威删除但是数据库未删除的回放记录
//删除保利威删除但是数据库未删除的回放记录
if
(
delReplayIdList
.
size
()
>
0
){
if
(
delReplayIdList
.
size
()
>
0
)
{
try
{
try
{
liveReplayMapper
.
deleteReplayBatch
(
delReplayIdList
);
liveReplayMapper
.
deleteReplayBatch
(
delReplayIdList
);
LOG
.
info
(
"直播回放转存回调,删除数据库多余记录{}条"
,
delReplayIdList
.
size
());
LOG
.
info
(
"直播回放转存回调,删除数据库多余记录{}条"
,
delReplayIdList
.
size
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"直播回放转存回调,删除数据库多余记录异常; "
,
e
);
LOG
.
error
(
"直播回放转存回调,删除数据库多余记录异常; "
,
e
);
}
}
}
}
...
@@ -1651,15 +1639,16 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1651,15 +1639,16 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
/**
/**
* 获取数据库要删除的回放记录
* 获取数据库要删除的回放记录
*
* @param polyvVideoPoolIdList 保利威的视频回放回调 key=vidPoolId
* @param polyvVideoPoolIdList 保利威的视频回放回调 key=vidPoolId
* @param channelOldReplayList 数据库中channel存在的回放视频
* @param channelOldReplayList 数据库中channel存在的回放视频
*/
*/
private
List
<
Long
>
getdelReplayList
(
List
<
String
>
polyvVideoPoolIdList
,
List
<
LiveReplay
>
channelOldReplayList
)
{
private
List
<
Long
>
getdelReplayList
(
List
<
String
>
polyvVideoPoolIdList
,
List
<
LiveReplay
>
channelOldReplayList
)
{
List
<
Long
>
delReplayIdList
=
new
ArrayList
<>();
List
<
Long
>
delReplayIdList
=
new
ArrayList
<>();
if
(
null
!=
channelOldReplayList
&&
!
channelOldReplayList
.
isEmpty
()){
if
(
null
!=
channelOldReplayList
&&
!
channelOldReplayList
.
isEmpty
())
{
channelOldReplayList
.
parallelStream
().
forEach
(
liveReplay
->
{
channelOldReplayList
.
parallelStream
().
forEach
(
liveReplay
->
{
String
videoPoolId
=
liveReplay
.
getVideoPoolId
();
String
videoPoolId
=
liveReplay
.
getVideoPoolId
();
if
(!
polyvVideoPoolIdList
.
contains
(
videoPoolId
)){
if
(!
polyvVideoPoolIdList
.
contains
(
videoPoolId
))
{
//需要删除的记录
//需要删除的记录
delReplayIdList
.
add
(
liveReplay
.
getId
());
delReplayIdList
.
add
(
liveReplay
.
getId
());
}
}
...
@@ -1685,10 +1674,10 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
...
@@ -1685,10 +1674,10 @@ public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, Liv
liveActivity
.
setCompanyId
(
companyId
);
liveActivity
.
setCompanyId
(
companyId
);
liveActivity
.
setShelves
(
1
);
liveActivity
.
setShelves
(
1
);
EntityWrapper
wrapper
=
new
EntityWrapper
(
liveActivity
);
EntityWrapper
wrapper
=
new
EntityWrapper
(
liveActivity
);
wrapper
.
setSqlSelect
(
"distinct("
+
field
+
"),"
+
"id "
)
wrapper
.
setSqlSelect
(
"distinct("
+
field
+
"),"
+
"id "
)
.
isNotNull
(
field
)
.
isNotNull
(
field
)
.
like
(
field
,
value
)
.
like
(
field
,
value
)
.
addFilter
(
field
+
"!=''"
)
.
addFilter
(
field
+
"!=''"
)
.
orderBy
(
"create_time"
,
false
);
.
orderBy
(
"create_time"
,
false
);
String
upperField
=
ClassUtil
.
getFieldName
(
field
);
String
upperField
=
ClassUtil
.
getFieldName
(
field
);
...
...
cloud-live-service/src/main/java/com/yizhi/live/application/util/LiveUtil.java
View file @
ad8c4089
...
@@ -19,11 +19,7 @@ import java.util.*;
...
@@ -19,11 +19,7 @@ import java.util.*;
@Component
@Component
public
class
LiveUtil
{
public
class
LiveUtil
{
private
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
15000
).
setConnectTimeout
(
15000
)
public
static
String
sendHttpPost
(
String
httpUrl
,
Map
<
String
,
String
>
maps
)
{
.
setConnectionRequestTimeout
(
15000
).
build
();
public
String
sendHttpPost
(
String
httpUrl
,
Map
<
String
,
String
>
maps
)
{
HttpPost
httpPost
=
new
HttpPost
(
httpUrl
);
HttpPost
httpPost
=
new
HttpPost
(
httpUrl
);
List
<
NameValuePair
>
nameValuePairs
=
new
ArrayList
<
NameValuePair
>();
List
<
NameValuePair
>
nameValuePairs
=
new
ArrayList
<
NameValuePair
>();
...
@@ -38,14 +34,14 @@ public class LiveUtil {
...
@@ -38,14 +34,14 @@ public class LiveUtil {
return
sendHttpPost
(
httpPost
);
return
sendHttpPost
(
httpPost
);
}
}
private
String
sendHttpPost
(
HttpPost
httpPost
)
{
private
static
String
sendHttpPost
(
HttpPost
httpPost
)
{
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
CloseableHttpResponse
response
=
null
;
HttpEntity
entity
=
null
;
HttpEntity
entity
=
null
;
String
responseContent
=
null
;
String
responseContent
=
null
;
try
{
try
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setConfig
(
RequestConfig
.
custom
().
setSocketTimeout
(
15000
).
setConnectTimeout
(
15000
).
setConnectionRequestTimeout
(
15000
).
build
()
);
response
=
httpClient
.
execute
(
httpPost
);
response
=
httpClient
.
execute
(
httpPost
);
entity
=
response
.
getEntity
();
entity
=
response
.
getEntity
();
responseContent
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
responseContent
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
...
@@ -66,16 +62,16 @@ public class LiveUtil {
...
@@ -66,16 +62,16 @@ public class LiveUtil {
return
responseContent
;
return
responseContent
;
}
}
public
String
generateSign
(
Map
<
String
,
String
>
parray
,
String
secretKey
)
{
public
static
String
generateSign
(
Map
<
String
,
String
>
parray
,
String
secretKey
)
{
Map
<
String
,
String
>
params
=
this
.
paraFilter
(
parray
);
Map
<
String
,
String
>
params
=
paraFilter
(
parray
);
String
concatedStr
=
this
.
concatParams
(
params
);
String
concatedStr
=
concatParams
(
params
);
String
plain
=
secretKey
+
concatedStr
+
secretKey
;
String
plain
=
secretKey
+
concatedStr
+
secretKey
;
String
encrypted
=
MD5Utils
.
getMD5String
(
plain
);
String
encrypted
=
MD5Utils
.
getMD5String
(
plain
);
String
upperCase
=
encrypted
.
toUpperCase
();
String
upperCase
=
encrypted
.
toUpperCase
();
return
upperCase
;
return
upperCase
;
}
}
private
Map
<
String
,
String
>
paraFilter
(
Map
<
String
,
String
>
sArray
)
{
private
static
Map
<
String
,
String
>
paraFilter
(
Map
<
String
,
String
>
sArray
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
if
(
sArray
==
null
||
sArray
.
size
()
<=
0
)
{
if
(
sArray
==
null
||
sArray
.
size
()
<=
0
)
{
return
result
;
return
result
;
...
@@ -91,7 +87,7 @@ public class LiveUtil {
...
@@ -91,7 +87,7 @@ public class LiveUtil {
return
result
;
return
result
;
}
}
private
String
concatParams
(
Map
<
String
,
String
>
params
)
{
private
static
String
concatParams
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
Collections
.
sort
(
keys
);
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
...
cloud-live-service/src/main/java/com/yizhi/live/application/util/PolyvUtils.java
View file @
ad8c4089
...
@@ -66,10 +66,12 @@ public class PolyvUtils {
...
@@ -66,10 +66,12 @@ public class PolyvUtils {
public
static
LiveStatusV2
getLiveStatus
(
String
channelId
,
Date
startAt
,
Date
endAt
,
Integer
liveStatus
)
{
public
static
LiveStatusV2
getLiveStatus
(
String
channelId
,
Date
startAt
,
Date
endAt
,
Integer
liveStatus
)
{
// 直播中
// 直播中
if
(
null
!=
liveStatus
&&
liveStatus
.
equals
(
LiveStatusEnum
.
LIVE
.
getCode
()))
{
if
(
null
!=
liveStatus
&&
liveStatus
.
equals
(
LiveStatusEnum
.
LIVE
.
getCode
()))
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----1"
);
return
LiveStatusV2
.
RUNNING
;
return
LiveStatusV2
.
RUNNING
;
}
}
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
getThirdLiveStatus
(
channelId
)))
{
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
getThirdLiveStatus
(
channelId
)))
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----2"
);
return
LiveStatusV2
.
RUNNING
;
return
LiveStatusV2
.
RUNNING
;
}
}
...
@@ -77,15 +79,19 @@ public class PolyvUtils {
...
@@ -77,15 +79,19 @@ public class PolyvUtils {
// 未开始
// 未开始
if
(
startAt
.
getTime
()
>
currentTime
)
{
if
(
startAt
.
getTime
()
>
currentTime
)
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----3"
);
return
LiveStatusV2
.
UN_START
;
return
LiveStatusV2
.
UN_START
;
}
}
Integer
count
=
getCountByChannel
(
channelId
,
startAt
,
new
Date
(
currentTime
));
Integer
count
=
getCountByChannel
(
channelId
,
startAt
,
new
Date
(
currentTime
));
if
(
count
>
0
)
{
if
(
count
>
0
)
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----4"
);
return
LiveStatusV2
.
REPLAY
;
return
LiveStatusV2
.
REPLAY
;
}
}
if
(
count
<=
0
&&
currentTime
>
endAt
.
getTime
())
{
if
(
count
<=
0
&&
currentTime
>
endAt
.
getTime
())
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----5"
);
return
LiveStatusV2
.
END
;
return
LiveStatusV2
.
END
;
}
}
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----6"
);
return
LiveStatusV2
.
UN_START
;
return
LiveStatusV2
.
UN_START
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment