更新
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
// Queues "重新分析" for the given prescriptions, exactly like the report window's button:
|
||||
// same permission checks, a new batch with a fresh snapshot, old reports retained.
|
||||
// Pass --apply to queue; without it only previews. Prints task metadata only.
|
||||
$serverRoot = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR;
|
||||
chdir($serverRoot);
|
||||
require $serverRoot . 'vendor/autoload.php';
|
||||
$app = new \think\App($serverRoot);
|
||||
$app->initialize();
|
||||
|
||||
use app\adminapi\logic\tcm\PrescriptionAiLogic;
|
||||
use app\common\service\prescriptionai\PrescriptionAiAccess;
|
||||
use think\facade\Db;
|
||||
|
||||
$apply = in_array('--apply', $argv, true);
|
||||
$ids = array_values(array_filter(array_map('intval', array_slice($argv, 1)), static fn (int $id): bool => $id > 0));
|
||||
$out = ['apply' => $apply, 'prescriptions' => []];
|
||||
foreach ($ids as $rxId) {
|
||||
$batch = Db::name('prescription_ai_batch')->where('prescription_id', $rxId)->order('id', 'desc')
|
||||
->field('id,actor_id,validity,status')->find();
|
||||
$entry = ['prescription_id' => $rxId, 'latest_batch' => (int) ($batch['id'] ?? 0), 'validity' => $batch['validity'] ?? ''];
|
||||
if (!$apply || !$batch) {
|
||||
$out['prescriptions'][] = $entry;
|
||||
continue;
|
||||
}
|
||||
$actor = (int) $batch['actor_id'];
|
||||
try {
|
||||
$entry['queued'] = PrescriptionAiLogic::regenerate($rxId, '本轮修复后重新生成对照', $actor, (array) PrescriptionAiAccess::actor($actor));
|
||||
} catch (\Throwable $e) {
|
||||
$entry['refused'] = $e->getMessage();
|
||||
}
|
||||
$out['prescriptions'][] = $entry;
|
||||
}
|
||||
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";
|
||||
Reference in New Issue
Block a user