|
@@ -10,6 +10,7 @@ |
|
@@ -10,6 +10,7 @@ |
|
10
|
namespace App\Console\Commands;
|
10
|
namespace App\Console\Commands;
|
|
11
|
|
11
|
|
|
12
|
use App\Models\Mail\Mail;
|
12
|
use App\Models\Mail\Mail;
|
|
|
|
13
|
+use App\Models\Project\Project;
|
|
13
|
use App\Models\User\User;
|
14
|
use App\Models\User\User;
|
|
14
|
use App\Services\ProjectServer;
|
15
|
use App\Services\ProjectServer;
|
|
15
|
use Illuminate\Console\Command;
|
16
|
use Illuminate\Console\Command;
|
|
@@ -40,17 +41,14 @@ class UpdateProgress extends Command |
|
@@ -40,17 +41,14 @@ class UpdateProgress extends Command |
|
40
|
*/
|
41
|
*/
|
|
41
|
public function handle()
|
42
|
public function handle()
|
|
42
|
{
|
43
|
{
|
|
43
|
- $project_id = Redis::rpop('updateProgress');
|
|
|
|
44
|
- while ($project_id){
|
|
|
|
45
|
- echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
|
|
|
|
46
|
- try {
|
|
|
|
47
|
- ProjectServer::useProject($project_id);
|
|
|
|
48
|
- $this->getUpdateProgress($project_id);
|
|
|
|
49
|
- DB::disconnect('custom_mysql');
|
|
|
|
50
|
- }catch (\Exception $e){
|
|
|
|
51
|
- echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
|
|
|
|
52
|
- }
|
|
|
|
53
|
- echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
|
44
|
+ //获取所有项目
|
|
|
|
45
|
+ $projectModel = new Project();
|
|
|
|
46
|
+ $list = $projectModel->list(['type'=>['in',[1,2,3,4]]]);
|
|
|
|
47
|
+ foreach ($list as $v){
|
|
|
|
48
|
+ echo date('Y-m-d H:i:s') . ' start: ' . $v['id'] . PHP_EOL;
|
|
|
|
49
|
+ ProjectServer::useProject($v['id']);
|
|
|
|
50
|
+ $this->getUpdateProgress($v['id']);
|
|
|
|
51
|
+ DB::disconnect('custom_mysql');
|
|
54
|
}
|
52
|
}
|
|
55
|
}
|
53
|
}
|
|
56
|
|
54
|
|
|
@@ -64,6 +62,7 @@ class UpdateProgress extends Command |
|
@@ -64,6 +62,7 @@ class UpdateProgress extends Command |
|
64
|
public function getUpdateProgress($project_id){
|
62
|
public function getUpdateProgress($project_id){
|
|
65
|
$info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first();
|
63
|
$info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first();
|
|
66
|
if(!empty($info)){
|
64
|
if(!empty($info)){
|
|
|
|
65
|
+ //超时时间
|
|
67
|
$time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60);
|
66
|
$time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60);
|
|
68
|
if($time > date("Y-m-d H:i:s")){
|
67
|
if($time > date("Y-m-d H:i:s")){
|
|
69
|
DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]);
|
68
|
DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]);
|
|
@@ -76,10 +75,9 @@ class UpdateProgress extends Command |
|
@@ -76,10 +75,9 @@ class UpdateProgress extends Command |
|
76
|
$data["content"] = "部分页面更新超时,请重新更新,或联系管理员";
|
75
|
$data["content"] = "部分页面更新超时,请重新更新,或联系管理员";
|
|
77
|
$mail = new Mail();
|
76
|
$mail = new Mail();
|
|
78
|
$mail->add($data);
|
77
|
$mail->add($data);
|
|
79
|
- }else{
|
|
|
|
80
|
- Redis::lpush('updateProgress', $project_id);
|
|
|
|
81
|
}
|
78
|
}
|
|
82
|
}
|
79
|
}
|
|
|
|
80
|
+ echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
|
|
83
|
return true;
|
81
|
return true;
|
|
84
|
}
|
82
|
}
|
|
85
|
} |
83
|
} |