参考文献本地大模型校对

This commit is contained in:
wyn
2026-05-26 17:33:34 +08:00
parent 68cf1867d8
commit c1107780a7
9 changed files with 1357 additions and 504 deletions

View File

@@ -7,6 +7,7 @@ use think\Env;
use think\Queue;
use think\Validate;
use app\common\CrossrefService;
use app\common\ReferenceCheckService;
class Preaccept extends Base
{
@@ -15,6 +16,26 @@ class Preaccept extends Base
parent::__construct($request);
}
/**
* 新增/修改导致文献集合改变后,清空整篇校对明细,使文章状态回到"未校对"。
* 失败仅记日志,不阻塞主流程。
*/
private function resetArticleChecksOnReferChange($pArticleId, $sourceTag = '')
{
$pArticleId = intval($pArticleId);
if ($pArticleId <= 0) {
return;
}
try {
(new ReferenceCheckService())->clearArticleChecksByPArticleId($pArticleId);
} catch (\Exception $e) {
\think\Log::error(
'resetArticleChecksOnReferChange[' . $sourceTag . '] p_article_id='
. $pArticleId . ' ' . $e->getMessage()
);
}
}
/**获取文章参考文献列表
* @return \think\response\Json
@@ -92,6 +113,7 @@ class Preaccept extends Base
return jsonError($rule->getError());
}
$this->production_article_refer_obj->where('p_article_id',$data['p_article_id'])->update(["state"=>1]);
$this->resetArticleChecksOnReferChange(intval($data['p_article_id']), 'discardRefersByParticleid');
return jsonSuccess([]);
}
@@ -142,6 +164,7 @@ class Preaccept extends Base
}
$adId= $this->production_article_refer_obj->insertGetId($insert);
$this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where("p_refer_id", "<>", $adId)->where("index", ">", $pre_refer['index'])->where('state', 0)->setInc('index');
$this->resetArticleChecksOnReferChange(intval($p_info['p_article_id']), 'addRefer');
return jsonSuccess([]);
@@ -198,6 +221,7 @@ class Preaccept extends Base
}
$adId= $this->production_article_refer_obj->insertGetId($insert);
$this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where("p_refer_id", "<>", $adId)->where("index", ">", $pre_refer['index'])->where('state', 0)->setInc('index');
$this->resetArticleChecksOnReferChange(intval($p_info['p_article_id']), 'addReferByParticleid');
return jsonSuccess([]);
}
@@ -233,6 +257,7 @@ class Preaccept extends Base
$insert['cs'] = 1;
$adId = $this->production_article_refer_obj->insertGetId($insert);
$this->production_article_refer_obj->where('p_article_id', $p_info['p_article_id'])->where("p_refer_id", "<>", $adId)->where("index", ">", $pre_refer['index'])->where('state', 0)->setInc('index');
$this->resetArticleChecksOnReferChange(intval($p_info['p_article_id']), 'addReferNotdoi');
return jsonSuccess([]);
}
@@ -462,6 +487,17 @@ class Preaccept extends Base
// }
// $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->update(['refer_doi' => $data['doi']]);
// my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->find());
//文献内容更新成功后异步重检该文献对应的全部校对明细(失败不阻塞主流程)
try {
(new ReferenceCheckService())->enqueueRecheckByPReferId(
intval($data['p_refer_id']),
intval($old_refer_info['p_article_id'])
);
} catch (\Exception $e) {
\think\Log::error('editRefer enqueueRecheckByPReferId p_refer_id=' . $data['p_refer_id'] . ' ' . $e->getMessage());
}
return jsonSuccess([]);
}
@@ -1453,6 +1489,7 @@ class Preaccept extends Base
return jsonError($rule->getError());
}
$refer_info = $this->production_article_refer_obj->where('p_refer_id', $data['p_refer_id'])->find();
$sibling_p_refer_id = 0;
if ($data['act'] == "up") {
$up_info = $this->production_article_refer_obj->where('p_article_id', $refer_info['p_article_id'])->where('index', $refer_info['index'] - 1)->where('state', 0)->find();
if (!$up_info) {
@@ -1460,6 +1497,7 @@ class Preaccept extends Base
}
$this->production_article_refer_obj->where('p_refer_id', $up_info['p_refer_id'])->setInc("index");
$this->production_article_refer_obj->where('p_refer_id', $refer_info['p_refer_id'])->setDec("index");
$sibling_p_refer_id = intval($up_info['p_refer_id']);
} else {
$down_info = $this->production_article_refer_obj->where('p_article_id', $refer_info['p_article_id'])->where('index', $refer_info['index'] + 1)->where('state', 0)->find();
if (!$down_info) {
@@ -1467,7 +1505,19 @@ class Preaccept extends Base
}
$this->production_article_refer_obj->where('p_refer_id', $refer_info['p_refer_id'])->setInc("index");
$this->production_article_refer_obj->where('p_refer_id', $down_info['p_refer_id'])->setDec("index");
$sibling_p_refer_id = intval($down_info['p_refer_id']);
}
// 仅同步本次交换的两条 p_refer_id 对应的校对明细 reference_no / refer_index
try {
(new ReferenceCheckService())->syncReferenceNoByPReferIds(
[intval($refer_info['p_refer_id']), $sibling_p_refer_id],
intval($refer_info['p_article_id'])
);
} catch (\Exception $e) {
\think\Log::error('sortRefer syncReferenceNoByPReferIds: ' . $e->getMessage());
}
return jsonSuccess([]);
}