package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.actor;

import akka.actor.AbstractActor;
import akka.actor.UntypedAbstractActor;
import akka.japi.pf.ReceiveBuilder;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentLogService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.ActorMessage;
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.FsmRouteDataService;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype")
public class MesHandlerEquipLogActor extends AbstractActor {
    //定义日志，很重要
    private static final Logger log = LoggerFactory.getLogger(MesHandlerEquipLogActor.class);

    @Autowired
    private IMesEquipmentLogService mesEquipmentLogService;
    /**
     * <p>重写接收方法</p>
     * @author hanchao 2018/4/16 21:31
     **/
    @Override
    public Receive createReceive() {

        return ReceiveBuilder.create().match(ActorMessage.class, o -> {

            mesEquipmentLogService.saveEquipmentLogToRedis(o);

        }).matchAny(o -> log.error("FiniteStateMachineActor--收到的意外的消息{}", o)).build();
    }
}
