项目初始化
This commit is contained in:
@@ -119,6 +119,52 @@ public class ErpScreenController {
|
||||
return chartDataItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 季度收支
|
||||
*/
|
||||
@RequestMapping(value = "getErpQuarterChart")
|
||||
@ResponseBody
|
||||
public List<ChartDataItem> getErpQuarterChart(ErpTransactionFlow erpTransactionFlow) {
|
||||
List<ChartDataItem> chartDataItems = new ArrayList<>();
|
||||
List<ErpTransactionFlow> flowList = erpTransactionFlowService.findList(erpTransactionFlow);
|
||||
Map<String, Map<String, Object>> accountMap = flowList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
flow -> flow.getYearDate() + "Q" + (Integer.parseInt(flow.getMonthDate()) + 2) / 3,
|
||||
Collectors.collectingAndThen(Collectors.toList(), list -> {
|
||||
BigDecimal sumValue01 = list.stream()
|
||||
.filter(flow -> flow.getFlowType().equals("2"))
|
||||
.map(ErpTransactionFlow::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal sumValue02 = list.stream()
|
||||
.filter(flow -> flow.getFlowType().equals("1"))
|
||||
.map(ErpTransactionFlow::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal sumValue04 = BigDecimalUtils.subtract(sumValue01, sumValue02);
|
||||
BigDecimal sumValue03 = BigDecimalUtils.percent(sumValue02, sumValue01);
|
||||
return Map.of(
|
||||
"sumValue01", sumValue01,
|
||||
"sumValue02", sumValue02,
|
||||
"sumValue03", sumValue03,
|
||||
"sumValue04", sumValue04
|
||||
);
|
||||
})
|
||||
));
|
||||
List<Map.Entry<String, Map<String, Object>>> sortedList = new ArrayList<>(accountMap.entrySet());
|
||||
sortedList.sort(Map.Entry.comparingByKey());
|
||||
for (Map.Entry<String, Map<String, Object>> entry : sortedList) {
|
||||
String quarter = entry.getKey();
|
||||
Map<String, Object> map = entry.getValue();
|
||||
ChartDataItem item = new ChartDataItem();
|
||||
item.setAxisName(quarter);
|
||||
item.setValue01(map.get("sumValue01").toString());
|
||||
item.setValue02(map.get("sumValue02").toString());
|
||||
item.setValue03(map.get("sumValue03").toString());
|
||||
item.setValue04(map.get("sumValue04").toString());
|
||||
chartDataItems.add(item);
|
||||
}
|
||||
return chartDataItems;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类收支
|
||||
@@ -151,12 +197,10 @@ public class ErpScreenController {
|
||||
BigDecimal v2 = (BigDecimal) e2.getValue().get("sumValue02");
|
||||
return v2.compareTo(v1);
|
||||
});
|
||||
long soring = 1;
|
||||
for (Map.Entry<String, Map<String, Object>> entry : sortedList) {
|
||||
String categoryName = entry.getKey();
|
||||
Map<String, Object> map = entry.getValue();
|
||||
ChartDataItem item = new ChartDataItem();
|
||||
item.setSoring(soring++);
|
||||
item.setAxisName(categoryName);
|
||||
item.setValue01(map.get("sumValue01").toString());
|
||||
item.setValue02(map.get("sumValue02").toString());
|
||||
|
||||
Reference in New Issue
Block a user