作者 张关杰

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

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