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

import com.sw.mes.yb.mcs.dto.BlankConfigDto;
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;

import java.util.List;

/**
 * 分选口规格配置信息下发监听
 * @Author: GaoXinJian
 * @Date: 2022-02-08 14:29
 */
@Component
public class BlankConfigEventListener implements SmartApplicationListener {
    @Autowired
    YbMesToMcsService mesToMcsService;
    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> aClass) {
        return aClass==BlankConfigEvent.class;
    }

    @Override
    @Async
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        BlankConfigEvent blankConfigEvent=(BlankConfigEvent) applicationEvent;
        List<BlankConfigDto> blankConfigDtoList = blankConfigEvent.getBlankConfigDtoList();
        mesToMcsService.blankConfig(blankConfigDtoList);
    }
}
