From 473325037b8c645b4227cb1943c4caf8ad24bdf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Thu, 17 Jun 2021 13:53:37 +0800 Subject: [PATCH] Update Queue.php --- app/admin/controller/Queue.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/Queue.php b/app/admin/controller/Queue.php index 7732ea3e4..843eb2dd2 100644 --- a/app/admin/controller/Queue.php +++ b/app/admin/controller/Queue.php @@ -54,15 +54,18 @@ class Queue extends Controller $this->command = "sudo -u {$_SERVER['USER']} {$process->think('xadmin:queue start')}"; } } + // 任务状态统计 $this->total = ['dos' => 0, 'pre' => 0, 'oks' => 0, 'ers' => 0]; $query = $this->app->db->name($this->table)->field('status,count(1) count'); - foreach ($query->group('status')->select()->toArray() as $item) { + $query->group('status')->select()->map(function ($item) { if ($item['status'] === 1) $this->total['pre'] = $item['count']; if ($item['status'] === 2) $this->total['dos'] = $item['count']; if ($item['status'] === 3) $this->total['oks'] = $item['count']; if ($item['status'] === 4) $this->total['ers'] = $item['count']; - } + }); + + // 页面变量赋值 $this->title = '系统任务管理'; $this->iswin = ProcessService::instance()->iswin(); // 任务列表查询及分页