package com.huimv.environ.eco;

import com.huimv.environ.eco.schedule.ScheduleTask;
import com.huimv.environ.eco.service.EcoDryListService;
import com.huimv.environ.env.utils.DateUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import sun.dc.pr.PRError;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

/**
 * @Project : huimv-farm-datacenter
 * @Package : ${}
 * @Description : TODO
 * @Version : 1.0
 * @Author : ZhuoNing
 * @Create : 2022/11/9
 **/
@SpringBootTest
public class TaskTest {
    @Autowired
    private ScheduleTask test;
    @Autowired
    private EcoDryListService ecoDryListService;
    @Autowired
    private DateUtil dateUtil;

//    @Test
//    public void testDevice() throws ParseException {
//        test.getDeviceFlow();
//    }

    @Test
    public void testCompareTemp(){
        String temp = "38.1";
        temp = "25.7";
        String temp1 = "25.6";
        String temp2 = "45.5";
        System.out.println("temp="+temp);
        if(Float.parseFloat(temp) > Float.parseFloat(temp1) && Float.parseFloat(temp)<Float.parseFloat(temp2)){
            System.out.println("烘干温度未达到烘干温度阈值");
        }else if(Float.parseFloat(temp)>=Float.parseFloat(temp2)){
            System.out.println("烘干温度已达到烘干温度阈值");
        }else{
            System.out.println("当前温度小于常温阈值");
        }
    }

    @Test
    public void testSendDryTempAlarm(){
        String alarmInfo = "2022-11-12,当前温度[40]未达到烘干阈值温度[50]";
        String farmId ="331023001";
        String todayTime = "2022-11-12 19:35:52";
        ecoDryListService.sendLowDryTempAlarm(alarmInfo,farmId,todayTime,todayTime);
    }

    @Test
    public void testAdd() throws ParseException {
        DateUtil dateUtil = new DateUtil();
        String addTime = "2022-11-13 11:36:08";
        System.out.println("newDate -10 ="+dateUtil.formatDateTime(dateUtil.getDateBeforeMinute(addTime,10)));
        System.out.println("newDate +10 ="+dateUtil.formatDateTime(dateUtil.getDateAfterMinute(addTime,10)));
    }
}
