This commit is contained in:
Your Name
2026-09-09 15:47:48 +08:00
parent bd5d5c5f08
commit cb10e75ead
98 changed files with 7031 additions and 804 deletions
@@ -466,8 +466,7 @@ class DiagnosisController extends BaseAdminController
}
/**
* @notes 触发后台异步同步当前诊单的腾讯云 IM 聊天记录到本地归档表
* 请求即返回,真正的同步逻辑在 fastcgi_finish_request 之后执行
* @notes 同步一页 IM 历史并返回真实进度;客户端持 token 续拉,归档后即可展示。
*/
public function triggerImChatSync()
{
@@ -486,20 +485,18 @@ class DiagnosisController extends BaseAdminController
return $this->fail(DiagnosisLogic::getError() ?: '诊单不存在或无权访问');
}
register_shutdown_function(function () use ($diagnosisId) {
try {
@set_time_limit(300);
ignore_user_abort(true);
DiagnosisLogic::syncImChatArchiveForDiagnosis($diagnosisId);
} catch (\Throwable $e) {
\think\facade\Log::warning('triggerImChatSync failed', [
'diagnosis_id' => $diagnosisId,
'err' => $e->getMessage(),
]);
}
});
return $this->success('已发起后台同步,几秒后请重新加载查看', ['queued' => true]);
try {
@set_time_limit(30);
$result = DiagnosisLogic::syncImChatArchiveStep(
$diagnosisId,
(int)$this->adminId,
(string)$this->request->post('sync_token', ''),
(string)$this->request->post('scope', '') === 'current'
);
return $this->data($result);
} catch (\Throwable $e) {
return $this->fail('聊天记录同步失败:' . $e->getMessage());
}
}
/**