作者 lyh

gx

@@ -140,25 +140,4 @@ class Demo extends Command @@ -140,25 +140,4 @@ class Demo extends Command
140 // } 140 // }
141 // return true; 141 // return true;
142 // } 142 // }
143 -  
144 - public function handle(){  
145 - $minorLanguageModel = new MinorLanguages();  
146 - $lists = $minorLanguageModel->list();  
147 - foreach ($lists as $v){  
148 - $d = new DeployOptimize();  
149 - $info = $d->read(['project_id'=>$v['project_id']]);  
150 - if($info === false){  
151 - continue;  
152 - }  
153 - if(!empty($info['minor_keywords'])){  
154 - $minor_keywords = json_decode($info['minor_keywords']);  
155 - foreach ($minor_keywords as $v1){  
156 - $v1 = (array)$v1;  
157 - if($v['language'] == $v1['name']){  
158 - $minorLanguageModel->edit(['minor_keywords'=>$v1['keyword']]);  
159 - }  
160 - }  
161 - }  
162 - }  
163 - }  
164 } 143 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SyncProjectFile.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/6/18 14:53
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\File\ErrorFile;
  13 +use App\Models\File\File;
  14 +use Illuminate\Console\Command;
  15 +
  16 +class SyncProjectFile extends Command
  17 +{
  18 + /**
  19 + * The name and signature of the console command.
  20 + *
  21 + * @var string
  22 + */
  23 + protected $signature = 'sync_project_file {project_id}';
  24 +
  25 + /**
  26 + * The console command description.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $description = '同步图片与文件';
  31 +
  32 +
  33 + public function handle(){
  34 + $project_id = $this->argument('project_id');
  35 + $fileModel = new File();
  36 + $lists = $fileModel->list(['project_id'=>$project_id]);//未同步成功的图片及文件
  37 + foreach ($lists as $k => $v){
  38 + if(strpos($v['path'], '/181/') !== false ){
  39 + $code = $this->synchronizationFiles($v['path']);
  40 + }else{
  41 + $code = $this->synchronizationFile($v['path']);
  42 + }
  43 + if((int)$code == 200){
  44 + echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
  45 + }
  46 + }
  47 + echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
  48 + return true;
  49 + }
  50 +
  51 + /**
  52 + * @remark :指定同步文件到獨立177服務器
  53 + * @name :synchronizationFile
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2024/4/8 11:10
  57 + */
  58 + public function synchronizationFile($path_name){
  59 + //同步到大文件
  60 + $file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
  61 + $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
  62 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
  63 + return shell_exec($cmd);
  64 + }
  65 +
  66 +
  67 + public function synchronizationFiles($path_name){
  68 + //同步到大文件
  69 + $file_path = config('filesystems.disks.s3')['cdn'].$path_name;
  70 + $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
  71 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
  72 + return shell_exec($cmd);
  73 + }
  74 +}