更新
This commit is contained in:
@@ -12,7 +12,7 @@ use think\console\Output;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 从腾讯云 IM 拉取诊单单聊漫游消息并写入本地归档表(建议 cron 每几小时执行)
|
||||
* 回调实时归档之外的定时补拉;按患者轮转,覆盖没有更新诊单的旧患者。
|
||||
*/
|
||||
class SyncImChatArchive extends Command
|
||||
{
|
||||
@@ -20,7 +20,7 @@ class SyncImChatArchive extends Command
|
||||
{
|
||||
$this->setName('sync_im_chat_archive')
|
||||
->setDescription('同步诊单腾讯云 IM 聊天记录到数据库归档')
|
||||
->addOption('since-days', null, Option::VALUE_OPTIONAL, '仅处理最近 N 天内更新过的诊单;0 表示不限制', '7')
|
||||
->addOption('since-days', null, Option::VALUE_OPTIONAL, '仅处理最近 N 天内更新过的诊单;默认0,覆盖旧患者聊天', '0')
|
||||
->addOption('limit', 'l', Option::VALUE_OPTIONAL, '本轮最多处理的诊单数量(1-500)', '50')
|
||||
->addOption('diagnosis-id', null, Option::VALUE_OPTIONAL, '只同步指定诊单 ID,设置后忽略 since-days', '0');
|
||||
}
|
||||
@@ -40,12 +40,15 @@ class SyncImChatArchive extends Command
|
||||
}
|
||||
|
||||
$stats = DiagnosisLogic::syncImChatArchiveBatch($sinceDays, $limit, $only);
|
||||
$output->writeln("处理诊单数: {$stats['diagnoses']},新插入行数(INSERT IGNORE 成功数): {$stats['inserted']}");
|
||||
$output->writeln("处理患者诊单数: {$stats['diagnoses']},新归档消息数: {$stats['inserted']}");
|
||||
if (!empty($stats['errors'])) {
|
||||
foreach ($stats['errors'] as $e) {
|
||||
$output->writeln("<error>{$e}</error>");
|
||||
Log::error('sync_im_chat_archive: ' . $e);
|
||||
}
|
||||
// 项目调度器 Console::call 不转发命令退出码,抛错才能写入定时任务失败状态。
|
||||
throw new \RuntimeException('IM 聊天归档未完全同步:' . implode(';', $stats['errors']));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user