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
28a520aa
Commit
28a520aa
authored
Sep 23, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加巴中经开区windows shell
parent
16866f5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
13 deletions
+158
-13
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+155
-12
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceModuleDistributeController.java
...x/module/device/web/DeviceModuleDistributeController.java
+2
-0
device-manager/src/main/resources/config/mybatis-sqlmap-config.xml
...nager/src/main/resources/config/mybatis-sqlmap-config.xml
+1
-1
No files found.
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
28a520aa
...
...
@@ -168,9 +168,7 @@ public class DeviceApiController {
try
{
DeviceEntity
deviceEntity
=
checkDeviceExistAndCreate
(
req
);
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
//authInfo.setHost(masterhost);
//设备地址修改为客户端访问服务端的ip地址
// authInfo.setHost(url.getHost());
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
authInfo
.
setHost
(
serverName
);
}
else
{
...
...
@@ -214,8 +212,6 @@ public class DeviceApiController {
ServerInfo
serverInfo
=
new
ServerInfo
();
serverInfo
.
setScheme
(
scheme
);
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
//buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
//判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在
String
resolution
=
deviceEntity
.
getResolution
();
if
(!
ObjectUtils
.
isEmpty
(
resolution
))
{
...
...
@@ -225,7 +221,6 @@ public class DeviceApiController {
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"
);
...
...
@@ -256,9 +251,6 @@ public class DeviceApiController {
}
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
());
...
...
@@ -286,10 +278,7 @@ public class DeviceApiController {
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_THIRDPARTY_QUEUE
,
condition
);
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_UPDATE_QUEUE
,
condition
);
}
// deviceService.getDeviceDao().update(deviceEntity);
rsp
.
setData
(
deviceResp
);
/* SendThirdPartyTask sendThirdPartyTask = new SendThirdPartyTask(deviceEntity, productEntity, platformEntity, deviceService);
sendTaskThreadPool.execute(sendThirdPartyTask);*/
}
catch
(
AppException
e
)
{
//log.error("接收数据失败", e);
rsp
.
setCode
(
e
.
getCode
());
...
...
@@ -303,7 +292,6 @@ public class DeviceApiController {
log
.
info
(
"响应【设备注册】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
//log.info("响应【设备注册】【响应体】--> " + JSONObject.toJSONString(rsp));
return
JSON
.
toJSONString
(
rsp
);
}
...
...
@@ -1185,6 +1173,161 @@ public class DeviceApiController {
}
/**
* 设备注册(内容不加密)
*
* @param req
* @return
*/
@PostMapping
(
"registerCopy"
)
@UnAuth
public
String
registerCopy
(
HttpServletRequest
request
,
@RequestBody
DeviceReq
req
)
{
log
.
info
(
"【设备注册】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
String
serverName
=
request
.
getHeader
(
"server-name"
);
String
scheme
=
request
.
getHeader
(
"server-scheme"
);
Integer
serverPort
=
DataUtil
.
converStr2Int
(
request
.
getHeader
(
"server-port"
),
0
);
String
xforwardedfor
=
request
.
getHeader
(
"x-forwarded-for"
);
String
realIP
=
request
.
getHeader
(
"X-Real-IP"
);
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
);
ApiResp
<
DeviceResp
>
rsp
=
new
ApiResp
<>();
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
DeviceResp
deviceResp
=
new
DeviceResp
();
URL
url
=
getServerUrl
();
try
{
DeviceEntity
deviceEntity
=
checkDeviceExistAndCreate
(
req
);
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
//设备地址修改为客户端访问服务端的ip地址
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
authInfo
.
setHost
(
serverName
);
}
else
{
log
.
info
(
"设置后台定义的参数地址!{}"
,
url
.
toString
());
authInfo
.
setHost
(
url
.
getHost
());
}
authInfo
.
setPort
(
port
);
authInfo
.
setUsername
(
username
);
authInfo
.
setPassword
(
password
);
authInfo
.
setMessageTtl
(
messageTtl
);
authInfo
.
setVirtualHost
(
virtualHost
);
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
.
getProductId
()))
{
throw
new
AppException
(
PRODUCT_IS_EMPTY
,
PRODUCT_IS_EMPTY_CONTENT
);
}
ProductEntity
productEntity
=
productService
.
getCache
(
deviceEntity
.
getProductId
().
toString
());
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
PRODUCT_IS_EMPTY
,
PRODUCT_IS_EMPTY_CONTENT
+
"productId:"
+
deviceEntity
.
getProductId
());
}
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
);
}
if
(
Objects
.
equals
(
deviceEntity
.
getDeviceStatus
(),
DeviceStatusEnum
.
未激活
.
getValue
()))
{
throw
new
AppException
(
DEVICE_UNACTIVE
,
DEVICE_UNACTIVE_CONTENT
);
}
//单一交换机
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
);
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
//判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在
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
))
{
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
);
}
//对外地址,访问ip+端口 端口号由platformEntity.getSendUrl()获取
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
());
}
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
(
"resp:"
+
JSON
.
toJSONString
(
registerResp
));
// String content = EncryptUtil.myEnscrt(JSON.toJSONString(registerResp), 9, DES_STR, ENCRYPT_STR);
deviceResp
.
setContent
(
JSON
.
toJSONString
(
registerResp
));
deviceEntity
.
setOnlineTime
(
new
Date
());
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
在线
.
getValue
());
deviceEntity
.
setDeviceVersion
(
req
.
getDeviceVersion
()
==
null
?
""
:
req
.
getDeviceVersion
());
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
);
}
rsp
.
setData
(
deviceResp
);
}
catch
(
AppException
e
)
{
//log.error("接收数据失败", e);
rsp
.
setCode
(
e
.
getCode
());
rsp
.
setMsg
(
e
.
getMessage
());
log
.
info
(
"响应【设备注册】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据异常"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
log
.
info
(
"响应【设备注册】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
return
JSON
.
toJSONString
(
rsp
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
UrlBuilder
testPath
=
UrlBuilder
.
of
().
setScheme
(
"https"
).
setHost
(
"10.12.185.213"
).
setPort
(
31078
).
addPath
(
"test/a"
);
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceModuleDistributeController.java
View file @
28a520aa
...
...
@@ -18,6 +18,7 @@ import com.mortals.xhx.module.device.model.DeviceModuleDistributeQuery;
import
com.mortals.xhx.module.device.service.DeviceModuleDistributeService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -78,6 +79,7 @@ public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingCon
/**
* 部署
*/
@ApiOperation
(
value
=
"部署"
,
notes
=
"部署"
)
@PostMapping
(
value
=
"active"
)
public
Rest
<
Void
>
deviceActive
(
@RequestBody
DeviceModuleDistributeEntity
moduleDistributeEntity
)
{
String
busiDesc
=
this
.
getModuleDesc
()
+
"设备模块部署"
;
...
...
device-manager/src/main/resources/config/mybatis-sqlmap-config.xml
View file @
28a520aa
...
...
@@ -19,7 +19,7 @@
<plugin
interceptor=
"com.mortals.framework.thirty.mybatis.LogInterceptor"
>
<property
name=
"enableExecutorTime"
value=
"true"
/>
<property
name=
"showSql"
value=
"
tru
e"
/>
<property
name=
"showSql"
value=
"
fals
e"
/>
</plugin>
</plugins>
</configuration>
\ 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