|
@@ -620,52 +620,19 @@ public class TkHomePageServiceImpl implements HomePageService { |
|
@@ -620,52 +620,19 @@ public class TkHomePageServiceImpl implements HomePageService { |
620
|
private void setAlarmAndMessageInfo(
|
620
|
private void setAlarmAndMessageInfo(
|
621
|
String tenantId, HomePageTopMessage messageInfo, BaseHomePageTop alarm)
|
621
|
String tenantId, HomePageTopMessage messageInfo, BaseHomePageTop alarm)
|
622
|
throws ExecutionException, InterruptedException {
|
622
|
throws ExecutionException, InterruptedException {
|
623
|
- List<EntityKey> entityFields = new ArrayList<>();
|
|
|
624
|
- entityFields.add(new EntityKey(EntityKeyType.ENTITY_FIELD, "name"));
|
|
|
625
|
- entityFields.add(new EntityKey(EntityKeyType.ENTITY_FIELD, "label"));
|
|
|
626
|
- entityFields.add(new EntityKey(EntityKeyType.ENTITY_FIELD, "additionalInfo"));
|
|
|
627
|
- List<EntityKey> latestValues = new ArrayList<>();
|
|
|
628
|
- latestValues.add(new EntityKey(EntityKeyType.TIME_SERIES, "transportMsgCount"));
|
|
|
629
|
- latestValues.add(new EntityKey(EntityKeyType.TIME_SERIES, "transportDataPointsCount"));
|
|
|
630
|
- latestValues.add(new EntityKey(EntityKeyType.TIME_SERIES, "createdAlarmsCount"));
|
|
|
631
|
-
|
623
|
+ List<String> dictionaries = new ArrayList<>();
|
|
|
624
|
+ dictionaries.add("transportMsgCount");
|
|
|
625
|
+ dictionaries.add("transportDataPointsCount");
|
|
|
626
|
+ dictionaries.add("createdAlarmsCount");
|
|
|
627
|
+ //查询所有数据
|
|
|
628
|
+ List<Integer> sumCount = deviceMapper.getMsgSumByTenantIdAndDictionary(tenantId,dictionaries);
|
|
|
629
|
+ if(!sumCount.isEmpty()){
|
|
|
630
|
+ messageInfo.setMessageCount(sumCount.get(0));
|
|
|
631
|
+ messageInfo.setDataPointsCount(sumCount.get(1));
|
|
|
632
|
+ alarm.setSumCount(sumCount.get(2));
|
|
|
633
|
+ }
|
632
|
TenantId currentTenantId = TenantId.fromUUID(UUID.fromString(tenantId));
|
634
|
TenantId currentTenantId = TenantId.fromUUID(UUID.fromString(tenantId));
|
633
|
ApiUsageState apiUsageState = apiUsageStateService.findTenantApiUsageState(currentTenantId);
|
635
|
ApiUsageState apiUsageState = apiUsageStateService.findTenantApiUsageState(currentTenantId);
|
634
|
- PageData<EntityData> pageData =
|
|
|
635
|
- queryEntityData(apiUsageState.getId(), currentTenantId, entityFields, latestValues);
|
|
|
636
|
- Map<EntityKeyType, Map<String, TsValue>> latest = pageData.getData().get(0).getLatest();
|
|
|
637
|
- latest
|
|
|
638
|
- .keySet()
|
|
|
639
|
- .forEach(
|
|
|
640
|
- item -> {
|
|
|
641
|
- if (item.equals(EntityKeyType.TIME_SERIES)) {
|
|
|
642
|
- Map<String, TsValue> tsValueMap = latest.get(item);
|
|
|
643
|
- tsValueMap
|
|
|
644
|
- .keySet()
|
|
|
645
|
- .forEach(
|
|
|
646
|
- mapKey -> {
|
|
|
647
|
- String tsValue = tsValueMap.get(mapKey).getValue();
|
|
|
648
|
- Integer value =
|
|
|
649
|
- StringUtils.isEmpty(tsValue)
|
|
|
650
|
- ? FastIotConstants.MagicNumber.ZERO
|
|
|
651
|
- : Integer.parseInt(tsValue);
|
|
|
652
|
- switch (mapKey) {
|
|
|
653
|
- case "createdAlarmsCount":
|
|
|
654
|
- alarm.setSumCount(value);
|
|
|
655
|
- break;
|
|
|
656
|
- case "transportMsgCount":
|
|
|
657
|
- messageInfo.setMessageCount(value);
|
|
|
658
|
- break;
|
|
|
659
|
- case "transportDataPointsCount":
|
|
|
660
|
- messageInfo.setDataPointsCount(value);
|
|
|
661
|
- break;
|
|
|
662
|
- default:
|
|
|
663
|
- break;
|
|
|
664
|
- }
|
|
|
665
|
- });
|
|
|
666
|
- }
|
|
|
667
|
- });
|
|
|
668
|
-
|
|
|
669
|
// 查询今日数据
|
636
|
// 查询今日数据
|
670
|
setTodayAlarmAndMessageInfo(currentTenantId, apiUsageState.getId(), messageInfo, alarm);
|
637
|
setTodayAlarmAndMessageInfo(currentTenantId, apiUsageState.getId(), messageInfo, alarm);
|
671
|
}
|
638
|
}
|