Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
58bd1241
Commit
58bd1241
authored
Feb 29, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部署资源添加分辨率字典
parent
10dbad6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
52 deletions
+66
-52
device-manager/db/add.sql
device-manager/db/add.sql
+2
-0
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+64
-52
No files found.
device-manager/db/add.sql
View file @
58bd1241
...
...
@@ -82,3 +82,5 @@ ALTER TABLE mortals_xhx_idgenerator ADD COLUMN `createTime` datetime(0) NULL DE
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`resolution`
varchar
(
64
)
DEFAULT
''
COMMENT
'设备分辨率'
AFTER
deviceInFloor
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`resolutionValue`
varchar
(
64
)
DEFAULT
''
COMMENT
'设备分辨率'
AFTER
resolution
;
UPDATE
mortals_xhx_device_module_distribute
SET
imageResolution
=
imageResolutionValue
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
58bd1241
...
...
@@ -159,7 +159,7 @@ public class DeviceApiController {
if
(
ObjectUtils
.
isEmpty
(
scheme
))
{
scheme
=
"http"
;
}
log
.
info
(
"scheme:{},request uri:{},request url:{},serverName:{},serverPort:{},xforwardedfor:{},realIP:{}"
,
scheme
,
request
.
getRequestURI
(),
request
.
getRequestURL
(),
serverName
,
serverPort
,
xforwardedfor
,
realIP
);
log
.
info
(
"scheme:{},request uri:{},request url:{},serverName:{},serverPort:{},xforwardedfor:{},realIP:{}"
,
scheme
,
request
.
getRequestURI
(),
request
.
getRequestURL
(),
serverName
,
serverPort
,
xforwardedfor
,
realIP
);
ApiResp
<
DeviceResp
>
rsp
=
new
ApiResp
<>();
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
DeviceResp
deviceResp
=
new
DeviceResp
();
...
...
@@ -215,7 +215,33 @@ public class DeviceApiController {
serverInfo
.
setScheme
(
scheme
);
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
//buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
//判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在
String
resolution
=
deviceEntity
.
getResolution
();
if
(!
ObjectUtils
.
isEmpty
(
resolution
))
{
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setProductId
(
productEntity
.
getId
());
query
.
setImageResolution
(
resolution
);
query
.
setDistribute
(
DistributeEnum
.
是
.
getValue
());
DeviceModuleDistributeEntity
distribute
=
deviceModuleDistributeService
.
selectOne
(
query
);
//homeDeviceUrl/1/pdj/1920x1080
String
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
distribute
.
getSiteId
(),
distribute
.
getProductCode
(),
distribute
.
getImageResolutionValue
());
//根据部署的资源 生成homeurl
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11078"
);
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
String
str
=
UrlBuilder
.
of
().
setScheme
(
scheme
).
setHost
(
serverName
).
setPort
(
serverPort
>
0
?
serverPort
:
11078
).
addPath
(
homeUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
else
{
String
str
=
UrlBuilder
.
of
(
domain
.
trim
()).
addPath
(
homeUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
}
else
{
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
}
//对外地址,访问ip+端口 端口号由platformEntity.getSendUrl()获取
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
int
port
=
uri
.
getPort
();
...
...
@@ -248,15 +274,15 @@ public class DeviceApiController {
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
在线
.
getValue
());
deviceEntity
.
setDeviceVersion
(
req
.
getDeviceVersion
()
==
null
?
""
:
req
.
getDeviceVersion
());
if
(
deviceEntity
.
getDeviceStatus
()==
DeviceStatusEnum
.
离线
.
getValue
())
{
if
(
deviceEntity
.
getDeviceStatus
()
==
DeviceStatusEnum
.
离线
.
getValue
())
{
DeviceEntity
condition
=
new
DeviceEntity
();
condition
.
setId
(
deviceEntity
.
getId
());
condition
.
setOnlineTime
(
new
Date
());
condition
.
setDeviceStatus
(
DeviceStatusEnum
.
在线
.
getValue
());
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_THIRDPARTY_QUEUE
,
condition
);
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_UPDATE_QUEUE
,
condition
);
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_UPDATE_QUEUE
,
condition
);
}
// deviceService.getDeviceDao().update(deviceEntity);
// deviceService.getDeviceDao().update(deviceEntity);
rsp
.
setData
(
deviceResp
);
/* SendThirdPartyTask sendThirdPartyTask = new SendThirdPartyTask(deviceEntity, productEntity, platformEntity, deviceService);
sendTaskThreadPool.execute(sendThirdPartyTask);*/
...
...
@@ -477,7 +503,31 @@ public class DeviceApiController {
ServerInfo
serverInfo
=
new
ServerInfo
();
serverInfo
.
setScheme
(
scheme
);
// buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
String
resolution
=
deviceEntity
.
getResolution
();
if
(!
ObjectUtils
.
isEmpty
(
resolution
))
{
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setProductId
(
productEntity
.
getId
());
query
.
setImageResolution
(
resolution
);
query
.
setDistribute
(
DistributeEnum
.
是
.
getValue
());
DeviceModuleDistributeEntity
distribute
=
deviceModuleDistributeService
.
selectOne
(
query
);
//homeDeviceUrl/1/pdj/1920x1080
String
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
distribute
.
getSiteId
(),
distribute
.
getProductCode
(),
distribute
.
getImageResolutionValue
());
//根据部署的资源 生成homeurl
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11078"
);
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
String
str
=
UrlBuilder
.
of
().
setScheme
(
scheme
).
setHost
(
serverName
).
setPort
(
serverPort
>
0
?
serverPort
:
11078
).
addPath
(
homeUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
else
{
String
str
=
UrlBuilder
.
of
(
domain
.
trim
()).
addPath
(
homeUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
}
else
{
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
}
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
int
port
=
uri
.
getPort
();
...
...
@@ -675,15 +725,7 @@ public class DeviceApiController {
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
/* list.stream()
.sorted(Comparator.comparing(DeviceMsgReq::getTimestamp))
.forEach(item -> {
cacheService.lpush(KEY_DEVICE_DOWN_MSG_QUEUE, item);
});*/
/* DownMsgTask downMsgTask = new DownMsgTask(list, platformService, productService, deviceService, deviceLogService, messageProducer);
sendTaskThreadPool.execute(downMsgTask);*/
deviceService
.
downMsg
(
list
);
}
catch
(
AppException
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
e
.
getCode
());
...
...
@@ -894,9 +936,9 @@ public class DeviceApiController {
deviceEntity
.
setCreateUserId
(
1L
);
deviceEntity
.
setCreateTime
(
new
Date
());
deviceEntity
.
setSwitchSend
(
false
);
if
(!
ObjectUtils
.
isEmpty
(
req
.
getResolution
())&&!
ObjectUtils
.
isEmpty
(
req
.
getResolutionValue
()))
{
if
(!
ObjectUtils
.
isEmpty
(
req
.
getResolution
()))
{
deviceEntity
.
setResolution
(
req
.
getResolution
());
deviceEntity
.
setResolutionValue
(
req
.
getResolution
Value
());
deviceEntity
.
setResolutionValue
(
req
.
getResolution
());
}
deviceService
.
save
(
deviceEntity
);
...
...
@@ -942,9 +984,9 @@ public class DeviceApiController {
deviceEntity
.
setLeadingOfficial
(
req
.
getLeadingOfficial
());
deviceEntity
.
setDeviceInFloor
(
req
.
getDeviceInFloor
());
deviceEntity
.
setDeviceInBuilding
(
req
.
getDeviceInBuilding
());
if
(!
ObjectUtils
.
isEmpty
(
req
.
getResolution
())&&!
ObjectUtils
.
isEmpty
(
req
.
getResolutionValue
()))
{
if
(!
ObjectUtils
.
isEmpty
(
req
.
getResolution
()))
{
deviceEntity
.
setResolution
(
req
.
getResolution
());
deviceEntity
.
setResolutionValue
(
req
.
getResolution
Value
());
deviceEntity
.
setResolutionValue
(
req
.
getResolution
());
}
deviceService
.
update
(
deviceEntity
);
}
...
...
@@ -1051,40 +1093,11 @@ public class DeviceApiController {
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setProductId
(
productEntity
.
getId
());
//query.setSelected(YesNoEnum.YES
.getValue());
query
.
setSelectedList
(
Arrays
.
asList
(
YesNoEnum
.
YES
.
getValue
(),
YesNoEnum
.
NO
.
getValue
()));
query
.
setOrderColList
(
Arrays
.
asList
(
new
OrderCol
(
"selected"
,
OrderCol
.
DESCENDING
)));
query
.
setDistribute
(
DistributeEnum
.
是
.
getValue
());
query
.
setSelectedList
(
Arrays
.
asList
(
YesNoEnum
.
YES
.
getValue
(),
YesNoEnum
.
NO
.
getValue
()));
query
.
setOrderColList
(
Arrays
.
asList
(
new
OrderCol
(
"selected"
,
OrderCol
.
DESCENDING
)));
DeviceModuleDistributeEntity
deviceModuleDistributeEntity
=
deviceModuleDistributeService
.
selectOne
(
query
);
if
(
ObjectUtils
.
isEmpty
(
deviceModuleDistributeEntity
))
{
/* //没有默认选择的资源,实施部署更新一个默认选择 todo
query = new DeviceModuleDistributeQuery();
query.setSiteId(deviceEntity.getSiteId());
query.setProductId(productEntity.getId());
query.setSelectedList(Arrays.asList(1,0));
// query.setSelected(YesNoEnum.NO.getValue());
deviceModuleDistributeEntity = deviceModuleDistributeService.selectOne(query);
if (!ObjectUtils.isEmpty(deviceModuleDistributeEntity)) {
//deviceModuleDistributeService.active(deviceModuleDistributeEntity, null);
homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", deviceModuleDistributeEntity.getSiteId(), deviceModuleDistributeEntity.getProductCode(), deviceModuleDistributeEntity.getImageResolutionValue());
//根据部署的资源 生成homeurl
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) {
String str = UrlBuilder.of().setScheme(scheme).setHost(serverName).setPort(serverPort > 0 ? serverPort : 11078).addPath(homeUrl).build();
// String str = UrlBuilder.of().setScheme("http").ofHttp(serverName).setPort(serverPort > 0 ? serverPort : 11078).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
serverInfo.setEventUrl(productEntity.getEventUrl());
} else {
String str = UrlBuilder.of(domain.trim()).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
serverInfo.setEventUrl(productEntity.getEventUrl());
}
} else {
log.info("资源为空!产品名称:{}",deviceEntity.getProductName());
}*/
}
else
{
//homeDeviceUrl/1/pdj/1920x1080
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
deviceModuleDistributeEntity
.
getSiteId
(),
deviceModuleDistributeEntity
.
getProductCode
(),
deviceModuleDistributeEntity
.
getImageResolutionValue
());
...
...
@@ -1093,7 +1106,6 @@ public class DeviceApiController {
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11078"
);
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
String
str
=
UrlBuilder
.
of
().
setScheme
(
scheme
).
setHost
(
serverName
).
setPort
(
serverPort
>
0
?
serverPort
:
11078
).
addPath
(
homeUrl
).
build
();
// String str = UrlBuilder.ofHttp(serverName).setPort(serverPort > 0 ? serverPort : 11078).addPath(homeUrl).build();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
...
...
@@ -1159,7 +1171,7 @@ public class DeviceApiController {
productVersionInfo
.
setDownloadUrl
(
decodeStr
);
}
/* productVersionInfo.setDownloadUrl(download);*/
/* productVersionInfo.setDownloadUrl(download);*/
log
.
info
(
"downurl:"
+
productVersionInfo
.
getDownloadUrl
());
}
...
...
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