参考文献作者堆叠
参考文献相关性检测 作者ai写作辅助检测工作
This commit is contained in:
@@ -7,6 +7,8 @@ use think\Env;
|
||||
use think\Queue;
|
||||
use think\Validate;
|
||||
use app\common\CrossrefService;
|
||||
use app\common\ReferenceCheckService;
|
||||
use app\common\ReferenceReferAuthorService;
|
||||
use app\common\ReferenceRelevanceCheckService;
|
||||
|
||||
class Preaccept extends Base
|
||||
@@ -36,6 +38,78 @@ class Preaccept extends Base
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增参考文献后同步作者明细到 t_production_article_refer_author
|
||||
*/
|
||||
private function syncReferAuthorsAfterInsert($pReferId, $pArticleId, array $refer)
|
||||
{
|
||||
$pReferId = intval($pReferId);
|
||||
$pArticleId = intval($pArticleId);
|
||||
if ($pReferId <= 0 || $pArticleId <= 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
(new ReferenceReferAuthorService())->syncOneRefer($pReferId, $pArticleId, $refer);
|
||||
} catch (\Exception $e) {
|
||||
\think\Log::error(
|
||||
'syncReferAuthorsAfterInsert p_refer_id=' . $pReferId
|
||||
. ' p_article_id=' . $pArticleId . ' ' . $e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑参考文献后同步作者明细;refer_doi 变化时先删后重新抓取入库
|
||||
*/
|
||||
private function syncReferAuthorsAfterUpdate($pReferId, $pArticleId, array $oldRefer, array $updata)
|
||||
{
|
||||
$pReferId = intval($pReferId);
|
||||
$pArticleId = intval($pArticleId);
|
||||
if ($pReferId <= 0 || $pArticleId <= 0 || empty($oldRefer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$newRefer = array_merge($oldRefer, $updata);
|
||||
$refUtil = new ReferenceCheckService();
|
||||
$oldDoi = $this->normalizeReferDoi($refUtil->extractDoiFromRefer($oldRefer));
|
||||
$newDoi = $this->normalizeReferDoi($refUtil->extractDoiFromRefer($newRefer));
|
||||
$doiChanged = $oldDoi !== $newDoi;
|
||||
|
||||
$authorChanged = false;
|
||||
if (array_key_exists('author', $updata)) {
|
||||
$authorChanged = trim((string)($oldRefer['author'] ?? '')) !== trim((string)$updata['author']);
|
||||
}
|
||||
|
||||
if (!$doiChanged && !$authorChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$svc = new ReferenceReferAuthorService();
|
||||
if ($doiChanged) {
|
||||
Db::name('production_article_refer_author')->where('p_refer_id', $pReferId)->delete();
|
||||
$svc->syncOneRefer($pReferId, $pArticleId, $newRefer);
|
||||
} elseif ($authorChanged) {
|
||||
$svc->syncFromReferAuthorField(
|
||||
$pReferId,
|
||||
$pArticleId,
|
||||
(string)($newRefer['author'] ?? '')
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\think\Log::error(
|
||||
'syncReferAuthorsAfterUpdate p_refer_id=' . $pReferId
|
||||
. ' p_article_id=' . $pArticleId . ' ' . $e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizeReferDoi($doi)
|
||||
{
|
||||
$doi = preg_replace('#^https?://(dx\.)?doi\.org/#i', '', trim((string)$doi));
|
||||
return strtolower(trim($doi, " \t\n\r\0\x0B/"));
|
||||
}
|
||||
|
||||
|
||||
/**获取文章参考文献列表
|
||||
* @return \think\response\Json
|
||||
@@ -165,6 +239,11 @@ 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');
|
||||
$this->syncReferAuthorsAfterInsert(
|
||||
$adId,
|
||||
intval($p_info['p_article_id']),
|
||||
array_merge($insert, ['p_refer_id' => $adId, 'p_article_id' => $p_info['p_article_id']])
|
||||
);
|
||||
return jsonSuccess([]);
|
||||
|
||||
|
||||
@@ -222,6 +301,12 @@ 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');
|
||||
$this->syncReferAuthorsAfterInsert(
|
||||
$adId,
|
||||
intval($p_info['p_article_id']),
|
||||
array_merge($insert, ['p_refer_id' => $adId, 'p_article_id' => $p_info['p_article_id']])
|
||||
);
|
||||
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
@@ -498,6 +583,13 @@ class Preaccept extends Base
|
||||
\think\Log::error('editRefer enqueueRecheckByPReferId p_refer_id=' . $data['p_refer_id'] . ' ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->syncReferAuthorsAfterUpdate(
|
||||
intval($data['p_refer_id']),
|
||||
intval($old_refer_info['p_article_id']),
|
||||
$old_refer_info,
|
||||
$updata
|
||||
);
|
||||
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user