|
@@ -1,12 +1,14 @@
|
|
|
package com.usky.sas.service.impl;
|
|
package com.usky.sas.service.impl;
|
|
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
-import com.usky.common.core.bean.CommonPage;
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
import com.usky.sas.domain.SasCollectionEvent;
|
|
import com.usky.sas.domain.SasCollectionEvent;
|
|
|
|
|
+import com.usky.sas.domain.SasConfig;
|
|
|
import com.usky.sas.domain.SasDevice;
|
|
import com.usky.sas.domain.SasDevice;
|
|
|
import com.usky.sas.domain.SasSnapEvent;
|
|
import com.usky.sas.domain.SasSnapEvent;
|
|
|
import com.usky.sas.mapper.SasCollectionEventMapper;
|
|
import com.usky.sas.mapper.SasCollectionEventMapper;
|
|
|
|
|
+import com.usky.sas.mapper.SasConfigMapper;
|
|
|
import com.usky.sas.mapper.SasDeviceMapper;
|
|
import com.usky.sas.mapper.SasDeviceMapper;
|
|
|
import com.usky.sas.mapper.SasSnapEventMapper;
|
|
import com.usky.sas.mapper.SasSnapEventMapper;
|
|
|
import com.usky.sas.service.SasHomepageService;
|
|
import com.usky.sas.service.SasHomepageService;
|
|
@@ -18,144 +20,826 @@ import com.usky.sas.service.vo.IntelligentEventPageRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.common.core.bean.CommonPage;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.sas.domain.*;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.sas.mapper.*;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.sas.service.SasHomepageService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.sas.service.SasIntelligentService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.sas.service.converter.EventConverter;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.usky.sas.service.vo.*;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
+
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
|
|
+
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
|
+
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+
|
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
|
|
|
+
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
+
|
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public class SasHomepageServiceImpl implements SasHomepageService {
|
|
public class SasHomepageServiceImpl implements SasHomepageService {
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private SasDeviceMapper sasDeviceMapper;
|
|
private SasDeviceMapper sasDeviceMapper;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private SasCollectionEventMapper sasCollectionEventMapper;
|
|
private SasCollectionEventMapper sasCollectionEventMapper;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private SasSnapEventMapper sasSnapEventMapper;
|
|
private SasSnapEventMapper sasSnapEventMapper;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private SasIntelligentService sasIntelligentService;
|
|
private SasIntelligentService sasIntelligentService;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private SasConfigMapper sasConfigMapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public HomepageInfoResponse getHomepageInfo() {
|
|
public HomepageInfoResponse getHomepageInfo() {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
List<SasDevice> devices = sasDeviceMapper.selectList(Wrappers.lambdaQuery());
|
|
List<SasDevice> devices = sasDeviceMapper.selectList(Wrappers.lambdaQuery());
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
HomepageInfoResponse resp = new HomepageInfoResponse();
|
|
HomepageInfoResponse resp = new HomepageInfoResponse();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
resp.setCameras(devices.stream().map(this::toCameraItem).collect(Collectors.toList()));
|
|
resp.setCameras(devices.stream().map(this::toCameraItem).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
HomepageInfoResponse.Statistics stat = new HomepageInfoResponse.Statistics();
|
|
HomepageInfoResponse.Statistics stat = new HomepageInfoResponse.Statistics();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
stat.setTotalDevices((long) devices.size());
|
|
stat.setTotalDevices((long) devices.size());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
stat.setOnlineDevices(devices.stream().filter(this::isOnline).count());
|
|
stat.setOnlineDevices(devices.stream().filter(this::isOnline).count());
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
LocalDateTime startOfDay = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
|
LocalDateTime startOfDay = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
LocalDateTime endOfDay = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
|
|
LocalDateTime endOfDay = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
LambdaQueryWrapper<SasCollectionEvent> wrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<SasCollectionEvent> wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
wrapper.between(SasCollectionEvent::getTriggerTime, startOfDay, endOfDay);
|
|
wrapper.between(SasCollectionEvent::getTriggerTime, startOfDay, endOfDay);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
long todayEvents = sasCollectionEventMapper.selectCount(wrapper);
|
|
long todayEvents = sasCollectionEventMapper.selectCount(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
stat.setTodayEvents(todayEvents);
|
|
stat.setTodayEvents(todayEvents);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 暂无单独报警事件表,这里先与今日事件数保持一致
|
|
// 暂无单独报警事件表,这里先与今日事件数保持一致
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
stat.setAlarmEvents(todayEvents);
|
|
stat.setAlarmEvents(todayEvents);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
resp.setStatistics(stat);
|
|
resp.setStatistics(stat);
|
|
|
|
|
|
|
|
- // 左下角:服务器信息与资源使用情况
|
|
|
|
|
- resp.setServerInfo(buildServerInfo());
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return resp;
|
|
return resp;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- private HomepageInfoResponse.ServerInfo buildServerInfo() {
|
|
|
|
|
- Runtime runtime = Runtime.getRuntime();
|
|
|
|
|
- long maxMemory = runtime.maxMemory();
|
|
|
|
|
- long totalMemory = runtime.totalMemory();
|
|
|
|
|
- long freeMemory = runtime.freeMemory();
|
|
|
|
|
- long usedMemory = totalMemory - freeMemory;
|
|
|
|
|
|
|
|
|
|
- HomepageInfoResponse.ServerInfo serverInfo = new HomepageInfoResponse.ServerInfo();
|
|
|
|
|
- serverInfo.setMemoryMaxMb(maxMemory == Long.MAX_VALUE ? null : maxMemory / (1024 * 1024));
|
|
|
|
|
- serverInfo.setMemoryUsedMb(usedMemory / (1024 * 1024));
|
|
|
|
|
- serverInfo.setMemoryFreeMb(freeMemory / (1024 * 1024));
|
|
|
|
|
- serverInfo.setAvailableProcessors(runtime.availableProcessors());
|
|
|
|
|
- serverInfo.setServerTime(LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
|
|
|
|
- return serverInfo;
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private HomepageInfoResponse.CameraItem toCameraItem(SasDevice d) {
|
|
private HomepageInfoResponse.CameraItem toCameraItem(SasDevice d) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
HomepageInfoResponse.CameraItem c = new HomepageInfoResponse.CameraItem();
|
|
HomepageInfoResponse.CameraItem c = new HomepageInfoResponse.CameraItem();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
c.setId(d.getId());
|
|
c.setId(d.getId());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
c.setName(d.getDeviceId());
|
|
c.setName(d.getDeviceId());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
c.setIpAddr(d.getIpAddr());
|
|
c.setIpAddr(d.getIpAddr());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
c.setStatus(isOnline(d) ? "online" : "offline");
|
|
c.setStatus(isOnline(d) ? "online" : "offline");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (d.getIpAddr() != null) {
|
|
if (d.getIpAddr() != null) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
c.setLiveUrl("rtsp://" + d.getIpAddr() + ":554/stream");
|
|
c.setLiveUrl("rtsp://" + d.getIpAddr() + ":554/stream");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
c.setPlaybackUrl("http://192.168.10.151/playback");
|
|
c.setPlaybackUrl("http://192.168.10.151/playback");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return c;
|
|
return c;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private boolean isOnline(SasDevice d) {
|
|
private boolean isOnline(SasDevice d) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (d.getTriggerTime() == null) {
|
|
if (d.getTriggerTime() == null) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return false;
|
|
return false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
long seconds = ChronoUnit.SECONDS.between(d.getTriggerTime(), LocalDateTime.now());
|
|
long seconds = ChronoUnit.SECONDS.between(d.getTriggerTime(), LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return seconds <= 60;
|
|
return seconds <= 60;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public CommonPage<IntelligentEventItem> getEventList(IntelligentEventPageRequest request) {
|
|
|
|
|
- return sasIntelligentService.queryEvents(request);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public CommonPage<IntelligentEventItem> getEventList(IntelligentEventPageRequest request) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return sasIntelligentService.queryEvents(request);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public List<IntelligentEventItem> getRealtimeNotificationEvents() {
|
|
public List<IntelligentEventItem> getRealtimeNotificationEvents() {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
LambdaQueryWrapper<SasSnapEvent> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SasSnapEvent> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
wrapper.eq(SasSnapEvent::getNotify, true);
|
|
wrapper.eq(SasSnapEvent::getNotify, true);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
wrapper.orderByDesc(SasSnapEvent::getTriggerTime);
|
|
wrapper.orderByDesc(SasSnapEvent::getTriggerTime);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
wrapper.last("LIMIT 20");
|
|
wrapper.last("LIMIT 20");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
List<SasSnapEvent> list = sasSnapEventMapper.selectList(wrapper);
|
|
List<SasSnapEvent> list = sasSnapEventMapper.selectList(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (list == null) {
|
|
if (list == null) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return list.stream().map(this::snapToEventItem).collect(Collectors.toList());
|
|
return list.stream().map(this::snapToEventItem).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public CommonPage<IntelligentEventItem> getAlertHistory(HomepageAlertHistoryRequest request) {
|
|
public CommonPage<IntelligentEventItem> getAlertHistory(HomepageAlertHistoryRequest request) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (!"snap".equals(request.getEventType())) {
|
|
if (!"snap".equals(request.getEventType())) {
|
|
|
- return new CommonPage<>(Collections.emptyList(), 0L, request.getCurrent().longValue(), request.getSize().longValue());
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return new CommonPage<>(Collections.emptyList(), 0L, request.getPage().longValue(), request.getPageSize().longValue());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<SasSnapEvent> page =
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<SasSnapEvent> page =
|
|
|
- new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(request.getCurrent(), request.getSize());
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(request.getPage(), request.getPageSize());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
LambdaQueryWrapper<SasSnapEvent> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SasSnapEvent> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
wrapper.eq(SasSnapEvent::getNotify, true);
|
|
wrapper.eq(SasSnapEvent::getNotify, true);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
wrapper.orderByDesc(SasSnapEvent::getTriggerTime);
|
|
wrapper.orderByDesc(SasSnapEvent::getTriggerTime);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
page = sasSnapEventMapper.selectPage(page, wrapper);
|
|
page = sasSnapEventMapper.selectPage(page, wrapper);
|
|
|
- List<SasSnapEvent> records = page.getRecords() == null ? Collections.emptyList() : page.getRecords();
|
|
|
|
|
- List<IntelligentEventItem> list = records.stream().map(this::snapToEventItem).collect(Collectors.toList());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ List<IntelligentEventItem> list = (page.getRecords() == null ? Collections.<SasSnapEvent>emptyList() : page.getRecords())
|
|
|
|
|
+ .stream().map(this::snapToEventItem).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return new CommonPage<>(list, page.getTotal(), page.getCurrent(), page.getSize());
|
|
return new CommonPage<>(list, page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private IntelligentEventItem snapToEventItem(SasSnapEvent e) {
|
|
private IntelligentEventItem snapToEventItem(SasSnapEvent e) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
IntelligentEventItem item = new IntelligentEventItem();
|
|
IntelligentEventItem item = new IntelligentEventItem();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setEventId(e.getEventId());
|
|
item.setEventId(e.getEventId());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setDeviceId(e.getDeviceId());
|
|
item.setDeviceId(e.getDeviceId());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setChannel(e.getChannel());
|
|
item.setChannel(e.getChannel());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setTriggerTime(e.getTriggerTime());
|
|
item.setTriggerTime(e.getTriggerTime());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setEventCode(e.getEventCode());
|
|
item.setEventCode(e.getEventCode());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setScenePicId(e.getScenePicId());
|
|
item.setScenePicId(e.getScenePicId());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setEventPicId(e.getEventPicId());
|
|
item.setEventPicId(e.getEventPicId());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setSimilarity(e.getSimilarity());
|
|
item.setSimilarity(e.getSimilarity());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setPersonCode(e.getPersonCode());
|
|
item.setPersonCode(e.getPersonCode());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setNotify(e.getNotify());
|
|
item.setNotify(e.getNotify());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
item.setScene(e.getScene());
|
|
item.setScene(e.getScene());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return item;
|
|
return item;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public SystemResourceResponse getSystemResource() {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SystemResourceResponse response = new SystemResourceResponse();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // CPU信息
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SystemResourceResponse.CpuInfo cpu = new SystemResourceResponse.CpuInfo();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Runtime runtime = Runtime.getRuntime();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ cpu.setCoreCount(runtime.availableProcessors());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 获取CPU使用率
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ com.sun.management.OperatingSystemMXBean osBean =
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double cpuUsage = osBean.getSystemCpuLoad() * 100;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ cpu.setUsageRate(df.format(cpuUsage) + "%");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ response.setCpu(cpu);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 内存信息
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SystemResourceResponse.MemoryInfo memory = new SystemResourceResponse.MemoryInfo();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long maxMemory = runtime.maxMemory();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long totalMemory = runtime.totalMemory();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long freeMemory = runtime.freeMemory();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long usedMemory = totalMemory - freeMemory;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double totalMemoryGB = maxMemory / (1024.0 * 1024.0 * 1024.0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double usedMemoryGB = usedMemory / (1024.0 * 1024.0 * 1024.0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double freeMemoryGB = (maxMemory - usedMemory) / (1024.0 * 1024.0 * 1024.0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double memoryUsageRate = (usedMemory * 100.0) / maxMemory;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ memory.setTotalSize(df.format(totalMemoryGB) + " GB");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ memory.setUsedSize(df.format(usedMemoryGB) + " GB");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ memory.setFreeSize(df.format(freeMemoryGB) + " GB");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ memory.setUsageRate(df.format(memoryUsageRate) + "%");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ response.setMemory(memory);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 磁盘信息
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SystemResourceResponse.DiskInfo disk = new SystemResourceResponse.DiskInfo();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ File[] roots = File.listRoots();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long totalSpace = 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long usableSpace = 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (File root : roots) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ totalSpace += root.getTotalSpace();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ usableSpace += root.getUsableSpace();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ long usedSpace = totalSpace - usableSpace;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double totalSpaceGB = totalSpace / (1024.0 * 1024.0 * 1024.0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double usedSpaceGB = usedSpace / (1024.0 * 1024.0 * 1024.0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double usableSpaceGB = usableSpace / (1024.0 * 1024.0 * 1024.0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ double diskUsageRate = totalSpace > 0 ? (usedSpace * 100.0) / totalSpace : 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ disk.setTotalSize(df.format(totalSpaceGB) + " GB");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ disk.setUsedSize(df.format(usedSpaceGB) + " GB");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ disk.setFreeSize(df.format(usableSpaceGB) + " GB");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ disk.setUsageRate(df.format(diskUsageRate) + "%");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ response.setDisk(disk);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // Agbox/MetaBus信息
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SystemResourceResponse.AgboxInfo agbox = new SystemResourceResponse.AgboxInfo();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ SasConfig config = sasConfigMapper.selectById(1);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (config != null) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setHost(config.getHost());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setPort(config.getPort());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setStatus("正常");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setEventListenStatus("监听中");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setHost("192.168.10.159");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setPort("1883");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setStatus("正常");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ agbox.setEventListenStatus("监听中");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ response.setAgboxMetaBus(agbox);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return response;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|