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
7a0859a9
Commit
7a0859a9
authored
Jan 31, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改设备通知刷新消息
parent
4d43ac55
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
10 deletions
+85
-10
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageProducer.java
...mortals/xhx/base/system/message/impl/MessageProducer.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+2
-1
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
...va/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
+72
-0
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
...er/src/main/java/com/mortals/xhx/common/key/Constant.java
+5
-0
device-manager/src/main/java/com/mortals/xhx/common/utils/DownMsgTask.java
...c/main/java/com/mortals/xhx/common/utils/DownMsgTask.java
+4
-7
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+1
-1
No files found.
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageProducer.java
View file @
7a0859a9
...
...
@@ -48,7 +48,7 @@ public class MessageProducer implements IMessageProduceService, RabbitMessageSer
@Override
public
void
syncOperSend
(
OperateLogPdu
operLogPdu
)
{
log
.
info
(
"send
po
erate log ==>{}"
,
JSON
.
toJSONString
(
operLogPdu
));
log
.
info
(
"send
op
erate log ==>{}"
,
JSON
.
toJSONString
(
operLogPdu
));
String
send
=
JSON
.
toJSONString
(
operLogPdu
);
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
OPERATION_LOG_QUEUE
,
send
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
7a0859a9
...
...
@@ -38,6 +38,7 @@ import com.mortals.xhx.common.utils.EncryptUtil;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.firm.model.FirmEntity
;
...
...
@@ -823,7 +824,7 @@ public class DeviceApiController {
if
(
ObjectUtils
.
isEmpty
(
req
.
getDeviceCode
()))
{
throw
new
AppException
(
DEVICE_CODE_IS_EMPTY
,
DEVICE_CODE_IS_EMPTY_CONTENT
);
}
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
(
));
DeviceEntity
deviceEntity
=
deviceService
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
req
.
getDeviceCode
()
));
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//初始化新增基础设备,后续在线完善信息后再行注册添加
deviceEntity
=
new
DeviceEntity
();
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
0 → 100644
View file @
7a0859a9
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.busiz.req.UploadDeviceReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
MESSAGETYPE_NOTIFY_REFRESH
;
@RestController
@Slf4j
@RequestMapping
(
"/notify"
)
public
class
DeviceSendMsgController
{
@Autowired
private
DeviceService
deviceService
;
@Autowired
private
MessageProducer
messageProducer
;
@PostMapping
(
"refreshMessage"
)
public
String
refreshMessage
(
@RequestBody
UploadDeviceReq
req
)
{
log
.
info
(
"【设备通知刷新数据】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
//查询站点设备并通知每个设备
List
<
DeviceEntity
>
deviceList
=
deviceService
.
find
(
new
DeviceQuery
().
siteId
(
req
.
getSiteId
()));
for
(
DeviceEntity
deviceEntity
:
deviceList
)
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
MESSAGETYPE_NOTIFY_REFRESH
);
header
.
put
(
MessageHeader
.
DEVICECODE
,
deviceEntity
.
getDeviceCode
());
header
.
put
(
MessageHeader
.
TIMESTAMP
,
DateUtils
.
getCurrStrDateTime
());
TbQueueMsg
queueMsg
=
new
DefaultTbQueueMsg
(
IdUtil
.
fastUUID
(),
"=="
,
header
);
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
debug
(
"响应【设备通知刷新数据】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
}
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
View file @
7a0859a9
...
...
@@ -108,6 +108,11 @@ public final class Constant {
*/
public
static
final
String
MESSAGETYPE_HEARTBEAT
=
"HEART_BEAT"
;
/**
* 消息类型(通知更新)
*/
public
static
final
String
MESSAGETYPE_NOTIFY_REFRESH
=
"NOTIFY_REFRESH"
;
/**
* 消息类型(upgread)
*/
...
...
device-manager/src/main/java/com/mortals/xhx/common/utils/DownMsgTask.java
View file @
7a0859a9
...
...
@@ -13,14 +13,11 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
import
com.mortals.xhx.module.device.model.DeviceLogEntity
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -57,7 +54,7 @@ public class DownMsgTask implements Runnable {
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
item
.
getDeviceCode
());
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//将上报信息转发到mq中
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
/*
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (ObjectUtils.isEmpty(platformEntity)) {
log.error("当前设备未配置所属系统平台,请在后台配置后再激活!");
return;
...
...
@@ -66,9 +63,9 @@ public class DownMsgTask implements Runnable {
if (ObjectUtils.isEmpty(productEntity)) {
log.error("当前设备未配置所属产品,请在后台配置后再激活!");
return;
}
String
exchangeName
=
platformEntity
.
getPlatformSn
()
+
Constant
.
EXCHANGE_SPLIT
+
productEntity
.
getProductCode
();
TopicPartitionInfo
info
=
TopicPartitionInfo
.
builder
().
exchangeName
(
exchangeName
).
topic
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceMac
()).
build
();
}
*/
//
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
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
item
.
getMessageType
());
header
.
put
(
MessageHeader
.
DEVICECODE
,
item
.
getDeviceCode
());
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
7a0859a9
...
...
@@ -668,7 +668,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
protected
void
updateBefore
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateBefore
(
entity
,
context
);
ProductEntity
productEntity
=
productService
.
get
(
entity
.
getProductId
(),
context
);
entity
.
setProductCode
(
productEntity
.
getProductCode
());
entity
.
setProductCode
(
productEntity
==
null
?
""
:
productEntity
.
getProductCode
());
updateDeviceHomeUrl
(
entity
);
}
...
...
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