package com.njcn;

import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.file.component.WavePicComponent;
import com.njcn.influx.imapper.DataFlickerMapper;
import com.njcn.influx.pojo.po.DataFlicker;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.utils.RedisUtil;
import lombok.SneakyThrows;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.io.FileInputStream;
import java.time.Instant;
import java.util.*;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2021年12月14日 12:55
 */
public class OssTest extends BaseJunitTest {

    @Autowired
    private FileStorageUtil fileStorageUtil;

    @Autowired
    private DataFlickerMapper dataFlickerMapper;

    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private WavePicComponent component;

    @Autowired
    private DrawPicUtil drawPicUtil;

    @SneakyThrows
    @Test
    public void dadada() {
        List<List<Object>> values=new ArrayList<>();
        List<Object> a = new ArrayList() {{
            add("2023-10-10 00:10:00");
            add(12.3);
        }};
        values.add(a);
        List<Object> a1 = new ArrayList() {{
            add("2023-10-10 00:20:00");
            add(22.3);
        }};
        values.add(a1);
        List<Object> a2 = new ArrayList() {{
            add("2023-10-10 00:30:00");
            add(32.3);
        }};
        values.add(a2);

        List<List<Object>> limit=new ArrayList<>();
        List<Object> b = new ArrayList() {{
            add("2023-10-10 00:10:00");
            add(40);
        }};
        limit.add(b);
        List<Object> b1 = new ArrayList() {{
            add("2023-10-10 00:20:00");
            add(40);
        }};
        limit.add(b1);
        List<Object> b2 = new ArrayList() {{
            add("2023-10-10 00:30:00");
            add(40);
        }};
        limit.add(b2);
        Map<String,List<List<Object>>> da = new HashMap<>();
        da.put("实际", new ArrayList<>());
//        String s = component.generateSteadyTargetImage("电压", da, "限制", limit);
        String s = drawPicUtil.drawSteadyTargetPic("电压", da, "限制", limit);
        System.out.println();
    }

    @SneakyThrows
    @Test
    public void dada() {

        String dada = redisUtil.getStringByKey( "11");
        String adada = redisUtil.getStringByKey(5, "11");
        String dadaada = redisUtil.getStringByKey( "11");

        System.out.println();
    }

    @SneakyThrows
    @Test
    public void test() {
        File file = new File("C:\\Users\\DELL\\Desktop\\6FEC92B75A104D1295715A661A2CC196.docx");
        String s = fileStorageUtil.uploadStream(new FileInputStream(file), OssPath.ALGORITHM, UUID.randomUUID() + ".docx");
        System.out.println("hello");

    }

    @SneakyThrows
    @Test
    public void testInflux() {
        List<DataFlicker> dataFlickers = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            DataFlicker dataFlicker = new DataFlicker();
            dataFlicker.setTime(Instant.now());
            dataFlicker.setFluc(12.5);
            dataFlicker.setLineId("123456");
            dataFlicker.setPhaseType("C");
            dataFlicker.setPlt(12.5);
            dataFlicker.setPst(12.5);
            dataFlicker.setQualityFlag("0");
            Thread.sleep(1000);
            dataFlickers.add(dataFlicker);
        }
        dataFlickerMapper.insertBatch(dataFlickers);
    }


}
