diff --git a/web-api/src/main/java/com/jeesite/modules/apps/web/ErpScreenController.java b/web-api/src/main/java/com/jeesite/modules/apps/web/ErpScreenController.java index 523066d..642e6a6 100644 --- a/web-api/src/main/java/com/jeesite/modules/apps/web/ErpScreenController.java +++ b/web-api/src/main/java/com/jeesite/modules/apps/web/ErpScreenController.java @@ -261,6 +261,63 @@ public class ErpScreenController { return chartDataItems; } + @RequestMapping(value = "getErpYearChart") + @ResponseBody + public List getErpYearChart(ErpTransactionFlow erpTransactionFlow) { + List chartDataItems = new ArrayList<>(); + List flowList = erpTransactionFlowService.findList(erpTransactionFlow); + Map> yearMap = flowList.stream() + .collect(Collectors.groupingBy( + ErpTransactionFlow::getYearDate, // 这里改成年 + 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(sumValue04, sumValue01); + return Map.of( + "sumValue01", sumValue01, + "sumValue02", sumValue02, + "sumValue03", sumValue03, + "sumValue04", sumValue04 + ); + }) + )); + List sortedYears = new ArrayList<>(yearMap.keySet()); + Collections.sort(sortedYears); + for (int i = 0; i < sortedYears.size(); i++) { + String currentYear = sortedYears.get(i); + Map current = yearMap.get(currentYear); + BigDecimal income = (BigDecimal) current.get("sumValue01"); + BigDecimal expend = (BigDecimal) current.get("sumValue02"); + BigDecimal profitRate = (BigDecimal) current.get("sumValue03"); + BigDecimal profit = (BigDecimal) current.get("sumValue04"); + BigDecimal lastIncome = BigDecimal.ZERO; + BigDecimal lastExpend = BigDecimal.ZERO; + if (i > 0) { + String lastYear = sortedYears.get(i - 1); + Map lastData = yearMap.get(lastYear); + lastIncome = (BigDecimal) lastData.get("sumValue01"); + lastExpend = (BigDecimal) lastData.get("sumValue02"); + } + ChartDataItem item = new ChartDataItem(); + item.setAxisName(currentYear); // 年份作为X轴 + item.setValue01(income.toString()); // 本年收入 + item.setValue02(expend.toString()); // 本年支出 + item.setValue03(profitRate.toString()); // 利润率 + item.setValue04(profit.toString()); // 净利润 + item.setValue05(lastIncome.toString()); // 上年收入 + item.setValue06(lastExpend.toString()); // 上年支出 + chartDataItems.add(item); + } + return chartDataItems; + } + /** * 季度收支 */ diff --git a/web-vue/packages/core/layouts/screen/welcome/Erp/components/ChartV02.vue b/web-vue/packages/core/layouts/screen/welcome/Erp/components/ChartV02.vue index 879a955..8c4d2a0 100644 --- a/web-vue/packages/core/layouts/screen/welcome/Erp/components/ChartV02.vue +++ b/web-vue/packages/core/layouts/screen/welcome/Erp/components/ChartV02.vue @@ -7,234 +7,315 @@ - \ No newline at end of file + .chart-card { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + overflow: hidden; + background: rgba(0, 0, 0, 0.1) url('@jeesite/assets/chart/box/16.png') no-repeat; + background-size: 100% 100%; + } + .chart-card-header { + height: 40px; + line-height: 40px; + padding: 0 16px; + background-color: rgba(26, 80, 139, 0.5); + border-bottom: 1px solid #1a508b; + display: flex; + align-items: center; + background: rgba(0, 0, 0, 0.1) url('@jeesite/assets/chart/title/03.png') no-repeat; + background-size: 100% 100%; + } + .chart-card-title { + font-size: 16px; + font-weight: 600; + color: #409eff; + letter-spacing: 0.5px; + } + .bar-line-chart-container { + flex: 1; + width: 100%; + height: calc(100% - 40px); + } + diff --git a/web-vue/packages/erp/api/erp/screen.ts b/web-vue/packages/erp/api/erp/screen.ts index 4ff8c23..bf2ec07 100644 --- a/web-vue/packages/erp/api/erp/screen.ts +++ b/web-vue/packages/erp/api/erp/screen.ts @@ -52,6 +52,9 @@ export interface ChartDataItem extends BasicModel { indexMin: number; // 指标最小 } +export const ErpYearChart = (params?: ErpTransactionFlow | any) => + defHttp.get({ url: adminPath + '/erp/screen/getErpYearChart', params }); + export const ErpMonthChart = (params?: ErpTransactionFlow | any) => defHttp.get({ url: adminPath + '/erp/screen/getErpMonthChart', params });