药师签署完成后自动将双签处方 PDF 归档到私有 COS
- 药师签署验签通过后,立即把最终双签 PDF 以私有对象上传到后台配置的腾讯云 COS, 对象键 private/esign/prescription/<环境>/<处方ID>-<sha256>.pdf,带 Content-MD5 校验,不返回任何 URL - 上传失败不影响签署:记录原因并指数退避,由 esign:archive-work 每分钟补传(最长 1 小时一次) - 签署日志新增「签署件已归档至云存储」/「归档未完成,系统将自动重试」 - 迁移 2026_11_27_prescription_review_archive.sql:归档字段 + 定时任务登记 Co-Authored-By: Claude Opus 5 (1M context) <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5 (1M context)
parent
dc5467cfa7
commit
90b9fff76a
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use app\common\service\esign\PrescriptionEsignArchive;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\console\input\Option;
|
||||
|
||||
/** 每分钟执行:补传药师签署后未成功归档到 COS 的处方 PDF。 */
|
||||
final class EsignArchiveWork extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('esign:archive-work')->setDescription('补传已签处方 PDF 到私有 COS')
|
||||
->addOption('limit', null, Option::VALUE_REQUIRED, '最多处理的处方数,1至100', '20');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output): int
|
||||
{
|
||||
try {
|
||||
$ids = PrescriptionEsignArchive::pending(max(1, min(100, (int) $input->getOption('limit'))));
|
||||
} catch (\Throwable) {
|
||||
// 抛出会让 Crontab 把任务置为错误并停止调度,归档补传就永久中断了。
|
||||
$output->writeln('ESIGN_ARCHIVE_WORK database_unavailable');
|
||||
return 1;
|
||||
}
|
||||
$archived = 0;
|
||||
foreach ($ids as $id) {
|
||||
$archived += PrescriptionEsignArchive::upload((int) $id) ? 1 : 0;
|
||||
}
|
||||
$output->writeln('ESIGN_ARCHIVE_WORK ' . json_encode(['selected' => count($ids), 'archived' => $archived,
|
||||
'deferred' => count($ids) - $archived]));
|
||||
return $archived === count($ids) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user