Commit 65ae7326 authored by liucx's avatar liucx

完善

parent a5f02bc0
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.pojo.dao.followAccount.FollowAccount;
import com.zfxftech.telmarket.common.pojo.dao.followAccount.FollowAccountPositionInfo;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.followAccount.FollowAccountPositionInfoService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountStockDealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* Create time: 2022/2/3
*/
@EnableScheduling
@Component
@Slf4j
public class FollowAccountAutoSellStockTask {
@Resource
FollowAccountPositionInfoService followAccountPositionInfoService;
@Scheduled(cron = "0 50 14 * * ?")
private void followAccountYieldsRecordRunTask() {
if(DateUtil.isTradeDay()){
log.info("开始自动卖出40个交易日前买入且依然在持仓的的股票");
Date startTime = new Date();
followAccountPositionInfoService.autoSellStockBy40TradeDay();
log.info("完成自动卖出" +DateUtil.calculateTimeGapSecond(startTime,new Date()) + "秒");
}else{
log.info("今天非交易日,退出自动卖出股票");
}
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxf.tools.wechat.helper.api.TemplateKeyWordBuilder;
import com.zfxftech.telmarket.common.enums.remind.InformTypeEnums;
import com.zfxftech.telmarket.common.pojo.dao.followAccount.FollowAccount;
import com.zfxftech.telmarket.common.pojo.dao.followAccount.FollowAccountStockOrder;
import com.zfxftech.telmarket.common.pojo.dao.permission.UsAdmin;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.UsAdminService;
import com.zfxftech.telmarket.service.business.WeChatTemplateMessageService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountStockDealService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountYieldsRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* Create time: 2022/2/3
*/
@EnableScheduling
@Component
@Slf4j
public class FollowAccountBuyInTwoStockRiskTask {
@Resource
FollowAccountService followAccountService;
@Resource
FollowAccountStockDealService followAccountStockDealService;
@Resource
UsAdminService usAdminService;
@Resource
WeChatTemplateMessageService weChatTemplateMessageService;
@Scheduled(cron = "0 0 9 * * ?")
private void followAccountYieldsRecordRunTask() {
if(DateUtil.isLastTradeDayOfMonth()){
log.info("今天是本月最后一个交易日:开始计算跟投账户本月是否买入至少两只股票");
Date startTime = new Date();
List<FollowAccount> list = followAccountService.getAllFollowAccount();
for(FollowAccount followAccount : list){
if(!followAccountStockDealService.ifBugTowStockMonthly(followAccount.getId())){
log.info("跟投账户【"+ followAccount.getProductName()+"】当月购买股票数量不足两只");
sendMsg(followAccount);
}
}
log.info("完成计算跟投账户本月是否买入至少两只股票 耗时" +DateUtil.calculateTimeGapSecond(startTime,new Date()) + "秒");
}else{
log.info("今天非本月最后一个交易日,退出计算");
}
}
private void sendMsg(FollowAccount faLoad){
UsAdmin admin = usAdminService.getAdminByUserId(faLoad.getAnalyst() + "");
TemplateKeyWordBuilder templateKeyWordBuilder = TemplateKeyWordBuilder.create();
templateKeyWordBuilder.addFirst("【" + "跟投账户提醒" + "】");
templateKeyWordBuilder.addKeyWord(DateUtil.getNow());
String stockInfo = "【 " + faLoad.getProductName() +"】 本月买入交易不足2次,请及时操作交易! " ;
templateKeyWordBuilder.addKeyWord(stockInfo,"#FF3030");
templateKeyWordBuilder.addRemark("投资建议仅供参考,据此操作风险自担!投资有风险,入市须谨慎!中方信富资格证书编号:zx0121。如有疑问请联系客服:4008888115。");
weChatTemplateMessageService.pushToAdminUser(admin,templateKeyWordBuilder, InformTypeEnums.TRADINGSTRATEGIES);
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.pojo.dao.followAccount.FollowAccount;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.followAccount.FollowAccountPositionInfoService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountYieldsRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* Create time: 2022/2/3
*/
@EnableScheduling
@Component
@Slf4j
public class FollowAccountFreeCountTask {
@Resource
FollowAccountService followAccountService;
@Resource
FollowAccountYieldsRecordService followAccountYieldsRecordService;
@Resource
FollowAccountPositionInfoService followAccountPositionInfoService;
@Scheduled(cron = "0 10 9 ? * MON-FRI")
private void followAccountYieldsRecordRunTask() {
try {
log.info("开始计算更新持仓可用股数");
Date startTime = new Date();
followAccountPositionInfoService.updateFollowAccountPositionFreeCountByDay();
log.info("持仓可用股数更新完成 共耗时:" + DateUtil.calculateTimeGapSecond(startTime,new Date()));
}catch (Exception e){
log.error("持仓可用股数更新失败",e);
}
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.config.CommonConfig;
import com.zfxftech.telmarket.common.enums.followAccount.FollowAccountCommonStatusEnum;
import com.zfxftech.telmarket.common.enums.followAccount.FollowAccountConfigRuleTypeEnum;
import com.zfxftech.telmarket.common.enums.followAccount.FollowAccountOrderDirectionEnum;
import com.zfxftech.telmarket.common.enums.followAccount.FollowAccountOrderTypeEnum;
import com.zfxftech.telmarket.common.pojo.dao.Quote;
import com.zfxftech.telmarket.common.pojo.dao.followAccount.*;
import com.zfxftech.telmarket.common.pojo.dto.followAccount.FollowAccountDto;
import com.zfxftech.telmarket.common.pojo.request.followAccount.FollowAccountStockOrderReq;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.common.util.followAccount.FollowAccountLockUtil;
import com.zfxftech.telmarket.service.business.StockCodeService;
import com.zfxftech.telmarket.service.followAccount.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Create time: 2022/1/26
*/
@Slf4j
@Component
@Order(value = 1)
public class FollowAccountStatisticsTask implements ApplicationRunner {
@Autowired
private CommonConfig commonConfig;
@Resource
StockCodeService stockCodeService;
@Resource
FollowAccountService followAccountService;
@Resource
FollowAccountLockUtil followAccountLockUtil;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("跟投账户整体数据更新开关状态:" + commonConfig.getFollowAccountStatisticsTaskSwitch());
ExecutorService executorService = Executors.newSingleThreadExecutor();
ExecutorService executorService1 = Executors.newFixedThreadPool(200);
CompletableFuture.runAsync(() -> {
while (true) {
if(commonConfig.getFollowAccountStatisticsTaskSwitch() != null && commonConfig.getFollowAccountStatisticsTaskSwitch().equals("run")) {
log.info("跟投账户整体数据更新任务开始启动");
Date startTime = new Date();
int size = 0;
List<CompletableFuture<String>> futureList = new ArrayList<>();
if (DateUtil.isTradeDay()) {
//List<CompletableFuture> cfList = new ArrayList();
List<FollowAccount> faList = new ArrayList<>();
try {
faList = followAccountService.getAllFollowAccountByTask();
size = faList.size();
}catch (Exception e){
log.error("获取全部跟投账户数据准备进行计算出错", e);
e.printStackTrace();
}
//开始循环跟投账户并计算
try {
for (FollowAccount followAccount : faList) {
//为每个跟投账户开启一个独立线程进行异步计算
CompletableFuture cf = CompletableFuture.supplyAsync(() -> {
//开始计算和更新持仓信息
try {
//List<FollowAccountPositionInfo> infoList = positionInfoService.getFollowAccountPositionInfoByFollowAccountId(followAccount.getId());
followAccountService.followAccountPositionInfoStatisticsList(followAccount);
} catch (Exception e) {
log.error("跟投账户整体数据更新线程出错", e);
followAccountLockUtil.backLock(followAccount.getId());
}
return "";
},executorService1).handle((result, ex) -> {
if (null != ex) {
log.info("出错啦",ex);
System.out.println(ex.getMessage());
return 0;
} else {
return result;
}
});
futureList.add(cf);
}
}catch (Exception e){
log.error("跟投账户发生未知错误",e);
}
}
try {
CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
//log.info("全部跟投账户开始更新数据--------主线程开始阻塞,等待更新全部完成--------");
combinedFuture.get();
log.info("跟投账户数据计算完成,本次共计算" + size + "个跟投账户数据。耗时" + DateUtil.calculateTimeGapSecond(startTime, new Date()) + "秒");
} catch (Exception e) {
log.error("跟投账户整体数据更新线程出错", e);
e.printStackTrace();
}
}else{
//log.info("跟投账户整体数据更新任务开关状态为关闭,任务不启动");
}
try {
Thread.sleep(5000);
}catch (Exception e){}
}
},executorService);
}
FollowAccountPositionInfo getFollowAccountPositionInfoStatistics(FollowAccountPositionInfo infoLoad){
BigDecimal price = stockCodeService.getStockQuote(infoLoad.getCode() + "").getNow();
BigDecimal currentAmount = price.multiply(new BigDecimal(infoLoad.getCount()));
infoLoad.setCurrentAmount(currentAmount);
infoLoad.setCurrentPrice(price);
infoLoad.setYieldsAmount(currentAmount.subtract(infoLoad.getCostPrice().multiply(infoLoad.getCostPrice())));
infoLoad.setYields((price.subtract(infoLoad.getCostPrice())).divide(infoLoad.getCostPrice(),4,BigDecimal.ROUND_HALF_DOWN));
return infoLoad;
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.enums.followAccount.FollowAccountUserStatusEnum;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.followAccount.FollowAccountPositionInfoService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountUserService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountYieldsRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
/**
* Create time: 2022/2/3
*/
@EnableScheduling
@Component
@Slf4j
public class FollowAccountUserStatusTask {
@Resource
FollowAccountUserService followAccountUserService;
@Scheduled(cron = "0 15 9 * * MON-FRI")
private void followAccountYieldsRecordRunTask() {
try {
log.info("开始启动更新跟投账户用户状态任务");
Date startTime = new Date();
followAccountUserService.updateFollowAccountUserStatus();
log.info("更新跟投账户用户状态任务完成 共耗时:" + DateUtil.calculateTimeGapSecond(startTime,new Date()));
}catch (Exception e){
log.error("更新跟投账户用户状态任务",e);
}
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.config.CommonConfig;
import com.zfxftech.telmarket.service.business.AccountProductRelationService;
import com.zfxftech.telmarket.service.business.FinanceCalculateService;
import com.zfxftech.telmarket.service.business.StockCodeService;
import com.zfxftech.telmarket.service.business.StockPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @version V1.0
* @title: PersonalAccountPositionTask
* @description:
* @author: zw
* @date: 2022/4/11:07 下午
*/
@Slf4j
@Component
@Order(value = 1)
public class PersonalAccountPositionTask implements ApplicationRunner {
@Resource
CommonConfig commonConfig;
@Resource
AccountProductRelationService accountProductRelationService;
@Resource
private StockPositionService stockPositionService;
@Resource
private FinanceCalculateService financeCalculateService;
@Resource
private StockCodeService stockCodeService;
@Override
public void run(ApplicationArguments args) throws Exception {
// if(commonConfig.getPersonalAccountPositionTaskSwitch() != null && commonConfig.getPersonalAccountPositionTaskSwitch().equals("run")) {
// log.info("计算私人定制==账户==更新账户盈亏比例 开始启动");
// ExecutorService executorService = Executors.newSingleThreadExecutor();
// ExecutorService executorService1 = Executors.newFixedThreadPool(200);
// CompletableFuture.runAsync(() -> {
// while(true) {
// Date startTime = new Date();
// int size = 0;
// List<CompletableFuture<String>> futureList = new ArrayList<>();
//// if (DateUtil.isTradeDay()) {
// //查询所有账户
// List<AccountProductRelation> accountList = accountProductRelationService.queryAll();
// //查询所有持仓
// List<StockPosition> stockPositions = stockPositionService.getAll();
// //查询所有股票
// Set<String> simulatedCodes = stockPositions.stream().map(StockPosition::getCode).collect(Collectors.toSet());
// Map<String, Quote> simulatedAndQuoteMapping = stockCodeService.batchQueryStockPrice(new ArrayList<>(simulatedCodes));
// //整理账户下所有持仓
// Map<Long, List<StockPosition>> marketIdAndStockPositionsMapping = new HashMap<>();
// for (StockPosition stockPosition : stockPositions) {
// Long marketId = stockPosition.getMarketId();
// if (marketIdAndStockPositionsMapping.containsKey(marketId)) {
// List<StockPosition> temStockPositions = marketIdAndStockPositionsMapping.get(marketId);
// temStockPositions.add(stockPosition);
// } else {
// List<StockPosition> stockPositionList = new ArrayList<>();
// stockPositionList.add(stockPosition);
// marketIdAndStockPositionsMapping.put(marketId, stockPositionList);
// }
// }
// size = accountList.size();
// if (null != accountList && accountList.size() > 0) {
// int len = 200;//限制条数
// int count = (size + len - 1) / len;//分批数
// for (int i = 0; i < count; i++) {
// List<AccountProductRelation> listPage = accountList.subList(i * len, ((i + 1) * len > size ? size : (i + 1) * len));
// //为私人订制开启一个独立线程进行异步计算
// CompletableFuture cf = CompletableFuture.supplyAsync(() -> {
// List<AccountProductRelation> tempList = new ArrayList<>();
// for (AccountProductRelation accountProductRelation : listPage){
// AccountProductRelation tempAccount = new AccountProductRelation();
// try {
// //持仓个数
// List<StockPosition> temStockPositions = marketIdAndStockPositionsMapping.get(accountProductRelation.getSimulatedMarketId());
// //总市值
// BigDecimal simulatedStocksTotalPrice = financeCalculateService.calculateTotalAssets(temStockPositions, simulatedAndQuoteMapping);
// //总资产=可用资金+总市值
// BigDecimal simulatedTotalPrice = BigDecimalUtil.add(accountProductRelation.getSimulatedFunding(),simulatedStocksTotalPrice);
// //盈亏比例
// BigDecimal simulatedTotalProfit = financeCalculateService.calculateProfitRate(simulatedTotalPrice, accountProductRelation.getInitialFunding());
// //持仓比例=总市值/总资产
// BigDecimal position = BigDecimalUtil.div(simulatedStocksTotalPrice, simulatedTotalPrice);
// tempAccount.setId(accountProductRelation.getId());
// tempAccount.setSimulatedTotalPrice(simulatedTotalPrice);
// tempAccount.setSimulatedTotalProfit(simulatedTotalProfit);
// tempAccount.setSimulatedProportion(position);
// tempList.add(tempAccount);
// }catch (Exception e){
// e.printStackTrace();
// log.error("计算私人定制==账户==更新持仓盈亏比例更新线程出错",e);
// }
// }
// accountProductRelationService.batchUpdateAccountProductRelation(tempList);
// return "";
// },executorService1).handle((result, ex) -> {
// if (null != ex) {
// log.info("出错啦",ex);
// System.out.println(ex.getMessage());
// return 0;
// } else {
// return result;
// }
// });
// futureList.add(cf);
// }
// }
//// }
// try {
// CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
// combinedFuture.get();
// log.info("计算私人定制==账户==更新持仓盈亏比例计算完成,本次共计算" + size + "个持仓数据。耗时" + DateUtil.calculateTimeGapSecond(startTime,new Date()) + "秒");
// Thread.sleep(3000);
// }catch (Exception e){
// e.printStackTrace();
// }
// }
// },executorService);
// }
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.followAccount.FollowAccountPositionInfoService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountYieldsRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
/**
* Create time: 2022/2/3
*/
@EnableScheduling
@Component
@Slf4j
public class PersonalReportTask {
@Resource
FollowAccountService followAccountService;
@Resource
FollowAccountYieldsRecordService followAccountYieldsRecordService;
@Resource
FollowAccountPositionInfoService followAccountPositionInfoService;
@Scheduled(cron = "0 15 15 * * MON-FRI")
private void followAccountYieldsRecordRunTask() {
try {
log.info("开始计算更新持仓可用股数");
Date startTime = new Date();
followAccountPositionInfoService.updateFollowAccountPositionFreeCountByDay();
log.info("持仓可用股数更新完成 共耗时:" + DateUtil.calculateTimeGapSecond(startTime,new Date()));
}catch (Exception e){
log.error("持仓可用股数更新失败",e);
}
}
}
package com.zfxftech.telmarket.task.followAccount;
import com.zfxftech.telmarket.common.config.CommonConfig;
import com.zfxftech.telmarket.common.pojo.dao.Quote;
import com.zfxftech.telmarket.common.pojo.dao.smart.SmartStockPosition;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.business.StockCodeService;
import com.zfxftech.telmarket.service.business.smart.SmartFinanceCalculateService;
import com.zfxftech.telmarket.service.business.smart.SmartStockPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @version V1.0
* @title: PersonalPositionTask
* @description:
* @author: zw
* @date: 2022/3/12:33 下午
*/
@Slf4j
@Component
@Order(value = 1)
public class SmarkPersonalPositionTask implements ApplicationRunner {
@Resource
private SmartStockPositionService smartStockPositionService;
@Resource
private StockCodeService stockCodeService;
@Resource
private SmartFinanceCalculateService smartFinanceCalculateService;
@Resource
CommonConfig commonConfig;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("智能跟投======"+commonConfig.getPersonalPositionTaskSwitch());
log.info("智能跟投 bool======"+commonConfig.getPersonalPositionTaskSwitch().equals("run"));
if(commonConfig.getPersonalPositionTaskSwitch() != null && commonConfig.getPersonalPositionTaskSwitch().equals("run")) {
log.info("智能跟投更新持仓盈亏比例 当日涨跌幅 开始启动");
ExecutorService executorService = Executors.newSingleThreadExecutor();
ExecutorService executorService1 = Executors.newFixedThreadPool(200);
CompletableFuture.runAsync(() -> {
while(true) {
Date startTime = new Date();
int size = 0;
List<CompletableFuture<String>> futureList = new ArrayList<>();
if (DateUtil.isTradeDayForCal()) {
List<SmartStockPosition> faList = smartStockPositionService.getAll();
size = faList.size();
if (null != faList && faList.size() > 0) {
int len = 20;//限制条数
int count = (size + len - 1) / len;//分批数
for (int i = 0; i < count; i++) {
List<SmartStockPosition> listPage = faList.subList(i * len, ((i + 1) * len > size ? size : (i + 1) * len));
//为私人订制开启一个独立线程进行异步计算
CompletableFuture cf = CompletableFuture.supplyAsync(() -> {
List<SmartStockPosition> tempList = new ArrayList<>();
for (SmartStockPosition stockPosition : listPage){
try {
SmartStockPosition tempStockPosition = new SmartStockPosition();
Quote quote = stockCodeService.getStockQuote(stockPosition.getCode());
//开始计算和更新盈亏比例涨跌幅
//盈亏比例
tempStockPosition.setProfitLossRatio(smartFinanceCalculateService.profitLossRatio(quote.getNow(),stockPosition.getCost()));
tempStockPosition.setRiseDownRange(smartFinanceCalculateService.riseDownRange(quote.getNow(),quote.getClose()));
tempStockPosition.setId(stockPosition.getId());
tempList.add(tempStockPosition);
}catch (Exception e){
e.printStackTrace();
log.error("智能跟投更新持仓盈亏比例当日涨跌幅更新线程出错",e);
}
}
smartStockPositionService.bactchUpdateStockPosition(tempList);
return "";
},executorService1).handle((result, ex) -> {
if (null != ex) {
log.info("出错啦",ex);
System.out.println(ex.getMessage());
return 0;
} else {
return result;
}
});
futureList.add(cf);
}
}
}
try {
CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
//log.info("全部跟投账户开始更新数据--------主线程开始阻塞,等待更新全部完成--------");
combinedFuture.get();
log.info("智能跟投定制更新持仓盈亏比例当日涨跌幅计算完成,本次共计算" + size + "个持仓数据。耗时" + DateUtil.calculateTimeGapSecond(startTime,new Date()) + "秒");
Thread.sleep(5000);
}catch (Exception e){
e.printStackTrace();
}
}
},executorService);
}
}
}
package com.zfxftech.telmarket.task.report;
import com.zfxftech.telmarket.common.pojo.dao.report.ReportData;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.service.business.AccountProductRelationService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountPositionInfoService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountService;
import com.zfxftech.telmarket.service.followAccount.FollowAccountYieldsRecordService;
import com.zfxftech.telmarket.service.report.PersonalReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
/**
* Create time: 2022/2/3
*/
@EnableScheduling
@Component
@Slf4j
public class PersonReportTask {
@Autowired
PersonalReportService personalReportService;
@Autowired
AccountProductRelationService accountProductRelationService;
@Scheduled(cron = "0 3 15 * * MON-FRI")
private void followAccountYieldsRecordRunTask() {
try {
log.info("开始生成私人订制日报表");
Date startTime = new Date();
personalReportService.personReportTask1();
log.info("私人订制日报表1生成完成 共耗时:" + DateUtil.calculateTimeGapSecond(startTime,new Date()));
personalReportService.personReportTask2();
personalReportService.personReportTask3();
personalReportService.personReportTask4();
log.info("私人订制日报表全部生成完成 共耗时:" + DateUtil.calculateTimeGapSecond(startTime,new Date()));
}catch (Exception e){
log.error("私人订制日报表生成失败",e);
}
}
}
......@@ -2,7 +2,7 @@ server:
port: 8081
spring:
application:
name: invest-admin
name: stockPrice-task
cloud:
nacos:
config:
......@@ -14,4 +14,4 @@ spring:
discovery:
group: APP_GROUP
server-addr: 47.93.96.150:8848
service: invest-admin
\ No newline at end of file
service: stockPrice-task
\ No newline at end of file
......@@ -2,7 +2,7 @@ server:
port: 8383
spring:
application:
name: invest-admin
name: stockPrice-task
cloud:
nacos:
config:
......@@ -14,4 +14,4 @@ spring:
discovery:
group: APP_GROUP
server-addr: 172.17.188.83:8848
service: invest-admin
\ No newline at end of file
service: stockPrice-task
\ No newline at end of file
......@@ -2,7 +2,7 @@ server:
port: 8083
spring:
application:
name: invest-admin
name: stockPrice-task
cloud:
nacos:
config:
......@@ -14,5 +14,5 @@ spring:
discovery:
group: APP_GROUP
server-addr: 172.17.188.83:8848
service: invest-admin
service: stockPrice-task
......@@ -8,7 +8,7 @@
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后,可以使“${}”来使用变量。 -->
<property name="log.path" value="/opt/logs/newinvest" />
<property name="log.path" value="/opt/logs/pricetack" />
<!--0. 日志格式和颜色渲染 -->
<!-- 彩色日志依赖的渲染类 -->
......
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