作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -42,7 +42,7 @@ class Count extends Command @@ -42,7 +42,7 @@ class Count extends Command
42 public function handle() 42 public function handle()
43 { 43 {
44 $list = DB::table('gl_project')->where('gl_project.extend_type','=',0) 44 $list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
45 - ->where('gl_project.type','!=',0) 45 + ->where('gl_project.type','!=',0)->where('gl_project.delete_status',0)
46 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') 46 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
47 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 47 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
48 ->select($this->selectParam())->get(); 48 ->select($this->selectParam())->get();
@@ -38,7 +38,7 @@ class InquiryMonthlyCount extends Command @@ -38,7 +38,7 @@ class InquiryMonthlyCount extends Command
38 */ 38 */
39 public function handle(){ 39 public function handle(){
40 $list = DB::table('gl_project')->where('gl_project.extend_type','=',0) 40 $list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
41 - ->where('gl_project.type','!=',0) 41 + ->where('gl_project.type','!=',0)->where('gl_project.delete_status',0)
42 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') 42 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
43 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 43 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
44 ->select($this->selectParam())->get()->toArray(); 44 ->select($this->selectParam())->get()->toArray();
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ServiceCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/1/29 15:29
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use App\Models\Devops\ServerConfig;
  13 +use App\Models\Project\Project;
  14 +use Illuminate\Console\Command;
  15 +
  16 +class ServiceCount extends Command
  17 +{
  18 + /**
  19 + * The name and signature of the console command.
  20 + *
  21 + * @var string
  22 + */
  23 + protected $signature = 'service_count';
  24 +
  25 + /**
  26 + * The console command description.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $description = '服务器数据库使用统计';
  31 +
  32 +
  33 + /**
  34 + * @remark :执行脚本
  35 + * @name :handle
  36 + * @author :lyh
  37 + * @method :post
  38 + * @time :2024/1/29 15:31
  39 + */
  40 + public function handle(){
  41 + return $this->serverConfigCount();
  42 + }
  43 +
  44 + /**
  45 + * @remark :域名统计统计
  46 + * @name :domainCount
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2024/1/29 15:33
  50 + */
  51 + public function serverConfigCount(){
  52 + $model = new ServerConfig();
  53 + $list = $model->list();
  54 + $projectModel = new Project();
  55 + foreach ($list as $v){
  56 + if($v['type'] == 1){
  57 + $count = $projectModel->formatQuery(['serve_id'=>$v['id']])->count();
  58 + //服务器
  59 + }else{
  60 + $count = $projectModel->formatQuery(['mysql_id'=>$v['id']])->count();
  61 + //数据库
  62 + }
  63 + $model->edit(['count'=>$count],['id'=>$v['id']]);
  64 + }
  65 + }
  66 +
  67 +}
@@ -59,17 +59,40 @@ class UpdateMainHtml extends Command @@ -59,17 +59,40 @@ class UpdateMainHtml extends Command
59 */ 59 */
60 public function handle(){ 60 public function handle(){
61 $projectModel = new Project(); 61 $projectModel = new Project();
62 - $list = $projectModel->list(['id'=>223]); 62 + $list = $projectModel->list(['is_upgrade'=>0,'type'=>['!=',0]]);
63 foreach ($list as $v){ 63 foreach ($list as $v){
64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
65 ProjectServer::useProject($v['id']); 65 ProjectServer::useProject($v['id']);
66 - $this->setBlogCustomContent(); 66 + $this->getVideoModule($v['id']);
67 DB::disconnect('custom_mysql'); 67 DB::disconnect('custom_mysql');
68 } 68 }
69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
70 } 70 }
71 71
72 /** 72 /**
  73 + * @remark :查看项目是否有video模块
  74 + * @name :getVideoModule
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2024/1/29 11:29
  78 + */
  79 + public function getVideoModule($project_id){
  80 + $customModel = new CustomModule();
  81 + $info = $customModel->read(['name'=>'视频模块']);
  82 + if($info === false){
  83 + echo date('Y-m-d H:i:s') . '添加,项目id:'.$project_id . PHP_EOL;
  84 + //执行添加
  85 + $data = [
  86 + 'name'=>'视频模块',
  87 + 'project_id'=>$project_id,
  88 + 'route'=>'video',
  89 + ];
  90 + $customModel->add($data);
  91 + }
  92 + return true;
  93 + }
  94 +
  95 + /**
73 * @remark :所有博客数据添加到自定义模块 96 * @remark :所有博客数据添加到自定义模块
74 * @name :setBlogCustom 97 * @name :setBlogCustom
75 * @author :lyh 98 * @author :lyh
@@ -26,6 +26,7 @@ class Kernel extends ConsoleKernel @@ -26,6 +26,7 @@ class Kernel extends ConsoleKernel
26 $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 26 $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
27 // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 27 // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
28 $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次 28 $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次
  29 + $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
29 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 30 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
30 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 31 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
31 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 32 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
@@ -14,6 +14,7 @@ use App\Http\Controllers\Bside\BaseController; @@ -14,6 +14,7 @@ use App\Http\Controllers\Bside\BaseController;
14 use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; 14 use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
15 use App\Models\CustomModule\CustomModuleCategory; 15 use App\Models\CustomModule\CustomModuleCategory;
16 use App\Models\CustomModule\CustomModuleContent; 16 use App\Models\CustomModule\CustomModuleContent;
  17 +use App\Models\RouteMap\RouteMap;
17 use App\Models\User\User; 18 use App\Models\User\User;
18 19
19 class CustomModuleContentController extends BaseController 20 class CustomModuleContentController extends BaseController
@@ -36,6 +37,7 @@ class CustomModuleContentController extends BaseController @@ -36,6 +37,7 @@ class CustomModuleContentController extends BaseController
36 if(!empty($lists)){ 37 if(!empty($lists)){
37 $data = $this->getAllCategoryName(); 38 $data = $this->getAllCategoryName();
38 foreach ($lists['list'] as $k=>$v){ 39 foreach ($lists['list'] as $k=>$v){
  40 + $v['url'] = $this->getUrl($v);
39 $v['category_name'] = $this->categoryName($v['category_id'],$data); 41 $v['category_name'] = $this->categoryName($v['category_id'],$data);
40 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']); 42 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
41 $v['operator_name'] = (new User())->getName($v['operator_id']); 43 $v['operator_name'] = (new User())->getName($v['operator_id']);
@@ -46,6 +48,27 @@ class CustomModuleContentController extends BaseController @@ -46,6 +48,27 @@ class CustomModuleContentController extends BaseController
46 } 48 }
47 49
48 /** 50 /**
  51 + * @remark :获取连接
  52 + * @name :getUrl
  53 + * @author :lyh
  54 + * @method :post
  55 + * @time :2024/1/29 14:56
  56 + */
  57 + public function getUrl($v){
  58 + $routeMapModel = new RouteMap();
  59 + if(!empty($v) && !empty($v['category_id'])){
  60 + $categoryIdArr = $v['category_id'];
  61 + $cate_id = (int)array_shift($categoryIdArr);
  62 + $routeInfo = $routeMapModel->read(['source'=>RouteMap::SOURCE_MODULE_CATE,'source_id'=>$cate_id]);
  63 + $v['path'] = ($routeInfo['route'] ?? '');
  64 + if(!empty($v['path'])){
  65 + $v['path'] = $v['path'].'/';
  66 + }
  67 + }
  68 + return $this->user['domain'].$v['path'].$v['route'];
  69 + }
  70 +
  71 + /**
49 * @remark :获取所有分类名称 72 * @remark :获取所有分类名称
50 * @name :getAllCategoryName 73 * @name :getAllCategoryName
51 * @author :lyh 74 * @author :lyh
@@ -133,6 +133,7 @@ class ProjectLogic extends BaseLogic @@ -133,6 +133,7 @@ class ProjectLogic extends BaseLogic
133 public function projectSave(){ 133 public function projectSave(){
134 DB::beginTransaction(); 134 DB::beginTransaction();
135 try { 135 try {
  136 + $this->param['project_location'] = 0;//TODO::图片文件存储不同地方,上线后删除
136 if($this->param['type'] == Project::TYPE_SEVEN){ 137 if($this->param['type'] == Project::TYPE_SEVEN){
137 //错误单直接返回,单独处理 138 //错误单直接返回,单独处理
138 $this->setTypeSevenEdit($this->param); 139 $this->setTypeSevenEdit($this->param);
@@ -47,20 +47,19 @@ class CopyProjectJob implements ShouldQueue @@ -47,20 +47,19 @@ class CopyProjectJob implements ShouldQueue
47 * @param UpdateHtml $event 47 * @param UpdateHtml $event
48 * @return void 48 * @return void
49 */ 49 */
50 - public function handle(CopyProject $event) 50 + public function handle()
51 { 51 {
52 - $this->param = $event->data;  
53 - $this->model = new Project(); 52 + $projectModel = new Project();
54 DB::beginTransaction(); 53 DB::beginTransaction();
55 try { 54 try {
56 //复制初始项目 55 //复制初始项目
57 - $data = $this->model::where('id', $this->param['project_id'])->first(); 56 + $data = $projectModel::where('id', $this->param['project_id'])->first();
58 $data = $data->getAttributes(); 57 $data = $data->getAttributes();
59 $type = $data['type']; 58 $type = $data['type'];
60 $data['type'] = 0; 59 $data['type'] = 0;
61 $data['title'] = $data['title'].'-copy'; 60 $data['title'] = $data['title'].'-copy';
62 unset($data['id']); 61 unset($data['id']);
63 - $project_id = $this->model->insertGetId($data); 62 + $project_id = $projectModel->insertGetId($data);
64 //复制部署表 63 //复制部署表
65 $buildModel = new DeployBuild(); 64 $buildModel = new DeployBuild();
66 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first(); 65 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();