package com.ruoyi.ucp;

import cn.hutool.core.date.DateUtil;
import com.ruoyi.ucp.entity.PointInfo;
import com.ruoyi.ucp.feign.AdapterApi;
import com.ruoyi.ucp.service.IPointInfoService;
import com.ruoyi.ucp.service.IStationInfoDayService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.util.List;

@SpringBootTest
class UcpAppTests {

    @Resource
    private AdapterApi adapter;
    @Resource
    private IPointInfoService pointService;

    @Test
    void contextLoads() {
        ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
        /*String k = "var point = \"NEM_SXJSFW.SX_XXXX_XXX_X_XX_XX_XXXX_FCC_CI134\";\n" +
                "var startTs = 1706166626000;\n" +
                "var endTs = 1706168006283;\n" +
                "var interval = 30;\n" +
                "var result = getHistorySnap(point, startTs, endTs, interval);";
        String s = "function getHistorySnap(point, startTs, endTs, interval) {\n" +
                "    var result = goldenAdapterApi.getHistorySnap(point, startTs, endTs, interval);\n" +
                "    return result;\n" +
                "}";*/
        try {
            /*List<PointData> historySnap = adapter.getHistorySnap(URI.create("http://127.0.0.1:8011/ts"),"NEM_SXJSFW.SX_XXXX_XXX_X_XX_XX_XXXX_FCC_CI134", 1706166626000L,
                    1706168006283L, 30);
            engine.put("adapter", adapter);
            //engine.put("mapper", mapper);
            engine.eval(s);
            engine.eval(k);
            Object eval = engine.eval("result");
            System.out.println();*/

            PointInfo info = new PointInfo();
            //info.setTableName("pro_basic_equipment_point");
            //info.setStationId("GJNY_SXGS_XZ_FDC_STA");
            info.setUniformCode("AQTS");
            List<PointInfo> entity = pointService.getByEntity(info);
            //List<LinkedHashMap<String, Object>> byInfo = mapper.getByInfo(info);
            System.out.println();
            DateUtil.offsetMinute(DateUtil.yesterday(), 3).getTime();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Resource
    private IStationInfoDayService stationInfoDayService;

    @Test
    public void test() {

    }
}
