Commit 9fd1f93c authored by liucx's avatar liucx

优化更新

parent d8e3c5e0
......@@ -57,4 +57,6 @@ public interface AccountProductRelationService extends IService<AccountProductRe
List<ProductCustomerFansDto> getProductUserList(Long productId);
List<AccountProductRelation> getRelationByProductIds(List<Long> ids);
void updateList(List<AccountProductRelation> list);
}
......@@ -58,4 +58,6 @@ public interface AssetAccountProductRelationService extends IService<AssetAccoun
List<AssetAccountProductRelation> getRelationByProductIds(List<Long> ids);
AssetMarketDetailsVO queryAssetSendFromLog(QueryAssetSendFromLogBO queryAssetSendFromLogBO);
void addAccountProductRelationList(List<AssetAccountProductRelation> assetAccountProductRelations);
}
......@@ -52,4 +52,6 @@ public interface SmartAccountProductRelationService extends IService<SmartAccoun
Object getMarkId(Long membaserId, List<Long> productList);
List<SmartAccountProductRelation> getRelationByProductIds(List<Long> ids);
void updateBatchById(List<SmartAccountProductRelation> productRelations);
}
......@@ -263,4 +263,9 @@ public class AccountProductRelationServiceImpl extends ServiceImpl<AccountProduc
return result;
}
@Override
public void updateList(List<AccountProductRelation> list) {
updateBatchById(list);
}
}
......@@ -466,6 +466,11 @@ public class AssetAccountProductRelationServiceImpl extends ServiceImpl<AssetAcc
return null;
}
@Override
public void addAccountProductRelationList(List<AssetAccountProductRelation> assetAccountProductRelations) {
updateBatchById(assetAccountProductRelations);
}
@Override
public List<AssetAccountProductRelation> getRelationByProductIds(List<Long> ids) {
List<Integer> status = Arrays.stream(AdminConstant.ProductStatusEnum.values())
......
......@@ -262,4 +262,9 @@ public class SmartAccountProductRelationServiceImpl extends ServiceImpl<SmartAcc
return result;
}
@Override
public void updateBatchById(List<SmartAccountProductRelation> productRelations) {
updateBatchById(productRelations);
}
}
......@@ -5,6 +5,7 @@ import com.zfxftech.telmarket.common.pojo.dao.MemberBase;
import com.zfxftech.telmarket.common.pojo.dao.asset.AssetAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.asset.AssetStockPosition;
import com.zfxftech.telmarket.common.pojo.vo.asset.AssetMarketDetailsVO;
import com.zfxftech.telmarket.common.util.BigDecimalUtil;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.common.util.OptionalUtil;
import com.zfxftech.telmarket.service.business.UsMemberBaseService;
......@@ -77,9 +78,17 @@ public class AssetStockPriceTask implements ApplicationRunner {
List<AssetAccountProductRelation> accountProductRelationList = this.page(accountProductRelations, pageNo.get(), pageSize);
CompletableFuture cf = CompletableFuture.supplyAsync(() -> {
List<AssetAccountProductRelation> assetAccountProductRelations = new ArrayList<>();
for (AssetAccountProductRelation accountProductRelation : accountProductRelationList) {
this.AccountProductRelationTask(accountProductRelation);
AssetAccountProductRelation assetAccountProductRelation = this.AccountProductRelationTask(accountProductRelation);
if(!ObjectUtils.isEmpty(assetAccountProductRelation) && !ObjectUtils.isEmpty(assetAccountProductRelation.getId())){
assetAccountProductRelations.add(assetAccountProductRelation);
}
}
accountProductRelationService.updateBatchById(assetAccountProductRelations);
return " ";
}, executorServicePersonal).handle((result, ex) -> {
if (null != ex) {
......@@ -139,8 +148,9 @@ public class AssetStockPriceTask implements ApplicationRunner {
//资管
public void AccountProductRelationTask(AssetAccountProductRelation accountProductRelation) {
public AssetAccountProductRelation AccountProductRelationTask(AssetAccountProductRelation accountProductRelation) {
Date startTime = new Date();
AssetAccountProductRelation productRelation = new AssetAccountProductRelation();
try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
......@@ -156,7 +166,9 @@ public class AssetStockPriceTask implements ApplicationRunner {
//汇总数据
AssetMarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
AssetAccountProductRelation productRelation = new AssetAccountProductRelation();
if(BigDecimalUtil.compare(new BigDecimal(marketDetailsVO.getTotalProfitRate()),accountProductRelation.getSimulatedTotalProfit(),0)){
return null;
}
productRelation.setId(accountProductRelation.getId());
//示范盈亏比例
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
......@@ -168,10 +180,12 @@ public class AssetStockPriceTask implements ApplicationRunner {
productRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
productRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(productRelation);
//accountProductRelationService.updateAccountProductRelation();
} catch (Exception e) {
log.error("资管更新数据错误:{}", e);
}
return productRelation;
}
......
......@@ -2,9 +2,11 @@ package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.config.CommonConfig;
import com.zfxftech.telmarket.common.pojo.dao.MemberBase;
import com.zfxftech.telmarket.common.pojo.dao.asset.AssetAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.smart.SmartAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.smart.SmartStockPosition;
import com.zfxftech.telmarket.common.pojo.vo.smart.SmartMarketDetailsVO;
import com.zfxftech.telmarket.common.util.BigDecimalUtil;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.common.util.OptionalUtil;
import com.zfxftech.telmarket.service.business.UsMemberBaseService;
......@@ -46,7 +48,7 @@ public class SmartStockPriceTask implements ApplicationRunner {
@Autowired
private SmartAccountProductRelationService accountProductRelationService;
private SmartAccountProductRelationService smartAccountProductRelationService;
@Autowired
private SmartStockPositionService stockPositionService;
@Autowired
......@@ -77,7 +79,7 @@ public class SmartStockPriceTask implements ApplicationRunner {
Integer pageSize = 50;
Date startTime = new Date();
List<CompletableFuture<String>> futureList = new ArrayList<>();
List<SmartAccountProductRelation> accountProductRelations = accountProductRelationService.queryAll();
List<SmartAccountProductRelation> accountProductRelations = smartAccountProductRelationService.queryAll();
if (!ObjectUtils.isEmpty(accountProductRelations) && accountProductRelations.size() > 0) {
log.info("智能跟投计算股票统计数据大小:{}", accountProductRelations.size());
Integer pageTOtl = accountProductRelations.size() % pageSize == 0 ? accountProductRelations.size() / pageSize : accountProductRelations.size() / pageSize + 1;
......@@ -85,9 +87,16 @@ public class SmartStockPriceTask implements ApplicationRunner {
List<SmartAccountProductRelation> accountProductRelationList = this.page(accountProductRelations, pageNo.get(), pageSize);
CompletableFuture cf = CompletableFuture.supplyAsync(() -> {
List<SmartAccountProductRelation> productRelations = new ArrayList<>();
for (SmartAccountProductRelation accountProductRelation : accountProductRelationList) {
this.AccountProductRelationTask(accountProductRelation);
SmartAccountProductRelation smartAccountProductRelation = this.AccountProductRelationTask(accountProductRelation);
if(!ObjectUtils.isEmpty(smartAccountProductRelation) && !ObjectUtils.isEmpty(smartAccountProductRelation.getId()) ) {
productRelations.add(smartAccountProductRelation);
}
}
smartAccountProductRelationService.updateBatchById(productRelations);
return " ";
}, executorServicePersonal).handle((result, ex) -> {
if (null != ex) {
......@@ -147,7 +156,9 @@ public class SmartStockPriceTask implements ApplicationRunner {
//智能跟投
public void AccountProductRelationTask(SmartAccountProductRelation accountProductRelation) {
public SmartAccountProductRelation AccountProductRelationTask(SmartAccountProductRelation accountProductRelation) {
SmartAccountProductRelation smartAccountProductRelation = new SmartAccountProductRelation();
try{
String type = SIMULATED.getCode();
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
......@@ -169,8 +180,12 @@ public class SmartStockPriceTask implements ApplicationRunner {
List<SmartStockPosition> stockPositions = stockPositionService.queryStockPositions(marketId);
//汇总数据
SmartMarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask( stockPositions, funding, accountProductRelation);
if(BigDecimalUtil.compare(new BigDecimal(marketDetailsVO.getTotalProfitRate()),accountProductRelation.getSimulatedTotalProfit(),0)){
return null;
}
//示范盈亏比例
SmartAccountProductRelation smartAccountProductRelation = new SmartAccountProductRelation();
smartAccountProductRelation.setId(accountProductRelation.getId());
smartAccountProductRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
//示范盘总资产
......@@ -181,11 +196,12 @@ public class SmartStockPriceTask implements ApplicationRunner {
smartAccountProductRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
smartAccountProductRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(smartAccountProductRelation);
//accountProductRelationService.updateAccountProductRelation(smartAccountProductRelation);
}
catch (Exception e){
log.error("更新数据错误:{}",e);
}
return smartAccountProductRelation;
}
......
......@@ -5,6 +5,7 @@ import com.zfxftech.telmarket.common.pojo.dao.AccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.MemberBase;
import com.zfxftech.telmarket.common.pojo.dao.StockPosition;
import com.zfxftech.telmarket.common.pojo.vo.MarketDetailsVO;
import com.zfxftech.telmarket.common.util.BigDecimalUtil;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.common.util.OptionalUtil;
import com.zfxftech.telmarket.service.business.*;
......@@ -82,8 +83,15 @@ public class StockPriceTask implements ApplicationRunner {
List<AccountProductRelation> accountProductRelationList = this.page(accountProductRelations, pageNo.get(), pageSize);
CompletableFuture cf = CompletableFuture.supplyAsync(() -> {
List<AccountProductRelation> list = new ArrayList<>();
for (AccountProductRelation accountProductRelation : accountProductRelationList) {
this.AccountProductRelationTask(accountProductRelation);
AccountProductRelation productRelation = this.AccountProductRelationTask(accountProductRelation);
if(!ObjectUtils.isEmpty(productRelation) && !ObjectUtils.isEmpty(productRelation.getId())){
list.add(productRelation);
}
accountProductRelationService.updateBatchById(list);
}
return " ";
}, executorServicePersonal).handle((result, ex) -> {
......@@ -144,7 +152,9 @@ public class StockPriceTask implements ApplicationRunner {
//私人定制
public void AccountProductRelationTask(AccountProductRelation accountProductRelation) {
public AccountProductRelation AccountProductRelationTask(AccountProductRelation accountProductRelation) {
AccountProductRelation productRelation = new AccountProductRelation();
try {
String type = SIMULATED.getCode();
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
......@@ -166,7 +176,12 @@ public class StockPriceTask implements ApplicationRunner {
List<StockPosition> stockPositions = stockPositionService.queryStockPositions(marketId);
//汇总数据
MarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
AccountProductRelation productRelation = new AccountProductRelation();
if(BigDecimalUtil.compare(new BigDecimal(marketDetailsVO.getTotalProfitRate()),accountProductRelation.getSimulatedTotalProfit(),0)){
return null;
}
productRelation.setId(accountProductRelation.getId());
//示范盈亏比例
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
......@@ -178,11 +193,12 @@ public class StockPriceTask implements ApplicationRunner {
productRelation.setPositionCount(ObjectUtils.isEmpty(stockPositions.size()) ? 0 : stockPositions.size());
//示范盘盈亏金额
productRelation.setProfitAmount(new BigDecimal(marketDetailsVO.getTotalProfit()));
accountProductRelationService.updateAccountProductRelation(productRelation);
//accountProductRelationService.updateAccountProductRelation(productRelation);
}catch (Exception e){
log.error("私人定制更新数据错误:{}",e);
}
return 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