新逻辑参考文献相关性整合之前的逻辑

This commit is contained in:
wyn
2026-06-30 09:30:33 +08:00
parent 9c8f7cc3b6
commit da71dfc04e
8 changed files with 162 additions and 190 deletions

View File

@@ -1312,9 +1312,9 @@ class References extends Base
return json_encode(['status' => 8,'msg' => 'fail']);
}
// ============================================================
// 参考文献「主题相关性」校对(独立模块,RabbitMQ 链式消费)
// 参考文献「主题相关性」校对RabbitMQ 链式消费,复用 reference_check 队列
// 表t_article_reference_relevance_check_result / t_article_reference_relevance_check_batch
// 消费php think reference_relevance:mq-consume
// 消费php think reference_check:mq-consume
// ============================================================
/**
@@ -1347,7 +1347,7 @@ class References extends Base
->where('p_article_id', $iPArticleId)
->count();
if (intval($existing) > 0) {
return jsonError('This article already has relevance check records. Use referenceRelevanceCheckResetAI to rerun.');
return jsonError('This article already has relevance check records.');
}
try {
@@ -1363,16 +1363,21 @@ class References extends Base
}
/**
* 相关性校对进度
* POST: p_article_id
* 相关性校对进度(同 referenceCheckProgressAI
* POST/GET: p_article_id(必填)
*/
public function referenceRelevanceCheckProgressAI()
{
$aParam = $this->request->post();
if (empty($aParam)) {
$aParam = $this->request->param();
}
$iPArticleId = empty($aParam['p_article_id']) ? 0 : intval($aParam['p_article_id']);
if ($iPArticleId <= 0) {
return jsonError('p_article_id is required');
return json_encode(array('status' => 2, 'msg' => 'Please select an article'));
}
try {
$result = (new ReferenceRelevanceCheckService())->getProgressByPArticleId($iPArticleId);
return jsonSuccess($result);
@@ -1382,12 +1387,8 @@ class References extends Base
}
/**
* 按 p_article_id 查整篇文章相关性校对总状态(用于前端按钮分流
*
* 按 p_article_id 查整篇文章相关性校对总状态(同 referenceCheckArticleStatusAI
* POST/GET: p_article_id必填
*
* 返回 status0=未校对 1=校对中 2=校对完成
* 计数维度为参考文献(按 reference_no 分组),与 referenceRelevanceCheckProgressAI 一致。
*/
public function referenceRelevanceCheckArticleStatusAI()
{
@@ -1398,7 +1399,7 @@ class References extends Base
$iPArticleId = empty($aParam['p_article_id']) ? 0 : intval($aParam['p_article_id']);
if ($iPArticleId <= 0) {
return jsonError('p_article_id is required');
return json_encode(array('status' => 2, 'msg' => 'Please select an article'));
}
try {
@@ -1410,16 +1411,21 @@ class References extends Base
}
/**
* 按 p_refer_id 查相关性校对明细
* POST: p_refer_id
* 按 p_refer_id 查单条参考文献的相关性校对明细与进度(同 referenceCheckDetailsAI
* POST/GET: p_refer_id(必填)
*/
public function referenceRelevanceCheckDetailsAI()
{
$aParam = $this->request->post();
if (empty($aParam)) {
$aParam = $this->request->param();
}
$iPReferId = empty($aParam['p_refer_id']) ? 0 : intval($aParam['p_refer_id']);
if ($iPReferId <= 0) {
return jsonError('p_refer_id is required');
return json_encode(array('status' => 2, 'msg' => 'Please select a reference'));
}
try {
$result = (new ReferenceRelevanceCheckService())->getDetailsByPReferId($iPReferId);
return jsonSuccess($result);
@@ -1496,47 +1502,15 @@ class References extends Base
}
/**
* 参考文献第一次校对(支撑力度
* @return \think\response\Json
* @deprecated 支撑力度校对已下线,请使用 allReferenceCheckAI主题相关性校对
*/
public function allReferenceCheckAI2(){
//获取参数
$aParam = empty($aParam) ? $this->request->post() : $aParam;
//必填值验证
$iPArticleId = empty($aParam['p_article_id']) ? '' : $aParam['p_article_id'];
if(empty($iPArticleId)){
return json_encode(array('status' => 2,'msg' => 'Please select an article' ));
}
//查询文章p_article_id 与 article_id 都要带,下游服务方法两者都用)
$aWhere = ['p_article_id' => $iPArticleId,'state' => ['in',[0,2]]];
$aProductionArticle = Db::name('production_article')->field('p_article_id,article_id')->where($aWhere)->find();
if(empty($aProductionArticle)){
return json_encode(array('status' => 3,'msg' => 'No articles found' ));
}
if($this->checkReferStatus($iPArticleId)==0){
return jsonError('Please correct the reference content before running the check.');
}
//已存在校对记录则禁止重复执行第一次校对,提示走重置接口
$iExisting = Db::name('article_reference_check_result')
->where('p_article_id', $iPArticleId)
->count();
if(intval($iExisting) > 0){
return jsonError('This article already has a reference check record. Please use the "Reset Check" endpoint to run the check again.');
}
try {
$svc = new ReferenceCheckService();
$result = $svc->enqueueByPArticle($aProductionArticle);
if (empty($result['check_ids'])) {
return jsonError('No reference citations were found in the article.');
}
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
}
public function allReferenceCheckAI2()
{
return jsonError('Support strength check is deprecated. Please use allReferenceCheckAI.');
}
/**
* 文献校对重置:删除该文章已有的全部校对明细,并重新入队整篇校对
* 文献校对重置:删除该文章已有的全部相关性校对明细,并重新入队整篇校对
* POST/GET: article_id必填
* @url /api/Article/referenceCheckReset
*/
@@ -1564,7 +1538,7 @@ class References extends Base
return json_encode(array('status' => 4,'msg' => 'Unbound article' ));
}
try {
$result = (new ReferenceCheckService())->resetAndRecheckByArticle($aProductionArticle);
$result = (new ReferenceRelevanceCheckService())->resetAndRecheckByArticle($aProductionArticle);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
@@ -1601,7 +1575,7 @@ class References extends Base
}
try {
$deleted = (new ReferenceCheckService())->clearArticleChecksByPArticleId($iPArticleId);
$deleted = (new ReferenceRelevanceCheckService())->clearByPArticleId($iPArticleId);
return jsonSuccess([
'p_article_id' => $iPArticleId,
'deleted' => intval($deleted),
@@ -1612,7 +1586,7 @@ class References extends Base
}
/**
* 按 p_article_id 查整篇引用校对进度(按 reference_no 分组聚合)
* 按 p_article_id 查整篇相关性校对进度(按 reference_no 分组聚合)
*
* POST/GET: p_article_id必填
*
@@ -1625,6 +1599,8 @@ class References extends Base
* records[i].status 与分组同一套数值含义(但 record 不会出现 1=校对中):
* 0 = 待校验 2 = 校对完成 3 = 校对失败
*
* records[i] 含 reason中英双语、reason_en、combined_reason中英双语、combined_reason_en
*
* summary 用字符串键pending / checking / completed / failed
*/
public function referenceCheckProgressAI()
@@ -1639,7 +1615,7 @@ class References extends Base
return json_encode(array('status' => 2, 'msg' => 'Please select an article'));
}
try {
$result = (new ReferenceCheckService())->getProgressByPArticleId($iPArticleId);
$result = (new ReferenceRelevanceCheckService())->getProgressByPArticleId($iPArticleId);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
@@ -1647,7 +1623,7 @@ class References extends Base
}
/**
* 按 p_article_id 查整篇文章引用校对总状态(用于前端按钮分流)
* 按 p_article_id 查整篇文章相关性校对总状态(用于前端按钮分流)
*
* POST/GET: p_article_id必填
*
@@ -1681,7 +1657,7 @@ class References extends Base
}
try {
$result = (new ReferenceCheckService())->getArticleProgressStatusByPArticleId($iPArticleId);
$result = (new ReferenceRelevanceCheckService())->getArticleProgressStatusByPArticleId($iPArticleId);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
@@ -1709,7 +1685,7 @@ class References extends Base
}
try {
$result = (new ReferenceCheckService())->getArticleCheckQueuePositionByPArticleId($iPArticleId);
$result = (new ReferenceRelevanceCheckService())->getArticleCheckQueuePositionByPArticleId($iPArticleId);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
@@ -1717,7 +1693,7 @@ class References extends Base
}
/**
* 某条参考文献下「校对失败」的明细重新校对(异步)
* 某条参考文献下「相关性校对失败」的明细重新校对(异步)
*
* POST/GET: p_refer_id必填
* p_article_id可选
@@ -1739,8 +1715,8 @@ class References extends Base
$iPArticleId = empty($aParam['p_article_id']) ? 0 : intval($aParam['p_article_id']);
try {
$result = (new ReferenceCheckService())->enqueueRecheckFailedByPReferId($iPReferId, $iPArticleId);
return jsonSuccess([]);
$result = (new ReferenceRelevanceCheckService())->enqueueRecheckFailedByPReferId($iPReferId, $iPArticleId);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
}
@@ -1769,7 +1745,7 @@ class References extends Base
$iPArticleId = empty($aParam['p_article_id']) ? 0 : intval($aParam['p_article_id']);
try {
$result = (new ReferenceCheckService())->enqueueRecheckFailedByPReferIdWithGroup($iPReferId, $iPArticleId);
$result = (new ReferenceRelevanceCheckService())->enqueueRecheckFailedByPReferIdWithGroup($iPReferId, $iPArticleId);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
@@ -1777,13 +1753,15 @@ class References extends Base
}
/**
* 按 p_refer_id 查单条参考文献的校对明细与进度
* 按 p_refer_id 查单条参考文献的相关性校对明细与进度
*
* POST/GET: p_refer_id必填
*
* 分组进度progress_status(0待/1中/2完成/3失败)、pending、done、failed、pass、
* is_pass、progress_percent、last_updated_at
* list 每项check_id、am_id、status、confidence、reason、is_match、is_pass
* list 每项check_id、am_id、status、is_relevant、relevance_level、relevance_role、
* relevance_score、reason中英双语【中文】/【English】、reason_en、
* combined_*、combined_reason_en、cite_group_refs、cite_check_mode、is_pass
*/
public function referenceCheckDetailsAI()
{
@@ -1798,7 +1776,7 @@ class References extends Base
}
try {
$result = (new ReferenceCheckService())->getCheckDetailsByPReferId($iPReferId);
$result = (new ReferenceRelevanceCheckService())->getDetailsByPReferId($iPReferId);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
@@ -1817,33 +1795,12 @@ class References extends Base
* 返回missing_p_refer_ids、matched_p_refer_ids、still_unmatched_p_refer_ids、
* queued、new_reference_nos、check_ids、queue
*/
/**
* @deprecated 支撑力度漏匹配补扫已下线,请清空后使用 allReferenceCheckAI 重新校对
*/
public function referenceCheckRematchNewAI()
{
$aParam = $this->request->post();
if (empty($aParam)) {
$aParam = $this->request->param();
}
$iPArticleId = empty($aParam['p_article_id']) ? 0 : intval($aParam['p_article_id']);
if ($iPArticleId <= 0) {
return json_encode(array('status' => 2, 'msg' => 'Please select an article'));
}
$aWhere = ['p_article_id' => $iPArticleId, 'state' => ['in', [0, 2]]];
$aProductionArticle = Db::name('production_article')->field('p_article_id,article_id')->where($aWhere)->find();
if (empty($aProductionArticle)) {
return json_encode(array('status' => 3, 'msg' => 'No articles found'));
}
if ($this->checkReferStatus($iPArticleId) == 0) {
return jsonError('Please correct the reference content before running the check.');
}
try {
$result = (new ReferenceCheckService())->enqueueNewlyMatchedByPArticle($aProductionArticle);
return jsonSuccess($result);
} catch (\Exception $e) {
return jsonError($e->getMessage());
}
return jsonError('Support strength rematch is deprecated. Please use referenceCheckResetAI or allReferenceCheckAI.');
}
public function checkReferStatus($p_article_id){