mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]修改系统任务管理
This commit is contained in:
parent
986bbcfc1d
commit
43a3883247
@ -15,9 +15,11 @@
|
|||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\admin\service\QueueService;
|
||||||
use library\Controller;
|
use library\Controller;
|
||||||
use think\Console;
|
use think\Console;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
use think\exception\HttpResponseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统系统任务
|
* 系统系统任务
|
||||||
@ -44,12 +46,17 @@ class Queue extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->title = '系统任务管理';
|
|
||||||
if (session('admin_user.username') === 'admin') {
|
if (session('admin_user.username') === 'admin') {
|
||||||
$this->cmd = 'php ' . env('root_path') . 'think xtask:start';
|
try {
|
||||||
$this->message = Console::call('xtask:state')->fetch();
|
$this->cmd = 'php ' . env('root_path') . 'think xtask:start';
|
||||||
|
$this->message = Console::call('xtask:state')->fetch();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->message = $exception->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->title = '系统任务管理';
|
||||||
$this->uris = Db::name($this->table)->distinct(true)->column('uri');
|
$this->uris = Db::name($this->table)->distinct(true)->column('uri');
|
||||||
|
// 查询任务列表
|
||||||
$query = $this->_query($this->table)->dateBetween('create_at,status_at');
|
$query = $this->_query($this->table)->dateBetween('create_at,status_at');
|
||||||
$query->equal('status,title,uri')->order('id desc')->page();
|
$query->equal('status,title,uri')->order('id desc')->page();
|
||||||
}
|
}
|
||||||
@ -61,13 +68,12 @@ class Queue extends Controller
|
|||||||
public function redo()
|
public function redo()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$where = ['id' => $this->request->post('id')];
|
$info = Db::name($this->table)->where(['id' => input('id', '0')])->find();
|
||||||
$info = Db::name($this->table)->where($where)->find();
|
if (empty($info)) $this->error('任务读取异常!');
|
||||||
if (empty($info)) $this->error('需要重置的任务获取异常!');
|
|
||||||
$data = isset($info['data']) ? json_decode($info['data'], true) : '[]';
|
$data = isset($info['data']) ? json_decode($info['data'], true) : '[]';
|
||||||
\app\admin\service\QueueService::add($info['title'], $info['uri'], $info['later'], $data, $info['double'], $info['desc']);
|
QueueService::add($info['title'], $info['uri'], $info['later'], $data, $info['double'], $info['desc']);
|
||||||
$this->success('任务重置成功!', url('@admin') . '#' . url('@admin/queue/index'));
|
$this->success('任务重置成功!', url('@admin') . '#' . url('@admin/queue/index'));
|
||||||
} catch (\think\exception\HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->error("任务重置失败,请稍候再试!<br> {$e->getMessage()}");
|
$this->error("任务重置失败,请稍候再试!<br> {$e->getMessage()}");
|
||||||
@ -82,12 +88,11 @@ class Queue extends Controller
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$isNot = false;
|
$isNot = false;
|
||||||
foreach (explode(',', $this->request->post('id', '0')) as $id) {
|
$this->ids = explode(',', input('id', '0'));
|
||||||
if (!\app\admin\service\QueueService::del($id)) $isNot = true;
|
foreach ($this->ids as $id) if (!QueueService::del($id)) $isNot = true;
|
||||||
}
|
|
||||||
if (empty($isNot)) $this->_delete($this->table);
|
if (empty($isNot)) $this->_delete($this->table);
|
||||||
$this->success($isNot ? '部分任务删除成功!' : '任务删除成功!');
|
$this->success($isNot ? '部分任务删除成功!' : '任务删除成功!');
|
||||||
} catch (\think\exception\HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->error("任务删除失败,请稍候再试!<br> {$e->getMessage()}");
|
$this->error("任务删除失败,请稍候再试!<br> {$e->getMessage()}");
|
||||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec::getLoader();
|
return ComposerAutoloaderInit5db223320ef8cea4a172beae38ba2159::getLoader();
|
||||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec
|
class ComposerAutoloaderInit5db223320ef8cea4a172beae38ba2159
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
@ -19,15 +19,15 @@ class ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec
|
|||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInit5db223320ef8cea4a172beae38ba2159', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInit5db223320ef8cea4a172beae38ba2159', 'loadClassLoader'));
|
||||||
|
|
||||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||||
if ($useStaticLoader) {
|
if ($useStaticLoader) {
|
||||||
require_once __DIR__ . '/autoload_static.php';
|
require_once __DIR__ . '/autoload_static.php';
|
||||||
|
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::getInitializer($loader));
|
call_user_func(\Composer\Autoload\ComposerStaticInit5db223320ef8cea4a172beae38ba2159::getInitializer($loader));
|
||||||
} else {
|
} else {
|
||||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||||
foreach ($map as $namespace => $path) {
|
foreach ($map as $namespace => $path) {
|
||||||
@ -48,19 +48,19 @@ class ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec
|
|||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
if ($useStaticLoader) {
|
if ($useStaticLoader) {
|
||||||
$includeFiles = Composer\Autoload\ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$files;
|
$includeFiles = Composer\Autoload\ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$files;
|
||||||
} else {
|
} else {
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
}
|
}
|
||||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
composerRequirebf3d7bafba7856774655ae55ece6c5ec($fileIdentifier, $file);
|
composerRequire5db223320ef8cea4a172beae38ba2159($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequirebf3d7bafba7856774655ae55ece6c5ec($fileIdentifier, $file)
|
function composerRequire5db223320ef8cea4a172beae38ba2159($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
require $file;
|
require $file;
|
||||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace Composer\Autoload;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec
|
class ComposerStaticInit5db223320ef8cea4a172beae38ba2159
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
|
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
|
||||||
@ -347,9 +347,9 @@ class ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec
|
|||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$classMap;
|
$loader->classMap = ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user