|
|
@@ -7,22 +7,29 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.hfln.portal.common.constant.UserConstants;
|
|
|
import com.hfln.portal.common.dto.data.event.EventListDTO;
|
|
|
import com.hfln.portal.common.dto.data.event.EventsDTO;
|
|
|
+import com.hfln.portal.common.dto.data.stat.ScreenAlarmDTO;
|
|
|
+import com.hfln.portal.common.dto.data.stat.ScreenFallingDTO;
|
|
|
+import com.hfln.portal.common.dto.data.stat.ScreenStatsDTO;
|
|
|
import com.hfln.portal.common.dto.data.user.UserDailyActiveDTO;
|
|
|
import com.hfln.portal.common.request.event.EventListParams;
|
|
|
import com.hfln.portal.common.request.event.WebEventsParams;
|
|
|
+import com.hfln.portal.common.request.stat.ScreenAlarmQueryParams;
|
|
|
+import com.hfln.portal.common.request.stat.ScreenFallingQueryParams;
|
|
|
+import com.hfln.portal.common.request.stat.ScreenStatQueryParams;
|
|
|
import com.hfln.portal.common.request.user.UserDailyActiveParams;
|
|
|
import com.hfln.portal.common.vo.PageRecord;
|
|
|
import com.hfln.portal.domain.customer.AdminUserType;
|
|
|
import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
|
import com.hfln.portal.domain.gateway.WebStatsGateway;
|
|
|
-import com.hfln.portal.infrastructure.po.DailyActiveUsers;
|
|
|
-import com.hfln.portal.infrastructure.po.EventList;
|
|
|
-import com.hfln.portal.infrastructure.po.UserInfo;
|
|
|
+import com.hfln.portal.infrastructure.po.*;
|
|
|
import com.hfln.portal.infrastructure.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -46,6 +53,9 @@ public class WebStatsGatewayImpl implements WebStatsGateway {
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TblTenantService tblTenantService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public PageRecord<EventListDTO> fallQuery(EventListParams params) {
|
|
|
@@ -187,6 +197,73 @@ public class WebStatsGatewayImpl implements WebStatsGateway {
|
|
|
|
|
|
return pageRecord;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ScreenStatsDTO queryScreen(ScreenStatQueryParams params) {
|
|
|
+ ScreenStatsDTO res = new ScreenStatsDTO();
|
|
|
+
|
|
|
+ TblTenant tenant = tblTenantService.getById(params.getTenantId());
|
|
|
+ res.setSystemGuardDay((int) ChronoUnit.DAYS.between(tenant.getCreateTime(), LocalDateTime.now()));
|
|
|
+
|
|
|
+ res.setDeviceCount(Math.toIntExact(devInfoService.lambdaQuery()
|
|
|
+ .eq(DevInfo::getTenantId, params.getTenantId())
|
|
|
+ .count()));
|
|
|
+ res.setOnlineCount(Math.toIntExact(devInfoService.lambdaQuery()
|
|
|
+ .eq(DevInfo::getTenantId, params.getTenantId())
|
|
|
+ .eq(DevInfo::getOnline, DevInfo.Constants.OnlineStatus.ONLINE)
|
|
|
+ .count()));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ res.setFallingCount(Math.toIntExact(eventListService.lambdaQuery()
|
|
|
+ .eq(EventList::getTenantId, params.getTenantId())
|
|
|
+ .count()));
|
|
|
+ res.setAlarmCount(Math.toIntExact(eventsService.lambdaQuery()
|
|
|
+ .eq(Events::getTenantId, params.getTenantId())
|
|
|
+ .count()));
|
|
|
+
|
|
|
+
|
|
|
+ res.setDetectedCount(Math.toIntExact(devInfoService.lambdaQuery()
|
|
|
+ .eq(DevInfo::getTenantId, params.getTenantId())
|
|
|
+ .ge(DevInfo::getOfflineTime, LocalDate.now())
|
|
|
+ .count()));
|
|
|
+ // @Schema(description = "年龄统计信息")
|
|
|
+ // private AgeInfo ageInfo;
|
|
|
+ //
|
|
|
+ // @Schema(description = "守护统计信息")
|
|
|
+ // private GuardInfo guardInfo;
|
|
|
+ //
|
|
|
+ // @Schema(description = "安装位置统计信息")
|
|
|
+ // private InstallPositionInfo installPositionInfo;
|
|
|
+
|
|
|
+ res.setInstallPositionList(devInfoService.queryInstallCountByTenantId(params.getTenantId()));
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ScreenAlarmDTO queryAlarm(ScreenAlarmQueryParams params) {
|
|
|
+
|
|
|
+ ScreenAlarmDTO screenAlarmDTO = new ScreenAlarmDTO();
|
|
|
+ if (params.getQueryType().equals("month")) {
|
|
|
+ screenAlarmDTO.setMonthStatInfo(eventsService.queryEventsInSixMonths(params.getTenantId()));
|
|
|
+ } else if (params.getQueryType().equals("day")) {
|
|
|
+ screenAlarmDTO.setDayStatInfo(eventsService.queryEventsInSevenDays(params.getTenantId()));
|
|
|
+ }
|
|
|
+ return screenAlarmDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ScreenFallingDTO queryFalling(ScreenFallingQueryParams params) {
|
|
|
+
|
|
|
+ ScreenFallingDTO screenAlarmDTO = new ScreenFallingDTO();
|
|
|
+ if (params.getQueryType().equals("month")) {
|
|
|
+ screenAlarmDTO.setMonthStatInfo(eventListService.queryEventsInSixMonths(params.getTenantId()));
|
|
|
+ } else if (params.getQueryType().equals("day")) {
|
|
|
+ screenAlarmDTO.setDayStatInfo(eventListService.queryEventsInSevenDays(params.getTenantId()));
|
|
|
+ }
|
|
|
+ return screenAlarmDTO;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|