作者 lyh

gx脚本更新路由

@@ -66,7 +66,6 @@ class UpdateBuildConfiguration extends Command @@ -66,7 +66,6 @@ class UpdateBuildConfiguration extends Command
66 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 66 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
67 ProjectServer::useProject($v['id']); 67 ProjectServer::useProject($v['id']);
68 $this->getProduct(); 68 $this->getProduct();
69 - gc_collect_cycles(); // 确保内存释放  
70 DB::disconnect('custom_mysql'); 69 DB::disconnect('custom_mysql');
71 } 70 }
72 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 71 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
@@ -81,29 +80,36 @@ class UpdateBuildConfiguration extends Command @@ -81,29 +80,36 @@ class UpdateBuildConfiguration extends Command
81 */ 80 */
82 public function getProduct(){ 81 public function getProduct(){
83 $productModel = new Product(); 82 $productModel = new Product();
84 - $lists = $productModel->list([],'id',['id','describe']);  
85 - $detailModel = new Detail();  
86 - if(!empty($lists)){  
87 - foreach ($lists as $k => $v){  
88 - if(empty($v['describe'])){  
89 - continue;  
90 - }  
91 - echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL;  
92 - $info = $detailModel->read(['product_id'=>$v['id']],['id']);  
93 - if($info === false){  
94 - $data = [  
95 - 'product_id'=>$v['id'],  
96 - 'column_id'=>1,  
97 - 'text_type'=>1,  
98 - 'title'=>'',  
99 - 'sort'=>1,  
100 - 'content'=>json_encode(['content'=>$v['describe']],true),  
101 - 'created_at'=>date('Y-m-d H:i:s'),  
102 - 'updated_at'=>date('Y-m-d H:i:s')  
103 - ];  
104 - $detailModel->insert($data); 83 + $page = 1;
  84 + while (true){
  85 + $lists = $productModel->lists([],$page,$page*5,['id','describe']);
  86 + $detailModel = new Detail();
  87 + if(!empty($lists['list'])){
  88 + foreach ($lists['list'] as $k => $v){
  89 + if(empty($v['describe'])){
  90 + continue;
  91 + }
  92 + echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL;
  93 + $info = $detailModel->read(['product_id'=>$v['id']],['id']);
  94 + if($info === false){
  95 + $data = [
  96 + 'product_id'=>$v['id'],
  97 + 'column_id'=>1,
  98 + 'text_type'=>1,
  99 + 'title'=>'',
  100 + 'sort'=>1,
  101 + 'content'=>json_encode(['content'=>$v['describe']],true),
  102 + 'created_at'=>date('Y-m-d H:i:s'),
  103 + 'updated_at'=>date('Y-m-d H:i:s')
  104 + ];
  105 + $detailModel->insert($data);
  106 + }
105 } 107 }
  108 + }else{
  109 + break;
  110 + return false;
106 } 111 }
  112 + $page++;
107 } 113 }
108 return true; 114 return true;
109 } 115 }