Commit facb5916 authored by liucx's avatar liucx

优化 只更新4个字段

parent 00ec197d
...@@ -52,24 +52,20 @@ public class AssetStockPriceTask implements ApplicationRunner { ...@@ -52,24 +52,20 @@ public class AssetStockPriceTask implements ApplicationRunner {
private UsMemberBaseService memberBaseService; private UsMemberBaseService memberBaseService;
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
log.info("资管计算股票统计日志开始",commonConfig.getAssetStockPriceTask()); log.info("资管计算股票统计日志开始", commonConfig.getAssetStockPriceTask());
//log.info("资管计算股票统计日志开始配置更新开关状态:" + commonConfig.getStockPriceTask()); //log.info("资管计算股票统计日志开始配置更新开关状态:" + commonConfig.getStockPriceTask());
if (commonConfig.getAssetStockPriceTask() != null && commonConfig.getAssetStockPriceTask().equals("run")) { if (commonConfig.getAssetStockPriceTask() != null && commonConfig.getAssetStockPriceTask().equals("run")) {
//if (true) { //if (true) {
//分页查询异动配置列表 //分页查询异动配置列表
ExecutorService PersonalexecutorService = Executors.newSingleThreadExecutor(); ExecutorService PersonalexecutorService = Executors.newSingleThreadExecutor();
ExecutorService executorServicePersonal = Executors.newFixedThreadPool(100); ExecutorService executorServicePersonal = Executors.newFixedThreadPool(100);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
while (true) { while (true) {
if (DateUtil.isTradeDayForChangeRemind()) { if (DateUtil.isTradeDayForChangeRemind()) {
// if (true) { // if (true) {
AtomicReference<Integer> pageNo = new AtomicReference<>(1); AtomicReference<Integer> pageNo = new AtomicReference<>(1);
Integer pageSize = 100; Integer pageSize = 100;
Date startTime = new Date(); Date startTime = new Date();
...@@ -145,36 +141,40 @@ public class AssetStockPriceTask implements ApplicationRunner { ...@@ -145,36 +141,40 @@ public class AssetStockPriceTask implements ApplicationRunner {
//资管 //资管
public void AccountProductRelationTask(AssetAccountProductRelation accountProductRelation) { public void AccountProductRelationTask(AssetAccountProductRelation accountProductRelation) {
String type = SIMULATED.getCode(); try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在"); String type = SIMULATED.getCode();
//查询客户信息 OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
Long marketId = accountProductRelation.getSimulatedMarketId(); //查询客户信息
//查询持仓信息 Long marketId = accountProductRelation.getSimulatedMarketId();
BigDecimal funding = null; //查询持仓信息
//获取可用资金 BigDecimal funding = null;
if (REAL.getCode().equals(type)) { //获取可用资金
return; if (REAL.getCode().equals(type)) {
} return;
if (SIMULATED.getCode().equals(type)) { }
funding = accountProductRelation.getSimulatedFunding(); if (SIMULATED.getCode().equals(type)) {
funding = accountProductRelation.getSimulatedFunding();
}
AssetAccountProductRelation productRelation = new AssetAccountProductRelation();
productRelation.setId(accountProductRelation.getId());
//获取所有买入过的股票
List<AssetStockPosition> stockPositions = stockPositionService.queryStockPositions(marketId);
//汇总数据
AssetMarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
//示范盈亏比例
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
//示范持仓比
productRelation.setSimulatedProportion(new BigDecimal(marketDetailsVO.getPosition()));
//示范盘持仓数量
productRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
productRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(productRelation);
} catch (Exception e) {
log.error("资管更新数据错误:{}", e);
} }
AssetAccountProductRelation productRelation = new AssetAccountProductRelation();
productRelation.setId(accountProductRelation.getId());
//获取所有买入过的股票
List<AssetStockPosition> stockPositions = stockPositionService.queryStockPositions(marketId);
//汇总数据
AssetMarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask( stockPositions, funding, accountProductRelation);
//示范盈亏比例
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
//示范持仓比
productRelation.setSimulatedProportion(new BigDecimal(marketDetailsVO.getPosition()));
//示范盘持仓数量
productRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
productRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(productRelation);
} }
......
...@@ -148,6 +148,7 @@ public class SmartStockPriceTask implements ApplicationRunner { ...@@ -148,6 +148,7 @@ public class SmartStockPriceTask implements ApplicationRunner {
//智能跟投 //智能跟投
public void AccountProductRelationTask(SmartAccountProductRelation accountProductRelation) { public void AccountProductRelationTask(SmartAccountProductRelation accountProductRelation) {
try{
String type = SIMULATED.getCode(); String type = SIMULATED.getCode();
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在"); OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
//查询客户信息 //查询客户信息
...@@ -181,6 +182,10 @@ public class SmartStockPriceTask implements ApplicationRunner { ...@@ -181,6 +182,10 @@ public class SmartStockPriceTask implements ApplicationRunner {
//示范盘盈亏金额 //示范盘盈亏金额
smartAccountProductRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit())); smartAccountProductRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(smartAccountProductRelation); accountProductRelationService.updateAccountProductRelation(smartAccountProductRelation);
}
catch (Exception e){
log.error("更新数据错误:{}",e);
}
} }
......
...@@ -145,39 +145,44 @@ public class StockPriceTask implements ApplicationRunner { ...@@ -145,39 +145,44 @@ public class StockPriceTask implements ApplicationRunner {
//私人定制 //私人定制
public void AccountProductRelationTask(AccountProductRelation accountProductRelation) { public void AccountProductRelationTask(AccountProductRelation accountProductRelation) {
String type = SIMULATED.getCode(); try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在"); String type = SIMULATED.getCode();
//查询客户信息 OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
Long customerId = accountProductRelation.getCustomerId(); //查询客户信息
MemberBase memberBase = memberBaseService.queryUsMemberBaseById(customerId); Long customerId = accountProductRelation.getCustomerId();
Long marketId = accountProductRelation.getSimulatedMarketId(); MemberBase memberBase = memberBaseService.queryUsMemberBaseById(customerId);
OptionalUtil.checkNull(memberBase, "查询用户数据不存在"); Long marketId = accountProductRelation.getSimulatedMarketId();
//查询持仓信息 OptionalUtil.checkNull(memberBase, "查询用户数据不存在");
BigDecimal funding = null; //查询持仓信息
//获取可用资金 BigDecimal funding = null;
if (REAL.getCode().equals(type)) { //获取可用资金
funding = accountProductRelation.getRealFunding(); if (REAL.getCode().equals(type)) {
funding = accountProductRelation.getRealFunding();
}
if (SIMULATED.getCode().equals(type)) {
funding = accountProductRelation.getSimulatedFunding();
}
//获取所有买入过的股票
List<StockPosition> stockPositions = stockPositionService.queryStockPositions(marketId);
//汇总数据
MarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
AccountProductRelation productRelation = new AccountProductRelation();
productRelation.setId(accountProductRelation.getId());
//示范盈亏比例
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
//示范持仓比
productRelation.setSimulatedProportion(new BigDecimal(marketDetailsVO.getPosition()));
//示范盘持仓数量
productRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
productRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(productRelation);
}catch (Exception e){
log.error("私人定制更新数据错误:{}",e);
} }
if (SIMULATED.getCode().equals(type)) {
funding = accountProductRelation.getSimulatedFunding();
}
//获取所有买入过的股票
List<StockPosition> stockPositions = stockPositionService.queryStockPositions(marketId);
//汇总数据
MarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
AccountProductRelation productRelation = new AccountProductRelation();
productRelation.setId(accountProductRelation.getId());
//示范盈亏比例
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
//示范持仓比
productRelation.setSimulatedProportion(new BigDecimal(marketDetailsVO.getPosition()));
//示范盘持仓数量
productRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
productRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(productRelation);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment