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
9afe7521
Commit
9afe7521
authored
May 17, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改消息组件
parent
1c150dec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+20
-3
No files found.
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
9afe7521
...
@@ -18,8 +18,10 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
...
@@ -18,8 +18,10 @@ 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.module.firm.model.FirmQuery
;
import
com.mortals.xhx.module.firm.model.FirmQuery
;
import
com.mortals.xhx.module.firm.service.FirmService
;
import
com.mortals.xhx.module.firm.service.FirmService
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductQuery
;
import
com.mortals.xhx.module.product.model.ProductQuery
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
...
@@ -123,19 +125,34 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
...
@@ -123,19 +125,34 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
DeviceEntity
deviceEntity
=
this
.
service
.
get
(
deviceId
,
getContext
());
DeviceEntity
deviceEntity
=
this
.
service
.
get
(
deviceId
,
getContext
());
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//将上报信息转发到mq中
//将上报信息转发到mq中
TopicPartitionInfo
info
=
TopicPartitionInfo
.
builder
().
topic
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceMac
()).
build
();
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
"当前设备未配置所属系统平台,请在后台配置后再激活!"
);
}
// authInfo.setHost(platformEntity.getPlatformSn());
ProductEntity
productEntity
=
productService
.
get
(
deviceEntity
.
getProductId
());
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
"当前设备未配置所属产品,请在后台配置后再激活!"
);
}
String
exchangeName
=
platformEntity
.
getPlatformSn
()
+
Constant
.
EXCHANGE_SPLIT
+
productEntity
.
getProductCode
();
TopicPartitionInfo
info
=
TopicPartitionInfo
.
builder
().
exchangeName
(
exchangeName
).
topic
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceMac
()).
build
();
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
Constant
.
MESSAGETYPE_UPGREAD
);
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
Constant
.
MESSAGETYPE_UPGREAD
);
JSONObject
obj
=
new
JSONObject
();
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"content"
,
content
);
obj
.
put
(
"content"
,
content
);
ApiResp
<
String
>
sendDeviceMessageResp
=
this
.
service
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
obj
),
null
);
ApiResp
<
String
>
sendDeviceMessageResp
=
this
.
service
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
obj
),
null
);
log
.
info
(
String
.
format
(
"sendMsgResp:%s"
,
JSON
.
toJSONString
(
sendDeviceMessageResp
)));
log
.
info
(
String
.
format
(
"sendMsgResp:%s"
,
JSON
.
toJSONString
(
sendDeviceMessageResp
)));
if
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
()
!=
sendDeviceMessageResp
.
getCode
())
{
if
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
()
!=
sendDeviceMessageResp
.
getCode
())
{
throw
new
AppException
(
"下发消息失败!"
);
throw
new
AppException
(
"下发消息失败!"
);
}
}
}
else
{
// Thread.sleep(50);
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
}
else
{
throw
new
AppException
(
"设备不存在!deviceId:"
+
deviceId
);
throw
new
AppException
(
"设备不存在!deviceId:"
+
deviceId
);
}
}
this
.
init
(
request
,
response
,
null
,
model
,
getContext
());
this
.
init
(
request
,
response
,
null
,
model
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
model
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
model
);
...
...
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