d5991813a6
- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext - 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示 - 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法 - 增加日志记录细节,便于调试策略执行中断时的错误信息 - 优化代码注释,提升代码可读性和维护性
80 lines
1.6 KiB
PHP
80 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace app\flow\vo;
|
|
|
|
/**
|
|
* 存储状态值对象
|
|
* 封装内镜的存储柜状态信息,不可变对象
|
|
*/
|
|
readonly class StorageStatus
|
|
{
|
|
public function __construct(
|
|
/** 内镜是否在存储柜中 */
|
|
public bool $isInStorage = false,
|
|
/** 最后一次存储操作类型:内镜放入/内镜取出 */
|
|
public string $lastAction = '',
|
|
/** 存储入库时间 */
|
|
public ?string $inTime = null,
|
|
) {}
|
|
|
|
/**
|
|
* 创建默认的存储状态(不在库中)
|
|
*/
|
|
public static function notInStorage(): self
|
|
{
|
|
return new self(isInStorage: false);
|
|
}
|
|
|
|
/**
|
|
* 创建入库状态
|
|
*/
|
|
public static function inStorage(string $inTime): self
|
|
{
|
|
return new self(
|
|
isInStorage: true,
|
|
lastAction: '内镜放入',
|
|
inTime: $inTime
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 创建出库状态
|
|
*/
|
|
public static function outOfStorage(): self
|
|
{
|
|
return new self(
|
|
isInStorage: false,
|
|
lastAction: '内镜取出',
|
|
inTime: null
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 判断是否已入库
|
|
*/
|
|
public function isStored(): bool
|
|
{
|
|
return $this->isInStorage;
|
|
}
|
|
|
|
/**
|
|
* 判断是否已出库
|
|
*/
|
|
public function isTakenOut(): bool
|
|
{
|
|
return !$this->isInStorage && $this->lastAction === '内镜取出';
|
|
}
|
|
|
|
/**
|
|
* 转换为数组
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'isInStorage' => $this->isInStorage,
|
|
'lastAction' => $this->lastAction,
|
|
'inTime' => $this->inTime,
|
|
];
|
|
}
|
|
}
|