|
@@ -29,9 +29,6 @@ class GeoQuestionRes extends Command |
|
@@ -29,9 +29,6 @@ class GeoQuestionRes extends Command |
|
29
|
* @var string
|
29
|
* @var string
|
|
30
|
*/
|
30
|
*/
|
|
31
|
protected $signature = 'geo_question_result';
|
31
|
protected $signature = 'geo_question_result';
|
|
32
|
-
|
|
|
|
33
|
- public $porject_id;//记录当时执行的project_id
|
|
|
|
34
|
-
|
|
|
|
35
|
/**
|
32
|
/**
|
|
36
|
* The console command description.
|
33
|
* The console command description.
|
|
37
|
*
|
34
|
*
|
|
@@ -40,6 +37,14 @@ class GeoQuestionRes extends Command |
|
@@ -40,6 +37,14 @@ class GeoQuestionRes extends Command |
|
40
|
protected $description = 'geo设置请求获取结果';
|
37
|
protected $description = 'geo设置请求获取结果';
|
|
41
|
|
38
|
|
|
42
|
|
39
|
|
|
|
|
40
|
+ public function demo()
|
|
|
|
41
|
+ {
|
|
|
|
42
|
+ // 1 2
|
|
|
|
43
|
+ // getTaskId -> redis -> [] 1、unlock -> select ; 2:lock sleep
|
|
|
|
44
|
+ // 1:select, 2:redis -> pop task
|
|
|
|
45
|
+ // last:mysql status:0, 1:running 2:1->running
|
|
|
|
46
|
+ }
|
|
|
|
47
|
+
|
|
43
|
/**
|
48
|
/**
|
|
44
|
* @return bool
|
49
|
* @return bool
|
|
45
|
*/
|
50
|
*/
|
|
@@ -51,6 +56,8 @@ class GeoQuestionRes extends Command |
|
@@ -51,6 +56,8 @@ class GeoQuestionRes extends Command |
|
51
|
sleep(300);
|
56
|
sleep(300);
|
|
52
|
continue;
|
57
|
continue;
|
|
53
|
}
|
58
|
}
|
|
|
|
59
|
+ $key = 'geo_question_result_' . date('Y-m-d') . '_' . $task_id;
|
|
|
|
60
|
+ $ttl = 600;
|
|
54
|
$this->output('执行的任务ID:' . $task_id);
|
61
|
$this->output('执行的任务ID:' . $task_id);
|
|
55
|
$geoQuestionModel = new GeoQuestion();
|
62
|
$geoQuestionModel = new GeoQuestion();
|
|
56
|
$taskInfo = $geoQuestionModel->read(['id'=>$task_id]);
|
63
|
$taskInfo = $geoQuestionModel->read(['id'=>$task_id]);
|
|
@@ -80,6 +87,7 @@ class GeoQuestionRes extends Command |
|
@@ -80,6 +87,7 @@ class GeoQuestionRes extends Command |
|
80
|
$geoResultModel = new GeoQuestionResult();
|
87
|
$geoResultModel = new GeoQuestionResult();
|
|
81
|
$geoLogModel = new GeoQuestionLog();
|
88
|
$geoLogModel = new GeoQuestionLog();
|
|
82
|
foreach ($taskInfo['question'] as $question) {
|
89
|
foreach ($taskInfo['question'] as $question) {
|
|
|
|
90
|
+
|
|
83
|
$en_question = Translate::tran($question, 'zh') ?? '';
|
91
|
$en_question = Translate::tran($question, 'zh') ?? '';
|
|
84
|
$this->output('项目ID:' . $taskInfo['project_id'] . ', 问题 开始:' . $question);
|
92
|
$this->output('项目ID:' . $taskInfo['project_id'] . ', 问题 开始:' . $question);
|
|
85
|
foreach ($platformsArr as $platform) {
|
93
|
foreach ($platformsArr as $platform) {
|
|
@@ -339,16 +347,15 @@ class GeoQuestionRes extends Command |
|
@@ -339,16 +347,15 @@ class GeoQuestionRes extends Command |
|
339
|
$key = 'geo_task_list';
|
347
|
$key = 'geo_task_list';
|
|
340
|
$task_id = Redis::rpop($key);
|
348
|
$task_id = Redis::rpop($key);
|
|
341
|
if(empty($task_id)){
|
349
|
if(empty($task_id)){
|
|
342
|
- //todo::这里需要执行统计一次,统计当前项目当前日期的统计
|
|
|
|
343
|
- # TODO 按照项目进行获取, 一个项目当天需要将所有跑完
|
|
|
|
344
|
- $project_id = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)->where('next_time', '<=', date('Y-m-d'))->orderBy('next_time', 'asc')->value('project_id');
|
|
|
|
345
|
- if (!empty($project_id)){
|
|
|
|
346
|
- $this->project_id = $project_id;
|
|
|
|
347
|
- $ids = GeoQuestion::where(['project_id' => $project_id, 'status' => GeoQuestion::STATUS_OPEN])->where('next_time', '<=', date('Y-m-d'))->pluck('id');
|
|
|
|
348
|
- foreach ($ids as $id) {
|
|
|
|
349
|
- Redis::lpush($key, $id);
|
350
|
+ $project_ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)->where('next_time', '<=', date('Y-m-d'))->orderBy('next_time', 'asc')->distinct()->pluck('project_id');
|
|
|
|
351
|
+ if(!empty($project_ids)){
|
|
|
|
352
|
+ foreach ($project_ids as $project_id){
|
|
|
|
353
|
+ $ids = GeoQuestion::where(['project_id' => $project_id, 'status' => GeoQuestion::STATUS_OPEN])->where('next_time', '<=', date('Y-m-d'))->pluck('id');
|
|
|
|
354
|
+ foreach ($ids as $id) {
|
|
|
|
355
|
+ Redis::lpush($key, $id);
|
|
|
|
356
|
+ }
|
|
|
|
357
|
+ $task_id = Redis::rpop($key);
|
|
350
|
}
|
358
|
}
|
|
351
|
- $task_id = Redis::rpop($key);
|
|
|
|
352
|
}
|
359
|
}
|
|
353
|
}
|
360
|
}
|
|
354
|
return $task_id;
|
361
|
return $task_id;
|