package com.bootdo.common.task;

import com.bootdo.common.utils.MD5;
import com.bootdo.system.domain.SearchDO;
import com.bootdo.system.service.SearchService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

@Component
public class Job implements org.quartz.Job {

    @Autowired
    private SearchService searchService;

    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        // 设备名称
        String deviceName = "冰箱";
        // mac地址
        String mac = "90:C0:0E:17:16:EH";
        // 序列号
        String Sn = "232313";

        String uniqe = MD5.getMd5String(deviceName + mac + Sn);

        String uniqeInfo = "732F309B61316A70DAE435095885EEFD";
        System.out.println("uniqe：" + uniqe + ",uniqeInfo:" + uniqeInfo);
        System.out.println("测试");

        SearchDO search = new SearchDO();
        search.setDeviceName(deviceName);
        search.setDeviceMac(mac);
        search.setDeviceSn(Sn);
        search.setLoadUniqe(uniqeInfo);
        search.setNewUniqe(uniqe);
        if(uniqeInfo.equals(uniqe)){
            search.setResult("success");
        }else{
            search.setResult("fail");
        }

        searchService.save(search);
    }

}