Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增显示今日收益 #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/bean/FundBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class FundBean {
private String costPrise;//持仓成本价
private String bonds;//持有份额
private String incomePercent;//收益率
private String todayIncome;//今日收益
private String income;//收益

public FundBean() {
Expand Down Expand Up @@ -138,6 +139,14 @@ public void setIncomePercent(String incomePercent) {
this.incomePercent = incomePercent;
}

public String getTodayIncome() {
return todayIncome;
}

public void setTodayIncome(String todayIncome) {
this.todayIncome = todayIncome;
}

public String getIncome() {
return income;
}
Expand Down Expand Up @@ -199,6 +208,8 @@ public String getValueByColumn(String colums, boolean colorful) {
return this.getBonds();
case "收益率":
return this.getCostPrise() != null ? this.getIncomePercent() + "%" : this.getIncomePercent();
case "今日收益":
return this.getTodayIncome();
case "收益":
return this.getIncome();
default:
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/handler/FundRefreshHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
};
// table.getColumn(getColumnName(2)).setCellRenderer(cellRenderer);
int columnIndex = WindowUtils.getColumnIndexByName(columnNames, "估算涨跌");

int columnIndex3 = WindowUtils.getColumnIndexByName(columnNames, "收益率");
int columnIndex4 = WindowUtils.getColumnIndexByName(columnNames, "收益");
int columnIndex5 = WindowUtils.getColumnIndexByName(columnNames, "今日收益");

table.getColumn(getColumnName(columnIndex)).setCellRenderer(cellRenderer);

table.getColumn(getColumnName(columnIndex3)).setCellRenderer(cellRenderer);
table.getColumn(getColumnName(columnIndex4)).setCellRenderer(cellRenderer);
table.getColumn(getColumnName(columnIndex5)).setCellRenderer(cellRenderer);
}

protected void updateData(FundBean bean) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/handler/TianTianFundHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ private void stepAction(List<String> codes) {
BigDecimal incomeDec = incomeDiff.multiply(bondDec)
.setScale(2, RoundingMode.HALF_UP);
bean.setIncome(incomeDec.toString());

// 计算当日收益
String dwjzStr = bean.getDwjz();
BigDecimal dwjz = new BigDecimal(dwjzStr);
BigDecimal todayIncome = now.add(dwjz.negate()).multiply(bondDec)
.setScale(2, RoundingMode.HALF_UP);
bean.setTodayIncome(todayIncome.toString());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/utils/WindowUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
public class WindowUtils {
//基金表头
public static final String FUND_TABLE_HEADER_KEY = "fund_table_header_key2"; //移动表头时存储的key
public static final String FUND_TABLE_HEADER_VALUE = "编码,基金名称,估算涨跌,当日净值,估算净值,持仓成本价,持有份额,收益率,收益,更新时间";
public static final String FUND_TABLE_HEADER_VALUE = "编码,基金名称,估算涨跌,当日净值,估算净值,持仓成本价,持有份额,收益率,今日收益,收益,更新时间";
//股票表头
public static final String STOCK_TABLE_HEADER_KEY = "stock_table_header_key2"; //移动表头时存储的key
public static final String STOCK_TABLE_HEADER_VALUE = "编码,股票名称,涨跌,涨跌幅,最高价,最低价,当前价,成本价,持仓,收益率,收益,更新时间";
public static final String STOCK_TABLE_HEADER_VALUE = "编码,股票名称,涨跌,涨跌幅,最高价,最低价,当前价,成本价,持仓,收益率,今日收益,收益,更新时间";
//货币表头
public static final String COIN_TABLE_HEADER_KEY = "coin_table_header_key2"; //移动表头时存储的key
public static final String COIN_TABLE_HEADER_VALUE = "编码,当前价,涨跌,涨跌幅,最高价,最低价,更新时间";
Expand All @@ -38,6 +38,7 @@ public class WindowUtils {
remapPinYinMap.put(PinYinUtils.toPinYin("成本价"), "成本价");
remapPinYinMap.put(PinYinUtils.toPinYin("持仓"), "持仓");
remapPinYinMap.put(PinYinUtils.toPinYin("收益率"), "收益率");
remapPinYinMap.put(PinYinUtils.toPinYin("今日收益"), "今日收益");
remapPinYinMap.put(PinYinUtils.toPinYin("收益"), "收益");

remapPinYinMap.put(PinYinUtils.toPinYin("持仓成本价"), "持仓成本价");
Expand Down