|
@@ -27,7 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.time.LocalDate;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
@@ -208,13 +208,9 @@ public class WebStatsGatewayImpl implements WebStatsGateway {
|
|
|
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()));
|
|
|
+ Map<String, BigDecimal> statInfo = devInfoService.queryStatInfo(params.getTenantId());
|
|
|
+ res.setDeviceCount(statInfo.get("deviceCount") == null ? 0 :statInfo.get("deviceCount").intValue());
|
|
|
+ res.setOnlineCount(statInfo.get("onlineCount") == null ? 0 :statInfo.get("onlineCount").intValue());
|
|
|
|
|
|
if (res.getOnlineCount() != 0) {
|
|
|
|
|
@@ -222,7 +218,6 @@ public class WebStatsGatewayImpl implements WebStatsGateway {
|
|
|
res.setActiveRate((double) activeCount / res.getOnlineCount());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
res.setFallingCount(Math.toIntExact(eventListService.lambdaQuery()
|
|
|
.eq(EventList::getTenantId, params.getTenantId())
|
|
|
.count()));
|
|
@@ -231,20 +226,73 @@ public class WebStatsGatewayImpl implements WebStatsGateway {
|
|
|
.count()));
|
|
|
|
|
|
|
|
|
- res.setDetectedCount(Math.toIntExact(devInfoService.lambdaQuery()
|
|
|
- .eq(DevInfo::getTenantId, params.getTenantId())
|
|
|
- .ge(DevInfo::getOnoffTime, LocalDate.now())
|
|
|
- .count()));
|
|
|
- // @Schema(description = "年龄统计信息")
|
|
|
- // private AgeInfo ageInfo;
|
|
|
- //
|
|
|
- // @Schema(description = "守护统计信息")
|
|
|
- // private GuardInfo guardInfo;
|
|
|
- //
|
|
|
- // @Schema(description = "安装位置统计信息")
|
|
|
- // private InstallPositionInfo installPositionInfo;
|
|
|
-
|
|
|
- res.setInstallPositionList(devInfoService.queryInstallCountByTenantId(params.getTenantId()));
|
|
|
+ res.setDetectedCount(statInfo.get("detectedCount") == null ? 0 :statInfo.get("detectedCount").intValue());
|
|
|
+
|
|
|
+ List<ScreenStatsDTO.InstallPositionInfo> installPositionList = new ArrayList<>();
|
|
|
+ ScreenStatsDTO.InstallPositionInfo toiletCount = new ScreenStatsDTO.InstallPositionInfo();
|
|
|
+ toiletCount.setInstallPosition("Toilet");
|
|
|
+ toiletCount.setCount(statInfo.get("toiletCount") == null ? 0 :statInfo.get("toiletCount").intValue());
|
|
|
+ installPositionList.add(toiletCount);
|
|
|
+
|
|
|
+ ScreenStatsDTO.InstallPositionInfo bedroomCount = new ScreenStatsDTO.InstallPositionInfo();
|
|
|
+ bedroomCount.setInstallPosition("Bedroom");
|
|
|
+ bedroomCount.setCount(statInfo.get("bedroomCount") == null ? 0 :statInfo.get("bedroomCount").intValue());
|
|
|
+ installPositionList.add(bedroomCount);
|
|
|
+
|
|
|
+ ScreenStatsDTO.InstallPositionInfo livingRoomCount = new ScreenStatsDTO.InstallPositionInfo();
|
|
|
+ livingRoomCount.setInstallPosition("LivingRoom");
|
|
|
+ livingRoomCount.setCount(statInfo.get("toiletCount") == null ? 0 :statInfo.get("toiletCount").intValue());
|
|
|
+ installPositionList.add(livingRoomCount);
|
|
|
+
|
|
|
+ ScreenStatsDTO.InstallPositionInfo restaurantCount = new ScreenStatsDTO.InstallPositionInfo();
|
|
|
+ restaurantCount.setInstallPosition("Restaurant");
|
|
|
+ restaurantCount.setCount(statInfo.get("restaurantCount") == null ? 0 :statInfo.get("restaurantCount").intValue());
|
|
|
+ installPositionList.add(restaurantCount);
|
|
|
+ res.setInstallPositionList(installPositionList);
|
|
|
+
|
|
|
+ List<ScreenStatsDTO.AgeInfo> ageList = new ArrayList<>();
|
|
|
+ ScreenStatsDTO.AgeInfo less60 = new ScreenStatsDTO.AgeInfo();
|
|
|
+ less60.setAgeRange("0-59");
|
|
|
+ less60.setCount(statInfo.get("less60") == null ? 0 :statInfo.get("less60").intValue());
|
|
|
+ ageList.add(less60);
|
|
|
+
|
|
|
+ ScreenStatsDTO.AgeInfo less70 = new ScreenStatsDTO.AgeInfo();
|
|
|
+ less70.setAgeRange("60-69");
|
|
|
+ less70.setCount(statInfo.get("less70") == null ? 0 :statInfo.get("less70").intValue());
|
|
|
+ ageList.add(less70);
|
|
|
+
|
|
|
+ ScreenStatsDTO.AgeInfo less80 = new ScreenStatsDTO.AgeInfo();
|
|
|
+ less80.setAgeRange("70-79");
|
|
|
+ less80.setCount(statInfo.get("less80") == null ? 0 :statInfo.get("less80").intValue());
|
|
|
+ ageList.add(less80);
|
|
|
+
|
|
|
+ ScreenStatsDTO.AgeInfo less90 = new ScreenStatsDTO.AgeInfo();
|
|
|
+ less90.setAgeRange("80-89");
|
|
|
+ less90.setCount(statInfo.get("less90") == null ? 0 :statInfo.get("less90").intValue());
|
|
|
+ ageList.add(less90);
|
|
|
+
|
|
|
+ ScreenStatsDTO.AgeInfo less100 = new ScreenStatsDTO.AgeInfo();
|
|
|
+ less100.setAgeRange("90-99");
|
|
|
+ less100.setCount(statInfo.get("less100") == null ? 0 :statInfo.get("less100").intValue());
|
|
|
+ ageList.add(less100);
|
|
|
+
|
|
|
+ ScreenStatsDTO.AgeInfo ge100 = new ScreenStatsDTO.AgeInfo();
|
|
|
+ ge100.setAgeRange("100+");
|
|
|
+ ge100.setCount(statInfo.get("ge100") == null ? 0 :statInfo.get("ge100").intValue());
|
|
|
+ ageList.add(ge100);
|
|
|
+ res.setAgeList(ageList);
|
|
|
+
|
|
|
+ List<ScreenStatsDTO.GuardInfo> guardList = new ArrayList<>();
|
|
|
+ ScreenStatsDTO.GuardInfo generalCount = new ScreenStatsDTO.GuardInfo();
|
|
|
+ generalCount.setGuardType("general");
|
|
|
+ generalCount.setCount(statInfo.get("generalCount") == null ? 0 :statInfo.get("generalCount").intValue());
|
|
|
+ guardList.add(generalCount);
|
|
|
+
|
|
|
+ ScreenStatsDTO.GuardInfo importantCount = new ScreenStatsDTO.GuardInfo();
|
|
|
+ importantCount.setGuardType("important");
|
|
|
+ importantCount.setCount(statInfo.get("importantCount") == null ? 0 :statInfo.get("importantCount").intValue());
|
|
|
+ guardList.add(importantCount);
|
|
|
+ res.setGuardList(guardList);
|
|
|
|
|
|
return res;
|
|
|
}
|