67 lines
1.4 KiB
PHP
67 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\flow\nodes;
|
|
|
|
use app\flow\DbOperationType;
|
|
use app\flow\ProcessContext;
|
|
use app\flow\VoiceMessage;
|
|
|
|
/**
|
|
* 消毒节点
|
|
* 处理消毒步骤
|
|
*/
|
|
class DisinfectNode 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 === RinseNode::getName()) {
|
|
$context->expectedNextStep = VoiceMessage::PLEASE_SWIPE_DISINFECT;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// 上一个步骤必须是漂洗 或者 晨洗
|
|
if (!$this->isRequiredNode($context->currentStep, [RinseNode::getName(), MorningWashNode::getName()])) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 具体处理逻辑
|
|
*/
|
|
protected function doHandle(ProcessContext $context): ProcessContext
|
|
{
|
|
// 更新步骤
|
|
$context->currentStep = '消毒';
|
|
|
|
|
|
$context->needDatabaseOperation = true;
|
|
$context->dbOperation = DbOperationType::INSERT;
|
|
$context->needWebSocketNotify = true;
|
|
|
|
return $context;
|
|
}
|
|
}
|