Commit 47275a79 authored by 赵啸非's avatar 赵啸非

修改统计逻辑

parent b86da8ce
......@@ -49,7 +49,9 @@ public class DeviceMessageStatController extends BaseCRUDJsonBodyMappingControll
//重新分组返回 [{date:2024-8}]
if (!ObjectUtils.isEmpty(statEntities)) {
//按月分组
Map<Integer, Map<String, List<DeviceMessageStatEntity>>> collect = statEntities.stream().collect(Collectors.groupingBy(DeviceMessageStatEntity::getMonth, Collectors.groupingBy(DeviceMessageStatEntity::getProductName, Collectors.toList())));
Map<Integer, Map<String, List<DeviceMessageStatEntity>>> collect = statEntities.stream()
.collect(Collectors.groupingBy(DeviceMessageStatEntity::getMonth, Collectors.groupingBy(DeviceMessageStatEntity::getProductName,
Collectors.toList())));
Map<Integer, Integer> monthStat = statEntities.stream().collect(Collectors.groupingBy(DeviceMessageStatEntity::getMonth, Collectors.summingInt(x -> x.getAlarmTotalCount())));
List<ProductEntity> productEntities = new ArrayList<ProductEntity>();
......@@ -65,7 +67,7 @@ public class DeviceMessageStatController extends BaseCRUDJsonBodyMappingControll
Map<String, List<DeviceMessageStatEntity>> map = new HashMap<>();
for (ProductEntity productEntity : productEntities) {
DeviceMessageStatEntity deviceMessageStatEntity = new DeviceMessageStatEntity();
deviceMessageStatEntity.initAttrValue();
deviceMessageStatEntity.setAlarmTotalCount(0);
map.put(productEntity.getProductName(), Arrays.asList(deviceMessageStatEntity));
}
collect.put(i, map);
......@@ -76,6 +78,8 @@ public class DeviceMessageStatController extends BaseCRUDJsonBodyMappingControll
}
model.put("stat", collect);
model.put("monthStat", monthStat);
model.put(KEY_RESULT_DATA, null);
}
return super.doListAfter(query, model, context);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment