[更新]修改系统任务管理

This commit is contained in:
Anyon 2019-08-05 10:23:40 +08:00
parent 986bbcfc1d
commit 43a3883247
4 changed files with 29 additions and 24 deletions

View File

@ -15,9 +15,11 @@
namespace app\admin\controller;
use app\admin\service\QueueService;
use library\Controller;
use think\Console;
use think\Db;
use think\exception\HttpResponseException;
/**
* 系统系统任务
@ -44,12 +46,17 @@ class Queue extends Controller
*/
public function index()
{
$this->title = '系统任务管理';
if (session('admin_user.username') === 'admin') {
$this->cmd = 'php ' . env('root_path') . 'think xtask:start';
$this->message = Console::call('xtask:state')->fetch();
try {
$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');
// 查询任务列表
$query = $this->_query($this->table)->dateBetween('create_at,status_at');
$query->equal('status,title,uri')->order('id desc')->page();
}
@ -61,13 +68,12 @@ class Queue extends Controller
public function redo()
{
try {
$where = ['id' => $this->request->post('id')];
$info = Db::name($this->table)->where($where)->find();
if (empty($info)) $this->error('需要重置的任务获取异常!');
$info = Db::name($this->table)->where(['id' => input('id', '0')])->find();
if (empty($info)) $this->error('任务读取异常!');
$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'));
} catch (\think\exception\HttpResponseException $exception) {
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("任务重置失败,请稍候再试!<br> {$e->getMessage()}");
@ -82,12 +88,11 @@ class Queue extends Controller
{
try {
$isNot = false;
foreach (explode(',', $this->request->post('id', '0')) as $id) {
if (!\app\admin\service\QueueService::del($id)) $isNot = true;
}
$this->ids = explode(',', input('id', '0'));
foreach ($this->ids as $id) if (!QueueService::del($id)) $isNot = true;
if (empty($isNot)) $this->_delete($this->table);
$this->success($isNot ? '部分任务删除成功!' : '任务删除成功!');
} catch (\think\exception\HttpResponseException $exception) {
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("任务删除失败,请稍候再试!<br> {$e->getMessage()}");

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec::getLoader();
return ComposerAutoloaderInit5db223320ef8cea4a172beae38ba2159::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec
class ComposerAutoloaderInit5db223320ef8cea4a172beae38ba2159
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec
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();
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());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit5db223320ef8cea4a172beae38ba2159::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInitbf3d7bafba7856774655ae55ece6c5ec
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirebf3d7bafba7856774655ae55ece6c5ec($fileIdentifier, $file);
composerRequire5db223320ef8cea4a172beae38ba2159($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequirebf3d7bafba7856774655ae55ece6c5ec($fileIdentifier, $file)
function composerRequire5db223320ef8cea4a172beae38ba2159($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec
class ComposerStaticInit5db223320ef8cea4a172beae38ba2159
{
public static $files = array (
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
@ -347,9 +347,9 @@ class ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbf3d7bafba7856774655ae55ece6c5ec::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5db223320ef8cea4a172beae38ba2159::$classMap;
}, null, ClassLoader::class);
}