Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
8 个修改的文件
包含
64 行增加
和
132 行删除
| @@ -5,6 +5,7 @@ namespace App\Console\Commands; | @@ -5,6 +5,7 @@ namespace App\Console\Commands; | ||
| 5 | use App\Http\Controllers\File\FileController; | 5 | use App\Http\Controllers\File\FileController; |
| 6 | use App\Models\ProjectAssociation\ProjectAssociation; | 6 | use App\Models\ProjectAssociation\ProjectAssociation; |
| 7 | use App\Models\File\DataFile; | 7 | use App\Models\File\DataFile; |
| 8 | +use App\Services\CosService; | ||
| 8 | use Dompdf\Dompdf; | 9 | use Dompdf\Dompdf; |
| 9 | use Dompdf\Options; | 10 | use Dompdf\Options; |
| 10 | use Illuminate\Console\Command; | 11 | use Illuminate\Console\Command; |
| @@ -36,6 +37,8 @@ class ProjectFilePDF extends Command | @@ -36,6 +37,8 @@ class ProjectFilePDF extends Command | ||
| 36 | 37 | ||
| 37 | protected $fileController; | 38 | protected $fileController; |
| 38 | 39 | ||
| 40 | + protected $CosService; | ||
| 41 | + | ||
| 39 | // 最大支持5个进程 | 42 | // 最大支持5个进程 |
| 40 | public $maxRunNumber = 50; | 43 | public $maxRunNumber = 50; |
| 41 | 44 | ||
| @@ -50,6 +53,7 @@ class ProjectFilePDF extends Command | @@ -50,6 +53,7 @@ class ProjectFilePDF extends Command | ||
| 50 | $this->DataFile = new DataFile(); | 53 | $this->DataFile = new DataFile(); |
| 51 | $this->time = date("Y-m"); | 54 | $this->time = date("Y-m"); |
| 52 | $this->fileController = new FileController(); | 55 | $this->fileController = new FileController(); |
| 56 | + $this->CosService = new CosService(); | ||
| 53 | parent::__construct(); | 57 | parent::__construct(); |
| 54 | } | 58 | } |
| 55 | 59 | ||
| @@ -86,83 +90,28 @@ class ProjectFilePDF extends Command | @@ -86,83 +90,28 @@ class ProjectFilePDF extends Command | ||
| 86 | $this->debug_echo('pdf生成失败!'); | 90 | $this->debug_echo('pdf生成失败!'); |
| 87 | return 0; | 91 | return 0; |
| 88 | } | 92 | } |
| 89 | - $file_path = json_encode($file_path['data']); | ||
| 90 | - $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); | 93 | + $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); |
| 91 | if (!$isRes) { | 94 | if (!$isRes) { |
| 92 | if ($count == 2) { | 95 | if ($count == 2) { |
| 93 | $lists->is_pdf = 2; | 96 | $lists->is_pdf = 2; |
| 94 | $lists->save(); | 97 | $lists->save(); |
| 95 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); | 98 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); |
| 96 | } else { | 99 | } else { |
| 97 | - redis_add($key, $count + 1); | 100 | + redis_set($key, $count + 1); |
| 98 | $this->debug_echo('项目文件数据保存失败! - ' . $key); | 101 | $this->debug_echo('项目文件数据保存失败! - ' . $key); |
| 99 | } | 102 | } |
| 100 | } | 103 | } |
| 101 | $lists->is_pdf = 1; | 104 | $lists->is_pdf = 1; |
| 102 | $lists->save(); | 105 | $lists->save(); |
| 103 | - $this->debug_echo('项目文件数据保存成功!'); | 106 | + $this->info('项目文件数据保存成功!'); |
| 104 | return 0; | 107 | return 0; |
| 105 | } | 108 | } |
| 106 | 109 | ||
| 107 | - /** | ||
| 108 | - * Execute the console command. | ||
| 109 | - * | ||
| 110 | - * @return int | ||
| 111 | - */ | ||
| 112 | -// public function handle() | ||
| 113 | -// { | ||
| 114 | -// # 0 - 未生成 | ||
| 115 | -// # 1 - 已生成 | ||
| 116 | -// # 2 - 其它问题 | ||
| 117 | -// $is_pdf = 0; | ||
| 118 | -// $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf) | ||
| 119 | -// ->where('project_id', '!=', 0) | ||
| 120 | -// ->where('friend_id', '!=', 0) | ||
| 121 | -// ->where('user_id', '!=', 0) | ||
| 122 | -// ->where('created_at', 'like', $this->time . '%')->first(); | ||
| 123 | -// | ||
| 124 | -// if (is_null($lists)) { | ||
| 125 | -// $this->error('没有任务,等待中'); | ||
| 126 | -// sleep(60); | ||
| 127 | -// return 0; | ||
| 128 | -// } | ||
| 129 | -// $key = $this->signature . '-' . $lists->id; | ||
| 130 | -// $count = redis_get($key); | ||
| 131 | -// $project_id = $lists->project_id; | ||
| 132 | -// $user_id = $lists->user_id; | ||
| 133 | -// $friend_id = $lists->friend_id; | ||
| 134 | -// // todo 根据项目查询数据 | ||
| 135 | -// $project_data = []; | ||
| 136 | -// $html = $this->html($project_data); | ||
| 137 | -// $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id); | ||
| 138 | -// | ||
| 139 | -// $file_path = $this->savePDF($html, $filename); | ||
| 140 | -// if (empty($file_path)) { | ||
| 141 | -// $this->debug_echo('pdf生成失败!'); | ||
| 142 | -// return 0; | ||
| 143 | -// } | ||
| 144 | -// $file_path = $file_path['data']; | ||
| 145 | -// $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); | ||
| 146 | -// if (!$isRes) { | ||
| 147 | -// if ($count == 2) { | ||
| 148 | -// $lists->status = 2; | ||
| 149 | -// $lists->save(); | ||
| 150 | -// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key); | ||
| 151 | -// } else { | ||
| 152 | -// redis_add($key, $count + 1); | ||
| 153 | -// $this->error('项目文件数据保存失败! - ' . $key); | ||
| 154 | -// } | ||
| 155 | -// } | ||
| 156 | -// $lists->status = 1; | ||
| 157 | -// $lists->save(); | ||
| 158 | -// $this->info('项目文件数据保存成功!'); | ||
| 159 | -// return 0; | ||
| 160 | -// } | ||
| 161 | 110 | ||
| 162 | /** | 111 | /** |
| 163 | * @param $html | 112 | * @param $html |
| 164 | * @param $filename | 113 | * @param $filename |
| 165 | - * @return array | 114 | + * @return string |
| 166 | */ | 115 | */ |
| 167 | public function savePDF($html, $filename) | 116 | public function savePDF($html, $filename) |
| 168 | { | 117 | { |
| @@ -192,14 +141,14 @@ class ProjectFilePDF extends Command | @@ -192,14 +141,14 @@ class ProjectFilePDF extends Command | ||
| 192 | $dompdf->render(); | 141 | $dompdf->render(); |
| 193 | 142 | ||
| 194 | // 获取PDF内容 | 143 | // 获取PDF内容 |
| 195 | - $pdfContent = $dompdf->output(); | ||
| 196 | - $this->fileController->path = '/V6/PDF'; | 144 | + $pdfContent = $dompdf->output(); |
| 145 | + $path = '/V6/PDF/' . $this->time; | ||
| 197 | 146 | ||
| 198 | // 将PDF内容保存到文件 | 147 | // 将PDF内容保存到文件 |
| 199 | @file_put_contents($savePath, $pdfContent); | 148 | @file_put_contents($savePath, $pdfContent); |
| 200 | // 创建一个文件实例 | 149 | // 创建一个文件实例 |
| 201 | $file = new File($savePath); | 150 | $file = new File($savePath); |
| 202 | - return $this->fileController->api_upload_single($file); | 151 | + return $this->CosService->uploadFile($file, $path, $filename . '.pdf'); |
| 203 | } | 152 | } |
| 204 | 153 | ||
| 205 | /** | 154 | /** |
| @@ -243,10 +243,12 @@ class HtmlCollect extends Command | @@ -243,10 +243,12 @@ class HtmlCollect extends Command | ||
| 243 | $path = $arr['path'] ?? ''; | 243 | $path = $arr['path'] ?? ''; |
| 244 | $query = $arr['query'] ?? ''; | 244 | $query = $arr['query'] ?? ''; |
| 245 | 245 | ||
| 246 | + $path_arr = explode('.', $path); | ||
| 246 | if ( | 247 | if ( |
| 247 | (empty($host) || $host == $web_url_domain || $host == $home_url) | 248 | (empty($host) || $host == $web_url_domain || $host == $home_url) |
| 248 | && $path | 249 | && $path |
| 249 | && (strpos($path, '.') !== false) | 250 | && (strpos($path, '.') !== false) |
| 251 | + && (end($path_arr) != 'html') | ||
| 250 | ) { | 252 | ) { |
| 251 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 253 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 252 | if (!$source) { | 254 | if (!$source) { |
| @@ -250,10 +250,12 @@ class HtmlLanguageCollect extends Command | @@ -250,10 +250,12 @@ class HtmlLanguageCollect extends Command | ||
| 250 | $path = $arr['path'] ?? ''; | 250 | $path = $arr['path'] ?? ''; |
| 251 | $query = $arr['query'] ?? ''; | 251 | $query = $arr['query'] ?? ''; |
| 252 | 252 | ||
| 253 | + $path_arr = explode('.', $path); | ||
| 253 | if ( | 254 | if ( |
| 254 | (empty($host) || $host == $web_url_domain || $host == $home_url) | 255 | (empty($host) || $host == $web_url_domain || $host == $home_url) |
| 255 | && $path | 256 | && $path |
| 256 | && (strpos($path, '.') !== false) | 257 | && (strpos($path, '.') !== false) |
| 258 | + && (end($path_arr) != 'html') | ||
| 257 | ) { | 259 | ) { |
| 258 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 260 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 259 | if (!$source) { | 261 | if (!$source) { |
| @@ -39,47 +39,6 @@ class WebsiteData extends Command | @@ -39,47 +39,6 @@ class WebsiteData extends Command | ||
| 39 | parent::__construct(); | 39 | parent::__construct(); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - /** | ||
| 43 | - * Execute the console command. | ||
| 44 | - * | ||
| 45 | - * @return int | ||
| 46 | - */ | ||
| 47 | -// public function handle() | ||
| 48 | -// { | ||
| 49 | -// # 0 - 未推送 | ||
| 50 | -// # 1 - 已推送 | ||
| 51 | -// # 2 - 其他问题 | ||
| 52 | -// $status = 0; | ||
| 53 | -// $lists = DataFile::query()->where('status', $status) | ||
| 54 | -// ->where('created_at', 'like', $this->time . '%')->first(); | ||
| 55 | -// if (is_null($lists)) { | ||
| 56 | -// $this->error('没有任务,等待中'); | ||
| 57 | -// sleep(30); | ||
| 58 | -// return 0; | ||
| 59 | -// } | ||
| 60 | -// | ||
| 61 | -// $key = $this->signature . '-' . $lists->id; | ||
| 62 | -// $count = redis_get($key); | ||
| 63 | -// $data = $lists; | ||
| 64 | -// | ||
| 65 | -// $url = env('AICC_URL'); | ||
| 66 | -// $msg = http_post($url, json_encode(compact('data'))); | ||
| 67 | -// $status_code = $msg['status']; | ||
| 68 | -// if ($status_code != 200) { | ||
| 69 | -// if ($count == 2) { | ||
| 70 | -// $lists->status = 2; | ||
| 71 | -// $lists->save(); | ||
| 72 | -// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key); | ||
| 73 | -// } else { | ||
| 74 | -// redis_add($key, $count + 1); | ||
| 75 | -// $this->error('项目文件数据保存失败! - ' . $key); | ||
| 76 | -// } | ||
| 77 | -// } | ||
| 78 | -// $lists->status = 1; | ||
| 79 | -// $lists->save(); | ||
| 80 | -// return 0; | ||
| 81 | -// } | ||
| 82 | - | ||
| 83 | public function start(): int | 42 | public function start(): int |
| 84 | { | 43 | { |
| 85 | # 0 - 未推送 | 44 | # 0 - 未推送 |
| @@ -99,14 +58,17 @@ class WebsiteData extends Command | @@ -99,14 +58,17 @@ class WebsiteData extends Command | ||
| 99 | $data = $lists; | 58 | $data = $lists; |
| 100 | $url = env('AICC_URL'); | 59 | $url = env('AICC_URL'); |
| 101 | $msg = http_post($url, json_encode(compact('data'))); | 60 | $msg = http_post($url, json_encode(compact('data'))); |
| 102 | - $status_code = $msg['status']; | 61 | + $status_code = 0; |
| 62 | + if ($msg) { | ||
| 63 | + $status_code = (int)$msg['status']; | ||
| 64 | + } | ||
| 103 | if ($status_code != 200) { | 65 | if ($status_code != 200) { |
| 104 | if ($count == 2) { | 66 | if ($count == 2) { |
| 105 | $lists->status = 2; | 67 | $lists->status = 2; |
| 106 | $lists->save(); | 68 | $lists->save(); |
| 107 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); | 69 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); |
| 108 | } else { | 70 | } else { |
| 109 | - redis_add($key, $count + 1); | 71 | + redis_set($key, $count + 1); |
| 110 | $this->debug_echo('项目文件数据保存失败! - ' . $key); | 72 | $this->debug_echo('项目文件数据保存失败! - ' . $key); |
| 111 | } | 73 | } |
| 112 | } | 74 | } |
| @@ -116,30 +78,6 @@ class WebsiteData extends Command | @@ -116,30 +78,6 @@ class WebsiteData extends Command | ||
| 116 | return 0; | 78 | return 0; |
| 117 | } | 79 | } |
| 118 | 80 | ||
| 119 | - /** | ||
| 120 | - * Execute the console command. | ||
| 121 | - * | ||
| 122 | - * @return int | ||
| 123 | - */ | ||
| 124 | -// public function handle() | ||
| 125 | -// { | ||
| 126 | -// $DataFile = new DataFile(); | ||
| 127 | -// $data = $DataFile->allData(); | ||
| 128 | -// # 详细数据 | ||
| 129 | -// $items = $data['items']; | ||
| 130 | -// # 总分页 | ||
| 131 | -// $totalPage = $data['totalPage']; | ||
| 132 | -// $this->post_data($items); | ||
| 133 | -// if ($totalPage > 1) { | ||
| 134 | -// for ($page = 2; $page <= $totalPage; $page++) { | ||
| 135 | -// $da = $DataFile->allData($page); | ||
| 136 | -// $this->post_data($da['items']); | ||
| 137 | -// } | ||
| 138 | -// } | ||
| 139 | -// $this->info('项目文件数据推送完成!'); | ||
| 140 | -// return 0; | ||
| 141 | -// } | ||
| 142 | - | ||
| 143 | public function post_data($data) | 81 | public function post_data($data) |
| 144 | { | 82 | { |
| 145 | $url = env('AICC_URL'); | 83 | $url = env('AICC_URL'); |
| @@ -38,8 +38,8 @@ class Kernel extends ConsoleKernel | @@ -38,8 +38,8 @@ class Kernel extends ConsoleKernel | ||
| 38 | $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息 | 38 | $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息 |
| 39 | $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新 | 39 | $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新 |
| 40 | $schedule->command('update_seo_tdk_crontab')->dailyAt('00:00')->withoutOverlapping(1); //更新上线项目TDK | 40 | $schedule->command('update_seo_tdk_crontab')->dailyAt('00:00')->withoutOverlapping(1); //更新上线项目TDK |
| 41 | - $schedule->command('website_data')->everyMinute()->withoutOverlapping(1); // 向AICC推送数据 | ||
| 42 | - $schedule->command('project_file_pdf')->everyMinute()->withoutOverlapping(1); // 网站项目数据,生成PDF文件 | 41 | + $schedule->command('website_data')->dailyAt('01:00')->withoutOverlapping(1); // 向AICC推送数据 |
| 42 | + $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件 | ||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Aside\Com; | @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Aside\Com; | ||
| 11 | 11 | ||
| 12 | use App\Helper\Common; | 12 | use App\Helper\Common; |
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | +use App\Models\Com\UpdateLog; | ||
| 14 | use App\Models\Project\ProjectUpdateTdk; | 15 | use App\Models\Project\ProjectUpdateTdk; |
| 15 | use App\Services\ProjectServer; | 16 | use App\Services\ProjectServer; |
| 16 | use Illuminate\Support\Facades\DB; | 17 | use Illuminate\Support\Facades\DB; |
| @@ -41,4 +42,20 @@ class UpdateController extends BaseController | @@ -41,4 +42,20 @@ class UpdateController extends BaseController | ||
| 41 | ProjectUpdateTdk::add_task($this->param['project_id']); | 42 | ProjectUpdateTdk::add_task($this->param['project_id']); |
| 42 | $this->response('任务添加成功'); | 43 | $this->response('任务添加成功'); |
| 43 | } | 44 | } |
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 采集项目所有内容 | ||
| 48 | + * @author Akun | ||
| 49 | + * @date 2023/11/24 11:33 | ||
| 50 | + */ | ||
| 51 | + public function dataCollect(){ | ||
| 52 | + $this->request->validate([ | ||
| 53 | + 'project_id'=>'required', | ||
| 54 | + ],[ | ||
| 55 | + 'project_id.required' => 'project_id不能为空', | ||
| 56 | + ]); | ||
| 57 | + | ||
| 58 | + UpdateLog::updateLog($this->param['project_id']); | ||
| 59 | + $this->response('任务添加成功'); | ||
| 60 | + } | ||
| 44 | } | 61 | } |
| @@ -33,10 +33,32 @@ class UpdateLog extends Model | @@ -33,10 +33,32 @@ class UpdateLog extends Model | ||
| 33 | $log->project_id = $project_id; | 33 | $log->project_id = $project_id; |
| 34 | $log->api_type = $type; | 34 | $log->api_type = $type; |
| 35 | $log->api_url = $url; | 35 | $log->api_url = $url; |
| 36 | - $log->sort = $type == 'category' ? 0 :1; | 36 | + $log->sort = $type == 'category' ? 0 : 1; |
| 37 | $log->collect_status = ($type == 'category' || $type == 'website_info') ? 1 : 0; | 37 | $log->collect_status = ($type == 'category' || $type == 'website_info') ? 1 : 0; |
| 38 | return $log->save(); | 38 | return $log->save(); |
| 39 | } | 39 | } |
| 40 | return true; | 40 | return true; |
| 41 | } | 41 | } |
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 重置更新日志 | ||
| 45 | + * @param $project_id | ||
| 46 | + * @return bool | ||
| 47 | + * @author Akun | ||
| 48 | + * @date 2023/11/24 11:43 | ||
| 49 | + */ | ||
| 50 | + public static function updateLog($project_id) | ||
| 51 | + { | ||
| 52 | + $logs = self::where('project_id', $project_id)->get(); | ||
| 53 | + | ||
| 54 | + foreach ($logs as $log) { | ||
| 55 | + $log->status = 0; | ||
| 56 | + if (!in_array($log->api_type, ['website_info', 'category'])) { | ||
| 57 | + $log->collect_status = 0; | ||
| 58 | + } | ||
| 59 | + $log->save(); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + return true; | ||
| 63 | + } | ||
| 42 | } | 64 | } |
| @@ -182,6 +182,8 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -182,6 +182,8 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 182 | }); | 182 | }); |
| 183 | //更新项目tdk | 183 | //更新项目tdk |
| 184 | Route::any('/updateSeoTdk', [Aside\Com\UpdateController::class, 'updateSeoTdk'])->name('admin.project_updateSeoTdk'); | 184 | Route::any('/updateSeoTdk', [Aside\Com\UpdateController::class, 'updateSeoTdk'])->name('admin.project_updateSeoTdk'); |
| 185 | + //项目内容采集 | ||
| 186 | + Route::any('/dataCollect', [Aside\Com\UpdateController::class, 'dataCollect'])->name('admin.project_dataCollect'); | ||
| 185 | }); | 187 | }); |
| 186 | 188 | ||
| 187 | //续费 | 189 | //续费 |
-
请 注册 或 登录 后发表评论