作者 张关杰

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

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SyncFile.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/4/17 10:05
  8 + */
  9 +
  10 +namespace App\Console\Commands\SyncFile;
  11 +
  12 +use App\Models\File\ErrorFile;
  13 +use Illuminate\Console\Command;
  14 +
  15 +class SyncFile extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'sync_file';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '同步图片与文件';
  30 +
  31 +
  32 + public function handle(){
  33 + $errorFileModel = new ErrorFile();
  34 + $lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件
  35 + foreach ($lists as $k => $v){
  36 + $code = $this->synchronizationFile($v['path']);
  37 + if((int)$code == 200){
  38 + echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
  39 + $errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
  40 + }
  41 + }
  42 + echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
  43 + return true;
  44 + }
  45 +
  46 + /**
  47 + * @remark :指定同步文件到獨立177服務器
  48 + * @name :synchronizationFile
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2024/4/8 11:10
  52 + */
  53 + public function synchronizationFile($path_name){
  54 + //同步到大文件
  55 + $file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
  56 + $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
  57 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
  58 + return shell_exec($cmd);
  59 + }
  60 +}
@@ -35,11 +35,12 @@ class EditVideoMp4 extends Command @@ -35,11 +35,12 @@ class EditVideoMp4 extends Command
35 35
36 public function handle(){ 36 public function handle(){
37 $projectModel = new Project(); 37 $projectModel = new Project();
38 - $list = $projectModel->list(['id'=>1]); 38 + $list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'type'=>['!=',0],'id'=>['<=',82]]);
39 $data = []; 39 $data = [];
40 foreach ($list as $v){ 40 foreach ($list as $v){
41 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 41 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
42 ProjectServer::useProject($v['id']); 42 ProjectServer::useProject($v['id']);
  43 + $this->copyTable();
43 $this->getHtml(); 44 $this->getHtml();
44 DB::disconnect('custom_mysql'); 45 DB::disconnect('custom_mysql');
45 } 46 }
@@ -56,9 +57,11 @@ class EditVideoMp4 extends Command @@ -56,9 +57,11 @@ class EditVideoMp4 extends Command
56 public function getHtml(){ 57 public function getHtml(){
57 $templateModel = new BTemplate(); 58 $templateModel = new BTemplate();
58 $templateList = $templateModel->list(); 59 $templateList = $templateModel->list();
  60 + if(!empty($templateList)){
59 foreach ($templateList as $v1){ 61 foreach ($templateList as $v1){
60 $this->getVideoSrc($v1['id'],$v1['main_html'],'main_html',$templateModel); 62 $this->getVideoSrc($v1['id'],$v1['main_html'],'main_html',$templateModel);
61 } 63 }
  64 + }
62 return true; 65 return true;
63 } 66 }
64 67
@@ -73,11 +76,13 @@ class EditVideoMp4 extends Command @@ -73,11 +76,13 @@ class EditVideoMp4 extends Command
73 $pattern = '/<video.*?src="([^"]+)"[^>]*>/i'; 76 $pattern = '/<video.*?src="([^"]+)"[^>]*>/i';
74 preg_match_all($pattern, $html, $matches); 77 preg_match_all($pattern, $html, $matches);
75 $srcLinks = $matches[1]; 78 $srcLinks = $matches[1];
  79 + if(!empty($srcLinks)){
76 foreach ($srcLinks as $link) { 80 foreach ($srcLinks as $link) {
77 $newLink = str_replace('ecdn6.globalso.com','v6-file.globalso.com', $link); 81 $newLink = str_replace('ecdn6.globalso.com','v6-file.globalso.com', $link);
78 $html = str_replace($link, $newLink, $html); 82 $html = str_replace($link, $newLink, $html);
79 } 83 }
80 $model->edit([$filed=>$html],['id'=>$id]); 84 $model->edit([$filed=>$html],['id'=>$id]);
  85 + }
81 return true; 86 return true;
82 } 87 }
83 88
@@ -92,7 +97,7 @@ class EditVideoMp4 extends Command @@ -92,7 +97,7 @@ class EditVideoMp4 extends Command
92 public function copyTable(){ 97 public function copyTable(){
93 // 原始表名和新表名 98 // 原始表名和新表名
94 $originalTableName = "gl_web_template"; 99 $originalTableName = "gl_web_template";
95 - $newTableName = "gl_web_template_copy"; 100 + $newTableName = "gl_web_template_c";
96 // 检查原始表是否存在 101 // 检查原始表是否存在
97 DB::connection('custom_mysql')->select("SHOW TABLES LIKE '{$originalTableName}'"); 102 DB::connection('custom_mysql')->select("SHOW TABLES LIKE '{$originalTableName}'");
98 DB::connection('custom_mysql')->statement("CREATE TABLE {$newTableName} LIKE {$originalTableName}"); 103 DB::connection('custom_mysql')->statement("CREATE TABLE {$newTableName} LIKE {$originalTableName}");
@@ -64,7 +64,10 @@ class TranslateLogic extends BaseLogic @@ -64,7 +64,10 @@ class TranslateLogic extends BaseLogic
64 } 64 }
65 $arr2 = []; 65 $arr2 = [];
66 foreach ($text_array as $val) { 66 foreach ($text_array as $val) {
67 - if (FALSE == in_array($val, $old_key)){ 67 + if($val == ' '){
  68 + continue;
  69 + }
  70 + if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){
68 $arr2[] = $val; 71 $arr2[] = $val;
69 } 72 }
70 } 73 }