Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7e058801
authored
Nov 01, 2024
by
姚冰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add] 设备离线正常处理
1 parent
a9f661be
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
src/main/java/vion/event/mqtt/MqttClientMessageListener.java
src/main/java/vion/event/mqtt/MqttClientMessageListener.java
View file @
7e05880
...
...
@@ -29,6 +29,7 @@ import vion.service.monitor.IRAgentEventService;
import
vion.utils.JsonUtil
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
vion
.
constant
.
MqttMessageType
.
WHOLEDAYA_ANALYZE
;
...
...
@@ -112,6 +113,14 @@ public class MqttClientMessageListener implements IMqttClientMessageListener {
EventRecord
eventRecord
=
JsonUtil
.
parseObject
(
payloadStr
,
EventRecord
.
class
);
String
list
=
(
String
)
eventRecord
.
getData
();
List
<
OfflineDevice
>
deviceList
=
JsonUtil
.
parseArray
(
list
,
OfflineDevice
.
class
);
List
<
EventRecord
>
records
=
new
ArrayList
<>();
if
(
deviceList
==
null
||
deviceList
.
isEmpty
())
{
EventRecord
eventRecord1
=
new
EventRecord
();
BeanUtil
.
copyProperties
(
eventRecord
,
eventRecord1
);
eventRecord1
.
setEventUid
(
eventRecord
.
getEventUid
());
//入库
records
.
add
(
eventRecord1
);
}
else
{
for
(
int
i
=
0
;
i
<
deviceList
.
size
();
i
++)
{
OfflineDevice
device
=
deviceList
.
get
(
i
);
EventRecord
eventRecord1
=
new
EventRecord
();
...
...
@@ -125,7 +134,12 @@ public class MqttClientMessageListener implements IMqttClientMessageListener {
eventRecord1
.
setStatus
(
EventStatusEnum
.
FAIL
.
getCode
());
}
//入库
recordService
.
save
(
eventRecord1
);
records
.
add
(
eventRecord1
);
}
}
if
(!
records
.
isEmpty
())
{
recordService
.
saveBatch
(
records
);
}
// logger.info("设备离线:{}", JSON.toJSONString(eventRecord));
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment