package com.chinaztt.mes.plan.state.masterproductionschedule; import com.chinaztt.mes.plan.entity.MasterProductionSchedule; import com.chinaztt.mes.plan.entity.OperationTaskProduce; import com.chinaztt.mes.plan.mapper.MasterProductionScheduleMapper; import com.chinaztt.mes.plan.mapper.OperationTaskProduceMapper; import com.chinaztt.mes.plan.state.masterproductionschedule.constant.MasterProductionScheduleEvents; import com.chinaztt.mes.plan.state.masterproductionschedule.constant.MasterProductionScheduleStateStringValues; import lombok.AllArgsConstructor; import org.springframework.messaging.Message; import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.annotation.OnTransition; import org.springframework.statemachine.annotation.WithStateMachine; import org.springframework.stereotype.Component; /** * @author ZTT */ @AllArgsConstructor @Component @WithStateMachine(id = "masterproductionscheduleStateMachine") public class MasterProductionScheduleStateListener { private MasterProductionScheduleMapper masterProductionScheduleMapper; /** * 待处理 */ @OnTransition(target = MasterProductionScheduleStateStringValues.PENDING) public boolean pending(StateMachine stateMachine, Message msg) { MasterProductionSchedule masterProductionSchedule = (MasterProductionSchedule) msg.getHeaders().get("masterProductionSchedule"); masterProductionSchedule.setState(MasterProductionScheduleStateStringValues.PENDING); masterProductionScheduleMapper.updateById(masterProductionSchedule); return true; } /** * 已处理 */ @OnTransition(target = MasterProductionScheduleStateStringValues.PROCESSED) public boolean pend(StateMachine stateMachine, Message msg) { MasterProductionSchedule masterProductionSchedule = (MasterProductionSchedule) msg.getHeaders().get("masterProductionSchedule"); masterProductionSchedule.setState(MasterProductionScheduleStateStringValues.PROCESSED); masterProductionScheduleMapper.updateById(masterProductionSchedule); return true; } /** * 取消,作废 */ @OnTransition(target = MasterProductionScheduleStateStringValues.CANCELED) public boolean cancal(StateMachine stateMachine, Message msg) { MasterProductionSchedule masterProductionSchedule = (MasterProductionSchedule) msg.getHeaders().get("masterProductionSchedule"); masterProductionSchedule.setState(MasterProductionScheduleStateStringValues.CANCELED); masterProductionScheduleMapper.updateById(masterProductionSchedule); return true; } }