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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 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;
...
@@ -29,6 +29,7 @@ import vion.service.monitor.IRAgentEventService;
import
vion.utils.JsonUtil
;
import
vion.utils.JsonUtil
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
static
vion
.
constant
.
MqttMessageType
.
WHOLEDAYA_ANALYZE
;
import
static
vion
.
constant
.
MqttMessageType
.
WHOLEDAYA_ANALYZE
;
...
@@ -112,20 +113,33 @@ public class MqttClientMessageListener implements IMqttClientMessageListener {
...
@@ -112,20 +113,33 @@ public class MqttClientMessageListener implements IMqttClientMessageListener {
EventRecord
eventRecord
=
JsonUtil
.
parseObject
(
payloadStr
,
EventRecord
.
class
);
EventRecord
eventRecord
=
JsonUtil
.
parseObject
(
payloadStr
,
EventRecord
.
class
);
String
list
=
(
String
)
eventRecord
.
getData
();
String
list
=
(
String
)
eventRecord
.
getData
();
List
<
OfflineDevice
>
deviceList
=
JsonUtil
.
parseArray
(
list
,
OfflineDevice
.
class
);
List
<
OfflineDevice
>
deviceList
=
JsonUtil
.
parseArray
(
list
,
OfflineDevice
.
class
);
for
(
int
i
=
0
;
i
<
deviceList
.
size
();
i
++)
{
List
<
EventRecord
>
records
=
new
ArrayList
<>();
OfflineDevice
device
=
deviceList
.
get
(
i
);
if
(
deviceList
==
null
||
deviceList
.
isEmpty
())
{
EventRecord
eventRecord1
=
new
EventRecord
();
EventRecord
eventRecord1
=
new
EventRecord
();
BeanUtil
.
copyProperties
(
eventRecord
,
eventRecord1
);
BeanUtil
.
copyProperties
(
eventRecord
,
eventRecord1
);
eventRecord1
.
setEventUid
(
eventRecord
.
getEventUid
());
eventRecord1
.
setEventUid
(
eventRecord
.
getEventUid
());
eventRecord1
.
setData
(
JsonUtil
.
toJsonString
(
device
));
eventRecord1
.
setMallUid
(
deviceList
.
get
(
i
).
getMallUid
());
if
(
StringUtils
.
isEmpty
(
device
.
getDevices
()))
{
eventRecord1
.
setStatus
(
EventStatusEnum
.
SUCCESS
.
getCode
());
}
else
{
eventRecord1
.
setStatus
(
EventStatusEnum
.
FAIL
.
getCode
());
}
//入库
//入库
recordService
.
save
(
eventRecord1
);
records
.
add
(
eventRecord1
);
}
else
{
for
(
int
i
=
0
;
i
<
deviceList
.
size
();
i
++)
{
OfflineDevice
device
=
deviceList
.
get
(
i
);
EventRecord
eventRecord1
=
new
EventRecord
();
BeanUtil
.
copyProperties
(
eventRecord
,
eventRecord1
);
eventRecord1
.
setEventUid
(
eventRecord
.
getEventUid
());
eventRecord1
.
setData
(
JsonUtil
.
toJsonString
(
device
));
eventRecord1
.
setMallUid
(
deviceList
.
get
(
i
).
getMallUid
());
if
(
StringUtils
.
isEmpty
(
device
.
getDevices
()))
{
eventRecord1
.
setStatus
(
EventStatusEnum
.
SUCCESS
.
getCode
());
}
else
{
eventRecord1
.
setStatus
(
EventStatusEnum
.
FAIL
.
getCode
());
}
//入库
records
.
add
(
eventRecord1
);
}
}
if
(!
records
.
isEmpty
())
{
recordService
.
saveBatch
(
records
);
}
}
// logger.info("设备离线:{}", JSON.toJSONString(eventRecord));
// 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