作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -27,7 +27,7 @@ class RemainDay extends Command
* @var 按优化时间统计
*/
protected $projectId = [
1434,1812,276,2414,2974
1434,1812,276,2414,2974,793
];//需要单独处理的项目
/**
... ...
... ... @@ -51,6 +51,12 @@ class GeoQuestionRes extends Command
sleep(300);
continue;
}
$lock_key = "geo_task_lock:$task_id";
if (!Redis::setnx($lock_key, 1)) {
$this->output("任务 $task_id 已被其他进程锁定,跳过");
continue;
}
Redis::expire($lock_key, 1200); // 1小时自动解锁
$this->output('执行的任务ID:' . $task_id);
$geoQuestionModel = new GeoQuestion();
$taskInfo = $geoQuestionModel->read(['id'=>$task_id]);
... ... @@ -345,7 +351,10 @@ class GeoQuestionRes extends Command
foreach ($project_ids as $project_id){
$ids = GeoQuestion::where(['project_id' => $project_id, 'status' => GeoQuestion::STATUS_OPEN])->where('next_time', '<=', date('Y-m-d'))->pluck('id');
foreach ($ids as $id) {
Redis::lpush($key, $id);
//检查任务是否执行过
if (!Redis::exists("geo_task_lock:$id")) {
Redis::lpush($key, $id);
}
}
$task_id = Redis::rpop($key);
}
... ...
... ... @@ -73,7 +73,7 @@ class GeoWritingsTask extends Command
'status'=>2,
'writings_id'=>$id,
];
$geoWritingsTaskModel->edit($data,['task_id'=>$task_id]);
$geoWritingsTaskModel->edit($data,['id'=>$task_id]);
}catch (\Exception $e){
echo date('Y-m-d H:i:s').'保存失败:'.$task_id.$e->getMessage().PHP_EOL;
continue;
... ...
... ... @@ -54,6 +54,7 @@ class GeoWritingsLogic extends BaseLogic
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$id]);
}else{
$this->param['type'] = GeoWritings::TYPE_SUBMIT;
$this->param['uniqid'] = uniqid().$this->param['project_id'];
$id = $this->model->addReturnId($this->param);
}
... ...
... ... @@ -135,16 +135,23 @@ class GeoQuestionResLogic extends BaseLogic
];
}else{
$keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]);
$keywordArrs = [];
$urlArrs = [];
foreach ($list as $item){
$keywordArrs = array_merge($keywordArrs,$item['keywords'] ?? []);
$urlArrs = array_merge($urlArrs,$item['url'] ??[]);
$questionTotalCount += count($item['question'] ?? []);
$keywordsTotalCount += count($item['keywords'] ?? []);
$urlTotalCount += count($item['url'] ?? []);
foreach ($item['keywords'] as $keyWordItem){
if (!array_key_exists($keyWordItem, $keywordArr)) {
$keywordArr[$keyWordItem] = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'keywords'=>['like','%"'.$keyWordItem.'"%']]);
}
}
}
// 去重
$keywordArrs = array_unique($keywordArrs);
$keywordsTotalCount = count($keywordArrs);
$urlArrs = array_unique($urlArrs);
$urlTotalCount = count($urlArrs);
$data = [
'question_count'=>$questionTotalCount,
'keywords_count'=>$keywordsTotalCount,
... ...
... ... @@ -35,7 +35,7 @@ class GeoConf extends Base
$optimize = Cache::get($key);
if (empty($optimize)) {
$optimize = ManageHr::where(['status' => ManageHr::STATUS_ONE, 'entry_position' => 46])->pluck('name', 'id')->toArray();
$optimize[1] = '陶婵';
$optimize[11] = '陶婵';
$optimize[875] = '艾媛媛';
ksort($optimize);
Cache::put($key, $optimize, 3600);
... ...