This commit is contained in:
zimoyin
2026-03-18 13:27:48 +08:00
parent 885b856baa
commit defe163190
7 changed files with 33 additions and 61 deletions
+2 -1
View File
@@ -15,9 +15,10 @@ FLOW_USE_CUSTOM_PROCESS = false
# 机器ID,用于分布式环境,确保唯一。0 为使用 MAC 地址,HASH 散列两位
MACHINE_ID = 0
LOG_LEVEL = TRACE
# TCP 服务器配置
TCP_SERVER_PORT = 50000
#LOG_FILTER = app.flow.ProcessEngine:initStrategies;app.flow.ProcessEngine:buildChain;app.flow.ProcessEngine:attachStrategies
#LOG_FILTER = flow
File diff suppressed because one or more lines are too long
+8
View File
@@ -122,6 +122,14 @@ class Config
get => $this->enableVirtualCleanerParser;
}
/**
* TODO 代码内部进行数据库记录行列转换
*/
public bool $enableInternalRowColumnConvert = true {
get => $this->enableInternalRowColumnConvert;
}
private function __construct()
{
$this->detectCircularDependency();
+1 -54
View File
@@ -244,63 +244,10 @@ class LoggerIns
// 3. 添加名称前缀 [name]
$namePrefix = "<RP_NAME:{$this->name}>";
$result = $namePrefix . $processedMessage;
if ($this->isFilter()) return "";
// if ($this->isFilter()) return "";
return $result;
}
/**
* 判断当前日志是否需要过滤(核心过滤逻辑)
* @return bool true=需要过滤,false=保留日志
*/
private function isFilter(): bool
{
$logFilter = Config::getInstance()->logFilter;
// 无过滤规则时直接返回false(不过滤)
if (empty($logFilter)) {
return false;
}
// 1. 解析调用堆栈,获取业务代码的类名/方法名
$stackInfo = $this->parseBusinessStackInfo();
$className = $stackInfo['class'] ?? $this->name ?? '';
$methodName = $stackInfo['method'] ?? '';
// 2. 通配符匹配函数
$matchWildcard = function (string $pattern, string $value): bool {
// 空规则特殊处理:如:debug 拆分后类规则为空,代表匹配所有类
if ($pattern === '') {
return true;
}
// 将通配符*转换为正则的.*,并转义其他特殊字符
$regexPattern = preg_quote($pattern, '/');
$regexPattern = str_replace('\*', '.*', $regexPattern);
// 正则全程匹配
return preg_match('/^' . $regexPattern . '$/', $value) === 1;
};
// 3. 遍历过滤规则,匹配则返回true(需要过滤)
foreach ($logFilter as $filter) {
// 跳过非法过滤规则
if (!is_string($filter)) {
continue;
}
// 拆分规则为类规则和方法规则(最多拆2部分,避免方法名含:)
[$filterClassRule, $filterMethodRule] = array_pad(explode(':', $filter, 2), 2, '*');
// 匹配类名规则(支持通配符*
$isClassMatch = $matchWildcard($filterClassRule, $className);
// 匹配方法名规则(支持通配符*
$isMethodMatch = $matchWildcard($filterMethodRule, $methodName);
// 类和方法都匹配时,返回true(过滤该日志)
if ($isClassMatch && $isMethodMatch) {
return true;
}
}
// 无匹配规则,返回false(保留日志)
return false;
}
/**
* 解析调用堆栈,获取实际业务代码的类名和方法名
+3
View File
@@ -177,5 +177,8 @@ return [
return $record;
}
],
'ignore' => [
app_path() . '/flow/config/AbstractConfig.php'
],
],
];
+10
View File
@@ -173,6 +173,7 @@ class VirtualityFlowProcessor
$st = strtotime($currentState->getActionStartTime());
$duration = time() - $st;
if (empty($st) || $duration < 0) $duration = null;
if ($duration == 0) $duration = 1;
$builder->currentStep($currentState->getCurrentStep())
->batchNo($currentState->getBatchNo())
->setDuration($duration)
@@ -228,10 +229,19 @@ class VirtualityFlowProcessor
public function swipe(string $operatorName, string $endoscopeName, string $readerType): ProcessContext
{
Logger::info("测试刷卡:{$operatorName}, {$endoscopeName}, {$readerType}");
// 如果当前流程中不存在人员卡就刷卡
$endoscopeData = $this->environment['endoscopes'][$endoscopeName]
?? throw new \InvalidArgumentException("未找到内镜: {$endoscopeName}");
// 获取内镜当前状态
/** @var ProcessContext $currentState */
$currentState = $this->endoscopeStates[$endoscopeData['id']] ?? null;
if ($currentState === null){
// 刷人员卡
$result = $this->swipeOperatorCard($operatorName, $readerType);
// 当前语音
Logger::info("当前语音:{$result->getFullVoice()}");
}
// 刷内镜卡
Logger::info("测试刷卡:{$endoscopeName}, {$readerType}");
+3
View File
@@ -2,6 +2,7 @@
namespace tests\flow\cases;
use app\config\Config;
use app\flow\config\ProcessConfig;
use app\flow\ProcessEngine;
use tests\flow\TestCase;
@@ -23,6 +24,7 @@ class ManualWashTest extends TestCase
{
parent::setUp();
$this->processor = VirtualityFlowProcessor::createStandard();
Config::getInstance()->setBlockMode(false);
}
protected function tearDown(): void
@@ -31,6 +33,7 @@ class ManualWashTest extends TestCase
$this->processor->reset();
}
// ==================== 1. 正常完整手工洗流程 ====================
/**