项目初始化
This commit is contained in:
@@ -98,7 +98,13 @@ public class ErpScreenController {
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
monthMap.put("sumValue" + monthName, sum);
|
||||
}
|
||||
|
||||
BigDecimal indexSum = list.stream()
|
||||
.map(ErpTransactionFlow::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(monthMap);
|
||||
result.put("indexSum", indexSum);
|
||||
result.put("accountId", accountId);
|
||||
return result;
|
||||
})
|
||||
@@ -120,12 +126,80 @@ public class ErpScreenController {
|
||||
item.setValue10(map.get("sumValue10").toString());
|
||||
item.setValue11(map.get("sumValue11").toString());
|
||||
item.setValue12(map.get("sumValue12").toString());
|
||||
item.setIndexSum(Optional.ofNullable(map.get("indexSum"))
|
||||
.filter(BigDecimal.class::isInstance)
|
||||
.map(BigDecimal.class::cast)
|
||||
.orElse(BigDecimal.ZERO));
|
||||
item.setBizKey(map.get("accountId").toString());
|
||||
chartDataItems.add(item);
|
||||
}
|
||||
return chartDataItems;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 账号按月
|
||||
*/
|
||||
@RequestMapping(value = "getErpCategoryMonthChart")
|
||||
@ResponseBody
|
||||
public List<ChartDataItem> getErpCategoryMonthChart(ErpTransactionFlow erpTransactionFlow) {
|
||||
List<ChartDataItem> chartDataItems = new ArrayList<>();
|
||||
List<ErpTransactionFlow> flowList = erpTransactionFlowService.findList(erpTransactionFlow);
|
||||
Map<String, Map<String, Object>> accountMap = flowList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ErpTransactionFlow::getCategoryName,
|
||||
Collectors.collectingAndThen(Collectors.toList(), list -> {
|
||||
String categoryId = list.stream()
|
||||
.findFirst()
|
||||
.map(ErpTransactionFlow::getCategoryId)
|
||||
.orElse("");
|
||||
Map<String, BigDecimal> monthMap = new HashMap<>();
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
String monthName = String.format("%02d", i);
|
||||
BigDecimal sum = list.stream()
|
||||
.filter(flow -> (flow.getMonthDate().equals(monthName)))
|
||||
.map(ErpTransactionFlow::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
monthMap.put("sumValue" + monthName, sum);
|
||||
}
|
||||
|
||||
BigDecimal indexSum = list.stream()
|
||||
.map(ErpTransactionFlow::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(monthMap);
|
||||
result.put("indexSum", indexSum);
|
||||
result.put("categoryId", categoryId);
|
||||
return result;
|
||||
})
|
||||
));
|
||||
for (Map.Entry<String, Map<String, Object>> entry : accountMap.entrySet()) {
|
||||
String categoryName = entry.getKey();
|
||||
Map<String, Object> map = entry.getValue();
|
||||
ChartDataItem item = new ChartDataItem();
|
||||
item.setAxisName(categoryName);
|
||||
item.setValue01(map.get("sumValue01").toString());
|
||||
item.setValue02(map.get("sumValue02").toString());
|
||||
item.setValue03(map.get("sumValue03").toString());
|
||||
item.setValue04(map.get("sumValue04").toString());
|
||||
item.setValue05(map.get("sumValue05").toString());
|
||||
item.setValue06(map.get("sumValue06").toString());
|
||||
item.setValue07(map.get("sumValue07").toString());
|
||||
item.setValue08(map.get("sumValue08").toString());
|
||||
item.setValue09(map.get("sumValue09").toString());
|
||||
item.setValue10(map.get("sumValue10").toString());
|
||||
item.setValue11(map.get("sumValue11").toString());
|
||||
item.setValue12(map.get("sumValue12").toString());
|
||||
item.setIndexSum(Optional.ofNullable(map.get("indexSum"))
|
||||
.filter(BigDecimal.class::isInstance)
|
||||
.map(BigDecimal.class::cast)
|
||||
.orElse(BigDecimal.ZERO));
|
||||
item.setBizKey(map.get("categoryId").toString());
|
||||
chartDataItems.add(item);
|
||||
}
|
||||
return chartDataItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 月份收支
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user