参考文献校对失败重新校对

This commit is contained in:
wyn
2026-07-16 11:23:22 +08:00
parent 3c0bebc2fb
commit f09af1d4e4
3 changed files with 348 additions and 9 deletions

View File

@@ -204,6 +204,77 @@ class ReferenceRelevanceCheckService
];
}
/**
* 仅重新校对某篇文章下 status=3失败的记录不刷新 refer_text / 文献摘要,只重置结果字段后入队。
* 联合引用组会整组重跑(与 enqueueRecheckFailedByPReferIdWithGroup 一致)。
*
* @param int $pArticleId
* @return array{p_article_id:int,reset:int,queued:int,check_ids:int[],transport:string,queue:string}
*/
public function recheckFailedOnlyByArticle($pArticleId)
{
$pArticleId = intval($pArticleId);
if ($pArticleId <= 0) {
throw new \InvalidArgumentException('p_article_id is required');
}
DbReconnectHelper::ensure();
$rows = Db::name('article_reference_relevance_check_result')
->where('p_article_id', $pArticleId)
->where('status', self::RECORD_FAILED)
->order('reference_no asc,am_id asc,text_start asc,id asc')
->select();
if (empty($rows)) {
return [
'p_article_id' => $pArticleId,
'reset' => 0,
'queued' => 0,
'check_ids' => [],
'transport' => self::TRANSPORT_RABBITMQ,
'queue' => self::TRANSPORT_RABBITMQ,
];
}
$now = date('Y-m-d H:i:s');
$resetFields = $this->relevanceCheckResultResetFields([
'updated_at' => $now,
]);
$targetRows = [];
foreach ($rows as $row) {
$groupRows = $this->findCitationGroupRows($row);
foreach ($groupRows as $gr) {
$checkId = $this->resolveCheckRowId($gr);
if ($checkId > 0) {
$targetRows[$checkId] = $gr;
}
}
}
$pendingJobs = [];
foreach ($targetRows as $row) {
$checkId = $this->resolveCheckRowId($row);
Db::name('article_reference_relevance_check_result')->where('id', $checkId)->update($resetFields);
$pendingJobs[] = [
'check_id' => $checkId,
'reference_no' => intval($row['reference_no']),
'am_id' => intval($row['am_id']),
'text_start' => intval($row['text_start']),
];
}
$checkIds = $this->enqueueChecksSortedByReferenceNo($pendingJobs, $pArticleId, 'recheck_failed');
return [
'p_article_id' => $pArticleId,
'reset' => count($targetRows),
'queued' => count($checkIds),
'check_ids' => $checkIds,
'transport' => self::TRANSPORT_RABBITMQ,
'queue' => self::TRANSPORT_RABBITMQ,
];
}
/**
* 某条参考文献下「校对失败」的明细重新校对(异步)
*