This commit is contained in:
Your Name
2026-09-10 15:19:17 +08:00
parent 27fbef9321
commit 36975c6c1b
487 changed files with 15696 additions and 78 deletions
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
// Read-only queue metadata diagnostic. Never print credentials or clinical content.
$serverRoot = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR;
chdir($serverRoot);
require $serverRoot . 'vendor/autoload.php';
$app = new \think\App($serverRoot);
$app->initialize();
try {
$out = [
'php_now' => time(), 'php_local_time' => date('c'),
'enabled' => (bool) config('prescription_analysis.enabled', false),
'start_at' => (int) config('prescription_analysis.start_at', 0),
'configured_key_present' => (string) config('prescription_analysis.encryption_key', '') !== '',
'local_key_present' => is_file(root_path('runtime') . 'prescription_ai_private/snapshot.key'),
'db_now' => \think\facade\Db::query('SELECT UNIX_TIMESTAMP() AS now')[0]['now'],
];
$fields = 'id,prescription_id,status,validity,trigger_type,wait_until,next_run_at,lock_until,prepare_attempts,error_code,cutoff_at,created_at,updated_at';
$out['prescription_batches'] = \think\facade\Db::name('prescription_ai_batch')
->where('prescription_id', 7556)->field($fields)->order('id', 'desc')->limit(5)->select()->toArray();
$ids = array_column($out['prescription_batches'], 'id');
$out['prescription_tasks'] = $ids ? \think\facade\Db::name('prescription_ai_task')->whereIn('batch_id', $ids)
->field('id,batch_id,model_key,status,attempts,total_attempts,next_run_at,lock_until,error_code,result_id,started_at,finished_at,updated_at')
->select()->toArray() : [];
$out['batch_counts'] = \think\facade\Db::name('prescription_ai_batch')
->field('status,COUNT(*) AS total,MIN(id) AS first_id,MAX(id) AS last_id')->group('status')->select()->toArray();
$out['model_counts'] = \think\facade\Db::name('prescription_ai_task')
->field('model_key,status,COUNT(*) AS total')->group('model_key,status')->select()->toArray();
$out['active_preparation'] = \think\facade\Db::name('prescription_ai_batch')
->where('lock_until', '>', time())->field($fields)->limit(10)->select()->toArray();
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), PHP_EOL;
} catch (\Throwable $error) {
echo json_encode(['diagnostic_error' => get_class($error), 'code' => $error->getCode()]), PHP_EOL;
exit(1);
}