From b08ca4c9bb6833fe6334a4786d0557c1a75f5ac3 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 14 May 2020 16:52:42 +0800 Subject: [PATCH] ComposerUpdate --- composer.lock | 8 ++-- vendor/composer/installed.json | 8 ++-- vendor/services.php | 2 +- .../think-library/src/command/Queue.php | 24 +++++++---- .../think-library/src/extend/DataExtend.php | 41 +++++++++---------- .../think-library/src/extend/ExcelExtend.php | 2 +- .../think-library/src/extend/HttpExtend.php | 4 +- .../src/service/AdminService.php | 2 +- .../src/service/SystemService.php | 16 ++++++-- 9 files changed, 62 insertions(+), 45 deletions(-) diff --git a/composer.lock b/composer.lock index 0d487cbb1..350ff4bed 100644 --- a/composer.lock +++ b/composer.lock @@ -915,12 +915,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9" + "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ac00eec5a084eecf07d4260d975fc2f3f52659d9", - "reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/38dabf5b9074b0f87de24aab4f4e939a06ef93ac", + "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac", "shasum": "", "mirrors": [ { @@ -964,7 +964,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-05-12T02:34:46+00:00" + "time": "2020-05-13T02:56:23+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 90d162ff1..ecf95f66a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -941,12 +941,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9" + "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ac00eec5a084eecf07d4260d975fc2f3f52659d9", - "reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/38dabf5b9074b0f87de24aab4f4e939a06ef93ac", + "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac", "shasum": "", "mirrors": [ { @@ -962,7 +962,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-05-12T02:34:46+00:00", + "time": "2020-05-13T02:56:23+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 9499da31f..c764b4eb1 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/command/Queue.php b/vendor/zoujingli/think-library/src/command/Queue.php index 06833ee8d..4de644a47 100644 --- a/vendor/zoujingli/think-library/src/command/Queue.php +++ b/vendor/zoujingli/think-library/src/command/Queue.php @@ -124,15 +124,25 @@ class Queue extends Command */ protected function cleanAction() { + // 清理 7 天前的历史任务记录 $map = [['exec_time', '<', time() - 7 * 24 * 3600]]; - $count1 = $this->app->db->name($this->table)->where($map)->delete(); - $this->setQueueProgress("清理 {$count1} 条历史任务成功"); - // 重置超60分钟无响应的记录 + $count = $this->app->db->name($this->table)->where($map)->delete(); + $this->setQueueProgress("本次清理了 {$count} 条历史任务记录"); + // 标记超过 1 小时未完成的任务为失败状态 $map = [['exec_time', '<', time() - 3600], ['status', '=', '2']]; - $count2 = $this->app->db->name($this->table)->where($map)->update([ - 'status' => '4', 'exec_desc' => '任务执行超时,已自动标识为失败!', - ]); - $this->setQueueProgress("处理 {$count2} 条超时间任务成功", 100); + list($used, $total) = [0, $this->app->db->name($this->table)->where($map)->count()]; + $this->app->db->name($this->table)->where($map)->chunk(100, function (Collection $result) use ($total, &$used) { + foreach ($result->toArray() as $item) { + $stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}"; + $this->setQueueProgress("[{$stridx}] 正在标记任务 {$item['code']} 超时", $used / $total * 100); + $item['loops_time'] > 0 ? $this->app->db->name($this->table)->where(['id' => $item['id']])->update([ + 'status' => 2, 'exec_desc' => '任务执行超时,已自动重置任务待!', + ]) : $this->app->db->name($this->table)->where(['id' => $item['id']])->update([ + 'status' => 4, 'exec_desc' => '任务执行超时,已自动标识为失败!', + ]); + } + }); + $this->setQueueSuccess("清理 {$count} 条历史任务,标识 {$total} 条超时任务"); } /** diff --git a/vendor/zoujingli/think-library/src/extend/DataExtend.php b/vendor/zoujingli/think-library/src/extend/DataExtend.php index 936761165..94658f0ef 100644 --- a/vendor/zoujingli/think-library/src/extend/DataExtend.php +++ b/vendor/zoujingli/think-library/src/extend/DataExtend.php @@ -24,45 +24,42 @@ class DataExtend { /** - * 一维数据数组生成数据树 - * @param array $list 数据列表 - * @param string $key ID_KEY - * @param string $pkey PID_KEY - * @param string $skey 子数据名称 + * 一维数组生成数据树 + * @param array $list 待处理数据 + * @param string $cid 自己的主键 + * @param string $pid 上级的主键 + * @param string $sub 子数组名称 * @return array */ - public static function arr2tree($list, $key = 'id', $pkey = 'pid', $skey = 'sub') + public static function arr2tree($list, $cid = 'id', $pid = 'pid', $sub = 'sub') { - list($tree, $map) = [[], []]; - foreach ($list as $item) $map[$item[$key]] = $item; - foreach ($list as $item) if (isset($item[$pkey]) && isset($map[$item[$pkey]])) { - $map[$item[$pkey]][$skey][] = &$map[$item[$key]]; - } else $tree[] = &$map[$item[$key]]; - unset($map); + list($tree, $tmp) = [[], array_combine(array_column($list, $cid), array_values($list))]; + foreach ($list as $vo) isset($vo[$pid]) && isset($tmp[$vo[$pid]]) ? $tmp[$vo[$pid]][$sub][] = &$tmp[$vo[$cid]] : $tree[] = &$tmp[$vo[$cid]]; + unset($tmp, $list); return $tree; } /** - * 一维数据数组生成数据树 - * @param array $list 数据列表 - * @param string $key ID_KEY - * @param string $pkey PID_KEY - * @param string $path - * @param string $ppath + * 一维数组生成数据树 + * @param array $list 待处理数据 + * @param string $cid 自己的主键 + * @param string $pid 上级的主键 + * @param string $cpath 当前 PATH + * @param string $ppath 上级 PATH * @return array */ - public static function arr2table(array $list, $key = 'id', $pkey = 'pid', $path = 'path', $ppath = '') + public static function arr2table(array $list, $cid = 'id', $pid = 'pid', $cpath = 'path', $ppath = '') { $tree = []; - foreach (self::arr2tree($list, $key, $pkey) as $attr) { - $attr[$path] = "{$ppath}-{$attr[$key]}"; + foreach (self::arr2tree($list, $cid, $pid) as $attr) { + $attr[$cpath] = "{$ppath}-{$attr[$cid]}"; $attr['sub'] = isset($attr['sub']) ? $attr['sub'] : []; $attr['spt'] = substr_count($ppath, '-'); $attr['spl'] = str_repeat(" ├ ", $attr['spt']); $sub = $attr['sub']; unset($attr['sub']); $tree[] = $attr; - if (!empty($sub)) $tree = array_merge($tree, self::arr2table($sub, $key, $pkey, $path, $attr[$path])); + if (!empty($sub)) $tree = array_merge($tree, self::arr2table($sub, $cid, $pid, $cpath, $attr[$cpath])); } return $tree; } diff --git a/vendor/zoujingli/think-library/src/extend/ExcelExtend.php b/vendor/zoujingli/think-library/src/extend/ExcelExtend.php index d43d655e7..46e235a28 100644 --- a/vendor/zoujingli/think-library/src/extend/ExcelExtend.php +++ b/vendor/zoujingli/think-library/src/extend/ExcelExtend.php @@ -16,7 +16,7 @@ namespace think\admin\extend; /** - * 转出CSV文件扩展 + * 导出CSV文件扩展 * Class ExcelExtend * @package think\admin\extend */ diff --git a/vendor/zoujingli/think-library/src/extend/HttpExtend.php b/vendor/zoujingli/think-library/src/extend/HttpExtend.php index bcaeccee3..de876ef81 100644 --- a/vendor/zoujingli/think-library/src/extend/HttpExtend.php +++ b/vendor/zoujingli/think-library/src/extend/HttpExtend.php @@ -174,7 +174,7 @@ class HttpExtend private static function getUserAgent() { if (!empty($_SERVER['HTTP_USER_AGENT'])) return $_SERVER['HTTP_USER_AGENT']; - $agents = [ + $aligs = [ "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0", @@ -185,6 +185,6 @@ class HttpExtend "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11", ]; - return $agents[array_rand($agents, 1)]; + return $aligs[array_rand($aligs, 1)]; } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/service/AdminService.php b/vendor/zoujingli/think-library/src/service/AdminService.php index 5b700bfff..e26f30a69 100644 --- a/vendor/zoujingli/think-library/src/service/AdminService.php +++ b/vendor/zoujingli/think-library/src/service/AdminService.php @@ -50,7 +50,7 @@ class AdminService extends Service */ public function getUserId() { - return $this->app->session->get('user.id', 0); + return intval($this->app->session->get('user.id', 0)); } /** diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index e2aa4b9a3..46ed3d544 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -73,9 +73,19 @@ class SystemService extends Service return htmlspecialchars($value); }, $this->data[$type])); } else { - if (isset($this->data[$type]) && isset($this->data[$type][$field])) { - return $outer === 'raw' ? $this->data[$type][$field] : htmlspecialchars($this->data[$type][$field]); - } else return ''; + if (isset($this->data[$type])) { + if ($field) { + if (isset($this->data[$type][$field])) { + return $outer === 'raw' ? $this->data[$type][$field] : htmlspecialchars($this->data[$type][$field]); + } + } else { + if ($outer === 'raw') foreach ($this->data[$type] as $key => $vo) { + $this->data[$type][$key] = htmlspecialchars($vo); + } + return $this->data[$type]; + } + } + return ''; } }