Files
tcpserver-flow/app/flow/nodes/MachineWashNode.php
T
2026-03-08 22:58:56 +08:00

82 lines
2.2 KiB
PHP

<?php
namespace app\flow\nodes;
use app\flow\DbOperationType;
use app\flow\ProcessContext;
use app\flow\VoiceMessage;
/**
* 机洗节点
* 处理机器清洗步骤,可插入到手工流程中
*/
class MachineWashNode 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_MACHINE_WASH;
}
return false;
}
// 需要晨洗但未完成:提示先进行晨洗
if ($context->needMorningWash && !$context->morningWashed) {
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_MORNING_WASH;
return false;
}
// 机洗可以在多个步骤后执行:空步骤(新流程)、结束、内镜取出、清洗,晨洗
if (!$this->isRequiredNode($context->currentStep, ['', '结束', '内镜取出', '清洗', MachineWashNode::getName()])) {
if ($context->currentStep === EndNode::getName()) $context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_MACHINE_WASH;
else $context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_END;
return false;
}
return true;
}
/**
* 具体处理逻辑
*/
protected function doHandle(ProcessContext $context): ProcessContext
{
// 设置流程类型为机洗
$context->processType = '机洗';
// 更新步骤
$context->currentStep = '机洗';
$context->needDatabaseOperation = true;
$context->dbOperation = DbOperationType::INSERT;
$context->needWebSocketNotify = true;
// 更新批次为机洗,
$context->processType = '机洗';
$context->dbOperation = DbOperationType::UPDATE;
return $context;
}
}