package com.jxy.marketall.task;

import com.jxy.common.core.utils.DateUtils;
import com.jxy.common.core.utils.StringUtils;
import com.jxy.common.redis.service.RedisService;
import com.jxy.marketall.dto.DateBigDecimalDto;
import com.jxy.marketall.dto.DateBigDecimalsDto;
import com.jxy.marketall.dto.MempoolTransactionDto;
import com.jxy.marketall.dto.RelativeSupplyDto;
import com.jxy.marketall.mapper.BTCV2Mapper;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
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.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;


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

    @Autowired
    private BTCV2Mapper btcv2Mapper;

    @Autowired
    private RedisService redisService;

    /** ProfitAddress所有数据 */
    //@Scheduled(cron = "0 23 0/1 * * ?").
    @Scheduled(cron = "0 0/1 * * * ?")
    public void ProfitAddressDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getProfitAddressList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "profit_addresses");
        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** LossAddress所有数据 */
    //@Scheduled(cron = "0 23 0/1 * * ?")
    @Scheduled(cron = "0 0/2 * * * ?")
    public void LossAddressDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getLossAddressList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "loss_addresses");

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** ProfitRatio所有数据 */
    //@Scheduled(cron = "0 23 0/1 * * ?")
    @Scheduled(cron = "0 0/2  * * * ?")
    public void ProfitRatioDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getProfitRatioList();
        List<DateBigDecimalsDto> tempList = btcv2Mapper.getProfitAndLoss();
        List<DateBigDecimalDto> list = tempList.stream().map(e -> {
            DateBigDecimalDto dto = new DateBigDecimalDto();
            dto.setDate(e.getDate());
            BigDecimal total = e.getValue1().add(e.getValue2());
            if (total.compareTo(BigDecimal.ZERO) == 0){
                dto.setValue(BigDecimal.ZERO);
            }else {
                dto.setValue(e.getValue1().divide(total,8,BigDecimal.ROUND_HALF_UP));
            }
            return dto;
        }).collect(Collectors.toList());

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** LthSupply所有数据 */
    @Scheduled(cron = "0 23 * * * ?")
    public void LthSupplyDataToRedis(){

        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "lth_supply");

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** SthSupply所有数据 */
    @Scheduled(cron = "0 24 * * * ?")
    public void SthSupplyDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getSthSupplyList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "sth_supply");

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** RealizedPrice所有数据 */
    @Scheduled(cron = "0 24 * * * ?")
    public void RealizedPriceDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getRealizedPriceList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "realized_price");

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** RelativeSupply 所有数据 */
    @Scheduled(cron = "0 24 0/1 * * ?")
    public void RelativeSupplyDataToRedis(){

        List<DateBigDecimalDto> list = btcv2Mapper.getRelativeSupplyList();
        //List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "relative_lth_sth");

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        list = tempAddUtxosData(list);

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

    }

    /** LthSthSupplyDistribution 所有数据 */
    @Scheduled(cron = "0 24 0/1 * * ?")
    public void LthSthSupplyDistributionDataToRedis(){

        List<RelativeSupplyDto> list = btcv2Mapper.getLthSthSupplyDistributionList();
        //过滤掉2018-10-01之前的数据
        Date start = DateUtils.parseDate("2018-10-01");
        list = list.stream().filter(dto -> (dto.getDate().after(start) || dto.getDate().equals(start))).collect(Collectors.toList());

        //List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "relative_lth_sth");

        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        RelativeSupplyDto dto1 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2018-10-21"))).findFirst().get(),dto1);
        dto1.setDate(DateUtils.parseDate("2018-10-22 00:00:00"));

        RelativeSupplyDto dto2 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2018-12-23"))).findFirst().get(),dto2);
        dto2.setDate(DateUtils.parseDate("2018-12-24 00:00:00"));

        RelativeSupplyDto dto3 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2018-12-30"))).findFirst().get(),dto3);
        dto3.setDate(DateUtils.parseDate("2018-12-31 00:00:00"));

        RelativeSupplyDto dto4 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2020-02-02"))).findFirst().get(),dto4);
        dto4.setDate(DateUtils.parseDate("2020-02-03 00:00:00"));

        RelativeSupplyDto dto5 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2021-10-25"))).findFirst().get(),dto5);
        dto5.setDate(DateUtils.parseDate("2021-10-26 00:00:00"));

        RelativeSupplyDto dto6 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2022-04-24"))).findFirst().get(),dto6);
        dto6.setDate(DateUtils.parseDate("2022-04-25 00:00:00"));

        RelativeSupplyDto dto7 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2023-02-04"))).findFirst().get(),dto7);
        dto7.setDate(DateUtils.parseDate("2023-02-05 00:00:00"));

        RelativeSupplyDto dto8 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2023-05-09"))).findFirst().get(),dto8);
        dto8.setDate(DateUtils.parseDate("2023-05-10 00:00:00"));

        RelativeSupplyDto dto9 = new RelativeSupplyDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2023-05-09"))).findFirst().get(),dto9);
        dto9.setDate(DateUtils.parseDate("2023-05-11 00:00:00"));

        list.add(dto1);
        list.add(dto2);
        list.add(dto3);
        list.add(dto4);
        list.add(dto5);
        list.add(dto6);
        list.add(dto7);
        list.add(dto8);
        list.add(dto9);

        //根据时间去重排序
        list = list.stream()
                .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(RelativeSupplyDto::getDate))),ArrayList::new));


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

    }

    /** LthProfitSupply所有数据 */
    @Scheduled(cron = "0 24 0/1 * * ?")
    public void LthProfitSupplyDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getLthProfitSupplyList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "lth_profit_supply");

        list = tempAddUtxosData(list);

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

    }

    /** SthProfitSupply所有数据 */
    @Scheduled(cron = "0 25 0/1 * * ?")
    public void SthProfitSupplyDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getSthProfitSupplyList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "sth_profit_supply");

        list = tempAddUtxosData(list);

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

    }

    /** LthLossSupply所有数据 */
    @Scheduled(cron = "0 25 0/1 * * ?")
    public void LthLossSupplyDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getLthLossSupplyList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "lth_loss_supply");

        list = tempAddUtxosData(list);

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

    }

    /** SthLossSupply所有数据 */
    @Scheduled(cron = "0 25 0/1 * * ?")
    public void SthLossSupplyDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getSthLossSupplyList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "sth_loss_supply");

        list = tempAddUtxosData(list);

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

    }

    /** LthProfitRatio所有数据 */
    @Scheduled(cron = "0 26 0/1 * * ?")
    public void LthProfitRatioDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getLthProfitRatioList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "lth_profit_ratio");

        list = tempAddUtxosData(list);

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

    }

    /** SthProfitRatio所有数据 */
    @Scheduled(cron = "0 26 0/1 * * ?")
    public void SthProfitRatioDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getSthProfitRatioList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "sth_profit_ratio");

        list = tempAddUtxosData(list);

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

    }

    /** SLRVRatio所有数据 */
    @Scheduled(cron = "0 26 0/1 * * ?")
    public void SLRVRatioDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getSLRVRatioList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("utxosv4", "slrv_ratio");

        list = tempAddUtxosData(list);

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

    }

    /** LthVolume所有数据 */
    @Scheduled(cron = "0 26 0/1 * * ?")
    public void LthVolumeDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getLthVolumeList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("dailyindsv3e2", "lth_volume");

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

    }

    /** Fee Ratio Multiple (FRM)所有数据 */
    @Scheduled(cron = "0 27 0/1 * * ?")
    public void FRMDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getFeeRatioMultipleList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("dailyindsv3e2", "frm");
        Date start = DateUtils.parseDate("2015-01-01");
        list = list.stream().filter(dto -> (dto.getDate().after(start) || dto.getDate().equals(start))).collect(Collectors.toList());

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

    }

    /** Cumulative Value-Days Destroyed (CVDD)所有数据 */
    @Scheduled(cron = "0 27 0/1 * * ?")
    public void CVDDDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getCVDDList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("dailyindsv3e2", "cvdd");

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

    }

    /** Balanced Price所有数据 */
    @Scheduled(cron = "0 27 0/1 * * ?")
    public void BalancedPriceDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getBalancedPriceList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("dailyindsv3e2", "balanced_price");

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

    }

    /** NVT Ratio所有数据 */
    @Scheduled(cron = "0 27 0/1 * * ?")
    public void NVTRatioDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getNVTRatioList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("dailyindsv3e2", "nvt_ratio");

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

    }

    /** NVT Sign所有数据 */
    //@Scheduled(cron = "0 27 0/1 * * ?")
    @Scheduled(cron = "0 0/1 * * * ?")
    public void NVTSignDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getNVTRatioList();
        List<DateBigDecimalsDto> tempList = btcv2Mapper.getNVTRatioAndVolume();
        //移动平均天数设置为90
        int day = 90;
        if(tempList.size() > day){
            /***    start        对nvtRatio做90天移动平均                 ***/
            BigDecimal total = BigDecimal.ZERO;

            BigDecimal divideNumber = new BigDecimal(day);
            for(int i = 0 ; i < 90 ;i++){
                total =  tempList.get(i).getValue1().add(total);
            }
            BigDecimal startY = total.divide(divideNumber, 8, BigDecimal.ROUND_HALF_UP);
            DateBigDecimalsDto startDto = new DateBigDecimalsDto();
            startDto.setDate(tempList.get(day-1).getDate());
            startDto.setValue1(startY.stripTrailingZeros());
            if(StringUtils.isNotNull(tempList.get(day-1).getValue2())){
                startDto.setValue2(tempList.get(day-1).getValue2());
            }else {
                startDto.setValue2(BigDecimal.ZERO);
            }


            List<DateBigDecimalsDto> newList = new ArrayList<>();
            newList.add(startDto);
            for (int i = day; i < tempList.size(); i++) {

                total = total.add(tempList.get(i).getValue1()).subtract(tempList.get(i-day).getValue1());

                startY = total.divide(divideNumber,8, BigDecimal.ROUND_HALF_UP);

                DateBigDecimalsDto dto = new DateBigDecimalsDto();
                dto.setDate(tempList.get(i).getDate());
                //返回给前端的参数需要删除多余的0
                dto.setValue1(startY.stripTrailingZeros());
                dto.setValue2(tempList.get(i).getValue2());
                if(StringUtils.isNotNull(tempList.get(i).getValue2())){
                    dto.setValue2(tempList.get(i).getValue2());
                }else {
                    dto.setValue2(BigDecimal.ZERO);
                }

                newList.add(dto);
            }

            /***    end        对nvtRatio做90天移动平均                 ***/

            List<DateBigDecimalDto> list = newList.stream().map(e -> {
                DateBigDecimalDto dto = new DateBigDecimalDto();
                dto.setDate(e.getDate());
                BigDecimal volume = e.getValue2();
                if (BigDecimal.ZERO.compareTo(volume) == 0){
                    dto.setValue(BigDecimal.ZERO);
                }else {
                    dto.setValue(e.getValue1().divide(volume,8,BigDecimal.ROUND_HALF_UP));
                }
                return dto;
            }).collect(Collectors.toList());

            //过滤掉2015之前过大的数据
            Date start = DateUtils.parseDate("2015-01-01");
            list = list.stream().filter(dto -> (dto.getDate().after(start) || dto.getDate().equals(start))).collect(Collectors.toList());

            if(list.size()>0){
                //存入redis 先删除原有数据再重新插入数据
                redisService.deleteObject("NVTSignList");
                redisService.setCacheList("NVTSignList",list);
            }
        }else {
            System.out.println("数据条数不足");
        }



    }


    /** Velocity所有数据 */
    @Scheduled(cron = "0 28 0/1 * * ?")
    public void VelocityDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getVelocityList();
        List<DateBigDecimalDto> list = btcv2Mapper.getListByTableAndField("dailyindsv3e2", "velocity");

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

    }

    /** Mempool待交易量和待交易费用所有数据 */
    @Scheduled(cron = "0 0/5 * * * ?")
    public void MempoolSizeDataToRedis(){

        //List<DateBigDecimalDto> list = btcv2Mapper.getVelocityList();
        List<MempoolTransactionDto> list = btcv2Mapper.getMempoolTransation();
        Collections.reverse(list);

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

    }

    public List<DateBigDecimalDto> tempAddUtxosData(List<DateBigDecimalDto> list){

        Date start = DateUtils.parseDate("2018-10-01");
        list = list.stream().filter(dto -> (dto.getDate().after(start) || dto.getDate().equals(start))).collect(Collectors.toList());
        //临时处理 补充缺失数据 同时去重 防止数据补充后产生重复数据
        //补充操作 拿前一天数据
        DateBigDecimalDto dto1 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2018-10-21"))).findFirst().get(),dto1);
        dto1.setDate(DateUtils.parseDate("2018-10-22 00:00:00"));

        DateBigDecimalDto dto2 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2018-12-23"))).findFirst().get(),dto2);
        dto2.setDate(DateUtils.parseDate("2018-12-24 00:00:00"));

        DateBigDecimalDto dto3 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2018-12-30"))).findFirst().get(),dto3);
        dto3.setDate(DateUtils.parseDate("2018-12-31 00:00:00"));

        DateBigDecimalDto dto4 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2020-02-02"))).findFirst().get(),dto4);
        dto4.setDate(DateUtils.parseDate("2020-02-03 00:00:00"));

        DateBigDecimalDto dto5 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2021-10-25"))).findFirst().get(),dto5);
        dto5.setDate(DateUtils.parseDate("2021-10-26 00:00:00"));

        DateBigDecimalDto dto6 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2022-04-24"))).findFirst().get(),dto6);
        dto6.setDate(DateUtils.parseDate("2022-04-25 00:00:00"));

        DateBigDecimalDto dto7 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2023-02-04"))).findFirst().get(),dto7);
        dto7.setDate(DateUtils.parseDate("2023-02-05 00:00:00"));

        DateBigDecimalDto dto8 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2023-05-09"))).findFirst().get(),dto8);
        dto8.setDate(DateUtils.parseDate("2023-05-10 00:00:00"));

        DateBigDecimalDto dto9 = new DateBigDecimalDto();
        BeanUtils.copyProperties(list.stream().filter(e -> DateUtils.isSameDay(e.getDate(),DateUtils.parseDate("2023-05-09"))).findFirst().get(),dto9);
        dto9.setDate(DateUtils.parseDate("2023-05-11 00:00:00"));

        list.add(dto1);
        list.add(dto2);
        list.add(dto3);
        list.add(dto4);
        list.add(dto5);
        list.add(dto6);
        list.add(dto7);
        list.add(dto8);
        list.add(dto9);

        //根据时间去重排序
        list = list.stream()
                .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(DateBigDecimalDto::getDate))),ArrayList::new));

        return list;
    }

}
