Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
ea0c8eb4
Commit
ea0c8eb4
authored
Jun 04, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.视频增加默认图片在连接不上及为进行接入时,前端轮播使用
parent
a43d629b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
29 deletions
+87
-29
CommonVideoEnum.java
.../amos/boot/module/cylinder/api/enums/CommonVideoEnum.java
+2
-1
CylinderUnitVideoServiceImpl.java
...er/flc/biz/service/impl/CylinderUnitVideoServiceImpl.java
+85
-28
No files found.
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/java/com/yeejoin/amos/boot/module/cylinder/api/enums/CommonVideoEnum.java
View file @
ea0c8eb4
...
@@ -14,7 +14,8 @@ import lombok.Getter;
...
@@ -14,7 +14,8 @@ import lombok.Getter;
@AllArgsConstructor
@AllArgsConstructor
public
enum
CommonVideoEnum
{
public
enum
CommonVideoEnum
{
HLS
(
"2"
,
"hls"
);
HLS
(
"2"
,
"hls"
),
IMG
(
"3"
,
"img"
);
private
String
code
;
private
String
code
;
private
String
name
;
private
String
name
;
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/biz/service/impl/CylinderUnitVideoServiceImpl.java
View file @
ea0c8eb4
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
service
.
impl
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.module.cylinder.api.enums.CommonVideoEnum
;
import
com.yeejoin.amos.boot.module.cylinder.api.enums.CommonVideoEnum
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CommonVideoDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CommonVideoDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitVideoDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitVideoDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnitVideo
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnitVideo
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderUnitVideoMapper
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderUnitVideoMapper
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderUnitVideoService
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderUnitVideoService
;
import
cn.hutool.http.HttpUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -38,54 +41,63 @@ public class CylinderUnitVideoServiceImpl extends BaseService<CylinderUnitVideoD
...
@@ -38,54 +41,63 @@ public class CylinderUnitVideoServiceImpl extends BaseService<CylinderUnitVideoD
private
static
final
String
CODE_49999
=
"49999"
;
private
static
final
String
CODE_49999
=
"49999"
;
private
static
final
String
CODE_201
=
"201"
;
private
static
final
String
CODE_201
=
"201"
;
private
static
final
String
CODE_401
=
"401"
;
private
static
final
String
CODE_401
=
"401"
;
private
static
final
String
CODE_403
=
"403"
;
private
static
final
String
CODE_403
=
"403"
;
private
static
final
String
CODE_404
=
"404"
;
private
static
final
String
CODE_404
=
"404"
;
private
static
final
String
CODE_20001
=
"20001"
;
private
static
final
String
CODE_20001
=
"20001"
;
@Value
(
"${cylinder.video.default.image.url:/upload/tzs/cylinder/no-connect.png}"
)
private
String
defaultVideoUrl
;
@Autowired
CylinderUnitServiceImpl
cylinderUnitService
;
@Override
@Override
public
List
<
CommonVideoDto
>
getUnitVideoUrl
(
String
unitSeq
)
{
public
List
<
CommonVideoDto
>
getUnitVideoUrl
(
String
unitSeq
)
{
List
<
CommonVideoDto
>
result
=
new
ArrayList
<
CommonVideoDto
>();
List
<
CommonVideoDto
>
result
=
new
ArrayList
<
CommonVideoDto
>();
LambdaQueryWrapper
<
CylinderUnitVideo
>
wrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
CylinderUnitVideo
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
CylinderUnitVideo:
:
getUnitSeq
,
unitSeq
);
wrapper
.
eq
(
CylinderUnitVideo:
:
getUnitSeq
,
unitSeq
);
CylinderUnitVideo
cylinderUnitVideo
=
this
.
getBaseMapper
().
selectOne
(
wrapper
);
CylinderUnitVideo
cylinderUnitVideo
=
this
.
getBaseMapper
().
selectOne
(
wrapper
);
if
(
null
!=
cylinderUnitVideo
)
{
if
(
null
!=
cylinderUnitVideo
)
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"appKey"
,
cylinderUnitVideo
.
getAppKey
());
requestInfo
.
put
(
"appKey"
,
cylinderUnitVideo
.
getAppKey
());
requestInfo
.
put
(
"appSecret"
,
cylinderUnitVideo
.
getAppSecret
());
requestInfo
.
put
(
"appSecret"
,
cylinderUnitVideo
.
getAppSecret
());
String
channelNos
=
cylinderUnitVideo
.
getChannelNo
();
List
<
CommonVideoDto
>
channelNoList
=
JSONObject
.
parseArray
(
channelNos
,
CommonVideoDto
.
class
);
try
{
try
{
String
accessTokenData
=
HttpUtil
.
post
(
cylinderUnitVideo
.
getTokenUrl
(),
requestInfo
);
String
accessTokenData
=
HttpUtil
.
post
(
cylinderUnitVideo
.
getTokenUrl
(),
requestInfo
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
accessTokenData
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
accessTokenData
);
String
msg
=
jsonObject
.
get
(
"msg"
).
toString
();
String
msg
=
jsonObject
.
get
(
"msg"
).
toString
();
String
code
=
jsonObject
.
get
(
"code"
).
toString
();
String
code
=
jsonObject
.
get
(
"code"
).
toString
();
if
(
CODE_10001
.
equals
(
code
)
||
CODE_10005
.
equals
(
code
)
||
CODE_10017
.
equals
(
code
)
||
CODE_10030
.
equals
(
code
)
||
CODE_49999
.
equals
(
code
)){
if
(
CODE_10001
.
equals
(
code
)
||
CODE_10005
.
equals
(
code
)
||
CODE_10017
.
equals
(
code
)
||
CODE_10030
.
equals
(
code
)
||
CODE_49999
.
equals
(
code
))
{
String
errorMsg
=
"code:"
+
code
+
"msg:"
+
msg
+
"appKey:"
+
cylinderUnitVideo
.
getAppKey
()+
"appSecret:"
+
cylinderUnitVideo
.
getAppSecret
();
String
errorMsg
=
"code:"
+
code
+
"msg:"
+
msg
+
"appKey:"
+
cylinderUnitVideo
.
getAppKey
()
+
"appSecret:"
+
cylinderUnitVideo
.
getAppSecret
();
logger
.
info
(
"视频token获取失败errorMsg"
,
errorMsg
);
logger
.
info
(
"视频token获取失败errorMsg"
,
errorMsg
);
this
.
setDefaultVideoIfConnectFailed
(
channelNoList
,
result
);
return
result
;
return
result
;
}
}
if
(
CODE_200
.
equals
(
code
))
{
if
(
CODE_200
.
equals
(
code
))
{
String
data
=
jsonObject
.
get
(
"data"
).
toString
();
String
data
=
jsonObject
.
get
(
"data"
).
toString
();
JSONObject
objTokenJson
=
JSON
.
parseObject
(
data
);
JSONObject
objTokenJson
=
JSON
.
parseObject
(
data
);
String
accessToken
=
objTokenJson
.
get
(
"accessToken"
).
toString
();
String
accessToken
=
objTokenJson
.
get
(
"accessToken"
).
toString
();
System
.
out
.
println
(
accessToken
);
System
.
out
.
println
(
accessToken
);
String
channelNos
=
cylinderUnitVideo
.
getChannelNo
();
List
<
CommonVideoDto
>
channelNoList
=
JSONObject
.
parseArray
(
channelNos
,
CommonVideoDto
.
class
);
// List<String> channelNoList = Arrays.asList(channelNos.split(","));
for
(
CommonVideoDto
channelNo
:
channelNoList
)
{
for
(
CommonVideoDto
channelNo
:
channelNoList
)
{
HashMap
<
String
,
Object
>
requestVideosInfo
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
requestVideosInfo
=
new
HashMap
<>();
requestVideosInfo
.
put
(
"accessToken"
,
accessToken
);
requestVideosInfo
.
put
(
"accessToken"
,
accessToken
);
requestVideosInfo
.
put
(
"deviceSerial"
,
cylinderUnitVideo
.
getDeviceSerial
());
requestVideosInfo
.
put
(
"deviceSerial"
,
cylinderUnitVideo
.
getDeviceSerial
());
requestVideosInfo
.
put
(
"channelNo"
,
channelNo
.
getKey
());
requestVideosInfo
.
put
(
"channelNo"
,
channelNo
.
getKey
());
requestVideosInfo
.
put
(
"protocol"
,
cylinderUnitVideo
.
getProtocol
());
requestVideosInfo
.
put
(
"protocol"
,
cylinderUnitVideo
.
getProtocol
());
requestVideosInfo
.
put
(
"expireTime"
,
cylinderUnitVideo
.
getExpireTime
());
requestVideosInfo
.
put
(
"expireTime"
,
cylinderUnitVideo
.
getExpireTime
());
String
videoData
=
HttpUtil
.
post
(
cylinderUnitVideo
.
getUrl
(),
requestVideosInfo
);
String
videoData
=
HttpUtil
.
post
(
cylinderUnitVideo
.
getUrl
(),
requestVideosInfo
);
JSONObject
videoJsonObject
=
JSON
.
parseObject
(
videoData
);
JSONObject
videoJsonObject
=
JSON
.
parseObject
(
videoData
);
String
msgVideo
=
videoJsonObject
.
get
(
"msg"
).
toString
();
String
msgVideo
=
videoJsonObject
.
get
(
"msg"
).
toString
();
String
codeVideo
=
videoJsonObject
.
get
(
"code"
).
toString
();
String
codeVideo
=
videoJsonObject
.
get
(
"code"
).
toString
();
if
(
CODE_201
.
equals
(
codeVideo
)
||
CODE_401
.
equals
(
codeVideo
)
||
CODE_403
.
equals
(
codeVideo
)
||
CODE_404
.
equals
(
codeVideo
)
||
CODE_20001
.
equals
(
codeVideo
)){
if
(
CODE_201
.
equals
(
codeVideo
)
||
CODE_401
.
equals
(
codeVideo
)
||
CODE_403
.
equals
(
codeVideo
)
||
CODE_404
.
equals
(
codeVideo
)
||
CODE_20001
.
equals
(
codeVideo
))
{
String
errorMsg
=
"code:"
+
codeVideo
+
"msg:"
+
msgVideo
+
"appKey:"
+
cylinderUnitVideo
.
getAppKey
()+
"appSecret:"
+
cylinderUnitVideo
.
getAppSecret
()+
"accessToken:"
+
accessToken
;
String
errorMsg
=
"code:"
+
codeVideo
+
"msg:"
+
msgVideo
+
"appKey:"
+
cylinderUnitVideo
.
getAppKey
()
+
"appSecret:"
+
cylinderUnitVideo
.
getAppSecret
()
+
"accessToken:"
+
accessToken
;
logger
.
info
(
"视频地址获取失败errorMsg"
,
errorMsg
);
logger
.
info
(
"视频地址获取失败errorMsg"
,
errorMsg
);
this
.
setDefaultChannelData
(
result
,
channelNo
);
continue
;
}
}
if
(
CODE_200
.
equals
(
codeVideo
))
{
if
(
CODE_200
.
equals
(
codeVideo
))
{
String
dataS
=
videoJsonObject
.
get
(
"data"
).
toString
();
String
dataS
=
videoJsonObject
.
get
(
"data"
).
toString
();
JSONObject
dd
=
JSON
.
parseObject
(
dataS
);
JSONObject
dd
=
JSON
.
parseObject
(
dataS
);
String
url
=
dd
.
get
(
"url"
).
toString
();
String
url
=
dd
.
get
(
"url"
).
toString
();
...
@@ -99,11 +111,55 @@ public class CylinderUnitVideoServiceImpl extends BaseService<CylinderUnitVideoD
...
@@ -99,11 +111,55 @@ public class CylinderUnitVideoServiceImpl extends BaseService<CylinderUnitVideoD
}
}
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
e
.
printStackTrace
(
);
this
.
setDefaultVideoIfConnectFailed
(
channelNoList
,
result
);
}
}
}
else
{
this
.
setDefaultVideoIfNoAccess
(
result
,
unitSeq
);
}
}
return
result
;
return
result
;
}
}
/**
* 通道连接不上时,返回通道的默认图片
*
* @param result 返回连接的总通道
* @param channelNo 未连接的通道
*/
private
void
setDefaultChannelData
(
List
<
CommonVideoDto
>
result
,
CommonVideoDto
channelNo
)
{
CommonVideoDto
commonVideoDto
=
new
CommonVideoDto
();
commonVideoDto
.
setUrl
(
""
);
commonVideoDto
.
setKey
(
channelNo
.
getKey
());
commonVideoDto
.
setType
(
CommonVideoEnum
.
IMG
.
getName
());
commonVideoDto
.
setTitle
(
channelNo
.
getTitle
());
commonVideoDto
.
setThumb
(
channelNo
.
getThumb
());
result
.
add
(
commonVideoDto
);
}
/**
* 连接不上时返回的气通道信息
*
* @param commonVideoDtos 当前气瓶单位的所有通道
* @param result 返回的结果集合
*/
private
void
setDefaultVideoIfConnectFailed
(
List
<
CommonVideoDto
>
commonVideoDtos
,
List
<
CommonVideoDto
>
result
)
{
// 先情况防止数据重复
result
.
clear
();
// 每个通道设备默认值
commonVideoDtos
.
forEach
(
channelNo
->
this
.
setDefaultChannelData
(
result
,
channelNo
));
}
private
void
setDefaultVideoIfNoAccess
(
List
<
CommonVideoDto
>
result
,
String
unitSeq
)
{
CylinderUnit
cylinderUnit
=
cylinderUnitService
.
getBaseMapper
().
selectOne
(
new
LambdaQueryWrapper
<
CylinderUnit
>().
eq
(
CylinderUnit:
:
getAppId
,
unitSeq
));
CommonVideoDto
commonVideoDto
=
new
CommonVideoDto
();
commonVideoDto
.
setUrl
(
""
);
commonVideoDto
.
setKey
(
UUID
.
fastUUID
().
toString
());
commonVideoDto
.
setType
(
CommonVideoEnum
.
IMG
.
getName
());
if
(
cylinderUnit
!=
null
){
commonVideoDto
.
setTitle
(
cylinderUnit
.
getUnitName
());
}
commonVideoDto
.
setThumb
(
defaultVideoUrl
);
result
.
add
(
commonVideoDto
);
}
}
}
\ No newline at end of file
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