正在显示
2 个修改的文件
包含
18 行增加
和
135 行删除
| @@ -55,10 +55,10 @@ class ProjectFilePDF extends Command | @@ -55,10 +55,10 @@ class ProjectFilePDF extends Command | ||
| 55 | 55 | ||
| 56 | public function start(): int | 56 | public function start(): int |
| 57 | { | 57 | { |
| 58 | - # 0 - 未生成 | ||
| 59 | - # 1 - 已生成 | ||
| 60 | - # 2 - 其它问题 | ||
| 61 | - $is_pdf = 0; | 58 | + # 1 - 未生成 |
| 59 | + # 2 - 已生成 | ||
| 60 | + # 3 - 其它问题 | ||
| 61 | + $is_pdf = 1; | ||
| 62 | $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf) | 62 | $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf) |
| 63 | ->where('project_id', '!=', 0) | 63 | ->where('project_id', '!=', 0) |
| 64 | ->where('friend_id', '!=', 0) | 64 | ->where('friend_id', '!=', 0) |
| @@ -90,76 +90,21 @@ class ProjectFilePDF extends Command | @@ -90,76 +90,21 @@ class ProjectFilePDF extends Command | ||
| 90 | $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); | 90 | $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); |
| 91 | if (!$isRes) { | 91 | if (!$isRes) { |
| 92 | if ($count == 2) { | 92 | if ($count == 2) { |
| 93 | - $lists->is_pdf = 2; | 93 | + $lists->is_pdf = 3; |
| 94 | $lists->save(); | 94 | $lists->save(); |
| 95 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); | 95 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); |
| 96 | } else { | 96 | } else { |
| 97 | - redis_add($key, $count + 1); | 97 | + redis_set($key, $count + 1); |
| 98 | $this->debug_echo('项目文件数据保存失败! - ' . $key); | 98 | $this->debug_echo('项目文件数据保存失败! - ' . $key); |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | - $lists->is_pdf = 1; | 101 | + $lists->is_pdf = 2; |
| 102 | $lists->save(); | 102 | $lists->save(); |
| 103 | $this->debug_echo('项目文件数据保存成功!'); | 103 | $this->debug_echo('项目文件数据保存成功!'); |
| 104 | return 0; | 104 | return 0; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | /** | 107 | /** |
| 108 | - * Execute the console command. | ||
| 109 | - * | ||
| 110 | - * @return int | ||
| 111 | - */ | ||
| 112 | -// public function handle() | ||
| 113 | -// { | ||
| 114 | -// # 0 - 未生成 | ||
| 115 | -// # 1 - 已生成 | ||
| 116 | -// # 2 - 其它问题 | ||
| 117 | -// $is_pdf = 0; | ||
| 118 | -// $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf) | ||
| 119 | -// ->where('project_id', '!=', 0) | ||
| 120 | -// ->where('friend_id', '!=', 0) | ||
| 121 | -// ->where('user_id', '!=', 0) | ||
| 122 | -// ->where('created_at', 'like', $this->time . '%')->first(); | ||
| 123 | -// | ||
| 124 | -// if (is_null($lists)) { | ||
| 125 | -// $this->error('没有任务,等待中'); | ||
| 126 | -// sleep(60); | ||
| 127 | -// return 0; | ||
| 128 | -// } | ||
| 129 | -// $key = $this->signature . '-' . $lists->id; | ||
| 130 | -// $count = redis_get($key); | ||
| 131 | -// $project_id = $lists->project_id; | ||
| 132 | -// $user_id = $lists->user_id; | ||
| 133 | -// $friend_id = $lists->friend_id; | ||
| 134 | -// // todo 根据项目查询数据 | ||
| 135 | -// $project_data = []; | ||
| 136 | -// $html = $this->html($project_data); | ||
| 137 | -// $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id); | ||
| 138 | -// | ||
| 139 | -// $file_path = $this->savePDF($html, $filename); | ||
| 140 | -// if (empty($file_path)) { | ||
| 141 | -// $this->debug_echo('pdf生成失败!'); | ||
| 142 | -// return 0; | ||
| 143 | -// } | ||
| 144 | -// $file_path = $file_path['data']; | ||
| 145 | -// $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); | ||
| 146 | -// if (!$isRes) { | ||
| 147 | -// if ($count == 2) { | ||
| 148 | -// $lists->status = 2; | ||
| 149 | -// $lists->save(); | ||
| 150 | -// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key); | ||
| 151 | -// } else { | ||
| 152 | -// redis_add($key, $count + 1); | ||
| 153 | -// $this->error('项目文件数据保存失败! - ' . $key); | ||
| 154 | -// } | ||
| 155 | -// } | ||
| 156 | -// $lists->status = 1; | ||
| 157 | -// $lists->save(); | ||
| 158 | -// $this->info('项目文件数据保存成功!'); | ||
| 159 | -// return 0; | ||
| 160 | -// } | ||
| 161 | - | ||
| 162 | - /** | ||
| 163 | * @param $html | 108 | * @param $html |
| 164 | * @param $filename | 109 | * @param $filename |
| 165 | * @return array | 110 | * @return array |
| @@ -39,53 +39,12 @@ class WebsiteData extends Command | @@ -39,53 +39,12 @@ class WebsiteData extends Command | ||
| 39 | parent::__construct(); | 39 | parent::__construct(); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - /** | ||
| 43 | - * Execute the console command. | ||
| 44 | - * | ||
| 45 | - * @return int | ||
| 46 | - */ | ||
| 47 | -// public function handle() | ||
| 48 | -// { | ||
| 49 | -// # 0 - 未推送 | ||
| 50 | -// # 1 - 已推送 | ||
| 51 | -// # 2 - 其他问题 | ||
| 52 | -// $status = 0; | ||
| 53 | -// $lists = DataFile::query()->where('status', $status) | ||
| 54 | -// ->where('created_at', 'like', $this->time . '%')->first(); | ||
| 55 | -// if (is_null($lists)) { | ||
| 56 | -// $this->error('没有任务,等待中'); | ||
| 57 | -// sleep(30); | ||
| 58 | -// return 0; | ||
| 59 | -// } | ||
| 60 | -// | ||
| 61 | -// $key = $this->signature . '-' . $lists->id; | ||
| 62 | -// $count = redis_get($key); | ||
| 63 | -// $data = $lists; | ||
| 64 | -// | ||
| 65 | -// $url = env('AICC_URL'); | ||
| 66 | -// $msg = http_post($url, json_encode(compact('data'))); | ||
| 67 | -// $status_code = $msg['status']; | ||
| 68 | -// if ($status_code != 200) { | ||
| 69 | -// if ($count == 2) { | ||
| 70 | -// $lists->status = 2; | ||
| 71 | -// $lists->save(); | ||
| 72 | -// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key); | ||
| 73 | -// } else { | ||
| 74 | -// redis_add($key, $count + 1); | ||
| 75 | -// $this->error('项目文件数据保存失败! - ' . $key); | ||
| 76 | -// } | ||
| 77 | -// } | ||
| 78 | -// $lists->status = 1; | ||
| 79 | -// $lists->save(); | ||
| 80 | -// return 0; | ||
| 81 | -// } | ||
| 82 | - | ||
| 83 | public function start(): int | 42 | public function start(): int |
| 84 | { | 43 | { |
| 85 | - # 0 - 未推送 | ||
| 86 | - # 1 - 已推送 | ||
| 87 | - # 2 - 其他问题 | ||
| 88 | - $status = 0; | 44 | + # 1 - 未推送 |
| 45 | + # 2 - 已推送 | ||
| 46 | + # 3 - 其他问题 | ||
| 47 | + $status = 1; | ||
| 89 | $lists = DataFile::query()->where('status', $status) | 48 | $lists = DataFile::query()->where('status', $status) |
| 90 | ->where('created_at', 'like', $this->time . '%')->first(); | 49 | ->where('created_at', 'like', $this->time . '%')->first(); |
| 91 | if (is_null($lists)) { | 50 | if (is_null($lists)) { |
| @@ -99,47 +58,26 @@ class WebsiteData extends Command | @@ -99,47 +58,26 @@ class WebsiteData extends Command | ||
| 99 | $data = $lists; | 58 | $data = $lists; |
| 100 | $url = env('AICC_URL'); | 59 | $url = env('AICC_URL'); |
| 101 | $msg = http_post($url, json_encode(compact('data'))); | 60 | $msg = http_post($url, json_encode(compact('data'))); |
| 102 | - $status_code = $msg['status']; | 61 | + $status_code = 0; |
| 62 | + if ($msg) { | ||
| 63 | + $status_code = (int)$msg['status']; | ||
| 64 | + } | ||
| 103 | if ($status_code != 200) { | 65 | if ($status_code != 200) { |
| 104 | if ($count == 2) { | 66 | if ($count == 2) { |
| 105 | - $lists->status = 2; | 67 | + $lists->status = 3; |
| 106 | $lists->save(); | 68 | $lists->save(); |
| 107 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); | 69 | $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); |
| 108 | } else { | 70 | } else { |
| 109 | - redis_add($key, $count + 1); | 71 | + redis_set($key, $count + 1); |
| 110 | $this->debug_echo('项目文件数据保存失败! - ' . $key); | 72 | $this->debug_echo('项目文件数据保存失败! - ' . $key); |
| 111 | } | 73 | } |
| 112 | } | 74 | } |
| 113 | - $lists->status = 1; | 75 | + $lists->status = 2; |
| 114 | $lists->save(); | 76 | $lists->save(); |
| 115 | $this->info('项目文件数据保存成功!'); | 77 | $this->info('项目文件数据保存成功!'); |
| 116 | return 0; | 78 | return 0; |
| 117 | } | 79 | } |
| 118 | 80 | ||
| 119 | - /** | ||
| 120 | - * Execute the console command. | ||
| 121 | - * | ||
| 122 | - * @return int | ||
| 123 | - */ | ||
| 124 | -// public function handle() | ||
| 125 | -// { | ||
| 126 | -// $DataFile = new DataFile(); | ||
| 127 | -// $data = $DataFile->allData(); | ||
| 128 | -// # 详细数据 | ||
| 129 | -// $items = $data['items']; | ||
| 130 | -// # 总分页 | ||
| 131 | -// $totalPage = $data['totalPage']; | ||
| 132 | -// $this->post_data($items); | ||
| 133 | -// if ($totalPage > 1) { | ||
| 134 | -// for ($page = 2; $page <= $totalPage; $page++) { | ||
| 135 | -// $da = $DataFile->allData($page); | ||
| 136 | -// $this->post_data($da['items']); | ||
| 137 | -// } | ||
| 138 | -// } | ||
| 139 | -// $this->info('项目文件数据推送完成!'); | ||
| 140 | -// return 0; | ||
| 141 | -// } | ||
| 142 | - | ||
| 143 | public function post_data($data) | 81 | public function post_data($data) |
| 144 | { | 82 | { |
| 145 | $url = env('AICC_URL'); | 83 | $url = env('AICC_URL'); |
-
请 注册 或 登录 后发表评论