作者 李美松

优化程序

... ... @@ -53,15 +53,20 @@ class ProjectFilePDF extends Command
parent::__construct();
}
public function handle()
{
}
public function start(): int
{
$status = 1; # 1 - 正常, 0 - 禁用
$is_pdf = 0; # 0 - 未生成 1 - 已生成 2 - 其它问题
$status = 0; # 0 - 未生成 1 - 已生成 2 - 其它问题
$lists = $this->DataFile::query()->where('status', $status)
->where('project_id', '!=', 0)
->where('friend_id', '!=', 0)
->where('user_id', '!=', 0)
->where('is_pdf', $is_pdf)->where('created_at', 'like', $this->time . '%')->first();
->where('created_at', 'like', $this->time . '%')->first();
if (is_null($lists)) {
$this->debug_echo('没有任务,等待中');
sleep(60);
... ... @@ -69,10 +74,9 @@ class ProjectFilePDF extends Command
}
$key = $this->signature . '-' . $lists->id;
$count = redis_get($key);
$item = $lists->getOriginal();
$project_id = $item->project_id;
$user_id = $item->user_id;
$friend_id = $item->friend_id;
$project_id = $lists->project_id;
$user_id = $lists->user_id;
$friend_id = $lists->friend_id;
// todo 根据项目查询数据
$project_data = [];
$html = $this->html($project_data);
... ...
... ... @@ -107,8 +107,8 @@ class FileController
*/
public function single(&$files){
$hash = hash_file('md5', $files->getPathname());
// $name = $files->getClientOriginalName();
$name = $files->getFilename();
$name = $files->getClientOriginalName();
// $name = $files->getFilename();
//查看文件是否存在
$fileModel = new File();
//查看图片是否已上传
... ... @@ -121,8 +121,8 @@ class FileController
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
}
$url = $this->config['root'].$this->path;
// $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$fileName = uniqid().rand(10000,99999).'.'.$files->getExtension();
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
// $fileName = uniqid().rand(10000,99999).'.'.$files->getExtension();
//同步数据到cos
if($this->upload_location == 1){
$cosService = new CosService();
... ...
... ... @@ -19,6 +19,7 @@
"mongodb/mongodb": "^1.6",
"mrgoon/aliyun-sms": "^2.0",
"phpoffice/phpspreadsheet": "^1.28",
"qcloud/cos-sdk-v5": "^2.6",
"swooletw/laravel-swoole": "^2.13"
},
"require-dev": {
... ...