作者 Your Name
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -18,7 +18,7 @@ use Illuminate\Console\Command; @@ -18,7 +18,7 @@ use Illuminate\Console\Command;
18 use Illuminate\Support\Facades\DB; 18 use Illuminate\Support\Facades\DB;
19 use App\Models\HomeCount\Count; 19 use App\Models\HomeCount\Count;
20 20
21 -class UpgradeCount extends Command 21 +class CountAll extends Command
22 { 22 {
23 23
24 /** 24 /**
@@ -26,7 +26,7 @@ class UpgradeCount extends Command @@ -26,7 +26,7 @@ class UpgradeCount extends Command
26 * 26 *
27 * @var string 27 * @var string
28 */ 28 */
29 - protected $signature = 'upgrade_counts'; 29 + protected $signature = 'count_all';
30 30
31 /** 31 /**
32 * The console command description. 32 * The console command description.
@@ -37,7 +37,7 @@ class UpgradeCount extends Command @@ -37,7 +37,7 @@ class UpgradeCount extends Command
37 37
38 public function handle(){ 38 public function handle(){
39 $projectModel = new Project(); 39 $projectModel = new Project();
40 - $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]); 40 + $list = $projectModel->list(['delete_status'=>0]);
41 foreach ($list as $v) { 41 foreach ($list as $v) {
42 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; 42 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
43 ProjectServer::useProject($v['id']); 43 ProjectServer::useProject($v['id']);
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -20,7 +20,7 @@ use Illuminate\Console\Command; @@ -20,7 +20,7 @@ use Illuminate\Console\Command;
20 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
21 use App\Models\HomeCount\Count; 21 use App\Models\HomeCount\Count;
22 22
23 -class UpgradeProjectCount extends Command 23 +class CountProject extends Command
24 { 24 {
25 const STATUS_ERROR = 400; 25 const STATUS_ERROR = 400;
26 public $error = 0; 26 public $error = 0;
@@ -29,7 +29,7 @@ class UpgradeProjectCount extends Command @@ -29,7 +29,7 @@ class UpgradeProjectCount extends Command
29 * 29 *
30 * @var string 30 * @var string
31 */ 31 */
32 - protected $signature = 'upgrade_count {project_id}'; 32 + protected $signature = 'count_project {project_id}';
33 33
34 /** 34 /**
35 * The console command description. 35 * The console command description.
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -21,14 +21,14 @@ use Illuminate\Console\Command; @@ -21,14 +21,14 @@ use Illuminate\Console\Command;
21 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
22 use App\Models\HomeCount\Count; 22 use App\Models\HomeCount\Count;
23 23
24 -class UpgradeCount extends Command 24 +class MonthAllCount extends Command
25 { 25 {
26 /** 26 /**
27 * The name and signature of the console command. 27 * The name and signature of the console command.
28 * 28 *
29 * @var string 29 * @var string
30 */ 30 */
31 - protected $signature = 'upgrade_month_counts'; 31 + protected $signature = 'month_all';
32 32
33 /** 33 /**
34 * The console command description. 34 * The console command description.
@@ -88,7 +88,7 @@ class UpgradeCount extends Command @@ -88,7 +88,7 @@ class UpgradeCount extends Command
88 $end = date('Y-m-t', strtotime($v['month'])); 88 $end = date('Y-m-t', strtotime($v['month']));
89 $arr['project_id'] = $project_id; 89 $arr['project_id'] = $project_id;
90 $res = $this->inquiry($url,$v['month']); 90 $res = $this->inquiry($url,$v['month']);
91 -// $arr['month_total'] = 0; 91 + $arr['total'] = 0;
92 if(isset($res['data']['count'])){ 92 if(isset($res['data']['count'])){
93 echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; 93 echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
94 $arr['month_total'] = $res['data']['count']; 94 $arr['month_total'] = $res['data']['count'];
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -21,14 +21,14 @@ use Illuminate\Console\Command; @@ -21,14 +21,14 @@ use Illuminate\Console\Command;
21 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
22 use App\Models\HomeCount\Count; 22 use App\Models\HomeCount\Count;
23 23
24 -class UpgradeProjectCount extends Command 24 +class MonthProjectCount extends Command
25 { 25 {
26 /** 26 /**
27 * The name and signature of the console command. 27 * The name and signature of the console command.
28 * 28 *
29 * @var string 29 * @var string
30 */ 30 */
31 - protected $signature = 'upgrade_month_count {project_id}'; 31 + protected $signature = 'month_project {project_id}';
32 32
33 /** 33 /**
34 * The console command description. 34 * The console command description.
@@ -28,23 +28,15 @@ class SyncSubmitTask extends Command @@ -28,23 +28,15 @@ class SyncSubmitTask extends Command
28 28
29 public function handle() 29 public function handle()
30 { 30 {
31 - $backup = false;  
32 while (true) { 31 while (true) {
33 - $task_id = $this->getTaskId();  
34 - if ($task_id > 2000000) {  
35 - $backup = true;  
36 - }  
37 - if (empty($task_id)) {  
38 - if ($backup) {  
39 - $this->backup();  
40 - $backup = false;  
41 - }  
42 - sleep(5); 32 + $task_id = Redis::rpop('sync_submit_task');
  33 + if(!$task_id){
  34 + sleep(3);
43 continue; 35 continue;
44 } 36 }
45 $this->output('任务' . $task_id . '开始'); 37 $this->output('任务' . $task_id . '开始');
46 $task_info = SyncSubmitTaskModel::find($task_id); 38 $task_info = SyncSubmitTaskModel::find($task_id);
47 - if (empty($task_info) || $task_info->status !=2) { 39 + if (empty($task_info) || $task_info->status !=3) {
48 $this->output('任务不存在或者已执行'); 40 $this->output('任务不存在或者已执行');
49 continue; 41 continue;
50 } 42 }
@@ -79,31 +71,6 @@ class SyncSubmitTask extends Command @@ -79,31 +71,6 @@ class SyncSubmitTask extends Command
79 } 71 }
80 } 72 }
81 73
82 - public function getTaskId()  
83 - {  
84 - $task_id = Redis::rpop('sync_submit_task');  
85 - $lockKey = 'lock_sync_submit_task';  
86 - if (empty($task_id)) {  
87 - // 获取锁  
88 - if (Redis::setnx($lockKey, 1)) {  
89 - // 设置锁的过期时间,防止死锁  
90 - Redis::expire($lockKey, 10);  
91 - $tasks = SyncSubmitTaskModel::where('status', 0)->limit(100)->get();  
92 - foreach ($tasks as $task) {  
93 - $task->status = 2;  
94 - $task->save();  
95 - Redis::lpush('sync_submit_task', $task->id);  
96 - }  
97 - $task_id = Redis::rpop('sync_submit_task');  
98 - Redis::del($lockKey);  
99 - } else {  
100 - // 未获取到锁  
101 - return '';  
102 - }  
103 - }  
104 - return $task_id;  
105 - }  
106 -  
107 /** 74 /**
108 * 输出处理日志 75 * 输出处理日志
109 */ 76 */
@@ -112,31 +79,4 @@ class SyncSubmitTask extends Command @@ -112,31 +79,4 @@ class SyncSubmitTask extends Command
112 echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; 79 echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
113 return true; 80 return true;
114 } 81 }
115 -  
116 - /**  
117 - * 备份数据  
118 - * @author zbj  
119 - * @date 2024/1/23  
120 - */  
121 - public function backup()  
122 - {  
123 - DB::beginTransaction();  
124 - try {  
125 - $table = (new SyncSubmitTaskModel())->getTable();  
126 - $new_table = $table . '_backup_' . date('Ymd');  
127 -  
128 - //重命名当前表  
129 - Schema::rename($table, $new_table);  
130 - //克隆表数据  
131 - DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table);  
132 -  
133 - DB::commit();  
134 -  
135 - $this->output('数据备份成功');  
136 - } catch (\Exception $e) {  
137 - $this->output('数据备份失败' . $e->getMessage());  
138 - DB::rollBack();  
139 - }  
140 - return true;  
141 - }  
142 } 82 }
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\Sync;
  4 +
  5 +
  6 +use App\Exceptions\InquiryFilterException;
  7 +use App\Models\Project\Project;
  8 +use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel;
  9 +use App\Services\SyncSubmitTaskService;
  10 +use Illuminate\Console\Command;
  11 +use Illuminate\Support\Facades\Cache;
  12 +use Illuminate\Support\Facades\DB;
  13 +use Illuminate\Support\Facades\Redis;
  14 +use Illuminate\Support\Facades\Schema;
  15 +use Illuminate\Support\Str;
  16 +
  17 +/**
  18 + *
  19 + * Class SyncSubmitTask
  20 + * @package App\Console\Commands
  21 + * @author zbj
  22 + * @date 2023/11/28
  23 + */
  24 +class SyncSubmitTaskDistribution extends Command
  25 +{
  26 +
  27 + protected $signature = 'sync_submit_task_distribution';
  28 + protected $description = '询盘、访问异步任务分发';
  29 +
  30 + public function handle()
  31 + {
  32 + while (true) {
  33 + $len = Redis::llen('sync_submit_task');
  34 + if (!$len) {
  35 + $max_id = SyncSubmitTaskModel::orderBy('id', 'desc')->value('id');
  36 + if ($max_id > 2000000) {
  37 + $this->backup();
  38 + } else {
  39 + $tasks = SyncSubmitTaskModel::where('status', 0)->limit(100)->get();
  40 + foreach ($tasks as $task) {
  41 + $task->status = 3;
  42 + $task->save();
  43 + Redis::lpush('sync_submit_task', $task->id);
  44 + }
  45 + }
  46 + }
  47 + sleep(3);
  48 + }
  49 + }
  50 +
  51 + /**
  52 + * 输出处理日志
  53 + */
  54 + public function output($message): bool
  55 + {
  56 + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
  57 + return true;
  58 + }
  59 +
  60 + /**
  61 + * 备份数据
  62 + * @author zbj
  63 + * @date 2024/1/23
  64 + */
  65 + public function backup()
  66 + {
  67 + DB::beginTransaction();
  68 + try {
  69 + $table = (new SyncSubmitTaskModel())->getTable();
  70 + $new_table = $table . '_backup_' . date('Ymd');
  71 +
  72 + //重命名当前表
  73 + Schema::rename($table, $new_table);
  74 + //克隆表数据
  75 + DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table);
  76 +
  77 + //未入队的写到新表
  78 + $list = DB::table($new_table)->where('status', 0)->get();
  79 + $data = [];
  80 + foreach ($list as $task) {
  81 + $data[] = [
  82 + 'type' => $task->type,
  83 + 'data' => json_encode($task->data),
  84 + 'created_at' => $task['created_at'],
  85 + 'updated_at' => $task['updated_at'],
  86 + ];
  87 + }
  88 + $data && SyncSubmitTaskModel::insert($data);
  89 +
  90 + DB::commit();
  91 +
  92 + $this->output('数据备份成功');
  93 + } catch (\Exception $e) {
  94 + $this->output('数据备份失败' . $e->getMessage());
  95 + DB::rollBack();
  96 + }
  97 + return $new_table ?? '';
  98 + }
  99 +}
