mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate
This commit is contained in:
parent
7c56cab8e3
commit
9b6ec3378f
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -937,12 +937,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "6095c8e362118fd00d00f924a7ec342859e88104"
|
"reference": "7fc5a459d6d05cb905b1e0c604a50e9a36795ecb"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/6095c8e362118fd00d00f924a7ec342859e88104",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7fc5a459d6d05cb905b1e0c604a50e9a36795ecb",
|
||||||
"reference": "6095c8e362118fd00d00f924a7ec342859e88104",
|
"reference": "7fc5a459d6d05cb905b1e0c604a50e9a36795ecb",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -959,7 +959,7 @@
|
|||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2020-12-10T08:26:28+00:00",
|
"time": "2020-12-15T10:00:46+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2020-12-14 18:23:12
|
// This file is automatically generated at:2020-12-15 18:12:50
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\admin\\Library',
|
0 => 'think\\admin\\Library',
|
||||||
|
@ -70,13 +70,14 @@ abstract class Command extends ThinkCommand
|
|||||||
/**
|
/**
|
||||||
* 设置进度消息并继续执行
|
* 设置进度消息并继续执行
|
||||||
* @param null|string $message 进度消息
|
* @param null|string $message 进度消息
|
||||||
* @param null|integer $progress 进度数值
|
* @param null|float $progress 进度数值
|
||||||
|
* @param integer $backline 回退行数
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
protected function setQueueProgress(?string $message = null, $progress = null)
|
protected function setQueueProgress(?string $message = null, $progress = null, $backline = 0): Command
|
||||||
{
|
{
|
||||||
if (defined('WorkQueueCode')) {
|
if (defined('WorkQueueCode')) {
|
||||||
$this->queue->progress(2, $message, $progress);
|
$this->queue->progress(2, $message, $progress, $backline);
|
||||||
} elseif (is_string($message)) {
|
} elseif (is_string($message)) {
|
||||||
$this->output->writeln($message);
|
$this->output->writeln($message);
|
||||||
}
|
}
|
||||||
|
7
vendor/zoujingli/think-library/src/Queue.php
vendored
7
vendor/zoujingli/think-library/src/Queue.php
vendored
@ -77,12 +77,13 @@ abstract class Queue
|
|||||||
/**
|
/**
|
||||||
* 设置任务的进度
|
* 设置任务的进度
|
||||||
* @param null|string $message 进度消息
|
* @param null|string $message 进度消息
|
||||||
* @param null|integer $progress 进度数值
|
* @param null|float $progress 进度数值
|
||||||
|
* @param integer $backline 回退行数
|
||||||
* @return Queue
|
* @return Queue
|
||||||
*/
|
*/
|
||||||
protected function setQueueProgress(?string $message = null, $progress = null): Queue
|
protected function setQueueProgress(?string $message = null, $progress = null, $backline = 0): Queue
|
||||||
{
|
{
|
||||||
$this->queue->progress(2, $message, $progress);
|
$this->queue->progress(2, $message, $progress, $backline);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ class Queue extends Command
|
|||||||
$this->updateQueue(3, $this->app->console->call(array_shift($attr), $attr)->fetch(), false);
|
$this->updateQueue(3, $this->app->console->call(array_shift($attr), $attr)->fetch(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception|\Error|\Throwable $exception) {
|
} catch (\Exception | \Error | \Throwable $exception) {
|
||||||
$code = $exception->getCode();
|
$code = $exception->getCode();
|
||||||
if (intval($code) !== 3) $code = 4;
|
if (intval($code) !== 3) $code = 4;
|
||||||
$this->updateQueue($code, $exception->getMessage());
|
$this->updateQueue($code, $exception->getMessage());
|
||||||
@ -333,7 +333,7 @@ class Queue extends Command
|
|||||||
if (isset($this->queue->record['loops_time']) && $this->queue->record['loops_time'] > 0) {
|
if (isset($this->queue->record['loops_time']) && $this->queue->record['loops_time'] > 0) {
|
||||||
try {
|
try {
|
||||||
$this->queue->initialize($this->code)->reset($this->queue->record['loops_time']);
|
$this->queue->initialize($this->code)->reset($this->queue->record['loops_time']);
|
||||||
} catch (\Exception|\Error|\Throwable $exception) {
|
} catch (\Exception | \Error | \Throwable $exception) {
|
||||||
$this->app->log->error("Queue {$this->queue->record['code']} Loops Failed. {$exception->getMessage()}");
|
$this->app->log->error("Queue {$this->queue->record['code']} Loops Failed. {$exception->getMessage()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,9 +154,10 @@ class QueueService extends Service
|
|||||||
* @param null|integer $status 任务状态
|
* @param null|integer $status 任务状态
|
||||||
* @param null|string $message 进度消息
|
* @param null|string $message 进度消息
|
||||||
* @param null|float $progress 进度数值
|
* @param null|float $progress 进度数值
|
||||||
|
* @param integer $backline 回退信息行
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function progress(?int $status = null, ?string $message = null, $progress = null): array
|
public function progress(?int $status = null, ?string $message = null, $progress = null, $backline = 0): array
|
||||||
{
|
{
|
||||||
$ckey = "queue_{$this->code}_progress";
|
$ckey = "queue_{$this->code}_progress";
|
||||||
if (is_numeric($status) && intval($status) === 3) {
|
if (is_numeric($status) && intval($status) === 3) {
|
||||||
@ -171,8 +172,11 @@ class QueueService extends Service
|
|||||||
$data = $this->app->cache->get($ckey, [
|
$data = $this->app->cache->get($ckey, [
|
||||||
'code' => $this->code, 'status' => $status, 'message' => $message, 'progress' => $progress, 'history' => [],
|
'code' => $this->code, 'status' => $status, 'message' => $message, 'progress' => $progress, 'history' => [],
|
||||||
]);
|
]);
|
||||||
} catch (\Exception|\Error $exception) {
|
} catch (\Exception | \Error $exception) {
|
||||||
return $this->progress($status, $message, $progress);
|
return $this->progress($status, $message, $progress, $backline);
|
||||||
|
}
|
||||||
|
while (count($data['history']) > 0 && $backline > 0) {
|
||||||
|
[--$backline, array_pop($data['history'])];
|
||||||
}
|
}
|
||||||
if (is_numeric($status)) $data['status'] = intval($status);
|
if (is_numeric($status)) $data['status'] = intval($status);
|
||||||
if (is_numeric($progress)) $progress = str_pad(sprintf("%.2f", $progress), 6, '0', STR_PAD_LEFT);
|
if (is_numeric($progress)) $progress = str_pad(sprintf("%.2f", $progress), 6, '0', STR_PAD_LEFT);
|
||||||
@ -201,14 +205,15 @@ class QueueService extends Service
|
|||||||
* @param integer $total 记录总和
|
* @param integer $total 记录总和
|
||||||
* @param integer $used 当前记录
|
* @param integer $used 当前记录
|
||||||
* @param string $message 文字描述
|
* @param string $message 文字描述
|
||||||
|
* @param integer $backline 回退行数
|
||||||
*/
|
*/
|
||||||
public function message(int $total, int $used, string $message = ''): void
|
public function message(int $total, int $used, string $message = '', $backline = 0): void
|
||||||
{
|
{
|
||||||
$total = $total < 1 ? 1 : $total;
|
$total = $total < 1 ? 1 : $total;
|
||||||
$prefix = str_pad("{$used}", strlen("{$total}"), '0', STR_PAD_LEFT);
|
$prefix = str_pad("{$used}", strlen("{$total}"), '0', STR_PAD_LEFT);
|
||||||
$message = "[{$prefix}/{$total}] {$message}";
|
$message = "[{$prefix}/{$total}] {$message}";
|
||||||
if (defined('WorkQueueCode')) {
|
if (defined('WorkQueueCode')) {
|
||||||
$this->progress(2, $message, sprintf("%.2f", $used / $total * 100));
|
$this->progress(2, $message, sprintf("%.2f", $used / $total * 100), $backline);
|
||||||
} else {
|
} else {
|
||||||
echo $message . PHP_EOL;
|
echo $message . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user