作者 李美松

优化程序

@@ -53,15 +53,20 @@ class ProjectFilePDF extends Command @@ -53,15 +53,20 @@ class ProjectFilePDF extends Command
53 parent::__construct(); 53 parent::__construct();
54 } 54 }
55 55
  56 +
  57 + public function handle()
  58 + {
  59 +
  60 + }
  61 +
56 public function start(): int 62 public function start(): int
57 { 63 {
58 - $status = 1; # 1 - 正常, 0 - 禁用  
59 - $is_pdf = 0; # 0 - 未生成 1 - 已生成 2 - 其它问题 64 + $status = 0; # 0 - 未生成 1 - 已生成 2 - 其它问题
60 $lists = $this->DataFile::query()->where('status', $status) 65 $lists = $this->DataFile::query()->where('status', $status)
61 ->where('project_id', '!=', 0) 66 ->where('project_id', '!=', 0)
62 ->where('friend_id', '!=', 0) 67 ->where('friend_id', '!=', 0)
63 ->where('user_id', '!=', 0) 68 ->where('user_id', '!=', 0)
64 - ->where('is_pdf', $is_pdf)->where('created_at', 'like', $this->time . '%')->first(); 69 + ->where('created_at', 'like', $this->time . '%')->first();
65 if (is_null($lists)) { 70 if (is_null($lists)) {
66 $this->debug_echo('没有任务,等待中'); 71 $this->debug_echo('没有任务,等待中');
67 sleep(60); 72 sleep(60);
@@ -69,10 +74,9 @@ class ProjectFilePDF extends Command @@ -69,10 +74,9 @@ class ProjectFilePDF extends Command
69 } 74 }
70 $key = $this->signature . '-' . $lists->id; 75 $key = $this->signature . '-' . $lists->id;
71 $count = redis_get($key); 76 $count = redis_get($key);
72 - $item = $lists->getOriginal();  
73 - $project_id = $item->project_id;  
74 - $user_id = $item->user_id;  
75 - $friend_id = $item->friend_id; 77 + $project_id = $lists->project_id;
  78 + $user_id = $lists->user_id;
  79 + $friend_id = $lists->friend_id;
76 // todo 根据项目查询数据 80 // todo 根据项目查询数据
77 $project_data = []; 81 $project_data = [];
78 $html = $this->html($project_data); 82 $html = $this->html($project_data);
@@ -107,8 +107,8 @@ class FileController @@ -107,8 +107,8 @@ class FileController
107 */ 107 */
108 public function single(&$files){ 108 public function single(&$files){
109 $hash = hash_file('md5', $files->getPathname()); 109 $hash = hash_file('md5', $files->getPathname());
110 -// $name = $files->getClientOriginalName();  
111 - $name = $files->getFilename(); 110 + $name = $files->getClientOriginalName();
  111 +// $name = $files->getFilename();
112 //查看文件是否存在 112 //查看文件是否存在
113 $fileModel = new File(); 113 $fileModel = new File();
114 //查看图片是否已上传 114 //查看图片是否已上传
@@ -121,8 +121,8 @@ class FileController @@ -121,8 +121,8 @@ class FileController
121 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name)); 121 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
122 } 122 }
123 $url = $this->config['root'].$this->path; 123 $url = $this->config['root'].$this->path;
124 -// $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();  
125 - $fileName = uniqid().rand(10000,99999).'.'.$files->getExtension(); 124 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  125 +// $fileName = uniqid().rand(10000,99999).'.'.$files->getExtension();
126 //同步数据到cos 126 //同步数据到cos
127 if($this->upload_location == 1){ 127 if($this->upload_location == 1){
128 $cosService = new CosService(); 128 $cosService = new CosService();
@@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
19 "mongodb/mongodb": "^1.6", 19 "mongodb/mongodb": "^1.6",
20 "mrgoon/aliyun-sms": "^2.0", 20 "mrgoon/aliyun-sms": "^2.0",
21 "phpoffice/phpspreadsheet": "^1.28", 21 "phpoffice/phpspreadsheet": "^1.28",
  22 + "qcloud/cos-sdk-v5": "^2.6",
22 "swooletw/laravel-swoole": "^2.13" 23 "swooletw/laravel-swoole": "^2.13"
23 }, 24 },
24 "require-dev": { 25 "require-dev": {