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
80d9d6d1
Commit
80d9d6d1
authored
Dec 21, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加register缓存接口
parent
257e6673
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
131 deletions
+12
-131
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+12
-131
No files found.
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
80d9d6d1
...
@@ -31,7 +31,6 @@ import com.mortals.xhx.busiz.rsp.*;
...
@@ -31,7 +31,6 @@ import com.mortals.xhx.busiz.rsp.*;
import
com.mortals.xhx.common.code.*
;
import
com.mortals.xhx.common.code.*
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.pdu.DeviceReq
;
import
com.mortals.xhx.common.pdu.DeviceReq
;
...
@@ -167,6 +166,9 @@ public class DeviceApiController {
...
@@ -167,6 +166,9 @@ public class DeviceApiController {
try
{
try
{
DeviceEntity
deviceEntity
=
checkDeviceExistAndCreate
(
req
);
DeviceEntity
deviceEntity
=
checkDeviceExistAndCreate
(
req
);
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
//authInfo.setHost(masterhost);
//设备地址修改为客户端访问服务端的ip地址
// authInfo.setHost(url.getHost());
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
authInfo
.
setHost
(
serverName
);
authInfo
.
setHost
(
serverName
);
}
else
{
}
else
{
...
@@ -211,7 +213,7 @@ public class DeviceApiController {
...
@@ -211,7 +213,7 @@ public class DeviceApiController {
serverInfo
.
setScheme
(
scheme
);
serverInfo
.
setScheme
(
scheme
);
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
//buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
//buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
s
cheme
,
s
erverName
,
serverPort
);
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
//对外地址,访问ip+端口 端口号由platformEntity.getSendUrl()获取
//对外地址,访问ip+端口 端口号由platformEntity.getSendUrl()获取
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
int
port
=
uri
.
getPort
();
int
port
=
uri
.
getPort
();
...
@@ -266,7 +268,7 @@ public class DeviceApiController {
...
@@ -266,7 +268,7 @@ public class DeviceApiController {
rsp
.
setMsg
(
e
.
getMessage
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
return
JSON
.
toJSONString
(
rsp
);
}
}
log
.
info
(
"响应【设备注册】【响应体】--> deviceCode:{} "
,
req
.
getDeviceCode
(
));
//log.info("响应【设备注册】【响应体】--> " + JSONObject.toJSONString(rsp
));
return
JSON
.
toJSONString
(
rsp
);
return
JSON
.
toJSONString
(
rsp
);
}
}
...
@@ -470,7 +472,7 @@ public class DeviceApiController {
...
@@ -470,7 +472,7 @@ public class DeviceApiController {
ServerInfo
serverInfo
=
new
ServerInfo
();
ServerInfo
serverInfo
=
new
ServerInfo
();
serverInfo
.
setScheme
(
scheme
);
serverInfo
.
setScheme
(
scheme
);
// buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
// buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
s
cheme
,
s
erverName
,
serverPort
);
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
int
port
=
uri
.
getPort
();
int
port
=
uri
.
getPort
();
...
@@ -1032,52 +1034,11 @@ public class DeviceApiController {
...
@@ -1032,52 +1034,11 @@ public class DeviceApiController {
}
}
}
}
private
void
buildHomeUrlBySite
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
,
String
scheme
,
String
serverName
,
Integer
serverPort
)
{
private
void
buildHomeUrlBySite
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
,
String
serverName
,
Integer
serverPort
)
{
//缓存实现路径选择
String
scheme
=
serverInfo
.
getScheme
();
String
keyYesPath
=
deviceEntity
.
getSiteId
()
+
"#"
+
productEntity
.
getId
()
+
"#"
+
YesNoEnum
.
YES
.
getValue
();
String
homeUrl
=
""
;
String
keyNoPath
=
deviceEntity
.
getSiteId
()
+
"#"
+
productEntity
.
getId
()
+
"#"
+
YesNoEnum
.
NO
.
getValue
();
String
homePathUrl
=
cacheService
.
get
(
RedisKey
.
KEY_DEVICE_DISBUTE_PATH_CHCHE
+
keyYesPath
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
homePathUrl
))
{
//缓存有 设置
setHomeUrl
(
serverInfo
,
scheme
,
serverName
,
serverPort
,
homePathUrl
);
// serverInfo.setHomeUrl(homePathUrl);
}
else
{
//查询 无 是否有缓存
homePathUrl
=
cacheService
.
get
(
RedisKey
.
KEY_DEVICE_DISBUTE_PATH_CHCHE
+
keyNoPath
,
String
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
homePathUrl
))
{
setHomeUrl
(
serverInfo
,
scheme
,
serverName
,
serverPort
,
homePathUrl
);
//serverInfo.setHomeUrl(homePathUrl);
}
else
{
//读取db数据
Boolean
homeUrlByDb
=
this
.
getHomeUrlByDb
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
if
(
ObjectUtils
.
isEmpty
(
homeUrlByDb
))
{
//未有资源
log
.
info
(
"资源为空!产品名称:{}"
,
deviceEntity
.
getProductName
());
}
else
{
//设置homeurl
if
(
homeUrlByDb
)
{
//yes
cacheService
.
set
(
RedisKey
.
KEY_DEVICE_DISBUTE_PATH_CHCHE
+
keyYesPath
,
serverInfo
.
getDistributePath
());
}
else
{
//no
cacheService
.
set
(
RedisKey
.
KEY_DEVICE_DISBUTE_PATH_CHCHE
+
keyYesPath
,
serverInfo
.
getDistributePath
());
}
}
}
}
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
//this.getHomeUrlByDb(deviceEntity,productEntity,serverInfo)
//根据站点与资源部署来生成homeurl
//根据站点与资源部署来生成homeurl
/*
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setProductId
(
productEntity
.
getId
());
query
.
setProductId
(
productEntity
.
getId
());
query
.
setSelected
(
YesNoEnum
.
YES
.
getValue
());
query
.
setSelected
(
YesNoEnum
.
YES
.
getValue
());
...
@@ -1107,7 +1068,7 @@ public class DeviceApiController {
...
@@ -1107,7 +1068,7 @@ public class DeviceApiController {
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
}
}
else
{
}
else
{
log.info("资源为空!产品名称:{}",
deviceEntity.getProductName());
log
.
info
(
"资源为空!产品名称:{}"
,
deviceEntity
.
getProductName
());
}
}
}
else
{
}
else
{
...
@@ -1128,88 +1089,8 @@ public class DeviceApiController {
...
@@ -1128,88 +1089,8 @@ public class DeviceApiController {
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setHomeUrl
(
decodeStr
);
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
}
}*/
}
private
static
void
setHomeUrl
(
ServerInfo
serverInfo
,
String
scheme
,
String
serverName
,
Integer
serverPort
,
String
homePathUrl
)
{
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
(
homePathUrl
).
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
);
}
else
{
String
str
=
UrlBuilder
.
of
(
domain
.
trim
()).
addPath
(
homePathUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
}
}
private
Boolean
getHomeUrlByDb
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
,
String
serverName
,
Integer
serverPort
)
{
String
homeUrl
=
""
;
Boolean
bool
=
true
;
String
scheme
=
serverInfo
.
getScheme
();
//根据站点与资源部署来生成homeurl
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setProductId
(
productEntity
.
getId
());
query
.
setSelected
(
YesNoEnum
.
YES
.
getValue
());
DeviceModuleDistributeEntity
deviceModuleDistributeEntity
=
deviceModuleDistributeService
.
selectOne
(
query
);
if
(
ObjectUtils
.
isEmpty
(
deviceModuleDistributeEntity
))
{
//No 路径
//没有默认选择的资源,实施部署更新一个默认选择 todo
query
=
new
DeviceModuleDistributeQuery
();
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setProductId
(
productEntity
.
getId
());
query
.
setSelected
(
YesNoEnum
.
NO
.
getValue
());
deviceModuleDistributeEntity
=
deviceModuleDistributeService
.
selectOne
(
query
);
if
(!
ObjectUtils
.
isEmpty
(
deviceModuleDistributeEntity
))
{
bool
=
false
;
//deviceModuleDistributeService.active(deviceModuleDistributeEntity, null);
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
deviceModuleDistributeEntity
.
getSiteId
(),
deviceModuleDistributeEntity
.
getProductCode
(),
deviceModuleDistributeEntity
.
getImageResolutionValue
());
serverInfo
.
setDistributePath
(
homeUrl
);
//根据部署的资源 生成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
);
}
else
{
String
str
=
UrlBuilder
.
of
(
domain
.
trim
()).
addPath
(
homeUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
}
}
else
{
log
.
info
(
"资源为空!产品名称:{}"
,
deviceEntity
.
getProductName
());
bool
=
null
;
}
}
else
{
//homeDeviceUrl/1/pdj/1920x1080
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
deviceModuleDistributeEntity
.
getSiteId
(),
deviceModuleDistributeEntity
.
getProductCode
(),
deviceModuleDistributeEntity
.
getImageResolutionValue
());
serverInfo
.
setDistributePath
(
homeUrl
);
//根据部署的资源 生成homeurl
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11078"
);
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
bool
=
true
;
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
);
}
else
{
bool
=
null
;
String
str
=
UrlBuilder
.
of
(
domain
.
trim
()).
addPath
(
homeUrl
).
build
();
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
serverInfo
.
setHomeUrl
(
decodeStr
);
}
}
}
return
bool
;
}
}
private
void
buildHomeUrl
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
,
String
serverName
,
Integer
serverPort
)
{
private
void
buildHomeUrl
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
,
String
serverName
,
Integer
serverPort
)
{
...
...
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