定时拉取聊天记录
This commit is contained in:
@@ -407,6 +407,36 @@ class DiagnosisController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 触发后台异步同步当前诊单的腾讯云 IM 聊天记录到本地归档表
|
||||
* 请求即返回,真正的同步逻辑在 fastcgi_finish_request 之后执行
|
||||
*/
|
||||
public function triggerImChatSync()
|
||||
{
|
||||
$diagnosisId = (int)$this->request->post('diagnosis_id', 0);
|
||||
if ($diagnosisId <= 0) {
|
||||
$diagnosisId = (int)$this->request->get('diagnosis_id', 0);
|
||||
}
|
||||
if ($diagnosisId <= 0) {
|
||||
return $this->fail('诊单ID不能为空');
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 绑定 TRTC 房间号到当前诊单通话记录(便于云端录制回调关联)
|
||||
* @return \think\response\Json
|
||||
|
||||
Reference in New Issue
Block a user