refactor(sis): 1

This commit is contained in:
2025-08-28 19:52:11 +08:00
parent d6623bb9da
commit db29ef77fa
2 changed files with 7 additions and 14 deletions

View File

@@ -249,6 +249,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
.toArray(BigDecimal[]::new);
hourMap.put("categories", hourCategories);
hourMap.put("data", hourData);
hourMap.put("total" , hourList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue());
// day
String[] monthArr = month.split("-");
@@ -262,6 +263,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
.toArray(BigDecimal[]::new);
dayMap.put("categories", dayCategories);
dayMap.put("data", dayData);
dayMap.put("total", dayList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue());
// month
List<Map<String, Object>> monthList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year);
@@ -274,6 +276,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
.toArray(BigDecimal[]::new);
monthMap.put("categories", monthCategories);
monthMap.put("data", monthData);
monthMap.put("total", monthList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue());
resultMap.put("hour", hourMap);