feat: 实现TCP Server
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace app\flow\nodes;
|
||||
|
||||
use app\flow\DbOperationType;
|
||||
use app\flow\ProcessContext;
|
||||
use app\flow\VoiceMessage;
|
||||
|
||||
/**
|
||||
* 漂洗节点
|
||||
* 处理漂洗步骤
|
||||
*/
|
||||
class RinseNode 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 === WashNode::getName()) {
|
||||
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_RINSE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 上一个步骤必须是清洗
|
||||
if (!$this->isRequiredNode($context->currentStep, [WashNode::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