feat: 实现TCP Server

This commit is contained in:
zimoyin
2026-03-02 21:59:43 +08:00
parent 043306819b
commit a79dfae57d
144 changed files with 15785 additions and 140 deletions
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace app\flow\nodes;
use app\flow\DbOperationType;
use app\flow\ProcessContext;
use app\flow\VoiceMessage;
use app\utils\Logger;
/**
* 晨洗节点(虚拟读卡器)
* 处理晨洗流程的开始
*/
class MorningWashNode extends AbstractProcessNode
{
/**
* 获取节点名称
*/
public static function getName(): string
{
return "晨洗";
}
/**
* 获取节点编码
*/
public function getCode(): string
{
return self::getName();
}
/**
* 判断当前节点是否能处理该步骤
*/
public function canHandle(ProcessContext $context): bool
{
// 只有需要晨洗且未完成晨洗时才处理
if (!$context->needMorningWash || $context->morningWashed) {
return false;
}
// 检查当前读卡器类型是否匹配
if (!$this->isRequiredNode($context->readerType, ['漂洗', '机洗'])){
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_MORNING_WASH;
return false;
}
return true;
}
/**
* 具体处理逻辑
*/
protected function doHandle(ProcessContext $context): ProcessContext
{
Logger::debug("处理晨洗节点");
// 标记晨洗已开始
$context->morningWashed = true;
// 设置流程类型
if ($context->readerType === '机洗') {
$context->processType = '机洗(晨洗)';
} else {
$context->processType = '手工洗(晨洗)';
}
// 更新当前步骤
$context->currentStep = self::getName();
$context->needDatabaseOperation = true;
$context->dbOperation = DbOperationType::INSERT;
$context->needWebSocketNotify = true;
return $context;
}
}