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

import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
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;

/**
 * @Description : 保存加工单信息工步
 * @Reference :
 * @Author : wangjie
 * @CreateDate : 2024/6/11 18:50
 * @Modify:
 **/
@Slf4j
@Service("mesWorkOrderSaveStepService")
public class MesWorkOrderSaveStepService extends BaseStepService {

    @Autowired
    private IMesProductionProcessContextStepService productionProcessContextStepService;

    @Override
    public StepResult execute(StationRequestBean reqBean) {

        //排序线 保存加工单信息工步
        if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == productionProcessContextStepService.getCenterType(reqBean)) return ((IStepService) SpringContextsUtil.getBean("mesWorkOrderSaveSortStepService")).executeInState(reqBean);

        //非排序线 保存加工单信息工步
        return ((IStepService) SpringContextsUtil.getBean("mesWorkOrderSaveNosortStepService")).executeInState(reqBean);

    }

}
