package test;

import com.github.pagehelper.PageInfo;
import com.gyee.SpringbootStart;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.common.spring.SpringUtils;
import com.gyee.frame.controller.health.EarlyWarnKnowledgeController;
import com.gyee.frame.model.auto.Alertrule2;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.StringUtils;
import lombok.SneakyThrows;
import org.springframework.boot.SpringApplication;

public class EarlyWarnKnowledgeTest {

    @SneakyThrows
    public static void main(String[] args) {

        SpringApplication.run(SpringbootStart.class, args);



        String wtId="MG01_03";
        String wpId="MHS_FDC";
        String year="2021";
        String month="1";
        String category="bbb";
        String name="故障";

        String expression="";
        Integer enabled=0;


        EarlyWarnKnowledgeController earlyWarnKnowledgeController= SpringUtils.getBean("earlyWarnKnowledgeController");

        Tablepar tablepar=new Tablepar();
        tablepar.setPageNum(1);
        tablepar.setPageSize(10);
        tablepar.setOrderByColumn("name");
        tablepar.setIsAsc("asc");


        Alertrule2 po=new Alertrule2();

        po.setId(StringUtils.getUUID());
        po.setCategory("ccc");
        po.setRank("3");
        po.setName("test1");
        po.setExpression("111");
        po.setEnabled(0);


        earlyWarnKnowledgeController.insertFaultknowledge(po);


        AjaxResult result=earlyWarnKnowledgeController.findFaultknowledge(po.getId());

        Alertrule2 po2=(Alertrule2)result.get("data");

        if(StringUtils.notEmp(po2))
        {
            po.setCategory("bbb");
            po.setRank("6");
            po.setName("test2");
            po.setExpression("222");
            po.setEnabled(1);
            earlyWarnKnowledgeController.updateFaultknowledge(po2);
        }
        AjaxResult ar = earlyWarnKnowledgeController.earlyWarnKnowledgeList(tablepar,null,category,null);

        PageInfo<Alertrule2> vos=(PageInfo<Alertrule2>)ar.get("data");


        for(Alertrule2 wtd:vos.getList())
        {
            System.out.println(wtd.getName()+"----------------"+wtd.getCategory()
                   +"----------------"+wtd.getRank()+"----------------"+wtd.getExpression()+"----------------"+wtd.getEnabled());
        }


        earlyWarnKnowledgeController.deleteFaultknowledge(po2.getId());

    }
}