@@ -9,6 +9,7 @@ use App\Http\Logic\Bside\Product\KeywordLogic; @@ -9,6 +9,7 @@ use App\Http\Logic\Bside\Product\KeywordLogic;
9 use App\Http\Requests\Bside\Product\KeywordRequest; 9 use App\Http\Requests\Bside\Product\KeywordRequest;
10 use App\Models\Com\NoticeLog; 10 use App\Models\Com\NoticeLog;
11 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
  12 +use App\Models\Product\KeywordPage;
12 use App\Models\Product\KeywordRelated; 13 use App\Models\Product\KeywordRelated;
13 use App\Models\Product\Product; 14 use App\Models\Product\Product;
14 use App\Models\RouteMap\RouteMap; 15 use App\Models\RouteMap\RouteMap;
@@ -242,6 +243,20 @@ class KeywordController extends BaseController @@ -242,6 +243,20 @@ class KeywordController extends BaseController
242 * @time :2024/7/2 10:14 243 * @time :2024/7/2 10:14
243 */ 244 */
244 public function batchUpdateKeyword(){ 245 public function batchUpdateKeyword(){
245 - $noticeLogModel = new NoticeLog(); 246 + $this->request->validate([
  247 + 'text'=>'required|array',
  248 + 'update_object'=>'required|array',
  249 + 'update_method'=>'required'
  250 + ],[
  251 + 'text.required' => '文件内容不能为空',
  252 + 'update_object.required' => '更新对象不为空',
  253 + 'update_object.array' => '更新对象为数组',
  254 + 'update_method.required' => '请求方式不为空'
  255 + ]);
  256 + $keywordPageModel = new KeywordPage();
  257 + $this->param['text'] = json_encode($this->param['text']);
  258 + $this->param['update_object'] = json_encode($this->param['update_object']);
  259 + $id = $keywordPageModel->addReturnId($this->param);
  260 + $this->response('success',Code::SUCCESS,['id'=>$id]);
246 } 261 }
247 } 262 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :KeywordPage.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/7/2 15:26
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class KeywordPage extends Base
  15 +{
  16 + protected $table = 'gl_product_keyword_page';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
@@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () {
271 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); 271 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
272 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); 272 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
273 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); 273 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
  274 + Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword');
274 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo'); 275 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
275 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); 276 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
276 //产品参数 277 //产品参数