Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-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-platform
Commits
7b570154
Commit
7b570154
authored
Aug 15, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备告警
parent
3ff5f8bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceStatTaskImpl.java
.../java/com/mortals/xhx/daemon/task/DeviceStatTaskImpl.java
+11
-5
No files found.
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceStatTaskImpl.java
View file @
7b570154
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.fasterxml.jackson.core.json.JsonGeneratorImpl
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.DateUtils
;
...
...
@@ -32,6 +33,8 @@ import java.util.Date;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.
KEY_DEVICE_TYPE_CACHE
;
/**
* 设备状态任务
*
...
...
@@ -51,6 +54,8 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
private
SendTaskThreadPool
sendTaskThreadPool
;
@Autowired
private
DeviceAlarmService
deviceAlarmService
;
@Autowired
private
ICacheService
cacheService
;
@Override
...
...
@@ -82,13 +87,14 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
//更新设备下线
device
.
setOfflineTime
(
new
Date
());
device
.
setDeviceOnlineStatus
(
DeviceOnlineStatusEnum
.
离线
.
getValue
());
cacheService
.
del
(
KEY_DEVICE_TYPE_CACHE
+
device
.
getDeviceCode
());
return
device
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
log
.
info
(
"更新设备下线:{} ,时间:{}"
,
JSON
.
toJSONString
(
collect
),
DateUtils
.
getStrDateTime
(
new
Date
(
System
.
currentTimeMillis
()
-
timeout
)));
deviceService
.
update
(
collect
,
null
);
log
.
info
(
"更新设备下线:{} ,时间:{}"
,
JSON
.
toJSONString
(
collect
),
DateUtils
.
getStrDateTime
(
new
Date
(
System
.
currentTimeMillis
()
-
timeout
)));
deviceService
.
update
(
collect
,
null
);
List
<
DeviceAlarmEntity
>
alarmEntityList
=
collect
.
stream
().
map
(
device
->
{
//新增告警信息
...
...
@@ -140,9 +146,9 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
deviceService
.
getCacheList
().
parallelStream
()
.
filter
(
f
->
f
.
getDeviceSource
()
==
DeviceSourceEnum
.
其它
.
getValue
())
.
peek
(
device
->
{
String
sendUrl
=
GlobalSysInfo
.
getParamValue
(
ParamKey
.
SYS_PARAM_SEND_QUERY_URL
,
"http://127.0.0.1:18211/m/test/equipStateQuery"
);
String
sendUrl
=
GlobalSysInfo
.
getParamValue
(
ParamKey
.
SYS_PARAM_SEND_QUERY_URL
,
"http://127.0.0.1:18211/m/test/equipStateQuery"
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"macAddress"
,
device
.
getDeviceMac
());
jsonObject
.
put
(
"macAddress"
,
device
.
getDeviceMac
());
SendTask
sendTask
=
new
SendTask
(
sendUrl
,
device
.
getId
(),
jsonObject
.
toJSONString
(),
deviceService
);
sendTaskThreadPool
.
execute
(
sendTask
);
}).
count
();
...
...
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