fix(process): 修复自定义配置 required 不生效

This commit is contained in:
zimoyin
2026-03-11 15:04:11 +08:00
parent f2ff4ae123
commit 8e617d06bc
11 changed files with 49 additions and 17 deletions
+10 -2
View File
@@ -138,6 +138,14 @@ abstract class AbstractProcessNode implements ProcessNodeInterface
return (!empty($this->getConfig()->required)) ? $this->getConfig()->required : $default;
}
/**
* 获取子节点数量
*/
public function getChildNodeCount(): int
{
return count($this->getChildNodes());
}
/**
* 是否是需要的前置节点
* @param string $currentStep
@@ -174,14 +182,14 @@ abstract class AbstractProcessNode implements ProcessNodeInterface
protected function stopNext(ProcessContext $context): ProcessContext
{
return $context->builder()
->skipNodeCount(count($this->getRemainingNodes()))
->skipNodeCount(count($this->getChildNodes()))
->build();
}
/**
* 获取剩余节点
*/
protected function getRemainingNodes(): array
public function getChildNodes(): array
{
$remainingNodes = [];
$node = $this->next;
+4
View File
@@ -31,6 +31,10 @@ interface ProcessNodeInterface
*/
public function handle(ProcessContext $context): ProcessContext;
public function getChildNodes(): array;
public function getChildNodeCount(): int;
/**
* 获取节点名称
* @return string
+1 -1
View File
@@ -63,7 +63,7 @@ class StorageInNode extends AbstractProcessNode
// 检查前置步骤要求
$validSteps = ['', '结束', '内镜取出', '测漏正常', '测漏异常'];
if (!in_array($context->getCurrentStep(), $validSteps)) {
if (!$this->isRequiredNode($context->getCurrentStep(), $validSteps)) {
Logger::debug('[StorageInNode] 当前步骤 {} 不符合入库条件', [$context->getCurrentStep()]);
return CanHandleResult::cannotHandle();
}
+2 -2
View File
@@ -60,14 +60,14 @@ class StorageNode extends AbstractProcessNode
if ($isInStorage) {
// 内镜已在库中,执行出库
$validSteps = ['内镜放入', '结束'];
if (!in_array($context->getCurrentStep(), $validSteps)) {
if (!$this->isRequiredNode($context->getCurrentStep(), $validSteps)) {
Logger::debug('[StorageNode] 当前步骤 {} 不符合出库条件', [$context->getCurrentStep()]);
return CanHandleResult::cannotHandle();
}
} else {
// 内镜不在库中,执行入库
$validSteps = ['', '结束', '内镜取出', '测漏正常', '测漏异常'];
if (!in_array($context->getCurrentStep(), $validSteps)) {
if (!$this->isRequiredNode($context->getCurrentStep(), $validSteps)) {
Logger::debug('[StorageNode] 当前步骤 {} 不符合入库条件', [$context->getCurrentStep()]);
return CanHandleResult::cannotHandle();
}
+1 -1
View File
@@ -63,7 +63,7 @@ class StorageOutNode extends AbstractProcessNode
// 检查前置步骤要求:必须在库中才能出库
$validSteps = ['内镜放入', '结束'];
if (!in_array($context->getCurrentStep(), $validSteps)) {
if (!$this->isRequiredNode($context->getCurrentStep(), $validSteps)) {
Logger::debug('[StorageOutNode] 当前步骤 {} 不符合出库条件', [$context->getCurrentStep()]);
return CanHandleResult::cannotHandle();
}
+3 -1
View File
@@ -49,8 +49,10 @@ class WashNode extends AbstractProcessNode
return CanHandleResult::cannotHandle(VoiceMessage::PLEASE_SWIPE_MORNING_WASH);
}
$validCurrentSteps = ['', '结束', '内镜取出', '内镜放入', '测漏正常', '晨洗'];
if (!in_array($context->getCurrentStep(), $validCurrentSteps)) {
if (!$this->isRequiredNode($context->getCurrentStep(), $validCurrentSteps)) {
// 读卡器是清洗但步骤不对(如终末漂洗时刷清洗),提示应该先刷结束
return CanHandleResult::cannotHandle();
}