package com.sw.mes.yb.mcs.event;

import com.sw.mes.yb.mcs.dto.CrystalTrayBindInfoDto;
import com.sw.mes.yb.mcs.service.YbMesToMcsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 圆棒托盘绑定接口监听
 * @Author: GaoXinJian
 * @Date: 2022-01-18 16:46
 */
@Component
public class CrystalTrayBindInfoEventListener implements SmartApplicationListener {
    @Autowired
    YbMesToMcsService ybMesToMcsService;
    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> aClass) {
        return aClass== CrystalTrayBindInfoEvent.class;
    }

    @Override
    @Async
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
    CrystalTrayBindInfoEvent crystalTrayBindInfoEvent =(CrystalTrayBindInfoEvent) applicationEvent;
        CrystalTrayBindInfoDto bindingInfoDto = crystalTrayBindInfoEvent.getBindingInfoDto();
        ybMesToMcsService.crystalTrayBindInfo(bindingInfoDto);
    }
}
