package com.tanpu.fund.job; import com.dangdang.ddframe.job.api.ShardingContext; import com.dangdang.ddframe.job.api.simple.SimpleJob; import com.tanpu.fund.enums.ProDisFreEnums; import com.tanpu.fund.enums.ProStatusEnums; import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * 计算收益率 * * 周收益率 */ public class ProfitRateJob implements SimpleJob { @Autowired FundInfoCustomMapper fundInfoCustomMapper; @Autowired FundCountService profitRateService; @Override public void execute(ShardingContext shardingContext) { //查询按周披露净值的基金 queryFundInfoNavVos(0, ProDisFreEnums.Week.getType()); } private void queryFundInfoNavVos(int pageSize, int proDisFre){ //查询按周披露净值的基金 List<Integer> statusList = new ArrayList<>(); statusList.add(ProStatusEnums.OPENING.getType()); statusList.add(ProStatusEnums.CHANGEMANGER.getType()); List<String> fundIds = fundInfoCustomMapper.queryFundNavByCondition(proDisFre, statusList, pageSize, 500); //查询计算 { if(!CollectionUtils.isEmpty(fundIds)) { //TODO 区间时间 Date startDate = null; Date endDate = null; profitRateService.sectionProfitRate(proDisFre, startDate, endDate, fundIds); } } if (!CollectionUtils.isEmpty(fundIds) && fundIds.size() == 500) { //递归每次取500条基金数据 queryFundInfoNavVos(pageSize + 500, proDisFre); } } }