ProfitRateServiceImplTest.java 1.95 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 60
package com.tanpu.fund.service.impl;

import com.tanpu.fund.enums.ProStatusEnums;
import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(SpringRunner.class)
 @SpringBootTest
 @ActiveProfiles("dev")
public class ProfitRateServiceImplTest {

    @Autowired
    FundCountService profitRateService;
    @Resource
    FundInfoCustomMapper fundInfoCustomMapper;
    @Resource
    FundNavMapper fundNavMapper;

    @Test
    public void sectionProfitRate() {
        //基金 HF0000000A
//        profitRateService.sectionProfitRate();

    }

    private void queryFundInfoNavVos(int pageSize, int proDisFre){
        //查询按周披露净值的基金
        List<Integer> statusList = new ArrayList<>();
        statusList.add(ProStatusEnums.OPENING.getType());
        statusList.add(ProStatusEnums.CHANGEMANGER.getType());
        statusList.add(ProStatusEnums.CLOSE.getType());
        List<String> fundInfoNavVos = fundInfoCustomMapper.queryFundNavByCondition(proDisFre, statusList, pageSize - 500, 500);

        //查询计算
        {
            if(!CollectionUtils.isEmpty(fundInfoNavVos)) {
                Date startDate = null;
                Date endDate = null;

                profitRateService.sectionProfitRate(proDisFre, startDate, endDate, fundInfoNavVos);
            }
        }

        if (!CollectionUtils.isEmpty(fundInfoNavVos) && fundInfoNavVos.size() == 500) {
            //递归每次取500条基金数据
            queryFundInfoNavVos(pageSize + 500, proDisFre);
        }
    }
}