作者 周海龙

合并分支 'zhl' 到 'master'

添加@功能,推送关键词加规则



查看合并请求 !1900
@@ -9,6 +9,7 @@ namespace App\Console\Commands\Monitor; @@ -9,6 +9,7 @@ namespace App\Console\Commands\Monitor;
9 9
10 use App\Models\Domain\DomainInfo; 10 use App\Models\Domain\DomainInfo;
11 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
  12 +use App\Models\Project\DeployOptimize;
12 use App\Models\Project\OnlineCheck; 13 use App\Models\Project\OnlineCheck;
13 use App\Models\Project\Project; 14 use App\Models\Project\Project;
14 use App\Repositories\ToolRepository; 15 use App\Repositories\ToolRepository;
@@ -259,9 +260,29 @@ class Supervisory extends Command @@ -259,9 +260,29 @@ class Supervisory extends Command
259 file_put_contents(storage_path('data/robots/' . date('Ymd'). 'log.json'), json_encode($tmp, 256)); 260 file_put_contents(storage_path('data/robots/' . date('Ymd'). 'log.json'), json_encode($tmp, 256));
260 unset($tmp); 261 unset($tmp);
261 262
  263 + // 所有路由
262 $domain = array_column($spot_projects, 'domain'); 264 $domain = array_column($spot_projects, 'domain');
263 $domain = array_unique(array_filter($domain)); 265 $domain = array_unique(array_filter($domain));
264 266
  267 + // 通知对应优化师
  268 + $tmp = [];
  269 + foreach ($spot_projects as $item) {
  270 + $tmp[$item['domain']] = $item['project_id'];
  271 + }
  272 + $project_ids = array_column($spot_projects, 'project_id');
  273 + $optimist = DeployOptimize::leftJoin('gl_manage', 'gl_project_deploy_optimize.optimist_mid', '=', 'gl_manage.id')
  274 + ->whereIn('project_id', $project_ids)
  275 + ->pluck('mobile', 'project_id')
  276 + ->toArray();
  277 +
  278 + $notice = [];
  279 + $all_url = array_merge($error_url, $error, $page_404, $tdk_error);
  280 + foreach ($all_url as $url) {
  281 + if (FALSE == empty($optimist[$tmp[parse_url($url, PHP_URL_HOST)]]))
  282 + $notice[] = '86' . $optimist[$tmp[parse_url($url, PHP_URL_HOST)]];
  283 + }
  284 + $notice = array_filter(array_unique($notice));
  285 +
265 $message[] = '开启robots项目数:' . count($robots_ids); 286 $message[] = '开启robots项目数:' . count($robots_ids);
266 $message[] = '关闭robots项目:' . ($close_ids ? implode(',', $close_ids) : '无'); 287 $message[] = '关闭robots项目:' . ($close_ids ? implode(',', $close_ids) : '无');
267 $message[] = '抽查项目数量: ' . count($domain); 288 $message[] = '抽查项目数量: ' . count($domain);
@@ -282,6 +303,7 @@ class Supervisory extends Command @@ -282,6 +303,7 @@ class Supervisory extends Command
282 'keyword' => '项目数据推送', 303 'keyword' => '项目数据推送',
283 'msg' => $msg, 304 'msg' => $msg,
284 'isAtAll' => false, // 是否@所有人 305 'isAtAll' => false, // 是否@所有人
  306 + 'atMobiles' => $notice
285 ]; 307 ];
286 $dingService->handle($body, $link); 308 $dingService->handle($body, $link);
287 } 309 }
@@ -10,6 +10,7 @@ use App\Models\RouteMap\RouteMap; @@ -10,6 +10,7 @@ use App\Models\RouteMap\RouteMap;
10 use App\Services\ProjectServer; 10 use App\Services\ProjectServer;
11 use Illuminate\Database\Eloquent\SoftDeletes; 11 use Illuminate\Database\Eloquent\SoftDeletes;
12 use Illuminate\Support\Facades\DB; 12 use Illuminate\Support\Facades\DB;
  13 +use Illuminate\Support\Str;
13 14
14 class Keyword extends Base 15 class Keyword extends Base
15 { 16 {
@@ -136,6 +137,18 @@ class Keyword extends Base @@ -136,6 +137,18 @@ class Keyword extends Base
136 foreach ($suffix_array as $suffix) { 137 foreach ($suffix_array as $suffix) {
137 array_push($result, trim($keyword . $suffix)); 138 array_push($result, trim($keyword . $suffix));
138 array_push($result, trim($prefix . $keyword . $suffix)); 139 array_push($result, trim($prefix . $keyword . $suffix));
  140 +
  141 + // 复数形式, 需要将单数的词也拼接上
  142 + if (Str::contains($suffix, ['Products', 'Exporters', 'Suppliers', 'Manufacturers'])) {
  143 + $suffix = trim($suffix, 's');
  144 + array_push($result, trim($keyword . $suffix));
  145 + array_push($result, trim($prefix . $keyword . $suffix));
  146 + }
  147 + if (Str::contains($suffix, [ 'Companies', 'Factories'])) {
  148 + $suffix = trim($suffix, 'ies');
  149 + array_push($result, trim($keyword . $suffix . 'y'));
  150 + array_push($result, trim($prefix . $keyword . $suffix . 'y'));
  151 + }
139 } 152 }
140 } catch (\Exception $e) { 153 } catch (\Exception $e) {
141 continue; 154 continue;
@@ -39,7 +39,7 @@ class DingService @@ -39,7 +39,7 @@ class DingService
39 'content' => $body['keyword'] . PHP_EOL . $body['msg'] 39 'content' => $body['keyword'] . PHP_EOL . $body['msg']
40 ], 40 ],
41 'at' => [ 41 'at' => [
42 - 'atMobiles' => [], 42 + 'atMobiles' => $body['atMobiles'],
43 'atUserIds' => [], 43 'atUserIds' => [],
44 'isAtAll' => $body['isAtAll'], 44 'isAtAll' => $body['isAtAll'],
45 ] 45 ]