package com.sw.mes.mcs.enent;

import com.sw.mes.mcs.dto.SquareBindingDto;
import com.sw.mes.mcs.service.MesToMcsService;
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 14:29
 */
@Component
public class SquareBindingEventListener implements SmartApplicationListener {
    @Autowired
    MesToMcsService mesToMcsService;
    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> aClass) {
        return aClass== SquareBindingEvent.class;
    }

    @Override
    @Async
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        SquareBindingEvent squareBindingEvent=(SquareBindingEvent) applicationEvent;
        SquareBindingDto squareBindingDto = squareBindingEvent.getSquareBindingDto();
        mesToMcsService.squareBinding(squareBindingDto);
    }
}
