作者 lyh

gx

@@ -72,70 +72,70 @@ class Demo extends Command @@ -72,70 +72,70 @@ class Demo extends Command
72 // return true; 72 // return true;
73 // } 73 // }
74 74
75 -// public function handle(){  
76 -// $keywordVideoModel = new KeywordVideoTask();  
77 -// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();  
78 -// $projectModel = new Project();  
79 -// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);  
80 -// $data = [];  
81 -// foreach ($list as $v){  
82 -// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;  
83 -// ProjectServer::useProject($v['id']);  
84 -// $this->saveKeyword();  
85 -// DB::disconnect('custom_mysql');  
86 -// }  
87 -// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;  
88 -// }  
89 -//  
90 -// /**  
91 -// * @remark :关键字有视频的改为1  
92 -// * @name :getProductKeywordInfo  
93 -// * @author :lyh  
94 -// * @method :post  
95 -// * @time :2024/5/31 9:54  
96 -// */  
97 -// public function saveKeyword(){  
98 -// $keywordModel = new Keyword();  
99 -// $rs = $keywordModel->edit(['is_video_keyword'=>1],['video'=>['!=',null]]);  
100 -// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;  
101 -// return true;  
102 -// }  
103 -  
104 public function handle(){ 75 public function handle(){
105 - //切换数据库配置  
106 - ProjectServer::useProject(1862);  
107 - return $this->initTable(1380,1862);  
108 - }  
109 -  
110 - public function initTable($project_id, $news_project_id)  
111 - {  
112 - config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);  
113 - $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();  
114 - $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();  
115 - $tables = array_column($tables, 'Tables_in_' . $database_name);  
116 - foreach ($tables as $table) {  
117 - $has_table = Schema::connection('custom_mysql')->hasTable($table);  
118 - if (!$has_table) {  
119 - $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");  
120 - DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式  
121 - }  
122 -  
123 - if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {  
124 - continue; 76 + $keywordVideoModel = new KeywordVideoTask();
  77 + $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
  78 + $projectModel = new Project();
  79 + $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
  80 + $data = [];
  81 + foreach ($list as $v){
  82 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  83 + ProjectServer::useProject($v['id']);
  84 + $this->saveKeyword();
  85 + DB::disconnect('custom_mysql');
125 } 86 }
126 - DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据  
127 - DB::connection('custom_mysql')->table($table)->insertUsing(  
128 - [], // 列名数组,留空表示插入所有列  
129 - function ($query) use ($table, $project_id) {  
130 - $name = 'gl_data_' . $project_id . '.' . $table;  
131 - $query->select('*')->from("{$name}"); 87 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
132 } 88 }
133 - );  
134 89
135 - if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {  
136 - DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);  
137 - }  
138 - } 90 + /**
  91 + * @remark :关键字有视频的改为1
  92 + * @name :getProductKeywordInfo
  93 + * @author :lyh
  94 + * @method :post
  95 + * @time :2024/5/31 9:54
  96 + */
  97 + public function saveKeyword(){
  98 + $keywordModel = new Keyword();
  99 + $rs = $keywordModel->edit(['is_video_keyword'=>0],['video'=>null]);
  100 + echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
139 return true; 101 return true;
140 } 102 }
  103 +
  104 +// public function handle(){
  105 +// //切换数据库配置
  106 +// ProjectServer::useProject(1862);
  107 +// return $this->initTable(1380,1862);
  108 +// }
  109 +//
  110 +// public function initTable($project_id, $news_project_id)
  111 +// {
  112 +// config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
  113 +// $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
  114 +// $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
  115 +// $tables = array_column($tables, 'Tables_in_' . $database_name);
  116 +// foreach ($tables as $table) {
  117 +// $has_table = Schema::connection('custom_mysql')->hasTable($table);
  118 +// if (!$has_table) {
  119 +// $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
  120 +// DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
  121 +// }
  122 +//
  123 +// if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {
  124 +// continue;
  125 +// }
  126 +// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
  127 +// DB::connection('custom_mysql')->table($table)->insertUsing(
  128 +// [], // 列名数组,留空表示插入所有列
  129 +// function ($query) use ($table, $project_id) {
  130 +// $name = 'gl_data_' . $project_id . '.' . $table;
  131 +// $query->select('*')->from("{$name}");
  132 +// }
  133 +// );
  134 +//
  135 +// if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
  136 +// DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
  137 +// }
  138 +// }
  139 +// return true;
  140 +// }
141 } 141 }