test
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace flow;
|
||||
|
||||
class PartTimeFlowProcessor
|
||||
{
|
||||
|
||||
}
|
||||
@@ -199,12 +199,18 @@ class VirtualContextBuilder
|
||||
*/
|
||||
public function currentStep(string $step): self
|
||||
{
|
||||
// 自动从环境配置加载该步骤的时长(如果未手动设置)
|
||||
$duration = $this->processStatus->duration;
|
||||
if ($duration === null && isset($this->stepDurations[$step])) {
|
||||
$duration = $this->stepDurations[$step];
|
||||
}
|
||||
|
||||
$this->processStatus = new ProcessStatus(
|
||||
currentStep: $step,
|
||||
processType: $this->processStatus->processType,
|
||||
batchNo: $this->processStatus->batchNo,
|
||||
actionStartTime: $this->processStatus->actionStartTime,
|
||||
duration: $this->processStatus->duration,
|
||||
duration: $duration,
|
||||
previousAction: $this->processStatus->previousAction
|
||||
);
|
||||
return $this;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace tests\flow;
|
||||
|
||||
use app\flow\config\ProcessConfig;
|
||||
use app\flow\context\ProcessContext;
|
||||
use app\flow\enum\VoiceMessage;
|
||||
use app\flow\ProcessEngine;
|
||||
use app\flow\context\bean\EndoscopeInfo;
|
||||
use app\flow\context\bean\OperatorInfo;
|
||||
@@ -160,16 +161,22 @@ class VirtualityFlowProcessor
|
||||
if (isset($this->operatorSessions[$readerData['id']])) {
|
||||
$opData = $this->operatorSessions[$readerData['id']];
|
||||
$builder->customOperator($opData['id'], $opData['name'], $opData['rfid']);
|
||||
} else {
|
||||
// 获取上一个记录的操作员
|
||||
$opData = $currentState->getOperator();
|
||||
$builder->customOperator($opData->id, $opData->name, $opData->rfid);
|
||||
|
||||
}
|
||||
|
||||
// 继承之前的流程状态
|
||||
if ($currentState !== null) {
|
||||
$st = strtotime($currentState->getActionStartTime());
|
||||
$duration = time() - $st;
|
||||
if (empty($st) || $duration <= 0) $duration = null;
|
||||
if (empty($st) || $duration < 0) $duration = null;
|
||||
$builder->currentStep($currentState->getCurrentStep())
|
||||
->batchNo($currentState->getBatchNo())
|
||||
->setDuration($duration)
|
||||
->actionStartTime(date("Y-m-d H:i:s"))
|
||||
->processType($currentState->getProcessType());
|
||||
|
||||
// 设置 previousAction:上一步骤名称就是当前状态的 currentStep
|
||||
@@ -186,7 +193,7 @@ class VirtualityFlowProcessor
|
||||
// 未刷人员卡检查
|
||||
if (!$context->hasOperator() && !isset($this->operatorSessions[$readerData['id']])) {
|
||||
$result = $context->createModifyBuilder()
|
||||
->error(\app\flow\enum\VoiceMessage::PLEASE_SWIPE_OPERATOR)
|
||||
->error(VoiceMessage::PLEASE_SWIPE_OPERATOR)
|
||||
->build();
|
||||
$this->history[] = $result;
|
||||
return $result;
|
||||
|
||||
@@ -94,7 +94,9 @@ class BlockTest extends TestCase
|
||||
|
||||
$engine = ProcessEngine::createStandard();
|
||||
$result = $engine->execute($context);
|
||||
|
||||
// 输出语音
|
||||
Logger::info("测试时间验证策略阻断 - 阻断模式开启 success:{}",[$result->isSuccess()]);
|
||||
Logger::info($result->getFullVoice());
|
||||
// 阻断模式下,时间不足应该导致流程失败
|
||||
$this->assertFalse($result->isSuccess(), '阻断模式下,时长不足应失败');
|
||||
}
|
||||
|
||||
@@ -76,6 +76,50 @@ class ManualWashTest extends TestCase
|
||||
// 验证最终步骤成功
|
||||
$this->assertTrue($result5->isSuccess(), '干燥步骤 isSuccess() 应为 true');
|
||||
}
|
||||
/**
|
||||
* 测试完整手工洗流程:清洗 -> 漂洗 -> 消毒 -> 终末漂洗 -> 干燥
|
||||
* 使用真实环境引擎执行
|
||||
*/
|
||||
public function testCompleteManualWashProcess2(): void
|
||||
{
|
||||
$operator = '操作员 1';
|
||||
$endoscope = '胃镜 1';
|
||||
|
||||
// 步骤 1:清洗
|
||||
$result1 = $this->processor->swipe($operator, $endoscope, '清洗');
|
||||
$this->assertSuccess($result1, '清洗步骤应成功');
|
||||
$this->assertStep($result1, '清洗');
|
||||
$this->assertNeedDatabaseOperation($result1);
|
||||
$batchNo = $result1->getBatchNo();
|
||||
$this->assertNotEmpty($batchNo, '应生成批次号');
|
||||
|
||||
// 步骤 2:漂洗
|
||||
$result2 = $this->processor->swipe($operator, $endoscope, '漂洗');
|
||||
$this->assertSuccess($result2, '漂洗步骤应成功');
|
||||
$this->assertStep($result2, '漂洗');
|
||||
$this->assertBatchNoEquals($result2, $batchNo, '批次号应保持一致');
|
||||
|
||||
// 步骤 3:消毒
|
||||
$result3 = $this->processor->swipe($operator, $endoscope, '消毒');
|
||||
$this->assertSuccess($result3, '消毒步骤应成功');
|
||||
$this->assertStep($result3, '消毒');
|
||||
$this->assertBatchNoEquals($result3, $batchNo, '批次号应保持一致');
|
||||
|
||||
// 步骤 4:终末漂洗
|
||||
$result4 = $this->processor->swipe($operator, $endoscope, '终末漂洗');
|
||||
$this->assertSuccess($result4, '终末漂洗步骤应成功');
|
||||
$this->assertStep($result4, '终末漂洗');
|
||||
$this->assertBatchNoEquals($result4, $batchNo, '批次号应保持一致');
|
||||
|
||||
// 步骤 5:干燥
|
||||
$result5 = $this->processor->swipe($operator, $endoscope, '干燥');
|
||||
$this->assertSuccess($result5, '干燥步骤应成功');
|
||||
$this->assertStep($result5, '干燥');
|
||||
$this->assertBatchNoEquals($result5, $batchNo, '批次号应保持一致');
|
||||
|
||||
// 验证最终步骤成功
|
||||
$this->assertTrue($result5->isSuccess(), '干燥步骤 isSuccess() 应为 true');
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试使用便捷方法执行完整手工洗流程
|
||||
|
||||
Reference in New Issue
Block a user