|
|
@@ -145,7 +145,7 @@ public class AcquisitionDailyServiceImpl implements AcquisitionDailyService {
|
|
|
|
|
|
// 计算月度小计
|
|
|
Map<String, Double> monthCategoryCountMap = calculateMonthCategoryCount(dailyItems, categoryNames);
|
|
|
- double totalCount = calculateTotalCountSum(dailyItems);
|
|
|
+ double totalCount = calculateTotalCountSum(dailyItems,categoryNames);
|
|
|
cumulativeTotalCount += totalCount;
|
|
|
Map<String, Object> subtotalDataVO = createSummaryRow(
|
|
|
month + "月小计", "", "", "数据", monthCategoryCountMap, totalCount, true, false);
|
|
|
@@ -156,8 +156,8 @@ public class AcquisitionDailyServiceImpl implements AcquisitionDailyService {
|
|
|
String lastYearMonth = getMonthMinusOneYear(month);
|
|
|
List<Map<String, Object>> lastYearMonthData = lastYearMonthMap.getOrDefault(lastYearMonth, new ArrayList<>());
|
|
|
Map<String, Double> lastYearMonthCategoryCountMap = calculateMonthCategoryCount(lastYearMonthData, categoryNames);
|
|
|
- double lastYearMonthTotal = calculateTotalCountSum(lastYearMonthData); // 新增:去年同期当月 totalCount
|
|
|
- lastYearCumulativeTotalCount += lastYearMonthTotal; // 新增:累加到去年同期累计
|
|
|
+ double lastYearMonthTotal = calculateTotalCountSum(lastYearMonthData,categoryNames);
|
|
|
+ lastYearCumulativeTotalCount += lastYearMonthTotal;
|
|
|
|
|
|
Map<String, Object> subtotalYoyVO = createYoyRow(
|
|
|
monthCategoryCountMap, lastYearMonthCategoryCountMap,
|
|
|
@@ -225,12 +225,6 @@ public class AcquisitionDailyServiceImpl implements AcquisitionDailyService {
|
|
|
totalCount += count;
|
|
|
}
|
|
|
row.put("totalCount", totalCount);
|
|
|
- data.put("totalCount",totalCount);
|
|
|
- /* Object totalCount = data.get("totalCount");
|
|
|
- if (totalCount != null) {
|
|
|
- row.put("totalCount", ((Number) totalCount).doubleValue());
|
|
|
- }*/
|
|
|
-
|
|
|
return row;
|
|
|
}
|
|
|
|
|
|
@@ -331,7 +325,7 @@ public class AcquisitionDailyServiceImpl implements AcquisitionDailyService {
|
|
|
yoyRow.put(categoryName, yoyPercent);
|
|
|
}
|
|
|
|
|
|
- yoyRow.put("totalCount", calcYoyPercent(currentTotal, lastYearTotal)); // 修改:使用传入的 totalCount
|
|
|
+ yoyRow.put("totalCount", calcYoyPercent(currentTotal, lastYearTotal));
|
|
|
|
|
|
return yoyRow;
|
|
|
}
|
|
|
@@ -355,11 +349,17 @@ public class AcquisitionDailyServiceImpl implements AcquisitionDailyService {
|
|
|
/**
|
|
|
* 计算列表的 totalCount 之和
|
|
|
*/
|
|
|
- private double calculateTotalCountSum(List<Map<String, Object>> dataList) {
|
|
|
+ private double calculateTotalCountSum(List<Map<String, Object>> dataList, List<String> categoryNames) {
|
|
|
return dataList.stream()
|
|
|
.mapToDouble(data -> {
|
|
|
- Object totalCount = data.get("totalCount");
|
|
|
- return totalCount != null ? ((Number) totalCount).doubleValue() : 0.0;
|
|
|
+ double sum = 0.0;
|
|
|
+ for (String categoryName : categoryNames) {
|
|
|
+ Object value = data.get(categoryName);
|
|
|
+ if (value != null) {
|
|
|
+ sum += ((Number) value).doubleValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sum;
|
|
|
})
|
|
|
.sum();
|
|
|
}
|