ProfitRateJob.java 1.76 KB
Newer Older
zp's avatar
zp committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
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);
        }
    }

}