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

import com.sw.mes.yb.mcs.dto.OrderConfigDto;
import com.sw.mes.yb.mcs.service.YbMesToMcsService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 订单水位信息下发事件监听
 * @Author: GaoXinJian
 * @Date: 2022-02-07 18:17
 */
@Log4j2
@Component
public class OrderConfigEventListener implements SmartApplicationListener {
    @Autowired
    YbMesToMcsService mesToMcsService;
    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
        return eventType == OrderConfigEvent.class;
    }
    @Override
    public boolean supportsSourceType(Class<?> sourceType) {
        return true;
    }
    @Override
    public int getOrder() {
        return 0;
    }
    @Override
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        OrderConfigEvent orderConfigEvent=(OrderConfigEvent) applicationEvent;
        List<OrderConfigDto> orderConfigDtoList=orderConfigEvent.getOrderConfigDtoList();
        mesToMcsService.orderConfig(orderConfigDtoList);
    }
}
