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
c5377899
Commit
c5377899
authored
Sep 23, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加巴中经开区windows shell
parent
28a520aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
0 deletions
+157
-0
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+157
-0
No files found.
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
c5377899
...
@@ -1328,6 +1328,163 @@ public class DeviceApiController {
...
@@ -1328,6 +1328,163 @@ public class DeviceApiController {
}
}
/**
* 设备更新,对安卓接口等
*
* @param req
* @return
*/
@PostMapping
(
"deviceUpdateCopy"
)
@UnAuth
public
String
deviceUpdateApiCopy
(
HttpServletRequest
request
,
@RequestBody
DeviceReq
req
)
{
String
serverName
=
request
.
getHeader
(
"server-name"
);
Integer
serverPort
=
DataUtil
.
converStr2Int
(
request
.
getHeader
(
"server-port"
),
0
);
String
scheme
=
request
.
getHeader
(
"server-scheme"
);
if
(
ObjectUtils
.
isEmpty
(
scheme
))
{
scheme
=
"http"
;
}
log
.
info
(
"【设备前端新增或更新】【请求体】-->{} ,serverName:{}"
,
JSONObject
.
toJSONString
(
req
),
serverName
);
ApiResp
<
DeviceResp
>
rsp
=
new
ApiResp
<>();
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
DeviceResp
deviceResp
=
new
DeviceResp
();
try
{
if
(
ObjectUtils
.
isEmpty
(
req
.
getDeviceCode
()))
{
throw
new
AppException
(
DEVICE_CODE_IS_EMPTY
,
DEVICE_CODE_IS_EMPTY_CONTENT
);
}
if
(
ObjectUtils
.
isEmpty
(
req
.
getSiteId
()))
{
throw
new
AppException
(
SITEID_IS_EMPTY
,
SITEID_IS_EMPTY_CONTENT
);
}
ProductEntity
productEntity
=
productService
.
getCache
(
req
.
getProductId
().
toString
());
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
PRODUCT_IS_EMPTY
,
PRODUCT_IS_EMPTY_CONTENT
);
}
if
(
ObjectUtils
.
isEmpty
(
productEntity
.
getPlatformId
()))
{
throw
new
AppException
(
PLATFORM_UNEXIST
,
PLATFORM_UNEXIST_CONTENT
);
}
PlatformEntity
platformEntity
=
platformService
.
getCache
(
productEntity
.
getPlatformId
().
toString
());
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
PLATFORM_IS_EMPTY
,
PLATFORM_IS_EMPTY_CONTENT
);
}
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//初始化新增基础设备,后续在线完善信息后再行注册添加
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
saveDevice
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
deviceEntity
.
setCreateTime
(
new
Date
());
deviceEntity
.
setCreateUserId
(
1L
);
deviceService
.
save
(
deviceEntity
,
null
);
}
else
{
//更新
updateDevice
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
//cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, deviceEntity);
deviceService
.
update
(
deviceEntity
,
null
);
}
if
(
deviceEntity
.
getDeviceStatus
()
==
DeviceStatusEnum
.
未激活
.
getValue
())
{
throw
new
AppException
(
DEVICE_UNACTIVE
,
DEVICE_UNACTIVE_CONTENT
);
}
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
URL
url
=
getServerUrl
();
//authInfo.setHost(masterhost);
authInfo
.
setHost
(
url
.
getHost
());
authInfo
.
setPort
(
port
);
authInfo
.
setUsername
(
username
);
authInfo
.
setPassword
(
password
);
authInfo
.
setMessageTtl
(
messageTtl
);
authInfo
.
setVirtualHost
(
virtualHost
);
// authInfo.setExchangeName(platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode());
authInfo
.
setExchangeName
(
QueueKey
.
DEFAULT_EXCHANGE
);
authInfo
.
setUploadTopicFilter
(
Constant
.
UPLOAD_TOPIC
+
deviceEntity
.
getDeviceCode
());
authInfo
.
setDownTopicFilter
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
());
RegisterResp
registerResp
=
new
RegisterResp
();
registerResp
.
setRabbmitInfo
(
authInfo
);
ServerInfo
serverInfo
=
new
ServerInfo
();
serverInfo
.
setScheme
(
scheme
);
// buildHomeUrl(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
);
if
(!
ObjectUtils
.
isEmpty
(
distribute
))
{
//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
);
}
}
else
{
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
}
URI
uri
=
new
URI
(
platformEntity
.
getSendUrl
());
int
port
=
uri
.
getPort
();
if
(
port
!=
-
1
&&
!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
String
serverUrl
=
UrlBuilder
.
of
().
setScheme
(
scheme
).
setHost
(
serverName
).
setPort
(
port
>
0
?
port
:
11078
).
build
();
//String serverUrl = UrlBuilder.ofHttp(serverName).setPort(port).build();
serverInfo
.
setServerUrl
(
serverUrl
);
}
else
{
serverInfo
.
setServerUrl
(
platformEntity
.
getSendUrl
());
}
//serverInfo.setServerUrl(platformEntity.getSendUrl());
//String phpUrl=GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090");
//serverInfo.setServerUrl(phpUrl);
registerResp
.
setServiceInfo
(
serverInfo
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
();
deviceInfo
.
setSiteId
(
deviceEntity
.
getSiteId
());
deviceInfo
.
setSiteCode
(
deviceEntity
.
getSiteCode
());
deviceInfo
.
setSiteName
(
deviceEntity
.
getSiteName
());
deviceInfo
.
setProductId
(
productEntity
.
getId
());
deviceInfo
.
setProductCode
(
productEntity
.
getProductCode
());
deviceInfo
.
setProductName
(
productEntity
.
getProductName
());
deviceInfo
.
setEnabled
(
deviceEntity
.
getEnabled
());
deviceInfo
.
setSource
(
deviceEntity
.
getSource
());
registerResp
.
setDeviceInfo
(
deviceInfo
);
log
.
info
(
"响应【设备前端新增或更新】【响应体】--> "
+
JSONObject
.
toJSONString
(
registerResp
));
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
registerResp
),
9
,
DES_STR
,
ENCRYPT_STR
);
deviceResp
.
setContent
(
JSON
.
toJSONString
(
registerResp
));
rsp
.
setData
(
deviceResp
);
}
catch
(
AppException
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
e
.
getCode
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
return
JSON
.
toJSONString
(
rsp
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
UrlBuilder
testPath
=
UrlBuilder
.
of
().
setScheme
(
"https"
).
setHost
(
"10.12.185.213"
).
setPort
(
31078
).
addPath
(
"test/a"
);
UrlBuilder
testPath
=
UrlBuilder
.
of
().
setScheme
(
"https"
).
setHost
(
"10.12.185.213"
).
setPort
(
31078
).
addPath
(
"test/a"
);
...
...
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