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

import com.sw.mes.yb.mcs.dto.SpellBindingDto;
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-02-08 17:07
 */
@Component
public class SpellBindingEventListener implements SmartApplicationListener {
    @Autowired
    YbMesToMcsService mesToMcsService;
    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> aClass) {
        return aClass==SpellBindingEvent.class;
    }

    @Override
    @Async
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        SpellBindingEvent spellBindingEvent=(SpellBindingEvent) applicationEvent;
        SpellBindingDto spellBindingDto=spellBindingEvent.getSpellBindingDto();
        mesToMcsService.spellBinding(spellBindingDto);
    }
}
