refactor(ProcessContext): 优化属性访问器为 getter/setter 格式
- 将部分私有属性调整为公共属性以便访问 - 使用 getter 访问器简化只读属性的获取方式 - 对可写属性添加 setter 访问器,规范属性赋值流程 - 使用简洁的箭头函数替代传统 getter/setter 代码块 - 增强代码可读性和一致性,便于后续维护和扩展
This commit is contained in:
+53
-33
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user