From d303f3501fcc7d18e6b57ff65a4106db7b8c82b6 Mon Sep 17 00:00:00 2001 From: zimoyin <2556608754@qq.com> Date: Tue, 10 Mar 2026 23:00:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ProcessContext):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=AE=BF=E9=97=AE=E5=99=A8=E4=B8=BA=20getter?= =?UTF-8?q?/setter=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将部分私有属性调整为公共属性以便访问 - 使用 getter 访问器简化只读属性的获取方式 - 对可写属性添加 setter 访问器,规范属性赋值流程 - 使用简洁的箭头函数替代传统 getter/setter 代码块 - 增强代码可读性和一致性,便于后续维护和扩展 --- app/flow/ProcessContext.php | 86 +++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/app/flow/ProcessContext.php b/app/flow/ProcessContext.php index 81890cb..bdb365e 100644 --- a/app/flow/ProcessContext.php +++ b/app/flow/ProcessContext.php @@ -39,7 +39,7 @@ class ProcessContext * 配置类 * @var Config */ - private Config $config; + public Config $config; // ==================== 基础信息 ==================== /** * 内镜ID @@ -49,7 +49,9 @@ class ProcessContext /** * 内镜名称 */ - public string $endoscopeName = ''; + public string $endoscopeName = '' { + get => $this->endoscopeName; + } /** * 内镜RFID卡号 @@ -70,7 +72,9 @@ class ProcessContext /** * 当前读卡器类型/功能 */ - public string $readerType = ''; + public string $readerType = '' { + get => $this->readerType; + } /** * 读卡器ID @@ -81,27 +85,33 @@ class ProcessContext /** * 当前操作步骤 */ - public string $currentStep = ''; + public string $currentStep = '' { + get => $this->currentStep; + set => $this->currentStep = $value; + } /** * @var EctActions 上一个操作步骤 */ public EctActions $previousAction { - get { - return $this->previousAction; - } + get => $this->previousAction; } /** * 流程类型: 手工洗 / 机洗 / 测漏 / 存储 / 手工洗(晨洗)/ 机洗(晨洗) */ - public string $processType = ''; + public string $processType = '' { + get => $this->processType; + set => $this->processType = $value; + } /** * 批次号 */ - public string $batchNo = ''; + public string $batchNo = '' { + get => $this->batchNo; + } /** * 操作开始时间 @@ -119,17 +129,25 @@ class ProcessContext /** * 是否需要晨洗 */ - public bool $needMorningWash = false; + public bool $needMorningWash = false { + get => $this->needMorningWash; + } /** * 是否已完成晨洗 */ - public bool $morningWashed = false; + public bool $morningWashed = false { + get => $this->morningWashed; + set => $this->morningWashed = $value; + } /** * 存储入库时间(用于晨洗判断) */ - public ?string $storageInTime = null; + public ?string $storageInTime = null { + get => $this->storageInTime; + set => $this->storageInTime = $value; + } /** * 今天洗消记录数 @@ -140,7 +158,10 @@ class ProcessContext /** * 内镜是否在存储柜中 */ - public bool $isInStorage = false; + public bool $isInStorage = false { + get => $this->isInStorage; + set => $this->isInStorage = $value; + } /** * 最后一次存储操作类型:入库/出库 @@ -200,16 +221,16 @@ class ProcessContext /** * 语音播报内容 */ - public string $voiceMessage = ''; + public string $voiceMessage = '' { + get => $this->voiceMessage; + } // ==================== 执行结果 ==================== /** * 流程执行结果 */ public bool $success = true { - get { - return $this->success; - } + get => $this->success; } /** @@ -232,30 +253,28 @@ class ProcessContext /** * 是否需要操作数据库 */ - public bool $needDatabaseOperation = false; + public bool $needDatabaseOperation = false { + get => $this->needDatabaseOperation; + set => $this->needDatabaseOperation = $value; + } /** * 数据库操作类型 insert / update * DbOperationType */ public array $dbOperation = [] { - get { - return $this->dbOperation; - } + get => $this->dbOperation; - set(DbOperationType|array $value) { - if (is_array($value)) { - $this->dbOperation = $value; - } else { - $this->dbOperation[] = $value; - } - } + set(DbOperationType|array $value) => is_array($value) ? $this->dbOperation = $value : $this->dbOperation[] = $value; } /** * 是否需要发送WebSocket通知 */ - public bool $needWebSocketNotify = false; + public bool $needWebSocketNotify = false { + get => $this->needWebSocketNotify; + set => $this->needWebSocketNotify = $value; + } /** * 这张卡是否是人员卡(而非内镜卡) @@ -272,9 +291,7 @@ class ProcessContext * ProcessEngine 无节点命中时直接读取此字段作为错误语音提示 */ public VoiceMessage $expectedNextStep = VoiceMessage::NONE { - get { - return $this->expectedNextStep; - } + get => $this->expectedNextStep; set { // 获取调用这个方法的类名 $callerClass = debug_backtrace()[1]['class'] ?? ''; @@ -287,7 +304,10 @@ class ProcessContext /** * @var int 设置后从当前节点跳过 skipNodeCount 个节点 */ - public int $skipNodeCount = 0; + public int $skipNodeCount = 0 { + get => $this->skipNodeCount; + set => $this->skipNodeCount = $value; + } public function __construct() {