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
e270fcc2
Commit
e270fcc2
authored
Oct 10, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.视频弹框接口联调修改
parent
015d2ae8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
46 deletions
+59
-46
CommonVideoDto.java
.../com/yeejoin/amos/boot/biz/common/dto/CommonVideoDto.java
+14
-0
BaseEnterpriseVideoServiceImpl.java
...mmon/biz/service/impl/BaseEnterpriseVideoServiceImpl.java
+29
-30
UnitVideoDto.java
...oin/amos/boot/module/statistics/api/dto/UnitVideoDto.java
+1
-2
VideoController.java
...boot/module/statistcs/biz/controller/VideoController.java
+5
-5
VideoServiceImpl.java
...t/module/statistcs/biz/service/impl/VideoServiceImpl.java
+10
-9
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/dto/CommonVideoDto.java
View file @
e270fcc2
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
dto
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
/**
* @author Administrator
*/
@Data
@ApiModel
(
value
=
"CommonVideoDto"
,
description
=
"通用视频信息"
)
public
class
CommonVideoDto
{
...
...
@@ -12,10 +16,20 @@ public class CommonVideoDto {
private
String
type
;
/**
* 列表时摄像头的名称,查询摄像头列表时要显示,故必须有此字段
*/
@JsonIgnore
private
String
label
;
/**
* 预览时摄像头的名称,摄像头预览时画面上有名称,故多数字段为空
*/
private
String
title
;
private
String
thumb
;
@JsonIgnore
private
String
parent
;
}
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/BaseEnterpriseVideoServiceImpl.java
View file @
e270fcc2
...
...
@@ -6,20 +6,21 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.dto.CommonVideoDto
;
import
com.yeejoin.amos.boot.biz.common.enums.CommonVideoEnum
;
import
com.yeejoin.amos.boot.module.common.api.dto.BaseEnterpriseVideoDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.BaseEnterpriseVideo
;
import
com.yeejoin.amos.boot.module.common.api.mapper.BaseEnterpriseVideoMapper
;
import
com.yeejoin.amos.boot.module.common.api.service.IBaseEnterpriseVideoService
;
import
com.yeejoin.amos.boot.module.common.api.dto.BaseEnterpriseVideoDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
constants
.
VideoConstant
.*;
import
static
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
constants
.
VideoConstant
.
CODE_200
;
/**
...
...
@@ -30,55 +31,45 @@ import static com.yeejoin.amos.boot.biz.common.constants.VideoConstant.CODE_200;
*/
@Service
@Slf4j
public
class
BaseEnterpriseVideoServiceImpl
extends
BaseService
<
BaseEnterpriseVideoDto
,
BaseEnterpriseVideo
,
BaseEnterpriseVideoMapper
>
implements
IBaseEnterpriseVideoService
{
public
class
BaseEnterpriseVideoServiceImpl
extends
BaseService
<
BaseEnterpriseVideoDto
,
BaseEnterpriseVideo
,
BaseEnterpriseVideoMapper
>
implements
IBaseEnterpriseVideoService
{
@Value
(
"${cylinder.video.default.image.url:/upload/tzs/cylinder/no-connect.png}"
)
private
String
defaultVideoUrl
;
public
List
<
CommonVideoDto
>
getUnitVideoUrl
(
String
useUnitCode
)
{
public
List
<
CommonVideoDto
>
getUnitVideoUrl
(
String
useUnitCode
,
String
regionCode
)
{
List
<
CommonVideoDto
>
result
=
new
ArrayList
<
CommonVideoDto
>();
LambdaQueryWrapper
<
BaseEnterpriseVideo
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
BaseEnterpriseVideo:
:
getUseUnitCode
,
useUnitCode
);
BaseEnterpriseVideo
cylinderUnitVideo
=
this
.
getBaseMapper
().
selectOne
(
wrapper
);
if
(
null
!=
cylinderUnitVideo
)
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"appKey"
,
cylinderUnitVideo
.
getAppKey
());
requestInfo
.
put
(
"appSecret"
,
cylinderUnitVideo
.
getAppSecret
());
String
channelNos
=
cylinderUnitVideo
.
getChannelNo
();
wrapper
.
like
(
StringUtils
.
isNotEmpty
(
regionCode
),
BaseEnterpriseVideo:
:
getRegionCode
,
regionCode
);
List
<
BaseEnterpriseVideo
>
videos
=
this
.
getBaseMapper
().
selectList
(
wrapper
);
for
(
BaseEnterpriseVideo
video
:
videos
)
{
Map
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"appKey"
,
video
.
getAppKey
());
requestInfo
.
put
(
"appSecret"
,
video
.
getAppSecret
());
String
channelNos
=
video
.
getChannelNo
();
List
<
CommonVideoDto
>
channelNoList
=
JSONObject
.
parseArray
(
channelNos
,
CommonVideoDto
.
class
);
try
{
String
accessTokenData
=
HttpUtil
.
post
(
cylinderUnitV
ideo
.
getTokenUrl
(),
requestInfo
);
String
accessTokenData
=
HttpUtil
.
post
(
v
ideo
.
getTokenUrl
(),
requestInfo
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
accessTokenData
);
String
msg
=
jsonObject
.
get
(
"msg"
).
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
))
{
String
errorMsg
=
"code:"
+
code
+
"msg:"
+
msg
+
"appKey:"
+
cylinderUnitVideo
.
getAppKey
()
+
"appSecret:"
+
cylinderUnitVideo
.
getAppSecret
();
log
.
info
(
"视频token获取失败errorMsg:{}"
,
errorMsg
);
this
.
setDefaultVideoIfConnectFailed
(
channelNoList
,
result
);
return
result
;
}
if
(
CODE_200
.
equals
(
code
))
{
String
data
=
jsonObject
.
get
(
"data"
).
toString
();
JSONObject
objTokenJson
=
JSON
.
parseObject
(
data
);
String
accessToken
=
objTokenJson
.
get
(
"accessToken"
).
toString
();
System
.
out
.
println
(
accessToken
);
for
(
CommonVideoDto
channelNo
:
channelNoList
)
{
Hash
Map
<
String
,
Object
>
requestVideosInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
requestVideosInfo
=
new
HashMap
<>();
requestVideosInfo
.
put
(
"accessToken"
,
accessToken
);
requestVideosInfo
.
put
(
"deviceSerial"
,
cylinderUnitV
ideo
.
getDeviceSerial
());
requestVideosInfo
.
put
(
"deviceSerial"
,
v
ideo
.
getDeviceSerial
());
requestVideosInfo
.
put
(
"channelNo"
,
channelNo
.
getKey
());
requestVideosInfo
.
put
(
"protocol"
,
cylinderUnitVideo
.
getProtocol
());
requestVideosInfo
.
put
(
"expireTime"
,
cylinderUnitVideo
.
getExpireTime
());
String
videoData
=
HttpUtil
.
post
(
cylinderUnitVideo
.
getUrl
(),
requestVideosInfo
);
requestVideosInfo
.
put
(
"protocol"
,
video
.
getProtocol
());
requestVideosInfo
.
put
(
"expireTime"
,
video
.
getExpireTime
());
log
.
info
(
"开始获取通道信息:{}"
,
JSONObject
.
toJSONString
(
requestVideosInfo
));
String
videoData
=
HttpUtil
.
post
(
video
.
getUrl
(),
requestVideosInfo
);
JSONObject
videoJsonObject
=
JSON
.
parseObject
(
videoData
);
String
msgVideo
=
videoJsonObject
.
get
(
"msg"
).
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
))
{
String
errorMsg
=
"code:"
+
codeVideo
+
"msg:"
+
msgVideo
+
"appKey:"
+
cylinderUnitVideo
.
getAppKey
()
+
"appSecret:"
+
cylinderUnitVideo
.
getAppSecret
()
+
"accessToken:"
+
accessToken
;
log
.
info
(
"视频地址获取失败errorMsg:{}"
,
errorMsg
);
this
.
setDefaultChannelData
(
result
,
channelNo
);
continue
;
}
if
(
CODE_200
.
equals
(
codeVideo
))
{
String
dataS
=
videoJsonObject
.
get
(
"data"
).
toString
();
JSONObject
dd
=
JSON
.
parseObject
(
dataS
);
...
...
@@ -86,12 +77,20 @@ public class BaseEnterpriseVideoServiceImpl extends BaseService<BaseEnterpriseVi
CommonVideoDto
commonVideoDto
=
new
CommonVideoDto
();
commonVideoDto
.
setUrl
(
url
);
commonVideoDto
.
setKey
(
channelNo
.
getKey
());
commonVideoDto
.
setType
(
CommonVideoEnum
.
getEnum
(
cylinderUnitV
ideo
.
getProtocol
()).
getName
());
commonVideoDto
.
setType
(
CommonVideoEnum
.
getEnum
(
v
ideo
.
getProtocol
()).
getName
());
commonVideoDto
.
setTitle
(
channelNo
.
getTitle
());
commonVideoDto
.
setThumb
(
channelNo
.
getThumb
());
result
.
add
(
commonVideoDto
);
}
else
{
String
errorMsg
=
"code:"
+
codeVideo
+
"msg:"
+
msgVideo
+
"appKey:"
+
video
.
getAppKey
()
+
"appSecret:"
+
video
.
getAppSecret
()
+
"accessToken:"
+
accessToken
;
log
.
info
(
"视频地址获取失败errorMsg:{}"
,
errorMsg
);
this
.
setDefaultChannelData
(
result
,
channelNo
);
}
}
}
else
{
String
errorMsg
=
"code:"
+
code
+
"msg:"
+
msg
+
"appKey:"
+
video
.
getAppKey
()
+
"appSecret:"
+
video
.
getAppSecret
();
log
.
info
(
"视频token获取失败errorMsg:{}"
,
errorMsg
);
this
.
setDefaultVideoIfConnectFailed
(
channelNoList
,
result
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-api/src/main/java/com/yeejoin/amos/boot/module/statistics/api/dto/UnitVideoDto.java
View file @
e270fcc2
package
com
.
yeejoin
.
amos
.
boot
.
module
.
statistics
.
api
.
dto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
lombok.Data
;
/**
* @author Administrator
*/
@Data
public
class
UnitVideoDto
extends
BaseDto
{
public
class
UnitVideoDto
{
private
String
id
;
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/controller/VideoController.java
View file @
e270fcc2
package
com
.
yeejoin
.
amos
.
boot
.
module
.
statistcs
.
biz
.
controller
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
com.yeejoin.amos.boot.biz.common.dto.CommonVideoDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto
;
import
com.yeejoin.amos.boot.module.statistcs.biz.service.impl.VideoServiceImpl
;
import
com.yeejoin.amos.boot.module.statistics.api.dto.UnitVideoDto
;
import
com.yeejoin.amos.boot.module.statistics.api.vo.TreeNodeVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -48,16 +48,16 @@ public class VideoController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"查询指定区域下的单位列表接口,带摄像头数量统计-不分页"
,
httpMethod
=
"GET"
)
@GetMapping
(
value
=
"/countByUnit"
)
public
ResponseModel
<
List
<
?
extends
Base
Dto
>>
getUnitList
(
@RequestParam
(
value
=
"code"
)
String
regionCode
)
{
List
<
?
extends
Base
Dto
>
re
=
videoService
.
getUnitList
(
regionCode
);
public
ResponseModel
<
List
<
UnitVideo
Dto
>>
getUnitList
(
@RequestParam
(
value
=
"code"
)
String
regionCode
)
{
List
<
UnitVideo
Dto
>
re
=
videoService
.
getUnitList
(
regionCode
);
return
ResponseHelper
.
buildResponse
(
re
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"查询指定单位下的摄像头列表接口-不分页"
,
httpMethod
=
"GET"
)
@GetMapping
(
value
=
"/list"
)
public
ResponseModel
<
List
<
CommonVideoDto
>>
getVideoList
(
@RequestParam
(
value
=
"code"
)
String
useUnitCode
)
{
List
<
CommonVideoDto
>
re
=
videoService
.
getVideoList
(
useUnitCode
);
public
ResponseModel
<
List
<
CommonVideoDto
>>
getVideoList
(
@RequestParam
(
value
=
"code"
)
String
useUnitCode
,
@RequestParam
(
value
=
"regionCode"
)
String
regionCode
)
{
List
<
CommonVideoDto
>
re
=
videoService
.
getVideoList
(
useUnitCode
,
regionCode
);
return
ResponseHelper
.
buildResponse
(
re
);
}
}
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/service/impl/VideoServiceImpl.java
View file @
e270fcc2
...
...
@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
com.yeejoin.amos.boot.biz.common.dto.CommonVideoDto
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto
;
...
...
@@ -80,24 +79,25 @@ public class VideoServiceImpl {
treeNodeVo
.
setParentId
(
String
.
valueOf
(
r
.
getParentId
()));
return
treeNodeVo
;
}).
collect
(
Collectors
.
toList
());
// 区域拼接为树结构
List
<
TreeNodeVo
>
treeNodeVos
=
regionNodes
.
stream
().
filter
(
r
->
StringUtils
.
isEmpty
(
r
.
getParentId
())
||
"0"
.
equals
(
r
.
getParentId
())).
map
(
r
->
{
TreeNodeVo
treeNodeVo
=
new
TreeNodeVo
();
BeanUtil
.
copyProperties
(
r
,
treeNodeVo
);
treeNodeVo
.
setChildren
(
this
.
getRegionTypeNode
(
treeNodeVo
,
regionNodes
));
treeNodeVo
.
setChildren
(
this
.
getRegionTypeNode
(
treeNodeVo
,
regionNodes
));
return
treeNodeVo
;
}).
collect
(
Collectors
.
toList
());
// 给区域的最下级增加直接下级->单位,id不是其他的parent_id则为树的叶子节点
treeNodeVos
.
forEach
(
t
->
{
treeNodeVos
.
forEach
(
t
->
{
this
.
setChildrenUnitTypeNode
(
regionNodes
,
t
,
baseEnterpriseInfos
,
videoEquipList
,
channelNoList
);
});
return
treeNodeVos
;
}
private
void
setChildrenUnitTypeNode
(
List
<
TreeNodeVo
>
regionNodes
,
TreeNodeVo
parentNode
,
List
<
TzBaseEnterpriseInfo
>
baseEnterpriseInfos
,
List
<
BaseEnterpriseVideo
>
videoEquipList
,
List
<
CommonVideoDto
>
channelNoList
)
{
if
(
regionNodes
.
stream
().
noneMatch
(
e
->
parentNode
.
getId
().
equals
(
e
.
getParentId
())))
{
if
(
regionNodes
.
stream
().
noneMatch
(
e
->
parentNode
.
getId
().
equals
(
e
.
getParentId
())))
{
parentNode
.
setChildren
(
this
.
buildUnitTypeNode
(
baseEnterpriseInfos
,
videoEquipList
,
channelNoList
,
parentNode
));
}
else
{
parentNode
.
getChildren
().
forEach
(
p
->
{
parentNode
.
getChildren
().
forEach
(
p
->
{
setChildrenUnitTypeNode
(
regionNodes
,
p
,
baseEnterpriseInfos
,
videoEquipList
,
channelNoList
);
});
}
...
...
@@ -135,7 +135,7 @@ public class VideoServiceImpl {
// 这个key需要全局唯一,用来页面左侧点击摄像头类型的节点时与右侧的摄像头列表进行定位
// @see /video/list->CommonVideoDto.key
treeNodeVo
.
setId
(
u
.
getKey
());
treeNodeVo
.
setName
(
u
.
get
Title
());
treeNodeVo
.
setName
(
u
.
get
Label
());
treeNodeVo
.
setParentId
(
parentNode
.
getId
());
return
treeNodeVo
;
}).
collect
(
Collectors
.
toList
());
...
...
@@ -177,7 +177,7 @@ public class VideoServiceImpl {
return
enterpriseVideoService
.
list
(
queryWrapper
);
}
public
List
<
?
extends
Base
Dto
>
getUnitList
(
String
regionCode
)
{
public
List
<
UnitVideo
Dto
>
getUnitList
(
String
regionCode
)
{
// 摄像头设备
List
<
BaseEnterpriseVideo
>
videoEquipList
=
getVideos
(
regionCode
);
// 摄像头对应的单位列表
...
...
@@ -186,6 +186,7 @@ public class VideoServiceImpl {
UnitVideoDto
unitVideoDto
=
new
UnitVideoDto
();
unitVideoDto
.
setId
(
e
.
getSequenceNbr
()
+
""
);
unitVideoDto
.
setName
(
e
.
getUseUnit
());
unitVideoDto
.
setCode
(
e
.
getUseUnitCode
());
// 摄像头通道
List
<
CommonVideoDto
>
channelNoList
=
this
.
getVideoChannel
(
videoEquipList
);
unitVideoDto
.
setCountNum
(
channelNoList
.
stream
().
filter
(
c
->
c
.
getParent
().
equals
(
e
.
getUseUnitCode
())).
count
());
...
...
@@ -193,8 +194,8 @@ public class VideoServiceImpl {
}).
collect
(
Collectors
.
toList
());
}
public
List
<
CommonVideoDto
>
getVideoList
(
String
useUnitCode
)
{
return
enterpriseVideoService
.
getUnitVideoUrl
(
useUnitCode
);
public
List
<
CommonVideoDto
>
getVideoList
(
String
useUnitCode
,
String
regionCode
)
{
return
enterpriseVideoService
.
getUnitVideoUrl
(
useUnitCode
,
regionCode
);
}
}
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