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

- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext
- 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示
- 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法
- 增加日志记录细节,便于调试策略执行中断时的错误信息
- 优化代码注释,提升代码可读性和维护性
This commit is contained in:
zimoyin
2026-03-11 02:40:45 +08:00
parent d5991813a6
commit 3471deb3f1
42 changed files with 1950 additions and 4418 deletions
+27 -8
View File
@@ -157,10 +157,11 @@ readonly class ProcessContext
return $this->stepDurations;
}
// ==================== 便捷查询方法 ====================
// ==================== 便捷查询方法(带数据来源标注) ====================
/**
* 获取当前步骤
* @return string 当前步骤名称 (来源: ProcessStatus)
*/
public function getCurrentStep(): string
{
@@ -169,6 +170,7 @@ readonly class ProcessContext
/**
* 获取流程类型
* @return string 流程类型 (来源: ProcessStatus)
*/
public function getProcessType(): string
{
@@ -177,6 +179,7 @@ readonly class ProcessContext
/**
* 获取批次号
* @return string 批次号 (来源: ProcessStatus)
*/
public function getBatchNo(): string
{
@@ -185,6 +188,7 @@ readonly class ProcessContext
/**
* 获取操作开始时间
* @return string 操作开始时间 (来源: ProcessStatus)
*/
public function getActionStartTime(): string
{
@@ -193,6 +197,7 @@ readonly class ProcessContext
/**
* 获取操作时长
* @return int|null 操作时长(秒)(来源: ProcessStatus)
*/
public function getDuration(): ?int
{
@@ -201,6 +206,7 @@ readonly class ProcessContext
/**
* 获取上一个操作记录
* @return \app\model\EctActions|null 上一个操作记录 (来源: ProcessStatus)
*/
public function getPreviousAction(): ?\app\model\EctActions
{
@@ -209,6 +215,7 @@ readonly class ProcessContext
/**
* 获取完整语音
* @return string 完整语音内容 (来源: VoiceState)
*/
public function getFullVoice(): string
{
@@ -217,6 +224,7 @@ readonly class ProcessContext
/**
* 流程是否成功
* @return bool 是否成功 (来源: ExecutionResult)
*/
public function isSuccess(): bool
{
@@ -225,22 +233,25 @@ readonly class ProcessContext
/**
* 是否需要操作数据库
* @return bool 是否需要数据库操作 (来源: ExecutionResult)
*/
public function needDatabaseOperation(): bool
public function isDatabaseOperationNeeded(): bool
{
return $this->result->needDatabaseOperation;
}
/**
* 是否需要WebSocket通知
* @return bool 是否需要通知 (来源: ExecutionResult)
*/
public function needWebSocketNotify(): bool
public function isWebSocketNotifyNeeded(): bool
{
return $this->result->needWebSocketNotify;
}
/**
* 获取数据库操作列表
* @return array 数据库操作列表 (来源: ExecutionResult)
*/
public function getDbOperations(): array
{
@@ -249,6 +260,7 @@ readonly class ProcessContext
/**
* 检查是否可以开始新流程
* @return bool 是否可以开始新流程 (来源: ProcessStatus)
*/
public function canStartNewProcess(): bool
{
@@ -257,6 +269,7 @@ readonly class ProcessContext
/**
* 检查是否已完成清洗流程
* @return bool 是否已完成 (来源: ProcessStatus)
*/
public function isWashProcessCompleted(): bool
{
@@ -265,6 +278,7 @@ readonly class ProcessContext
/**
* 是否有操作员
* @return bool 是否有有效操作员 (来源: OperatorInfo)
*/
public function hasOperator(): bool
{
@@ -281,40 +295,45 @@ readonly class ProcessContext
/**
* 是否需要增强洗
* @return bool 是否需要增强洗 (来源: ReminderStatus)
*/
public function needEnhanceWash(): bool
public function isEnhanceWashNeeded(): bool
{
return $this->reminder->needEnhanceWash;
}
/**
* 是否需要测漏提醒
* @return bool 是否需要测漏提醒 (来源: ReminderStatus)
*/
public function needLeakTestRemind(): bool
public function isLeakTestRemindNeeded(): bool
{
return $this->reminder->needLeakTestRemind;
}
/**
* 是否需要存储提醒
* @return bool 是否需要存储提醒 (来源: ReminderStatus)
*/
public function needStorageRemind(): bool
public function isStorageRemindNeeded(): bool
{
return $this->reminder->needStorageRemind;
}
/**
* 是否已测漏
* @return bool 是否已测漏 (来源: ReminderStatus)
*/
public function isLeakTestDone(): bool
public function isLeakTestDoneByReminder(): bool
{
return $this->reminder->leakTestDone;
}
/**
* 获取测漏结果
* @return string 测漏结果 (来源: ReminderStatus)
*/
public function getLeakTestResult(): string
public function getLeakTestResultByReminder(): string
{
return $this->reminder->leakTestResult;
}
+3 -19
View File
@@ -15,6 +15,7 @@ use app\flow\vo\StorageStatus;
use app\flow\vo\VoiceState;
use app\flow\enum\DbOperationType;
use app\flow\enum\VoiceMessage;
use app\flow\vo\BatchNo;
use app\model\EctActions;
use app\net\PacketContext;
use app\repository\EctActionsRepository;
@@ -316,28 +317,11 @@ class ProcessContextBuilder
/**
* 生成批次号
* @return string 批次号值
*/
private function generateBatchNo(): string
{
$existingBatchNo = null;
if (!$this->endoscope->isEmpty()) {
$existingBatchNo = EctActionsRepository::new()->findTodayActiveBatchNo($this->config->machineId);
}
$datePart = date('Ymd');
$sequence = 1;
if (!empty($existingBatchNo)) {
$existingDatePart = substr($existingBatchNo, 0, 8);
$existingSequence = substr($existingBatchNo, 10, 4);
if ($existingDatePart === $datePart && is_numeric($existingSequence)) {
$sequence = (int)$existingSequence + 1;
}
}
$sequencePart = str_pad($sequence, 4, '0', STR_PAD_LEFT);
return $datePart . $this->config->machineId . $sequencePart;
return BatchNo::generate($this->config->machineId)->value;
}
// ==================== 值对象设置方法 ====================