|
@@ -134,13 +134,15 @@ public class DevicePingInfoService extends SuperService {
|
|
|
* 检查设备的状态
|
|
* 检查设备的状态
|
|
|
*/
|
|
*/
|
|
|
public void checkDeviceState() {
|
|
public void checkDeviceState() {
|
|
|
-// log.info("checkDeviceState: {}", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
|
|
|
|
+ log.info("checkDeviceState: {}", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
List<DeviceInfo> list = deviceInfoDao.findAll();
|
|
List<DeviceInfo> list = deviceInfoDao.findAll();
|
|
|
if (ObjectUtils.isNotEmpty(list)) {
|
|
if (ObjectUtils.isNotEmpty(list)) {
|
|
|
long time = System.currentTimeMillis();
|
|
long time = System.currentTimeMillis();
|
|
|
list.parallelStream().forEach(deviceInfo -> {
|
|
list.parallelStream().forEach(deviceInfo -> {
|
|
|
- OnLineState onLineState = OnLineState.OnLine;
|
|
|
|
|
- List<DevicePingInfo> _list = devicePingInfoDao.findTop5ByDeviceIdOrderByCreateTimeDesc(deviceInfo.getDeviceId());
|
|
|
|
|
|
|
+ // 默认离线
|
|
|
|
|
+ OnLineState onLineState = OnLineState.OffLine;
|
|
|
|
|
+ List<DevicePingInfo> _list = devicePingInfoDao.findTop5ByDeviceIdOrderByCreateTimeDesc(
|
|
|
|
|
+ deviceInfo.getDeviceId());
|
|
|
if (_list != null && _list.size() > 2) {
|
|
if (_list != null && _list.size() > 2) {
|
|
|
Long firstTime = _list.get(0).getCreateTime();
|
|
Long firstTime = _list.get(0).getCreateTime();
|
|
|
Long lastTime = _list.get(_list.size() - 1).getCreateTime();
|
|
Long lastTime = _list.get(_list.size() - 1).getCreateTime();
|
|
@@ -154,7 +156,7 @@ public class DevicePingInfoService extends SuperService {
|
|
|
onLineState = OnLineState.OffLine;
|
|
onLineState = OnLineState.OffLine;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ log.info("{} {}", deviceInfo.getDeviceId(), onLineState);
|
|
|
if (onLineState != deviceInfo.getOnLineState()) {
|
|
if (onLineState != deviceInfo.getOnLineState()) {
|
|
|
log.info("设备在线状态改变:{} {}", deviceInfo.getDeviceName(), onLineState);
|
|
log.info("设备在线状态改变:{} {}", deviceInfo.getDeviceName(), onLineState);
|
|
|
Map<String, Object> standardData = new HashMap<String, Object>();
|
|
Map<String, Object> standardData = new HashMap<String, Object>();
|