ComposerUpdate

This commit is contained in:
Anyon 2020-09-24 11:36:59 +08:00
parent 9c9e1f69a4
commit 468f8bd0e2
6 changed files with 46 additions and 25 deletions

View File

@ -958,17 +958,17 @@
}, },
{ {
"name": "zoujingli/think-library", "name": "zoujingli/think-library",
"version": "v6.0.12", "version": "v6.0.13",
"version_normalized": "6.0.12.0", "version_normalized": "6.0.13.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "a25e52f4f8af59ee55e33d00fff42ee919abba46" "reference": "4f492966b363a613ec7e89af47db0c59fe322350"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a25e52f4f8af59ee55e33d00fff42ee919abba46", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/4f492966b363a613ec7e89af47db0c59fe322350",
"reference": "a25e52f4f8af59ee55e33d00fff42ee919abba46", "reference": "4f492966b363a613ec7e89af47db0c59fe322350",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -985,7 +985,7 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-09-24T02:44:19+00:00", "time": "2020-09-24T03:26:07+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

View File

@ -41,7 +41,7 @@ class Library extends Service
/** /**
* 扩展库版本号 * 扩展库版本号
*/ */
const VERSION = '6.0.12'; const VERSION = '6.0.13';
/** /**
* 启动服务 * 启动服务

View File

@ -64,7 +64,7 @@ class Database extends Command
[$total, $used] = [count($tables = $this->getTables()), 0]; [$total, $used] = [count($tables = $this->getTables()), 0];
$this->setQueueProgress("总共需要修复 {$total} 张数据表", 0); $this->setQueueProgress("总共需要修复 {$total} 张数据表", 0);
foreach ($tables as $table) { foreach ($tables as $table) {
$stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}"; $stridx = progress_prefix($total, ++$used);
$this->setQueueProgress("[{$stridx}] 正在修复数据表 {$table}", $used / $total * 100); $this->setQueueProgress("[{$stridx}] 正在修复数据表 {$table}", $used / $total * 100);
$this->app->db->query("REPAIR TABLE `{$table}`"); $this->app->db->query("REPAIR TABLE `{$table}`");
} }
@ -83,7 +83,7 @@ class Database extends Command
[$total, $used] = [count($tables = $this->getTables()), 0]; [$total, $used] = [count($tables = $this->getTables()), 0];
$this->setQueueProgress("总共需要优化 {$total} 张数据表", 0); $this->setQueueProgress("总共需要优化 {$total} 张数据表", 0);
foreach ($tables as $table) { foreach ($tables as $table) {
$stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}"; $stridx = progress_prefix($total, ++$used);
$this->setQueueProgress("[{$stridx}] 正在优化数据表 {$table}", $used / $total * 100); $this->setQueueProgress("[{$stridx}] 正在优化数据表 {$table}", $used / $total * 100);
$this->app->db->query("OPTIMIZE TABLE `{$table}`"); $this->app->db->query("OPTIMIZE TABLE `{$table}`");
} }

View File

@ -114,20 +114,26 @@ class Install extends Command
} }
} }
protected function installFile() private function installFile()
{ {
$data = ModuleService::instance()->grenerateDifference($this->rules, $this->ignore); $module = ModuleService::instance();
if (empty($data)) $this->output->writeln('No need to update the file if the file comparison is consistent'); $data = $module->grenerateDifference($this->rules, $this->ignore);
else foreach ($data as $file) { if (empty($data)) {
[$state, $mode, $name] = ModuleService::instance()->updateFileByDownload($file); $this->output->writeln('No need to update the file if the file comparison is consistent');
if ($state) {
if ($mode === 'add') $this->output->writeln("--- {$name} add successfully");
if ($mode === 'mod') $this->output->writeln("--- {$name} update successfully");
if ($mode === 'del') $this->output->writeln("--- {$name} delete successfully");
} else { } else {
if ($mode === 'add') $this->output->writeln("--- {$name} add failed"); [$total, $used] = [count($data), 0];
if ($mode === 'mod') $this->output->writeln("--- {$name} update failed"); foreach ($data as $file) {
if ($mode === 'del') $this->output->writeln("--- {$name} delete failed"); $prefix = progress_prefix($total, ++$used);
[$state, $mode, $name] = $module->updateFileByDownload($file);
if ($state) {
if ($mode === 'add') $this->output->writeln("[{$prefix}] --- {$name} add successfully");
if ($mode === 'mod') $this->output->writeln("[{$prefix}] --- {$name} update successfully");
if ($mode === 'del') $this->output->writeln("[{$prefix}] --- {$name} delete successfully");
} else {
if ($mode === 'add') $this->output->writeln("[{$prefix}] --- {$name} add failed");
if ($mode === 'mod') $this->output->writeln("[{$prefix}] --- {$name} update failed");
if ($mode === 'del') $this->output->writeln("[{$prefix}] --- {$name} delete failed");
}
} }
} }
} }

View File

@ -189,12 +189,12 @@ class Queue extends Command
$this->app->db->name($this->table)->whereOr([$map1, $map2])->chunk(100, function (Collection $result) use ($total, &$loops, &$timeout) { $this->app->db->name($this->table)->whereOr([$map1, $map2])->chunk(100, function (Collection $result) use ($total, &$loops, &$timeout) {
foreach ($result->toArray() as $item) { foreach ($result->toArray() as $item) {
$item['loops_time'] > 0 ? $loops++ : $timeout++; $item['loops_time'] > 0 ? $loops++ : $timeout++;
$prefix = str_pad($timeout + $loops, strlen("{$total}"), 0, STR_PAD_LEFT); $prefix = progress_prefix($total, $timeout + $loops);
if ($item['loops_time'] > 0) { if ($item['loops_time'] > 0) {
$this->setQueueProgress("[{$prefix}/{$total}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total); $this->setQueueProgress("[{$prefix}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total);
[$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!']; [$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!'];
} else { } else {
$this->setQueueProgress("[{$prefix}/{$total}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total); $this->setQueueProgress("[{$prefix}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total);
[$status, $message] = [4, '任务执行超时,已自动标识为失败!']; [$status, $message] = [4, '任务执行超时,已自动标识为失败!'];
} }
$this->app->db->name($this->table)->where(['id' => $item['id']])->update(['status' => $status, 'exec_desc' => $message]); $this->app->db->name($this->table)->where(['id' => $item['id']])->update(['status' => $status, 'exec_desc' => $message]);

View File

@ -141,6 +141,7 @@ if (!function_exists('sysoplog')) {
return SystemService::instance()->setOplog($action, $content); return SystemService::instance()->setOplog($action, $content);
} }
} }
if (!function_exists('encode')) { if (!function_exists('encode')) {
/** /**
* 加密 UTF8 字符串 * 加密 UTF8 字符串
@ -282,3 +283,17 @@ if (!function_exists('down_file')) {
return $result['url'] ?? $source; return $result['url'] ?? $source;
} }
} }
if (!function_exists('progress_prefix')) {
/**
* 生成进度前缀文字
* @param integer $total
* @param integer $used
* @param string $char
* @return string
*/
function progress_prefix(int $total, int $used, string $char = '0'): string
{
return str_pad("{$used}", strlen("{$total}"), $char, STR_PAD_LEFT) . "/{$total}";
}
}