perf: 直接使用仓库类简化代码
This commit is contained in:
1
.idea/data_source_mapping.xml
generated
1
.idea/data_source_mapping.xml
generated
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourcePerFileMappings">
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/a8b9cd0a-335e-42ae-991a-f2733200afbf/console.sql" value="a8b9cd0a-335e-42ae-991a-f2733200afbf" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/f7d817dc-8c9c-479f-b469-583df17cb013/console.sql" value="f7d817dc-8c9c-479f-b469-583df17cb013" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,7 +2,7 @@ package com.lanyuanxiaoyao.leopard.server.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Task;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.StockService;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.StockRepository;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.TaskTemplateService;
|
||||
import com.lanyuanxiaoyao.service.template.controller.GlobalResponse;
|
||||
import java.util.Arrays;
|
||||
@@ -86,11 +86,11 @@ public class CommonOptionsController {
|
||||
"bg-pink-900"
|
||||
);
|
||||
|
||||
private final StockService stockService;
|
||||
private final StockRepository stockRepository;
|
||||
private final TaskTemplateService taskTemplateService;
|
||||
|
||||
public CommonOptionsController(StockService stockService, TaskTemplateService taskTemplateService) {
|
||||
this.stockService = stockService;
|
||||
public CommonOptionsController(StockRepository stockRepository, TaskTemplateService taskTemplateService) {
|
||||
this.stockRepository = stockRepository;
|
||||
this.taskTemplateService = taskTemplateService;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class CommonOptionsController {
|
||||
.toList()
|
||||
);
|
||||
case "stock_industry" -> GlobalResponse.responseSuccess(
|
||||
stockService.findDistinctIndustries()
|
||||
stockRepository.findDistinctIndustries()
|
||||
.stream()
|
||||
.map(industry -> new Option(industry, industry))
|
||||
.toList()
|
||||
|
||||
@@ -3,24 +3,11 @@ package com.lanyuanxiaoyao.leopard.server.service;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Daily;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.DailyRepository;
|
||||
import com.lanyuanxiaoyao.service.template.service.SimpleServiceSupport;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DailyService extends SimpleServiceSupport<Daily> {
|
||||
private final DailyRepository dailyRepository;
|
||||
|
||||
public DailyService(DailyRepository repository) {
|
||||
super(repository);
|
||||
this.dailyRepository = repository;
|
||||
}
|
||||
|
||||
public List<LocalDate> findDistinctTradeDate() {
|
||||
return dailyRepository.findDistinctTradeDate();
|
||||
}
|
||||
|
||||
public List<LocalDate> findDistinctTradeDateByStockId(Long stockId) {
|
||||
return dailyRepository.findDistinctTradeDateByStockId(stockId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.DailyService;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.StockService;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.DailyRepository;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.StockRepository;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.TaskService;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.TuShareService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
@@ -18,21 +18,22 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@LiteflowComponent("check_daily")
|
||||
public class CheckDailyNode extends TaskNodeComponent {
|
||||
private final StockService stockService;
|
||||
private final DailyService dailyService;
|
||||
private final StockRepository stockRepository;
|
||||
private final DailyRepository dailyRepository;
|
||||
|
||||
private final TuShareService tuShareService;
|
||||
|
||||
public CheckDailyNode(TaskService taskService, StockService stockService, DailyService dailyService, TuShareService tuShareService) {
|
||||
public CheckDailyNode(TaskService taskService, StockRepository stockRepository, DailyRepository dailyRepository, TuShareService tuShareService) {
|
||||
super(taskService);
|
||||
this.stockService = stockService;
|
||||
this.dailyService = dailyService;
|
||||
this.stockRepository = stockRepository;
|
||||
this.dailyRepository = dailyRepository;
|
||||
this.tuShareService = tuShareService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
var reports = new ArrayList<MissedTradeReport>();
|
||||
var stocks = stockService.list();
|
||||
var stocks = stockRepository.findAll();
|
||||
var exchanges = stocks.stream().map(Stock::getMarket).distinct().toList();
|
||||
for (Stock.Market exchange : exchanges) {
|
||||
var nowDate = LocalDate.now();
|
||||
@@ -48,7 +49,7 @@ public class CheckDailyNode extends TaskNodeComponent {
|
||||
for (Stock stock : stocks) {
|
||||
log.info("正在处理:{} {}", stock.getCode(), stock.getName());
|
||||
if (exchange.equals(stock.getMarket())) {
|
||||
var existsTradeDates = dailyService.findDistinctTradeDateByStockId(stock.getId());
|
||||
var existsTradeDates = dailyRepository.findDistinctTradeDateByStockId(stock.getId());
|
||||
var missedTradeDates = allTradeDates.stream()
|
||||
.filter(date -> date.isAfter(stock.getListedDate()) || date.isEqual(stock.getListedDate()))
|
||||
.filter(date -> !existsTradeDates.contains(date))
|
||||
|
||||
@@ -4,8 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Daily;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.DailyService;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.StockService;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.DailyRepository;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.StockRepository;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.TuShareService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
@@ -20,14 +20,16 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
@Slf4j
|
||||
@LiteflowComponent("update_daily")
|
||||
public class UpdateDailyNode extends NodeComponent {
|
||||
private final StockService stockService;
|
||||
private final DailyService dailyService;
|
||||
private final StockRepository stockRepository;
|
||||
private final DailyRepository dailyRepository;
|
||||
|
||||
private final TuShareService tuShareService;
|
||||
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
|
||||
public UpdateDailyNode(StockService stockService, DailyService dailyService, TuShareService tuShareService, TransactionTemplate transactionTemplate) {
|
||||
this.stockService = stockService;
|
||||
this.dailyService = dailyService;
|
||||
public UpdateDailyNode(StockRepository stockRepository, DailyRepository dailyRepository, TuShareService tuShareService, TransactionTemplate transactionTemplate) {
|
||||
this.stockRepository = stockRepository;
|
||||
this.dailyRepository = dailyRepository;
|
||||
this.tuShareService = tuShareService;
|
||||
this.transactionTemplate = transactionTemplate;
|
||||
}
|
||||
@@ -44,9 +46,9 @@ public class UpdateDailyNode extends NodeComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
var existsTradeDates = dailyService.findDistinctTradeDate();
|
||||
var existsTradeDates = dailyRepository.findDistinctTradeDate();
|
||||
var nowDate = LocalDate.now();
|
||||
var stocks = stockService.list();
|
||||
var stocks = stockRepository.findAll();
|
||||
var stocksMap = stocks.stream().collect(Collectors.toMap(Stock::getCode, stock -> stock));
|
||||
tradeDates.stream()
|
||||
.filter(date -> date.isBefore(nowDate) || date.isEqual(nowDate))
|
||||
@@ -83,7 +85,7 @@ public class UpdateDailyNode extends NodeComponent {
|
||||
daily.setTurnover(item.get(10) == null ? null : Double.parseDouble(item.get(10)) * 1000);
|
||||
daily.setFactor(factor);
|
||||
daily.setStock(stock);
|
||||
dailyService.save(daily);
|
||||
dailyRepository.save(daily);
|
||||
}
|
||||
}
|
||||
log.info("Trade date: {} {}", tradeDate, count);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.lanyuanxiaoyao.leopard.server.service.task;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.BalanceSheet;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.CashFlow;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Income;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.QBalanceSheet;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.QCashFlow;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.QIncome;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.BalanceSheetRepository;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.CashFlowRepository;
|
||||
@@ -25,20 +29,20 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@LiteflowComponent("update_finance")
|
||||
public class UpdateFinanceNode extends TaskNodeComponent {
|
||||
private final TuShareService tuShareService;
|
||||
|
||||
private final StockRepository stockRepository;
|
||||
private final IncomeRepository incomeRepository;
|
||||
private final BalanceSheetRepository balanceSheetRepository;
|
||||
private final CashFlowRepository cashFlowRepository;
|
||||
|
||||
public UpdateFinanceNode(TaskService taskService, TuShareService tuShareService, StockRepository stockRepository, IncomeRepository incomeRepository, BalanceSheetRepository balanceSheetRepository, CashFlowRepository cashFlowRepository) {
|
||||
private final TuShareService tuShareService;
|
||||
|
||||
public UpdateFinanceNode(TaskService taskService, StockRepository stockRepository, IncomeRepository incomeRepository, BalanceSheetRepository balanceSheetRepository, CashFlowRepository cashFlowRepository, TuShareService tuShareService) {
|
||||
super(taskService);
|
||||
this.tuShareService = tuShareService;
|
||||
this.stockRepository = stockRepository;
|
||||
this.incomeRepository = incomeRepository;
|
||||
this.balanceSheetRepository = balanceSheetRepository;
|
||||
this.cashFlowRepository = cashFlowRepository;
|
||||
this.tuShareService = tuShareService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +51,6 @@ public class UpdateFinanceNode extends TaskNodeComponent {
|
||||
var stocksMap = stocks.stream().collect(Collectors.toMap(Stock::getCode, stock -> stock));
|
||||
var currentYear = LocalDate.now().getYear();
|
||||
for (int year = 1990; year < currentYear; year++) {
|
||||
|
||||
var response = tuShareService.incomeList(year);
|
||||
for (List<String> item : response.data().items()) {
|
||||
var code = item.get(0);
|
||||
@@ -55,36 +58,38 @@ public class UpdateFinanceNode extends TaskNodeComponent {
|
||||
continue;
|
||||
}
|
||||
var stock = stocksMap.get(code);
|
||||
var income = new Income();
|
||||
var income = incomeRepository.findOne(
|
||||
QIncome.income.year.eq(year)
|
||||
.and(QIncome.income.stock.code.eq(stock.getCode()))
|
||||
).orElse(new Income());
|
||||
income.setStock(stock);
|
||||
income.setYear(year);
|
||||
income.setBasicEarningsPerShare(Double.parseDouble(item.get(1)));
|
||||
income.setDilutedEarningsPerShare(Double.parseDouble(item.get(2)));
|
||||
income.setTotalOperatingRevenue(Double.parseDouble(item.get(3)));
|
||||
income.setOperatingRevenue(Double.parseDouble(item.get(4)));
|
||||
income.setTotalOperatingCost(Double.parseDouble(item.get(5)));
|
||||
income.setOperatingCost(Double.parseDouble(item.get(6)));
|
||||
income.setSellingExpense(Double.parseDouble(item.get(7)));
|
||||
income.setAdministrativeExpense(Double.parseDouble(item.get(8)));
|
||||
income.setFinancialExpense(Double.parseDouble(item.get(9)));
|
||||
income.setOperatingExpense(Double.parseDouble(item.get(10)));
|
||||
income.setOperatingProfit(Double.parseDouble(item.get(11)));
|
||||
income.setAddNonOperatingIncome(Double.parseDouble(item.get(12)));
|
||||
income.setLessNonOperatingExpense(Double.parseDouble(item.get(13)));
|
||||
income.setTotalProfit(Double.parseDouble(item.get(14)));
|
||||
income.setIncomeTaxExpense(Double.parseDouble(item.get(15)));
|
||||
income.setNetProfitIncludingMinorityInterest(Double.parseDouble(item.get(16)));
|
||||
income.setNetProfitExcludingMinorityInterest(Double.parseDouble(item.get(17)));
|
||||
income.setComprehensiveIncomeAttributableToParent(Double.parseDouble(item.get(18)));
|
||||
income.setComprehensiveIncomeAttributableToMinorityShareholders(Double.parseDouble(item.get(19)));
|
||||
income.setEarningsBeforeInterestAndTax(Double.parseDouble(item.get(20)));
|
||||
income.setEarningsBeforeInterestTaxDepreciationAndAmortization(Double.parseDouble(item.get(21)));
|
||||
income.setBeginningUndistributedProfit(Double.parseDouble(item.get(22)));
|
||||
income.setDistributableProfit(Double.parseDouble(item.get(23)));
|
||||
income.setResearchAndDevelopmentExpense(Double.parseDouble(item.get(24)));
|
||||
income.setFinancialExpenseInterestExpense(Double.parseDouble(item.get(25)));
|
||||
income.setNetProfitFromContinuingOperations(Double.parseDouble(item.get(26)));
|
||||
income.setNetProfitFromDiscontinuedOperations(Double.parseDouble(item.get(27)));
|
||||
income.setBasicEarningsPerShare(NumberUtil.parseDouble(item.get(1), null));
|
||||
income.setDilutedEarningsPerShare(NumberUtil.parseDouble(item.get(2), null));
|
||||
income.setTotalOperatingRevenue(NumberUtil.parseDouble(item.get(3), null));
|
||||
income.setOperatingRevenue(NumberUtil.parseDouble(item.get(4), null));
|
||||
income.setTotalOperatingCost(NumberUtil.parseDouble(item.get(5), null));
|
||||
income.setOperatingCost(NumberUtil.parseDouble(item.get(6), null));
|
||||
income.setSellingExpense(NumberUtil.parseDouble(item.get(7), null));
|
||||
income.setAdministrativeExpense(NumberUtil.parseDouble(item.get(8), null));
|
||||
income.setFinancialExpense(NumberUtil.parseDouble(item.get(9), null));
|
||||
income.setOperatingExpense(NumberUtil.parseDouble(item.get(10), null));
|
||||
income.setOperatingProfit(NumberUtil.parseDouble(item.get(11), null));
|
||||
income.setAddNonOperatingIncome(NumberUtil.parseDouble(item.get(12), null));
|
||||
income.setLessNonOperatingExpense(NumberUtil.parseDouble(item.get(13), null));
|
||||
income.setTotalProfit(NumberUtil.parseDouble(item.get(14), null));
|
||||
income.setIncomeTaxExpense(NumberUtil.parseDouble(item.get(15), null));
|
||||
income.setNetProfitIncludingMinorityInterest(NumberUtil.parseDouble(item.get(16), null));
|
||||
income.setNetProfitExcludingMinorityInterest(NumberUtil.parseDouble(item.get(17), null));
|
||||
income.setComprehensiveIncomeAttributableToParent(NumberUtil.parseDouble(item.get(18), null));
|
||||
income.setComprehensiveIncomeAttributableToMinorityShareholders(NumberUtil.parseDouble(item.get(19), null));
|
||||
income.setEarningsBeforeInterestAndTax(NumberUtil.parseDouble(item.get(20), null));
|
||||
income.setBeginningUndistributedProfit(NumberUtil.parseDouble(item.get(21), null));
|
||||
income.setDistributableProfit(NumberUtil.parseDouble(item.get(22), null));
|
||||
income.setResearchAndDevelopmentExpense(NumberUtil.parseDouble(item.get(23), null));
|
||||
income.setFinancialExpenseInterestExpense(NumberUtil.parseDouble(item.get(24), null));
|
||||
income.setNetProfitFromContinuingOperations(NumberUtil.parseDouble(item.get(25), null));
|
||||
income.setNetProfitFromDiscontinuedOperations(NumberUtil.parseDouble(item.get(26), null));
|
||||
incomeRepository.save(income);
|
||||
}
|
||||
|
||||
@@ -95,39 +100,42 @@ public class UpdateFinanceNode extends TaskNodeComponent {
|
||||
continue;
|
||||
}
|
||||
var stock = stocksMap.get(code);
|
||||
var balanceSheet = new BalanceSheet();
|
||||
var balanceSheet = balanceSheetRepository.findOne(
|
||||
QBalanceSheet.balanceSheet.year.eq(year)
|
||||
.and(QBalanceSheet.balanceSheet.stock.code.eq(stock.getCode()))
|
||||
).orElse(new BalanceSheet());
|
||||
balanceSheet.setStock(stock);
|
||||
balanceSheet.setYear(year);
|
||||
balanceSheet.setEndingTotalShares(Double.parseDouble(item.get(1)));
|
||||
balanceSheet.setCapitalSurplus(Double.parseDouble(item.get(2)));
|
||||
balanceSheet.setUndistributedProfit(Double.parseDouble(item.get(3)));
|
||||
balanceSheet.setMonetaryFunds(Double.parseDouble(item.get(4)));
|
||||
balanceSheet.setAccountsReceivable(Double.parseDouble(item.get(5)));
|
||||
balanceSheet.setInventories(Double.parseDouble(item.get(6)));
|
||||
balanceSheet.setTotalCurrentAssets(Double.parseDouble(item.get(7)));
|
||||
balanceSheet.setLongTermEquityInvestments(Double.parseDouble(item.get(8)));
|
||||
balanceSheet.setLongTermReceivables(Double.parseDouble(item.get(9)));
|
||||
balanceSheet.setFixedAssets(Double.parseDouble(item.get(10)));
|
||||
balanceSheet.setResearchAndDevelopmentExpenditures(Double.parseDouble(item.get(11)));
|
||||
balanceSheet.setGoodwill(Double.parseDouble(item.get(12)));
|
||||
balanceSheet.setTotalNonCurrentAssets(Double.parseDouble(item.get(13)));
|
||||
balanceSheet.setTotalAssets(Double.parseDouble(item.get(14)));
|
||||
balanceSheet.setLongTermBorrowings(Double.parseDouble(item.get(15)));
|
||||
balanceSheet.setShortTermBorrowings(Double.parseDouble(item.get(16)));
|
||||
balanceSheet.setAccountsPayable(Double.parseDouble(item.get(17)));
|
||||
balanceSheet.setAdvancesReceived(Double.parseDouble(item.get(18)));
|
||||
balanceSheet.setTotalCurrentLiabilities(Double.parseDouble(item.get(19)));
|
||||
balanceSheet.setTotalNonCurrentLiabilities(Double.parseDouble(item.get(20)));
|
||||
balanceSheet.setTotalLiabilities(Double.parseDouble(item.get(21)));
|
||||
balanceSheet.setTotalShareholdersEquityExcludingMinorityInterest(Double.parseDouble(item.get(22)));
|
||||
balanceSheet.setTotalShareholdersEquityIncludingMinorityInterest(Double.parseDouble(item.get(23)));
|
||||
balanceSheet.setTotalLiabilitiesAndShareholdersEquity(Double.parseDouble(item.get(24)));
|
||||
balanceSheet.setAccountsReceivable(Double.parseDouble(item.get(25)));
|
||||
balanceSheet.setPayables(Double.parseDouble(item.get(26)));
|
||||
balanceSheet.setNotesAndAccountsReceivable(Double.parseDouble(item.get(27)));
|
||||
balanceSheet.setNotesAndAccountsPayable(Double.parseDouble(item.get(28)));
|
||||
balanceSheet.setOtherReceivablesTotal(Double.parseDouble(item.get(29)));
|
||||
balanceSheet.setFixedAssetsTotal(Double.parseDouble(item.get(30)));
|
||||
balanceSheet.setEndingTotalShares(NumberUtil.parseDouble(item.get(1), null));
|
||||
balanceSheet.setCapitalSurplus(NumberUtil.parseDouble(item.get(2), null));
|
||||
balanceSheet.setUndistributedProfit(NumberUtil.parseDouble(item.get(3), null));
|
||||
balanceSheet.setMonetaryFunds(NumberUtil.parseDouble(item.get(4), null));
|
||||
balanceSheet.setAccountsReceivable(NumberUtil.parseDouble(item.get(5), null));
|
||||
balanceSheet.setInventories(NumberUtil.parseDouble(item.get(6), null));
|
||||
balanceSheet.setTotalCurrentAssets(NumberUtil.parseDouble(item.get(7), null));
|
||||
balanceSheet.setLongTermEquityInvestments(NumberUtil.parseDouble(item.get(8), null));
|
||||
balanceSheet.setLongTermReceivables(NumberUtil.parseDouble(item.get(9), null));
|
||||
balanceSheet.setFixedAssets(NumberUtil.parseDouble(item.get(10), null));
|
||||
balanceSheet.setResearchAndDevelopmentExpenditures(NumberUtil.parseDouble(item.get(11), null));
|
||||
balanceSheet.setGoodwill(NumberUtil.parseDouble(item.get(12), null));
|
||||
balanceSheet.setTotalNonCurrentAssets(NumberUtil.parseDouble(item.get(13), null));
|
||||
balanceSheet.setTotalAssets(NumberUtil.parseDouble(item.get(14), null));
|
||||
balanceSheet.setLongTermBorrowings(NumberUtil.parseDouble(item.get(15), null));
|
||||
balanceSheet.setShortTermBorrowings(NumberUtil.parseDouble(item.get(16), null));
|
||||
balanceSheet.setAccountsPayable(NumberUtil.parseDouble(item.get(17), null));
|
||||
balanceSheet.setAdvancesReceived(NumberUtil.parseDouble(item.get(18), null));
|
||||
balanceSheet.setTotalCurrentLiabilities(NumberUtil.parseDouble(item.get(19), null));
|
||||
balanceSheet.setTotalNonCurrentLiabilities(NumberUtil.parseDouble(item.get(20), null));
|
||||
balanceSheet.setTotalLiabilities(NumberUtil.parseDouble(item.get(21), null));
|
||||
balanceSheet.setTotalShareholdersEquityExcludingMinorityInterest(NumberUtil.parseDouble(item.get(22), null));
|
||||
balanceSheet.setTotalShareholdersEquityIncludingMinorityInterest(NumberUtil.parseDouble(item.get(23), null));
|
||||
balanceSheet.setTotalLiabilitiesAndShareholdersEquity(NumberUtil.parseDouble(item.get(24), null));
|
||||
balanceSheet.setAccountsReceivable(NumberUtil.parseDouble(item.get(25), null));
|
||||
balanceSheet.setPayables(NumberUtil.parseDouble(item.get(26), null));
|
||||
balanceSheet.setNotesAndAccountsReceivable(NumberUtil.parseDouble(item.get(27), null));
|
||||
balanceSheet.setNotesAndAccountsPayable(NumberUtil.parseDouble(item.get(28), null));
|
||||
balanceSheet.setOtherReceivablesTotal(NumberUtil.parseDouble(item.get(29), null));
|
||||
balanceSheet.setFixedAssetsTotal(NumberUtil.parseDouble(item.get(30), null));
|
||||
balanceSheetRepository.save(balanceSheet);
|
||||
}
|
||||
|
||||
@@ -138,21 +146,25 @@ public class UpdateFinanceNode extends TaskNodeComponent {
|
||||
continue;
|
||||
}
|
||||
var stock = stocksMap.get(code);
|
||||
var cashFlow = new CashFlow();
|
||||
var cashFlow = cashFlowRepository.findOne(
|
||||
QCashFlow.cashFlow.year.eq(year)
|
||||
.and(QCashFlow.cashFlow.stock.code.eq(stock.getCode()))
|
||||
).orElse(new CashFlow());
|
||||
NumberUtil.parseDouble(item.get(1), null);
|
||||
cashFlow.setStock(stock);
|
||||
cashFlow.setYear(year);
|
||||
cashFlow.setNetProfit(Double.parseDouble(item.get(1)));
|
||||
cashFlow.setFinancialExpense(Double.parseDouble(item.get(2)));
|
||||
cashFlow.setCashReceivedFromSalesAndServices(Double.parseDouble(item.get(3)));
|
||||
cashFlow.setSubtotalOfCashInflowsFromOperatingActivities(Double.parseDouble(item.get(4)));
|
||||
cashFlow.setCashPaidToAndForEmployees(Double.parseDouble(item.get(5)));
|
||||
cashFlow.setCashPaidForVariousTaxes(Double.parseDouble(item.get(6)));
|
||||
cashFlow.setNetCashFlowFromOperatingActivities(Double.parseDouble(item.get(7)));
|
||||
cashFlow.setSubtotalOfCashInflowsFromInvestingActivities(Double.parseDouble(item.get(8)));
|
||||
cashFlow.setCashPaidForAcquisitionOfFixedIntangibleAndOtherLongTermAssets(Double.parseDouble(item.get(9)));
|
||||
cashFlow.setSubtotalOfCashOutflowsFromInvestingActivities(Double.parseDouble(item.get(10)));
|
||||
cashFlow.setSubtotalOfCashOutflowsFromFinancingActivities(Double.parseDouble(item.get(11)));
|
||||
cashFlow.setBeginningBalanceOfCashAndCashEquivalents(Double.parseDouble(item.get(12)));
|
||||
cashFlow.setNetProfit(NumberUtil.parseDouble(item.get(1), null));
|
||||
cashFlow.setFinancialExpense(NumberUtil.parseDouble(item.get(2), null));
|
||||
cashFlow.setCashReceivedFromSalesAndServices(NumberUtil.parseDouble(item.get(3), null));
|
||||
cashFlow.setSubtotalOfCashInflowsFromOperatingActivities(NumberUtil.parseDouble(item.get(4), null));
|
||||
cashFlow.setCashPaidToAndForEmployees(NumberUtil.parseDouble(item.get(5), null));
|
||||
cashFlow.setCashPaidForVariousTaxes(NumberUtil.parseDouble(item.get(6), null));
|
||||
cashFlow.setNetCashFlowFromOperatingActivities(NumberUtil.parseDouble(item.get(7), null));
|
||||
cashFlow.setSubtotalOfCashInflowsFromInvestingActivities(NumberUtil.parseDouble(item.get(8), null));
|
||||
cashFlow.setCashPaidForLongTermAssets(NumberUtil.parseDouble(item.get(9), null));
|
||||
cashFlow.setSubtotalOfCashOutflowsFromInvestingActivities(NumberUtil.parseDouble(item.get(10), null));
|
||||
cashFlow.setSubtotalOfCashOutflowsFromFinancingActivities(NumberUtil.parseDouble(item.get(11), null));
|
||||
cashFlow.setBeginningBalanceOfCashAndCashEquivalents(NumberUtil.parseDouble(item.get(12), null));
|
||||
cashFlowRepository.save(cashFlow);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.lanyuanxiaoyao.leopard.server.service.task;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.StockService;
|
||||
import com.lanyuanxiaoyao.leopard.core.repository.StockRepository;
|
||||
import com.lanyuanxiaoyao.leopard.server.service.TuShareService;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
@@ -13,18 +13,19 @@ import java.util.stream.Collectors;
|
||||
|
||||
@LiteflowComponent("update_stock")
|
||||
public class UpdateStockNode extends NodeComponent {
|
||||
private final StockService stockService;
|
||||
private final StockRepository stockRepository;
|
||||
|
||||
private final TuShareService tuShareService;
|
||||
|
||||
public UpdateStockNode(StockService stockService, TuShareService tuShareService) {
|
||||
this.stockService = stockService;
|
||||
public UpdateStockNode(StockRepository stockRepository, TuShareService tuShareService) {
|
||||
this.stockRepository = stockRepository;
|
||||
this.tuShareService = tuShareService;
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
@Override
|
||||
public void process() {
|
||||
var stocks = stockService.list();
|
||||
var stocks = stockRepository.findAll();
|
||||
var stocksMap = stocks.stream().collect(Collectors.toMap(Stock::getCode, stock -> stock));
|
||||
var targetCodes = new HashSet<String>();
|
||||
tuShareService.stockList()
|
||||
@@ -60,8 +61,8 @@ public class UpdateStockNode extends NodeComponent {
|
||||
.filter(stock -> !targetCodes.contains(stock.getCode()))
|
||||
.map(Stock::getId)
|
||||
.toList();
|
||||
stockService.remove(deleteStocks);
|
||||
stockRepository.deleteByIds(deleteStocks);
|
||||
|
||||
stockService.save(stocks);
|
||||
stockRepository.saveAll(stocks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,9 @@ spring:
|
||||
async:
|
||||
request-timeout: 3600000
|
||||
datasource:
|
||||
# url: jdbc:mysql://mysql.lanyuanxiaoyao.com:43780/leopard?useSSL=false
|
||||
# url: jdbc:mysql://192.168.31.127:3780/leopard?useSSL=false
|
||||
url: jdbc:postgresql://81.71.3.24:6785/leopard_dev
|
||||
username: leopard
|
||||
password: '9NEzFzovnddf@PyEP?e*AYAWnCyd7UhYwQK$pJf>7?ccFiN^x4$eKEZ5~E<7<+~X'
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
driver-class-name: org.postgresql.Driver
|
||||
jpa:
|
||||
generate-ddl: true
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE flow PUBLIC "liteflow" "https://liteflow.cc/liteflow.dtd">
|
||||
<flow>
|
||||
<chain id="update_stock_information">
|
||||
CATCH(THEN(task_start, update_stock, task_end)).DO(task_error)
|
||||
</chain>
|
||||
<chain id="update_daily_information">
|
||||
CATCH(THEN(task_start, update_daily, task_end)).DO(task_error)
|
||||
</chain>
|
||||
<chain id="check_daily">
|
||||
CATCH(THEN(task_start, check_daily, task_end)).DO(task_error)
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user