81 lines
2.0 KiB
PHP
81 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace app\flow\nodes;
|
|
|
|
use app\flow\DbOperationType;
|
|
use app\flow\ProcessContext;
|
|
use app\flow\VoiceMessage;
|
|
use app\utils\Logger;
|
|
|
|
/**
|
|
* 清洗节点
|
|
* 处理手工清洗步骤
|
|
*/
|
|
class WashNode extends AbstractProcessNode
|
|
{
|
|
|
|
/**
|
|
* 获取节点名称
|
|
*/
|
|
public static function getName(): string
|
|
{
|
|
return "清洗";
|
|
}
|
|
|
|
/**
|
|
* 获取节点编码
|
|
*/
|
|
public function getCode(): string
|
|
{
|
|
return self::getName();
|
|
}
|
|
|
|
/**
|
|
* 判断当前节点是否能处理该步骤
|
|
*/
|
|
public function canHandle(ProcessContext $context): bool
|
|
{
|
|
|
|
// 读卡器不是本节点,不处理
|
|
if (!$this->isMatchReaderType($context)) {
|
|
return false;
|
|
}
|
|
|
|
// 需要晨洗但未完成:提示先进行晨洗
|
|
if ($context->needMorningWash && !$context->morningWashed) {
|
|
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_MORNING_WASH;
|
|
return false;
|
|
}
|
|
|
|
$validCurrentSteps = ['', '结束', '内镜取出', '内镜放入', '测漏正常', '晨洗'];
|
|
if (!in_array($context->currentStep, $validCurrentSteps)) {
|
|
// 读卡器是清洗但步骤不对(如终末漂洗时刷清洗),提示应该先刷结束
|
|
// $context->expectedNextStep = "清洗应在流程开始时刷,当前步骤为{$context->currentStep},请先刷结束卡重新开始";
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 具体处理逻辑
|
|
*/
|
|
protected function doHandle(ProcessContext $context): ProcessContext
|
|
{
|
|
// 设置流程类型
|
|
if (empty($context->processType) || $context->processType === '晨洗') {
|
|
$context->processType = '手工洗';
|
|
}
|
|
|
|
// 更新步骤
|
|
$context->currentStep = self::getName();
|
|
|
|
|
|
$context->needDatabaseOperation = true;
|
|
$context->dbOperation = DbOperationType::INSERT;
|
|
$context->needWebSocketNotify = true;
|
|
|
|
return $context;
|
|
}
|
|
}
|