作者 赵彬吉
... ... @@ -38,6 +38,7 @@ class SyncFile extends Command
echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
$errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
}
gc_collect_cycles();
}
echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
return true;
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api;
use App\Exceptions\InquiryFilterException;
use App\Models\Visit\SyncSubmitTask;
use App\Services\CosService;
use Illuminate\Http\Request;
... ... @@ -26,10 +27,14 @@ class SelfSiteController extends BaseController
$traffic = $request->input('traffic', SyncSubmitTask::TRAFFIC_DEFAULT);//是否引流
$files = $request->input('files', []);//文件
if (empty($data)) {
if (empty($data) || empty($domain)) {
return $this->error('参数错误');
}
if (!in_array($type, [SyncSubmitTask::TYPE_VISIT, SyncSubmitTask::TYPE_INQUIRY])) {
return $this->error('类型错误');
}
if (!empty($files)) {
try {
foreach ($files as $key => $file) {
... ... @@ -42,6 +47,8 @@ class SelfSiteController extends BaseController
'original_name' => $fileinfo['name'],
];
}
} catch (InquiryFilterException $e) {
return $this->error($e->getMessage());
} catch (\Exception $e) {
return $this->error('File upload fail');
}
... ...
... ... @@ -61,6 +61,7 @@ class ProjectController extends BaseController
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->leftJoin('gl_web_setting_template', 'gl_project.id', '=', 'gl_web_setting_template.project_id')
->where('gl_project.delete_status',Project::TYPE_ZERO)
->where('gl_project.extend_type',Project::TYPE_ZERO);
$query = $this->searchParam($query);
... ... @@ -115,6 +116,7 @@ class ProjectController extends BaseController
'gl_project_deploy_optimize.quality_mid AS quality_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.api_no AS api_no',
'gl_web_setting_template.template_id AS template_id',
];
return $select;
}
... ...
... ... @@ -6,6 +6,8 @@ use App\Enums\Common\Code;
use App\Helper\Translate;
use App\Http\Controllers\Controller;
use App\Http\Controllers\type;
use App\Jobs\CopyProjectJob;
use App\Jobs\SyncImageFileJob;
use App\Models\File\ErrorFile;
use App\Models\File\Image as ImageModel;
use App\Models\Project\Project;
... ... @@ -262,14 +264,14 @@ class ImageController extends Controller
* @time :2024/4/8 11:10
*/
public function synchronizationImage($fileName){
//同步到大文件
$file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
}
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
// $file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
// $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
// $code = shell_exec($cmd);
// if(200 != (int)$code){
// $errorFileModel = new ErrorFile();
// $errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
// }
return true;
}
... ...
<?php
namespace App\Jobs;
use App\Events\CopyImageFile;
use App\Models\File\ErrorFile;
use App\Models\File\File as FileModel;
use App\Models\File\Image as ImageModel;
use App\Services\AmazonS3Service;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyncImageFileJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3; // 可配置任务重试次数
protected $param;
/**
* Create a new job instance.
*
* @param CopyImageFile $event
* @return void
*/
public function __construct($data)
{
$this->param = $data;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
return true;
}
}
... ...
... ... @@ -60,6 +60,10 @@ class RouteMap extends Base
}
$i=1;
$sign = generateRoute($title);
$length = strlen($sign);
if($length > 100){
$sign = trim(mb_substr($sign, 0, 100, 'UTF-8'),'-');
}
$info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
$suffix = '';
if(empty($info)){
... ...
... ... @@ -21,7 +21,7 @@ class Visit extends Base
//连接数据库
protected $connection = 'custom_mysql';
protected $appends = ['device_text'];
protected $fillable = ['id','ip','device_port','country','city','url','referrer_url','depth','domain','updated_date', 'created_at'];
protected $fillable = ['id','ip','device_port','country','city','url','referrer_url','depth','domain','is_inquiry','original_id','updated_date', 'created_at'];
const DEVICE_PC = 1;
const DEVICE_MOBILE = 2;
... ...