正在显示
1 个修改的文件
包含
13 行增加
和
7 行删除
| @@ -33,7 +33,7 @@ class InitKeywordComment extends Command | @@ -33,7 +33,7 @@ class InitKeywordComment extends Command | ||
| 33 | */ | 33 | */ |
| 34 | protected $description = '初始化关键字评论'; | 34 | protected $description = '初始化关键字评论'; |
| 35 | 35 | ||
| 36 | - | 36 | + public $number = 100; |
| 37 | 37 | ||
| 38 | public function handle(){ | 38 | public function handle(){ |
| 39 | return $this->_action(467); | 39 | return $this->_action(467); |
| @@ -47,7 +47,17 @@ class InitKeywordComment extends Command | @@ -47,7 +47,17 @@ class InitKeywordComment extends Command | ||
| 47 | echo date('Y-m-d H:i:s').'start:' . $item['id'] . PHP_EOL; | 47 | echo date('Y-m-d H:i:s').'start:' . $item['id'] . PHP_EOL; |
| 48 | $project_id = $item['data']['project_id']; | 48 | $project_id = $item['data']['project_id']; |
| 49 | echo date('Y-m-d H:i:s').'执行的项目id:' . $project_id . PHP_EOL; | 49 | echo date('Y-m-d H:i:s').'执行的项目id:' . $project_id . PHP_EOL; |
| 50 | - $this->_action($project_id); | 50 | + try { |
| 51 | + $this->_action($project_id); | ||
| 52 | + $count = $keywordCommonModel->counts(['project_id'=>$project_id]); | ||
| 53 | + if($count > 100){ | ||
| 54 | + $item->status = NoticeLog::STATUS_SUCCESS; | ||
| 55 | + $item->save(); | ||
| 56 | + } | ||
| 57 | + }catch (\Exception $e){ | ||
| 58 | + echo date('Y-m-d H:i:s').'错误信息:'.$e->getMessage().PHP_EOL; | ||
| 59 | + continue; | ||
| 60 | + } | ||
| 51 | echo date('Y-m-d H:i:s').'end:' . $item['id'] . PHP_EOL; | 61 | echo date('Y-m-d H:i:s').'end:' . $item['id'] . PHP_EOL; |
| 52 | } | 62 | } |
| 53 | } | 63 | } |
| @@ -73,7 +83,7 @@ class InitKeywordComment extends Command | @@ -73,7 +83,7 @@ class InitKeywordComment extends Command | ||
| 73 | $item = str_replace("'", '"', $item); | 83 | $item = str_replace("'", '"', $item); |
| 74 | // 解码成 PHP 关联数组 | 84 | // 解码成 PHP 关联数组 |
| 75 | $item = json_decode($item, true); | 85 | $item = json_decode($item, true); |
| 76 | - if(!isset($item) || !isset($item)){ | 86 | + if(!isset($item['name']) || !isset($item['comment'])){ |
| 77 | continue; | 87 | continue; |
| 78 | } | 88 | } |
| 79 | $data[] = [ | 89 | $data[] = [ |
| @@ -89,10 +99,6 @@ class InitKeywordComment extends Command | @@ -89,10 +99,6 @@ class InitKeywordComment extends Command | ||
| 89 | $keywordCommonModel = new AggregateKeywordComment(); | 99 | $keywordCommonModel = new AggregateKeywordComment(); |
| 90 | $keywordCommonModel->insertAll($data); | 100 | $keywordCommonModel->insertAll($data); |
| 91 | } | 101 | } |
| 92 | - $count = $keywordCommonModel->counts(['project_id'=>$project_id]); | ||
| 93 | - if($count < 100){ | ||
| 94 | - $this->_action($project_id); | ||
| 95 | - } | ||
| 96 | return true; | 102 | return true; |
| 97 | } | 103 | } |
| 98 | } | 104 | } |
-
请 注册 或 登录 后发表评论