package com.jiayue.ipfcst.console.service;

import com.alibaba.fastjson.JSON;
import com.jiayue.ipfcst.BaseTest;
import com.jiayue.ipfcst.common.data.entity.WindTowerStatusData;
import com.jiayue.ipfcst.dataexchange.service.EnvironmentDataAnyTimeGenerator;
import com.jiayue.ipfcst.dataexchange.service.EnvironmentDataGenerator;
import com.jiayue.ipfcst.dataexchange.service.equipmentstatusdata.WindTowerStatusDataService;
import org.joda.time.DateTime;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import javax.xml.crypto.Data;

/**
 * da
 *
 * @author: xiuwei
 * @version:
 */
public class TestEnvironmentGenerator extends BaseTest {

  @Autowired
  EnvironmentDataGenerator environmentDataGenerator;


  @Autowired
  EnvironmentDataAnyTimeGenerator environmentDataAnyTimeGenerator;
  @Autowired
  WindTowerStatusDataService windTowerStatusDataService;

  @Test
  public void tt() throws InterruptedException {
    DateTime dateTime=DateTime.now().minusDays(1).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
    for (; ; ) {
      WindTowerStatusData f = environmentDataAnyTimeGenerator.getWindTowerDataGenerator(1).generateWindTowerData(dateTime);
      System.out.println(f.iToString());
      System.out.println(f.getTime());
      new Thread(()->windTowerStatusDataService.save(f)).run();
      Thread.sleep(60L);
      dateTime=dateTime.plusMinutes(1);
    }

  }


  @Test
  public void tt1() throws InterruptedException {
    DateTime d = DateTime.now().minusDays(1).withSecondOfMinute(0).withMinuteOfHour(0).withHourOfDay(0);
    for (; ; ) {
      WindTowerStatusData f = environmentDataAnyTimeGenerator.getWindTowerDataGenerator(8).generateWindTowerData(d);
      System.out.println(d+":\r\n"+f.iToString());
      System.out.println(DateTime.now());
      new Thread(()->windTowerStatusDataService.save(f)).run();
      Thread.sleep(100L);
      d=d.plusMinutes(1);
    }

  }

}
