177c3ae9b2
- 将 ProcessContext 中的 builder() 重命名为 createModifyBuilder() 并添加调用栈日志 - ProcessContextBuilder 中所有 with* 方法统一改为 set* 命名风格 - Flow 各节点及流程处理器中调用 builder() 替换为 createModifyBuilder() - 虚拟测试环境相关 ContextBuilder 中方法同步改名保持一致 - 优化流程节点中上下文修改代码调用,提升代码规范性 - 添加Config中加载自定义流程配置的占位注释及代码 - 无功能改动,纯代码风格及命名规范调整
84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace app\flow\nodes;
|
|
|
|
use app\flow\enum\DbOperationType;
|
|
use app\flow\context\ProcessContext;
|
|
use app\flow\enum\VoiceMessage;
|
|
use app\flow\context\bean\CanHandleResult;
|
|
use app\flow\context\bean\MorningWashStatus;
|
|
use app\utils\Logger;
|
|
|
|
/**
|
|
* 晨洗节点(虚拟读卡器)
|
|
* 处理晨洗流程的开始
|
|
*/
|
|
class MorningWashNode extends AbstractProcessNode
|
|
{
|
|
/**
|
|
* 获取节点名称
|
|
*/
|
|
public static function getName(): string
|
|
{
|
|
return "晨洗";
|
|
}
|
|
|
|
/**
|
|
* 获取节点编码
|
|
*/
|
|
public function getCode(): string
|
|
{
|
|
return self::getName();
|
|
}
|
|
|
|
/**
|
|
* 判断当前节点是否能处理该步骤
|
|
*/
|
|
public function canHandle(ProcessContext $context): CanHandleResult
|
|
{
|
|
// 如果内镜未取出
|
|
if ($context->getStorage()->isInStorage) {
|
|
return CanHandleResult::cannotHandle(VoiceMessage::PLEASE_SWIPE_STORAGE_OUT);
|
|
}
|
|
|
|
// 只有需要晨洗且未完成晨洗时才处理
|
|
if (!$context->getMorningWash()->needMorningWash || $context->getMorningWash()->morningWashed) {
|
|
return CanHandleResult::cannotHandle();
|
|
}
|
|
|
|
// 检查当前读卡器类型是否匹配
|
|
if (!$this->isRequiredNode($context->getReader()->type, ['漂洗', '机洗'])){
|
|
return CanHandleResult::cannotHandle(VoiceMessage::PLEASE_SWIPE_MORNING_WASH);
|
|
}
|
|
return CanHandleResult::canHandle();
|
|
}
|
|
|
|
/**
|
|
* 具体处理逻辑
|
|
*/
|
|
protected function doHandle(ProcessContext $context): ProcessContext
|
|
{
|
|
Logger::debug("处理晨洗节点");
|
|
|
|
// 标记晨洗已开始
|
|
$morningWash = new MorningWashStatus(
|
|
needMorningWash: $context->getMorningWash()->needMorningWash,
|
|
morningWashed: true,
|
|
startTime: $context->getMorningWash()->startTime,
|
|
todayWashRecords: $context->getMorningWash()->todayWashRecords
|
|
);
|
|
|
|
// 设置流程类型
|
|
$processType = $context->getReader()->type === '机洗' ? '机洗(晨洗)' : '手工洗(晨洗)';
|
|
|
|
return $context->createModifyBuilder()
|
|
->setMorningWash($morningWash)
|
|
->setProcessType($processType)
|
|
->setCurrentStep(self::getName())
|
|
->setNeedDatabaseOperation()
|
|
->setDbOperation(DbOperationType::INSERT)
|
|
->setNeedWebSocketNotify()
|
|
->build();
|
|
}
|
|
}
|