1
This commit is contained in:
36
application/api/job/FillExpertCountry.php
Normal file
36
application/api/job/FillExpertCountry.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\job;
|
||||||
|
|
||||||
|
use think\queue\Job;
|
||||||
|
use app\common\ExpertFinderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 队列任务:用本地大模型从 affiliation 推断国家,写入 expert.country_id / country。
|
||||||
|
* 处理完当前专家后,自动找下一个推入队列(链式执行),直到全部处理完。
|
||||||
|
*
|
||||||
|
* 队列名:FetchExperts
|
||||||
|
* 启动 worker:php think queue:listen --queue FetchExperts
|
||||||
|
*/
|
||||||
|
class FillExpertCountry
|
||||||
|
{
|
||||||
|
public function fire(Job $job, $data)
|
||||||
|
{
|
||||||
|
$expertId = intval(isset($data['expert_id']) ? $data['expert_id'] : 0);
|
||||||
|
$affiliation = isset($data['affiliation']) ? trim((string)$data['affiliation']) : '';
|
||||||
|
|
||||||
|
$service = new ExpertFinderService();
|
||||||
|
|
||||||
|
if ($expertId && $affiliation !== '') {
|
||||||
|
try {
|
||||||
|
$service->fillExpertCountry($expertId, $affiliation);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$service->log('[FillExpertCountry] expert_id=' . $expertId . ' exception=' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$job->delete();
|
||||||
|
|
||||||
|
$service->enqueueNextCountryFill(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user