ai-refactor(flow): 调整抽象流程节点实现和依赖路径

- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext
- 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示
- 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法
- 增加日志记录细节,便于调试策略执行中断时的错误信息
- 优化代码注释,提升代码可读性和维护性
This commit is contained in:
zimoyin
2026-03-11 00:48:10 +08:00
parent d303f3501f
commit e040fccba6
45 changed files with 819 additions and 2718 deletions
+16 -14
View File
@@ -4,8 +4,9 @@ namespace app\flow\strategies;
use app\flow\config\MorningMode;
use app\flow\config\MorningWashConfig;
use app\flow\ProcessContext;
use app\flow\context\ProcessContext;
use app\flow\nodes\ProcessNodeInterface;
use app\flow\vo\MorningWashStatus;
use app\utils\Logger;
/**
@@ -30,16 +31,17 @@ class MorningWashStrategy extends AbstractStrategy
*/
protected function doExecute(ProcessContext $context, ProcessNodeInterface $node): ProcessContext
{
$isEnd = $context->currentStep == '结束';
$isEnd = $context->getCurrentStep() == '结束';
$needMorning = $this->checkNeedMorningWash($context) && $isEnd;
$context->needMorningWash = $needMorning;
$morningWash = new MorningWashStatus(
needMorningWash: $needMorning,
morningWashed: !$needMorning,
startTime: $context->getMorningWash()->startTime,
todayWashRecords: $context->getMorningWash()->todayWashRecords
);
// 如果不需要晨洗,标记为已完成
if (!$needMorning) {
$context->morningWashed = true;
}
return $context;
return $context->builder()->withMorningWash($morningWash)->build();
}
/**
@@ -62,9 +64,9 @@ class MorningWashStrategy extends AbstractStrategy
*/
protected function checkByStorageTime(ProcessContext $context): bool
{
$storageInTime = $context->storageInTime;
$lastActionType = $context->previousAction->action_type_name;
$lastProcessName = $context->previousAction->process_name;
$storageInTime = $context->getStorage()->inTime;
$lastActionType = $context->getPreviousAction()?->action_type_name;
$lastProcessName = $context->getPreviousAction()?->process_name;
// 如果最后一次操作是存储且已取出
if ($lastActionType === '存储' && $lastProcessName === '内镜取出') {
@@ -94,7 +96,7 @@ class MorningWashStrategy extends AbstractStrategy
*/
protected function hasWashRecordToday(ProcessContext $context): bool
{
return $context->todayWashRecords === 0;
return $context->getMorningWash()->todayWashRecords === 0;
}
/**
@@ -103,7 +105,7 @@ class MorningWashStrategy extends AbstractStrategy
protected function checkBySpecificTypes(ProcessContext $context): bool
{
$specificTypes = $this->morningWashConfig->getExpand('specific_types', []);
return in_array($context->endoscopeType, $specificTypes);
return in_array($context->getEndoscope()->type, $specificTypes);
}
/**