作者 lyh

gx

@@ -9,6 +9,8 @@ @@ -9,6 +9,8 @@
9 9
10 namespace App\Console\Commands; 10 namespace App\Console\Commands;
11 11
  12 +use App\Models\Mail\Mail;
  13 +use App\Models\User\User;
12 use App\Services\ProjectServer; 14 use App\Services\ProjectServer;
13 use Illuminate\Console\Command; 15 use Illuminate\Console\Command;
14 use Illuminate\Support\Facades\DB; 16 use Illuminate\Support\Facades\DB;
@@ -39,15 +41,15 @@ class UpdateProgress extends Command @@ -39,15 +41,15 @@ class UpdateProgress extends Command
39 public function handle() 41 public function handle()
40 { 42 {
41 while (true){ 43 while (true){
42 - $project_id = Redis::rpop('updateSeoTdk'); 44 + $project_id = Redis::rpop('updateProgress');
43 if(!$project_id){ 45 if(!$project_id){
44 sleep(2); 46 sleep(2);
45 continue; 47 continue;
46 } 48 }
47 echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL; 49 echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
48 -  
49 try { 50 try {
50 ProjectServer::useProject($project_id); 51 ProjectServer::useProject($project_id);
  52 + $this->getUpdateProgress($project_id);
51 DB::disconnect('custom_mysql'); 53 DB::disconnect('custom_mysql');
52 }catch (\Exception $e){ 54 }catch (\Exception $e){
53 echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; 55 echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
@@ -63,10 +65,25 @@ class UpdateProgress extends Command @@ -63,10 +65,25 @@ class UpdateProgress extends Command
63 * @method :post 65 * @method :post
64 * @time :2023/11/1 10:47 66 * @time :2023/11/1 10:47
65 */ 67 */
66 - public function getUpdateProgress(){  
67 - $list = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->get();  
68 - if(!empty($list)){  
69 - $list = $list->toArray(); 68 + public function getUpdateProgress($project_id){
  69 + $info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first();
  70 + if(!empty($info)){
  71 + $time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60);
  72 + if($time > date("Y-m-d H:i:s")){
  73 + DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]);
  74 + //获取当前项目的用户
  75 + $user = new User();
  76 + $info = $user->read(['project_id'=>$project_id,'role'=>0]);
  77 + //发送站内信,请重新更新
  78 + $data["title"] = "页面更新通知";
  79 + $data["user_list"] = $info['id'];
  80 + $data["content"] = "部分页面更新超时,请重新更新,或联系管理员";
  81 + $mail = new Mail();
  82 + $mail->add($data);
  83 + }else{
  84 + Redis::lpush('updateProgress', $project_id);
  85 + }
70 } 86 }
  87 + return true;
71 } 88 }
72 } 89 }
@@ -141,7 +141,7 @@ class CNoticeController extends BaseController @@ -141,7 +141,7 @@ class CNoticeController extends BaseController
141 ]; 141 ];
142 $updateProgressModel = new UpdateProgress(); 142 $updateProgressModel = new UpdateProgress();
143 $updateProgressModel->insert($data); 143 $updateProgressModel->insert($data);
144 - Redis::lpush('updateProgress', $this->param['project_id']); 144 + Redis::lpush('updateProgress', $this->user['project_id']);
145 return true; 145 return true;
146 } 146 }
147 147