ai-refactor(flow): 调整抽象流程节点实现和依赖路径
- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext - 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示 - 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法 - 增加日志记录细节,便于调试策略执行中断时的错误信息 - 优化代码注释,提升代码可读性和维护性
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\flow\vo;
|
||||
|
||||
use app\model\EctActions;
|
||||
|
||||
/**
|
||||
* 流程状态值对象
|
||||
* 封装流程执行过程中的状态信息(不可变)
|
||||
*/
|
||||
readonly class ProcessStatus
|
||||
{
|
||||
public function __construct(
|
||||
/** 当前操作步骤 */
|
||||
public string $currentStep = '',
|
||||
/** 流程类型 */
|
||||
public string $processType = '',
|
||||
/** 批次号 */
|
||||
public string $batchNo = '',
|
||||
/** 操作开始时间 */
|
||||
public string $actionStartTime = '',
|
||||
/** 操作时长(秒) */
|
||||
public ?int $duration = null,
|
||||
/** 上一个操作记录 */
|
||||
public ?EctActions $previousAction = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 创建空状态
|
||||
*/
|
||||
public static function empty(): self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否可以开始新流程
|
||||
*/
|
||||
public function canStartNewProcess(): bool
|
||||
{
|
||||
$validSteps = ['', '结束', '内镜取出', '测漏正常', '测漏异常'];
|
||||
return in_array($this->currentStep, $validSteps);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否已完成清洗流程
|
||||
*/
|
||||
public function isWashProcessCompleted(): bool
|
||||
{
|
||||
return $this->currentStep === '结束';
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有上一个操作
|
||||
*/
|
||||
public function hasPreviousAction(): bool
|
||||
{
|
||||
return $this->previousAction !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为数组
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'currentStep' => $this->currentStep,
|
||||
'processType' => $this->processType,
|
||||
'batchNo' => $this->batchNo,
|
||||
'actionStartTime' => $this->actionStartTime,
|
||||
'duration' => $this->duration,
|
||||
'previousActionId' => $this->previousAction?->action_id,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user