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.FaultKnowledgeController;
import com.gyee.frame.model.auto.P3DeviceFault;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.StringUtils;
import lombok.SneakyThrows;
import org.springframework.boot.SpringApplication;

public class FaultKnowledgeTest {

    @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 name="故障";
        String halttype="fff";
        String faultlevel="3";

        FaultKnowledgeController faultKnowledgeController= SpringUtils.getBean("faultKnowledgeController");

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


        P3DeviceFault po=new P3DeviceFault();

        po.setId(StringUtils.getUUID());
        po.setHalttype("ccc");
        po.setFaultlevel(3);
        po.setDevicemodel("aaa");
        po.setHalttype("bbb");

        faultKnowledgeController.insertFaultknowledge(po);


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

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

        if(StringUtils.notEmp(po2))
        {
            po2.setHalttype("ddd");
            po2.setFaultlevel(6);
            po2.setDevicemodel("eee");
            po2.setHalttype("fff");

            faultKnowledgeController.updateFaultknowledge(po2);
        }
        AjaxResult ar = faultKnowledgeController.faultknowledgeList(tablepar,null,halttype,null);

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


        for(P3DeviceFault wtd:vos.getList())
        {
            System.out.println(wtd.getName()+"----------------"+wtd.getHalttype()
                   +"----------------"+wtd.getFaultlevel()+"----------------"+wtd.getDevicemodel());
        }


        faultKnowledgeController.deleteFaultknowledge(po2.getId());

    }
}
