diff --git a/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockController.java b/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockController.java index c871c44..58eb442 100644 --- a/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockController.java +++ b/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockController.java @@ -66,9 +66,28 @@ public class StockController extends SimpleControllerSupport new CashFlowItem( - NumberHelper.formatFinanceDouble(fi.getNetProfit()) + NumberHelper.formatFinanceDouble(fi.getNetProfit()), + NumberHelper.formatFinanceDouble(fi.getCashFlowFromOperatingActivities()), + NumberHelper.formatFinanceDouble(fi.getCashFlowFromInvestingActivities()), + NumberHelper.formatFinanceDouble(fi.getCashFlowFromFinancingActivities()) )) - .orElse(new CashFlowItem()) + .orElse(new CashFlowItem()), + financeIndicator + .map(fi -> new IndicateItem( + NumberHelper.formatFinanceDouble(fi.getCurrentRatio()), + NumberHelper.formatFinanceDouble(fi.getQuickRatio()), + NumberHelper.formatFinanceDouble(fi.getReturnOnEquity()), + NumberHelper.formatFinanceDouble(fi.getReturnOnAssets()), + NumberHelper.formatFinanceDouble(fi.getAccountsReceivableTurnover()), + NumberHelper.formatDaysDouble(fi.getDaysAccountsReceivableTurnover()), + NumberHelper.formatFinanceDouble(fi.getInventoryTurnover()), + NumberHelper.formatDaysDouble(fi.getDaysInventoryTurnover()), + NumberHelper.formatFinanceDouble(fi.getFixedAssetsTurnover()), + NumberHelper.formatDaysDouble(fi.getDaysFixedAssetsTurnover()), + NumberHelper.formatFinanceDouble(fi.getTotalAssetsTurnover()), + NumberHelper.formatDaysDouble(fi.getDaysTotalAssetsTurnover()) + )) + .orElse(new IndicateItem()) )); } @@ -125,7 +144,8 @@ public class StockController extends SimpleControllerSupport { if (isNil(value)) { return '-' @@ -25,7 +24,13 @@ const formatFinanceNumber = (value: number): string => { return isNegative ? `-${formatted}` : formatted } -// 格式化百分比数字显示的公共函数 +const formatDaysNumber = (value: number): string => { + if (isNil(value)) { + return '-' + } + return `${value.toFixed(0)}天` +} + const formatPercentageNumber = (value: number): string => { if (isNil(value)) { return '-' @@ -33,7 +38,7 @@ const formatPercentageNumber = (value: number): string => { return `${(value * 100).toFixed(2)}%` } -type FinanceType = 'PERCENTAGE' | 'FINANCE' +type FinanceType = 'PERCENTAGE' | 'FINANCE' | 'DAYS' const financePropertyLabel = (id: string | undefined, label: string, type: FinanceType, field: string): Schema => { if (!id) { @@ -43,7 +48,20 @@ const financePropertyLabel = (id: string | undefined, label: string, type: Finan } } let current = new Date().getFullYear() - let formatter: (value: number) => string = type === 'PERCENTAGE' ? formatPercentageNumber : formatFinanceNumber + let formatter: (value: number) => string + switch (type) { + case 'PERCENTAGE': + formatter = formatPercentageNumber + break + case 'FINANCE': + formatter = formatFinanceNumber + break + case 'DAYS': + formatter = formatDaysNumber + break + default: + formatter = (v: number) => v.toFixed(2) + } return { type: 'wrapper', size: 'none', @@ -229,29 +247,21 @@ function StockDetail() { { label: financePropertyLabel(id, '总资产', 'FINANCE', 'totalAssets'), content: '${balanceSheet.totalAssets}', - span: 4, + span: 2, + }, + { + label: financePropertyLabel(id, '总负债', 'FINANCE', 'totalLiabilities'), + content: '${balanceSheet.totalLiabilities}', + span: 2, }, { label: financePropertyLabel(id, '流动资产', 'FINANCE', 'currentAssets'), content: '${balanceSheet.currentAssets}', }, - { - label: financePropertyLabel(id, '流动资产占比', 'PERCENTAGE', 'currentAssetsToTotalAssetsRatio'), - content: '${balanceSheet.currentAssetsRatio}', - }, - { - label: financePropertyLabel(id, '非流动资产', 'FINANCE', 'fixedAssets'), - content: '${balanceSheet.fixedAssets}', - }, { label: financePropertyLabel(id, '非流动资产占比', 'PERCENTAGE', 'fixedAssetsToTotalAssetsRatio'), content: '${balanceSheet.fixedAssetsRatio}', }, - { - label: financePropertyLabel(id, '总负债', 'FINANCE', 'totalLiabilities'), - content: '${balanceSheet.totalLiabilities}', - span: 4, - }, { label: financePropertyLabel(id, '流动负债', 'FINANCE', 'currentLiabilities'), content: '${balanceSheet.currentLiabilities}', @@ -260,6 +270,14 @@ function StockDetail() { label: financePropertyLabel(id, '流动负债占比', 'PERCENTAGE', 'currentLiabilitiesToTotalAssetsRatio'), content: '${balanceSheet.currentLiabilitiesRatio}', }, + { + label: financePropertyLabel(id, '流动资产占比', 'PERCENTAGE', 'currentAssetsToTotalAssetsRatio'), + content: '${balanceSheet.currentAssetsRatio}', + }, + { + label: financePropertyLabel(id, '非流动资产', 'FINANCE', 'fixedAssets'), + content: '${balanceSheet.fixedAssets}', + }, { label: financePropertyLabel(id, '非流动负债', 'FINANCE', 'longTermLiabilities'), content: '${balanceSheet.longTermLiabilities}', @@ -300,6 +318,62 @@ function StockDetail() { }, ], }, + '财务指标', + { + className: 'my-2', + type: 'property', + column: 4, + items: [ + { + label: financePropertyLabel(id, '流动比率', 'FINANCE', 'currentRatio'), + content: '${indicate.currentRatio}', + }, + { + label: financePropertyLabel(id, '速动比率', 'FINANCE', 'quickRatio'), + content: '${indicate.quickRatio}', + }, + { + label: financePropertyLabel(id, 'ROE', 'FINANCE', 'returnOnEquity'), + content: '${indicate.roe}', + }, + { + label: financePropertyLabel(id, 'ROA', 'FINANCE', 'returnOnAssets'), + content: '${indicate.roa}', + }, + { + label: financePropertyLabel(id, '应收账款周转率', 'FINANCE', 'accountsReceivableTurnover'), + content: '${indicate.accountsReceivableTurnover}', + }, + { + label: financePropertyLabel(id, '应收账款周转天', 'DAYS', 'daysAccountsReceivableTurnover'), + content: '${indicate.daysAccountsReceivableTurnover}', + }, + { + label: financePropertyLabel(id, '存货周转率', 'FINANCE', 'inventoryTurnover'), + content: '${indicate.inventoryTurnover}', + }, + { + label: financePropertyLabel(id, '存货周转天', 'DAYS', 'daysInventoryTurnover'), + content: '${indicate.daysInventoryTurnover}', + }, + { + label: financePropertyLabel(id, '固定资产周转率', 'FINANCE', 'fixedAssetsTurnover'), + content: '${indicate.fixedAssetsTurnover}', + }, + { + label: financePropertyLabel(id, '固定资产周转天', 'DAYS', 'daysFixedAssetsTurnover'), + content: '${indicate.daysFixedAssetsTurnover}', + }, + { + label: financePropertyLabel(id, '总资产周转率', 'FINANCE', 'totalAssetsTurnover'), + content: '${indicate.totalAssetsTurnover}', + }, + { + label: financePropertyLabel(id, '总资产周转天', 'DAYS', 'daysTotalAssetsTurnover'), + content: '${indicate.daysTotalAssetsTurnover}', + }, + ], + }, {type: 'divider'}, ], },