From 4bc8726015582cf2619b2482d354afdbfb7c0b2e Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 21 Aug 2019 15:15:03 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Queue.php | 32 +++++++++++++++++++++++++ application/admin/sys.php | 5 ++-- application/admin/view/queue/index.html | 16 +++++++++---- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/application/admin/controller/Queue.php b/application/admin/controller/Queue.php index 6f54930c9..d93cfe6c5 100644 --- a/application/admin/controller/Queue.php +++ b/application/admin/controller/Queue.php @@ -17,6 +17,7 @@ namespace app\admin\controller; use library\Controller; use think\Console; +use think\exception\HttpResponseException; /** * 系统系统任务 @@ -50,6 +51,7 @@ class Queue extends Controller $this->message = $exception->getMessage(); } $this->title = '系统任务管理'; + $this->iswin = PATH_SEPARATOR === ';'; $query = $this->_query($this->table)->dateBetween('create_at,end_at'); $query->like('title,preload')->equal('status')->order('id desc')->page(); } @@ -65,6 +67,36 @@ class Queue extends Controller $this->_save($this->table, ['status' => '1']); } + /** + * (WIN)创建任务监听进程 + * @auth true + */ + public function processStart() + { + try { + $this->success(nl2br(Console::call('xtask:start')->fetch())); + } catch (HttpResponseException $exception) { + throw $exception; + } catch (\Exception $e) { + $this->error($e->getMessage()); + } + } + + /** + * (WIN)停止任务监听进程 + * @auth true + */ + public function processStop() + { + try { + $this->success(nl2br(Console::call('xtask:stop')->fetch())); + } catch (HttpResponseException $exception) { + throw $exception; + } catch (\Exception $e) { + $this->error($e->getMessage()); + } + } + /** * 删除系统任务 * @auth true diff --git a/application/admin/sys.php b/application/admin/sys.php index 5507b05ae..02e079c95 100644 --- a/application/admin/sys.php +++ b/application/admin/sys.php @@ -87,14 +87,13 @@ if (!function_exists('sysqueue')) { $result = Db::name('SystemQueue')->insert([ 'title' => $title, 'preload' => $loade, 'data' => json_encode($data, JSON_UNESCAPED_UNICODE), - 'time' => ($later > 0 ? time() + $later : time()) - 3, - 'double' => intval($double), + 'time' => $later > 0 ? time() + $later : time(), + 'double' => intval($double), 'create_at' => date('Y-m-d H:i:s'), ]); return $result !== false; } } - if (!function_exists('local_image')) { /** * 下载远程文件到本地 diff --git a/application/admin/view/queue/index.html b/application/admin/view/queue/index.html index 3305b89d2..1157ff390 100644 --- a/application/admin/view/queue/index.html +++ b/application/admin/view/queue/index.html @@ -2,8 +2,16 @@ {block name="button"} -{if auth("admin/queue/remove")} - +{if auth("remove")} + +{/if} + +{if auth("processstart") && $iswin} + +{/if} + +{if auth("processstop") && $iswin} + {/if} {/block} @@ -36,8 +44,8 @@ 任务指令:{$vo.preload} - 创建时间:{$vo.create_at|format_datetime|raw}
- 跟进时间:{$vo.end_at|format_datetime|raw} + 创建时间:{$vo.create_at|format_datetime} / {$vo.time|format_datetime}
+ 执行时间:{$vo.start_at|format_datetime} / {$vo.end_at|format_datetime} 任务状态:{eq name='vo.double' value='1'}