已经完成一个文章校对了,但换个文章id就报错了,排查前备份
This commit is contained in:
@@ -36,6 +36,9 @@ class ReferenceCheck
|
||||
|
||||
try {
|
||||
$checkId = intval(isset($data['check_id']) ? $data['check_id'] : 0);
|
||||
if ($checkId <= 0 && !empty($jobData['data']['check_id'])) {
|
||||
$checkId = intval($jobData['data']['check_id']);
|
||||
}
|
||||
$sClassName = get_class($this);
|
||||
$sRedisKey = "queue_job:{$sClassName}:{$checkId}";
|
||||
$sRedisValue = uniqid() . '_' . getmypid();
|
||||
@@ -61,45 +64,47 @@ class ReferenceCheck
|
||||
}
|
||||
|
||||
try {
|
||||
$mainInfo = Db::name('article_main')->where('am_id', $row['am_id'])->find();
|
||||
$contentA = trim($mainInfo['content']);//trim((string)(isset($row['origin_text']) ? $row['origin_text'] : ''));
|
||||
if ($contentA === '' && !empty($row['content_a'])) {
|
||||
$contentA = trim((string)$row['content_a']);
|
||||
}
|
||||
$contentB = trim((string)(isset($row['refer_text']) ? $row['refer_text'] : ''));
|
||||
$svc = new ReferenceCheckService();
|
||||
|
||||
if ($contentB === '' && intval($row['p_refer_id']) > 0) {
|
||||
$contentA = $svc->resolveMainContentForJob($row);
|
||||
$contentB = trim((string)(isset($row['refer_text']) ? $row['refer_text'] : ''));
|
||||
$refer = null;
|
||||
|
||||
if (intval($row['p_refer_id']) > 0) {
|
||||
$refer = Db::name('production_article_refer')
|
||||
->where('p_refer_id', intval($row['p_refer_id']))
|
||||
->where('status', 0)
|
||||
->where('state', 0)
|
||||
->find();
|
||||
if ($refer) {
|
||||
$contentB = (new ReferenceCheckService())->formatReferForLlm($refer);
|
||||
if ($refer && $contentB === '') {
|
||||
$contentB = $svc->formatReferForLlm($refer);
|
||||
}
|
||||
}
|
||||
|
||||
if ($contentA === '' || $contentB === '') {
|
||||
$this->markFailed($checkId, 'Missing content_a or reference text');
|
||||
$this->markFailed($checkId, 'Missing article_main.content or refer_text');
|
||||
$job->delete();
|
||||
return;
|
||||
}
|
||||
|
||||
$llm = new LLMService();
|
||||
$llmResult = $llm->checkReference($contentA, $contentB);
|
||||
$isMatch = !empty($llmResult['is_match']);
|
||||
$llmResult = $llm->checkReference($contentA, $contentB, false);
|
||||
$canSupport = $svc->parseLlmCanSupport($llmResult);
|
||||
$confidence = floatval($llmResult['confidence']);
|
||||
|
||||
Db::name('article_reference_check_result')->where('id', $checkId)->update([
|
||||
'is_match' => $isMatch ? 1 : 0,
|
||||
'confidence' => $llmResult['confidence'],
|
||||
'reason' => $llmResult['reason'],
|
||||
$svc->updateCheckResult($checkId, [
|
||||
'can_support' => $canSupport ? 1 : 0,
|
||||
'is_match' => $canSupport ? 1 : 0,
|
||||
'confidence' => $confidence,
|
||||
'reason' => isset($llmResult['reason']) ? $llmResult['reason'] : '',
|
||||
'status' => 1,
|
||||
'error_msg' => '',
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$svc->maybeEnqueueSecondPass($checkId, $confidence);
|
||||
|
||||
$amId = intval(isset($row['am_id']) ? $row['am_id'] : 0);
|
||||
if ($amId > 0) {
|
||||
(new ReferenceCheckService())->syncAmRefCheckStatus($amId);
|
||||
$svc->syncAmRefCheckStatus($amId);
|
||||
}
|
||||
$this->QueueRedis->finishJob($sRedisKey, 'completed', $this->completedExprie, $sRedisValue);
|
||||
$job->delete();
|
||||
@@ -127,11 +132,14 @@ class ReferenceCheck
|
||||
private function markFailed($checkId, $msg)
|
||||
{
|
||||
$row = Db::name('article_reference_check_result')->where('id', $checkId)->find();
|
||||
Db::name('article_reference_check_result')->where('id', $checkId)->update([
|
||||
'status' => 2,
|
||||
'error_msg' => mb_substr($msg, 0, 500),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
try {
|
||||
(new ReferenceCheckService())->updateCheckResult($checkId, [
|
||||
'status' => 2,
|
||||
'error_msg' => $msg,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
\think\Log::error('ReferenceCheck markFailed: ' . $e->getMessage());
|
||||
}
|
||||
$amId = empty($row) ? 0 : intval(isset($row['am_id']) ? $row['am_id'] : 0);
|
||||
if ($amId > 0) {
|
||||
(new ReferenceCheckService())->syncAmRefCheckStatus($amId);
|
||||
|
||||
Reference in New Issue
Block a user