Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-devicemonitor
This project
Loading...
Sign in
Toggle navigation
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 9fb1e49e
authored
Sep 14, 2021
by
黄小葱
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增接口--实现接口(2)
1 parent
0a0f933f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
4 deletions
src/main/java/cn/com/glsx/devicemonitor/modules/api/DeviceApiController.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/utils/DeviceUtils.java
src/main/java/cn/com/glsx/devicemonitor/modules/api/DeviceApiController.java
View file @
9fb1e49
...
@@ -58,6 +58,12 @@ public class DeviceApiController implements DeviceFeignService {
...
@@ -58,6 +58,12 @@ public class DeviceApiController implements DeviceFeignService {
return
R
.
ok
().
data
(
statusModel
);
return
R
.
ok
().
data
(
statusModel
);
}
}
/**
* 批量获取设备状态
* @param sns
* @param offlineTime
* @return
*/
@Override
@Override
@PostMapping
(
value
=
"/listDeviceStatusBySns"
)
@PostMapping
(
value
=
"/listDeviceStatusBySns"
)
public
R
<
List
<
DeviceStatusModel
>>
listDeviceStatusBySns
(
Collection
<
String
>
sns
,
Long
offlineTime
)
{
public
R
<
List
<
DeviceStatusModel
>>
listDeviceStatusBySns
(
Collection
<
String
>
sns
,
Long
offlineTime
)
{
...
@@ -68,7 +74,6 @@ public class DeviceApiController implements DeviceFeignService {
...
@@ -68,7 +74,6 @@ public class DeviceApiController implements DeviceFeignService {
return
R
.
ok
().
data
(
deviceStatusList
);
return
R
.
ok
().
data
(
deviceStatusList
);
}
}
/**
/**
* 获取设备上点总个数
* 获取设备上点总个数
*
*
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
View file @
9fb1e49
...
@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
@Service
@Service
...
@@ -70,8 +71,26 @@ public class DeviceServiceImpl implements DeviceService {
...
@@ -70,8 +71,26 @@ public class DeviceServiceImpl implements DeviceService {
if
(
CollectionUtils
.
isEmpty
(
sns
))
{
if
(
CollectionUtils
.
isEmpty
(
sns
))
{
return
statusModels
;
return
statusModels
;
}
}
//TODO 正在实现...
Map
<
String
,
Device
>
deviceMap
=
deviceMapper
.
selectBySns
(
sns
).
stream
().
collect
(
Collectors
.
toMap
(
Device:
:
getSn
,
device
->
device
));
List
<
DeviceLoginDto
>
deviceLoginList
=
alarmCenterApi
.
listDeviceLoginBySns
(
String
.
join
(
","
,
sns
));
Map
<
String
,
DeviceLoginDto
>
loginDtoMap
=
deviceLoginList
.
stream
().
collect
(
Collectors
.
toMap
(
DeviceLoginDto:
:
getSn
,
deviceLoginDto
->
deviceLoginDto
));
Iterator
<
String
>
iterator
=
sns
.
stream
().
iterator
();
while
(
iterator
.
hasNext
())
{
String
sn
=
iterator
.
next
();
Device
device
=
deviceMap
.
get
(
sn
);
if
(
device
==
null
)
{
device
=
getRemoteDevice
(
sn
);
}
if
(
device
==
null
)
{
continue
;
}
DeviceLoginDto
deviceLogin
=
loginDtoMap
.
get
(
sn
);
if
(
deviceLogin
==
null
)
{
continue
;
}
statusModels
.
add
(
DeviceUtils
.
parseDeviceStatus
(
deviceLogin
,
device
.
getSource
(),
offlineTime
));
}
return
statusModels
;
return
statusModels
;
}
}
...
@@ -86,11 +105,16 @@ public class DeviceServiceImpl implements DeviceService {
...
@@ -86,11 +105,16 @@ public class DeviceServiceImpl implements DeviceService {
if
(
device
!=
null
)
{
if
(
device
!=
null
)
{
return
device
;
return
device
;
}
}
device
=
getRemoteDevice
(
sn
);
return
device
;
}
public
Device
getRemoteDevice
(
String
sn
)
{
TrackInfoBo
trackInfoBo
=
remoteDeviceService
.
getDeviceBySn
(
sn
);
TrackInfoBo
trackInfoBo
=
remoteDeviceService
.
getDeviceBySn
(
sn
);
if
(
trackInfoBo
==
null
)
{
if
(
trackInfoBo
==
null
)
{
return
null
;
return
null
;
}
}
device
=
new
Device
();
Device
device
=
new
Device
();
BeanUtils
.
copyProperties
(
trackInfoBo
,
device
);
BeanUtils
.
copyProperties
(
trackInfoBo
,
device
);
return
device
;
return
device
;
}
}
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/utils/DeviceUtils.java
View file @
9fb1e49
...
@@ -19,10 +19,12 @@ public class DeviceUtils {
...
@@ -19,10 +19,12 @@ public class DeviceUtils {
*/
*/
public
static
DeviceStatusModel
parseDeviceStatus
(
DeviceLoginDto
deviceLogin
,
Integer
source
,
long
offlineTime
)
{
public
static
DeviceStatusModel
parseDeviceStatus
(
DeviceLoginDto
deviceLogin
,
Integer
source
,
long
offlineTime
)
{
DeviceStatusModel
deviceStatus
=
new
DeviceStatusModel
();
DeviceStatusModel
deviceStatus
=
new
DeviceStatusModel
();
deviceStatus
.
setSource
(
source
);
if
(
deviceLogin
==
null
)
{
if
(
deviceLogin
==
null
)
{
return
deviceStatus
;
return
deviceStatus
;
}
}
deviceStatus
.
setSource
(
source
);
deviceStatus
.
setSn
(
deviceLogin
.
getSn
());
Date
lastGprsDate
=
deviceLogin
.
getLastgprstime
();
Date
lastGprsDate
=
deviceLogin
.
getLastgprstime
();
Date
lastRttrackDate
=
deviceLogin
.
getLastrttrack
();
Date
lastRttrackDate
=
deviceLogin
.
getLastrttrack
();
if
(
lastGprsDate
==
null
&&
lastRttrackDate
==
null
)
{
if
(
lastGprsDate
==
null
&&
lastRttrackDate
==
null
)
{
...
...
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