修改自动推广的相关任务

This commit is contained in:
wangjinlei
2026-05-08 17:59:08 +08:00
parent 336fa08a18
commit c36eba77b1
4 changed files with 7 additions and 100 deletions

View File

@@ -4,7 +4,6 @@ namespace app\api\job;
use think\queue\Job;
use app\common\PlagiarismService;
use app\common\QueueJob;
/**
* 队列任务:上传论文到 Turnitin + 触发 similarity 检测。
@@ -20,38 +19,17 @@ use app\common\QueueJob;
*/
class PlagiarismRun
{
private $oQueueJob;
public function __construct()
{
$this->oQueueJob = new QueueJob();
}
public function fire(Job $job, $data)
{
$this->oQueueJob->init($job);
$checkId = isset($data['check_id']) ? intval($data['check_id']) : 0;
$filePath = isset($data['file_path']) ? (string)$data['file_path'] : '';
if ($checkId <= 0 || $filePath === '') {
$this->oQueueJob->log("PlagiarismRun 无效参数 check_id={$checkId} file_path={$filePath},删除任务");
$job->delete();
return;
}
try {
$svc = new PlagiarismService();
$svc->runUploadAndTrigger($checkId, $filePath);
$this->oQueueJob->log("PlagiarismRun 完成 | check_id={$checkId}");
$job->delete();
} catch (\Exception $e) {
// PlagiarismService 内部已经把状态置为 failed致命 DB 错误下 handleException 会 exit(1)
$this->oQueueJob->handleException($e, $job, "check_id={$checkId}");
} catch (\Throwable $e) {
$this->oQueueJob->handleException($e, $job, "check_id={$checkId}");
} finally {
$this->oQueueJob->finnal();
}
$svc = new PlagiarismService();
$svc->runUploadAndTrigger($checkId, $filePath);
$job->delete();
}
}