feat: 实现TCP Server
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace app\flow\nodes;
|
||||
|
||||
use app\flow\DbOperationType;
|
||||
use app\flow\ProcessContext;
|
||||
use app\flow\VoiceMessage;
|
||||
|
||||
/**
|
||||
* 结束节点
|
||||
* 处理流程结束步骤
|
||||
*/
|
||||
class EndNode extends AbstractProcessNode
|
||||
{
|
||||
/**
|
||||
* 获取节点名称
|
||||
*/
|
||||
public static function getName(): string
|
||||
{
|
||||
return '结束';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点编码
|
||||
*/
|
||||
public function getCode(): string
|
||||
{
|
||||
return '结束';
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前节点是否能处理该步骤
|
||||
*/
|
||||
public function canHandle(ProcessContext $context): bool
|
||||
{
|
||||
if (!$this->isMatchReaderType($context)) {
|
||||
if ($context->currentStep === DryNode::getName() && $context->currentStep === FinalRinseNode::getName()) {
|
||||
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_END;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 上一个步骤必须是干燥、终末漂洗或机洗
|
||||
$validSteps = ['干燥', '终末漂洗', '机洗'];
|
||||
if ($this->isRequiredNode($context->currentStep, ['干燥', '终末漂洗', '机洗'])) {
|
||||
if ($context->currentStep === FinalRinseNode::getName()) {
|
||||
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_WASH;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 具体处理逻辑
|
||||
*/
|
||||
protected function doHandle(ProcessContext $context): ProcessContext
|
||||
{
|
||||
// 更新步骤
|
||||
$context->currentStep = '结束';
|
||||
|
||||
$context->needDatabaseOperation = true;
|
||||
$context->dbOperation = DbOperationType::INSERT;
|
||||
$context->needWebSocketNotify = true;
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user