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

import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseModuleService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IModuleService;
import cn.estsh.i3plus.pojo.mes.bean.MesStateMachineStatus;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description : 展示组件：非排序生产
 * @Author :wangjie
 **/
@Slf4j
@Service("mesProductionModuleService")
public class MesProductionModuleService extends BaseModuleService {

    @Autowired
    private IMesProductionProcessContextStepService productionProcessContextStepService;

    @Override
    public void init(StationRequestBean reqBean) {

        //排序线 装配件匹配工步
        if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == productionProcessContextStepService.getCenterType(reqBean)) ((IModuleService) SpringContextsUtil.getBean("mesProductionSortModuleService")).init(reqBean);

        //非排序线 装配件匹配工步
        else ((IModuleService) SpringContextsUtil.getBean("mesProductionNoSortModuleService")).init(reqBean);

    }

    @Override
    public boolean execStateModule(StationRequestBean reqBean, List<MesStateMachineStatus> states, Map<String, String> wcpcMap) {
        init(reqBean);
        return true;
    }

}
