自动查重

This commit is contained in:
wangjinlei
2026-05-20 11:58:10 +08:00
parent 53e6ddbd9e
commit cfa3f791f4
11 changed files with 938 additions and 58 deletions

View File

@@ -12,7 +12,7 @@ use think\Validate;
* 论文查重Turnitin / Crossref Similarity Check控制器。
*
* 触发方式:纯手工(编辑后台点"查重"按钮)。
* 报告策略:在线 viewer URL 临时签名 + PDF 永久落盘 runtime/plagiarism/
* 报告策略:PDF 在 poll 完成时落盘;在线 viewer URL 通过 getReportUrl 按需生成(临时签名)
*
* 主要接口:
* POST submit 触发查重
@@ -37,12 +37,14 @@ class Plagiarism extends Base
* article_id 必填
* file_url 选填;不传则按 article_id 在 t_article_file 找 manuscirpt
* editor_id 选填;触发人 user_id前端拿不到也可以传 0
* check_type 选填full默认全文| body_only正文| both各提交一条
*/
public function submit()
{
$articleId = intval($this->request->param('article_id', 0));
$fileUrl = trim($this->request->param('file_url', ''));
$editorId = intval($this->request->param('editor_id', 0));
$checkType = trim($this->request->param('check_type', 'full'));
if ($articleId <= 0) {
return jsonError('article_id required');
@@ -53,8 +55,12 @@ class Plagiarism extends Base
$localPath = $fileUrl !== ''
? $svc->resolveFileUrlToLocal($fileUrl)
: $svc->locateArticleManuscript($articleId);
$checkId = $svc->submit($articleId, $localPath, $editorId, 'manual');
return jsonSuccess(['check_id' => $checkId]);
if (strtolower($checkType) === 'both') {
$ids = $svc->submitBoth($articleId, $localPath, $editorId, 'manual');
return jsonSuccess($ids);
}
$checkId = $svc->submit($articleId, $localPath, $editorId, 'manual', $checkType);
return jsonSuccess(['check_id' => $checkId, 'check_type' => strtolower($checkType) ?: 'full']);
} catch (\Throwable $e) {
return jsonError($e->getMessage());
}
@@ -257,10 +263,14 @@ class Plagiarism extends Base
'similarity_score' => floatval($r['similarity_score']),
'tii_report_status' => (string)$r['tii_report_status'],
'has_pdf' => !empty($r['pdf_local_path']),
'local_pdf_url' => $r['pdf_local_path'],
'has_viewer_url' => !empty($r['view_only_url']) && intval($r['view_only_url_expire']) > time(),
'attempts' => intval($r['attempts']),
'error_msg' => (string)$r['error_msg'],
'source_file_name' => (string)$r['source_file_name'],
'check_type' => (string)($r['check_type'] ?? 'full'),
'check_type_label' => $this->checkTypeLabel($r['check_type'] ?? 'full'),
'derived_file_path'=> (string)($r['derived_file_path'] ?? ''),
'trigger_source' => (string)$r['trigger_source'],
'triggered_by' => intval($r['triggered_by']),
'ctime' => intval($r['ctime']),
@@ -268,6 +278,15 @@ class Plagiarism extends Base
];
}
private function checkTypeLabel($checkType)
{
$t = strtolower(trim((string) $checkType));
if ($t === 'body_only' || $t === 'body') {
return '正文查重';
}
return '全文查重';
}
private function stateLabel($state)
{
$map = [