作者 李美松

线上去测试

@@ -35,7 +35,7 @@ class ProjectFilePDF extends Command @@ -35,7 +35,7 @@ class ProjectFilePDF extends Command
35 protected $time; 35 protected $time;
36 36
37 // 最大支持5个进程 37 // 最大支持5个进程
38 - public int $maxRunNumber = 50; 38 + public int $maxRunNumber = 50;
39 39
40 public FileController $fileController; 40 public FileController $fileController;
41 41
@@ -54,10 +54,49 @@ class ProjectFilePDF extends Command @@ -54,10 +54,49 @@ class ProjectFilePDF extends Command
54 } 54 }
55 55
56 56
57 - public function handle()  
58 - {  
59 -  
60 - } 57 +// public function handle()
  58 +// {
  59 +// $status = 0; # 0 - 未生成 1 - 已生成 2 - 其它问题
  60 +// $lists = $this->DataFile::query()->where('status', $status)
  61 +// ->where('project_id', '!=', 0)
  62 +// ->where('friend_id', '!=', 0)
  63 +// ->where('user_id', '!=', 0)
  64 +// ->where('created_at', 'like', $this->time . '%')->first();
  65 +// if (is_null($lists)) {
  66 +// $this->error('没有任务,等待中');
  67 +// sleep(60);
  68 +// return 0;
  69 +// }
  70 +// $key = $this->signature . '-' . $lists->id;
  71 +// $count = redis_get($key);
  72 +// $project_id = $lists->project_id;
  73 +// $user_id = $lists->user_id;
  74 +// $friend_id = $lists->friend_id;
  75 +// // todo 根据项目查询数据
  76 +// $project_data = [];
  77 +// $html = $this->html($project_data);
  78 +// $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
  79 +// $file_path = $this->savePDF($html, $filename);
  80 +// if (empty($file_path)) {
  81 +// $this->error('pdf生成失败!');
  82 +// return 0;
  83 +// }
  84 +// $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);
  85 +// if (!$isRes) {
  86 +// if ($count == 2) {
  87 +// $lists->is_pdf = 2;
  88 +// $lists->save();
  89 +// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key);
  90 +// } else {
  91 +// redis_add($key, $count + 1);
  92 +// $this->error('项目文件数据保存失败! - ' . $key);
  93 +// }
  94 +// }
  95 +// $lists->is_pdf = 1;
  96 +// $lists->save();
  97 +// $this->error('项目文件数据保存成功!');
  98 +// return 0;
  99 +// }
61 100
62 public function start(): int 101 public function start(): int
63 { 102 {
@@ -138,8 +177,10 @@ class ProjectFilePDF extends Command @@ -138,8 +177,10 @@ class ProjectFilePDF extends Command
138 177
139 // 创建一个文件实例 178 // 创建一个文件实例
140 $file = new File($savePath); 179 $file = new File($savePath);
  180 +// var_dump($file->getExtension());
  181 +// exit();
141 182
142 - return $this->fileController->single($file); 183 + echo $this->fileController->single($file);
143 } 184 }
144 185
145 /** 186 /**
@@ -106,9 +106,9 @@ class FileController @@ -106,9 +106,9 @@ class FileController
106 * @time :2023/6/17 16:32 106 * @time :2023/6/17 16:32
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(); 110 $name = $files->getClientOriginalName();
111 -// $name = $files->getFilename(); 111 + $name = $files->getFilename();
112 //查看文件是否存在 112 //查看文件是否存在
113 $fileModel = new File(); 113 $fileModel = new File();
114 //查看图片是否已上传 114 //查看图片是否已上传
@@ -134,6 +134,7 @@ class FileController @@ -134,6 +134,7 @@ class FileController
134 } 134 }
135 } 135 }
136 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); 136 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
  137 +// $this->saveMysql($fileModel,$files->getSize(),$files->getExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
137 return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 138 return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
138 } 139 }
139 140
@@ -204,7 +205,7 @@ class FileController @@ -204,7 +205,7 @@ class FileController
204 $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name); 205 $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
205 $data[] = $this->responseData($this->path.'/'.$fileName, $name); 206 $data[] = $this->responseData($this->path.'/'.$fileName, $name);
206 } 207 }
207 - $this->response('资源',Code::SUCCESS,$data); 208 + $this->response('资源',Code::SUCCESS,$data);
208 } 209 }
209 210
210 211