package com.jxy.marketall.task;

import com.jxy.common.redis.service.RedisService;
import com.jxy.marketall.dto.DateBigDecimalDto;
import com.jxy.marketall.dto.GoldenRatioMultiplierDto;
import com.jxy.marketall.dto.PiCycleTIDto;
import com.jxy.marketall.mapper.BTCMapper;
import com.jxy.marketall.mapper.ETHMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.List;


/**
 * @Description TODO
 * @Date 2022/7/7 18:03
 * @Author 杜懿
 */
@Configuration
@EnableScheduling
public class ETHNoChainV2Task {

    @Autowired
    private ETHMapper ethMapper;

    @Autowired
    private RedisService redisService;

    /** Pi Cycle Top Indicator PI周期顶指标所有数据 */
    //@Scheduled(cron = "20 1 0/4 * * ?")
    @Scheduled(cron = "20 0/2 * * * ?")
    public void PiCycleTopIndicatorDataToRedis(){

        List<PiCycleTIDto> list = ethMapper.getPiCycleTIList();

        if(list.size()>0){
            //存入redis 先删除原有数据再重新插入数据
            redisService.deleteObject("ETHPiCTIList");
            redisService.setCacheList("ETHPiCTIList",list);
        }

    }

    /** Golden Ratio Multiplier 黄金比例乘数 所有数据 */
    //@Scheduled(cron = "20 1 0/4 * * ?")
    @Scheduled(cron = "20 0/2 * * * ?")
    public void GRMDataToRedis(){

        List<GoldenRatioMultiplierDto> list = ethMapper.getGoldenRatioMultiplier();

        if(list.size()>0){
            //存入redis 先删除原有数据再重新插入数据
            redisService.deleteObject("ETHGoldenRatioMultiplierList");
            redisService.setCacheList("ETHGoldenRatioMultiplierList",list);
        }

    }
}
