项目初始化
This commit is contained in:
@@ -9,10 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@@ -76,6 +73,60 @@ public class ErpScreenController {
|
||||
return chartDataItems;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 账号按月
|
||||
*/
|
||||
@RequestMapping(value = "getErpAccountMonthChart")
|
||||
@ResponseBody
|
||||
public List<ChartDataItem> getErpAccountMonthChart(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::getAccountName,
|
||||
Collectors.collectingAndThen(Collectors.toList(), list -> {
|
||||
String accountId = list.stream()
|
||||
.findFirst()
|
||||
.map(ErpTransactionFlow::getAccountId)
|
||||
.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);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>(monthMap);
|
||||
result.put("accountId", accountId);
|
||||
return result;
|
||||
})
|
||||
));
|
||||
for (Map.Entry<String, Map<String, Object>> entry : accountMap.entrySet()) {
|
||||
String accountName = entry.getKey();
|
||||
Map<String, Object> map = entry.getValue();
|
||||
ChartDataItem item = new ChartDataItem();
|
||||
item.setAxisName(accountName);
|
||||
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.setBizKey(map.get("accountId").toString());
|
||||
chartDataItems.add(item);
|
||||
}
|
||||
return chartDataItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 月份收支
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user