作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !2315
@@ -75,8 +75,17 @@ class GeoQuestionRes extends Command @@ -75,8 +75,17 @@ class GeoQuestionRes extends Command
75 $result_data = $geoService->setWebSearchChatAction($q_item,$p_item); 75 $result_data = $geoService->setWebSearchChatAction($q_item,$p_item);
76 echo 'success:'.$result_data['code'].PHP_EOL; 76 echo 'success:'.$result_data['code'].PHP_EOL;
77 if(isset($result_data) && $result_data['code'] == 200){ 77 if(isset($result_data) && $result_data['code'] == 200){
78 - $keywords = $this->getKeywords($keywordArr,$result_data['text'] ?? []);  
79 - $urls = $this->getUrl($urlArr,$result_data['annotations'] ?? []); 78 + $result_data_annotations[] = $result_data['text'];
  79 + if(!empty($result_data['annotations'])){
  80 + $url = array_column($result_data['annotations'], 'url');
  81 + $title = array_column($result_data['annotations'], 'title');
  82 + $result_data_annotations = array_merge($url,$title,$result_data_annotations);
  83 + dd($result_data['annotations']);
  84 + }else{
  85 + continue;
  86 + }
  87 + $keywords = $this->getKeywords($keywordArr,$result_data_annotations ?? []);
  88 + $urls = $this->getUrl($urlArr,$result_data_annotations ?? []);
80 } 89 }
81 }catch (\Exception $e){ 90 }catch (\Exception $e){
82 echo $e->getMessage().PHP_EOL; 91 echo $e->getMessage().PHP_EOL;
@@ -100,16 +109,9 @@ class GeoQuestionRes extends Command @@ -100,16 +109,9 @@ class GeoQuestionRes extends Command
100 }else{ 109 }else{
101 $geoResultModel->edit($data,['id'=>$resultInfo['id']]); 110 $geoResultModel->edit($data,['id'=>$resultInfo['id']]);
102 } 111 }
103 - $data_log = [  
104 - 'project_id'=>$info['project_id'],  
105 - 'question_id'=>$info['id'],  
106 - 'platform'=>$p_item,  
107 - 'question'=>$q_item,  
108 - 'text'=>json_encode($result_data ?? [],true),  
109 - 'type'=>$info['type'] ?? 1  
110 - ]; 112 + //日志记录
111 $geoLogModel = new GeoQuestionLog(); 113 $geoLogModel = new GeoQuestionLog();
112 - $geoLogModel->addReturnId($data_log); 114 + $geoLogModel->addReturnId($data);
113 } 115 }
114 } 116 }
115 //更新下次执行时间 117 //更新下次执行时间
@@ -124,22 +126,13 @@ class GeoQuestionRes extends Command @@ -124,22 +126,13 @@ class GeoQuestionRes extends Command
124 * @method :post 126 * @method :post
125 * @time :2025/7/3 16:38 127 * @time :2025/7/3 16:38
126 */ 128 */
127 - public function getUrl($urlArr = [],$result_annotations = [],$result_text = []){ 129 + public function getUrl($urlArr = [],$result_annotations = []){
128 $url = []; 130 $url = [];
129 if(!empty($urlArr)){ 131 if(!empty($urlArr)){
  132 + $str = implode(',',$result_annotations);
130 foreach ($urlArr as $u_item){ 133 foreach ($urlArr as $u_item){
131 - if(!empty($result_text)){  
132 - if (str_contains($result_text, $u_item)) {  
133 - $url[] = $u_item;  
134 - }  
135 - }  
136 - if(!empty($result_annotations)){  
137 - foreach ($result_annotations as $a_item){  
138 - echo 'url'.$a_item['url_citation']['url'].PHP_EOL.'当前的url:'.$u_item;  
139 - if (str_contains($a_item['url_citation']['url'], $u_item) || str_contains($a_item['url_citation']['title'], $u_item)) {  
140 - $url[] = $u_item;  
141 - }  
142 - } 134 + if (str_contains($str, $u_item)) {
  135 + $url[] = $u_item;
143 } 136 }
144 } 137 }
145 } 138 }
@@ -156,8 +149,9 @@ class GeoQuestionRes extends Command @@ -156,8 +149,9 @@ class GeoQuestionRes extends Command
156 public function getKeywords($keywordArr = [],$result_text = []){ 149 public function getKeywords($keywordArr = [],$result_text = []){
157 $keywords = []; 150 $keywords = [];
158 if(!empty($keywordArr) && !empty($result_text)){ 151 if(!empty($keywordArr) && !empty($result_text)){
  152 + $str = implode(',',$result_text);
159 foreach ($keywordArr as $k_item){ 153 foreach ($keywordArr as $k_item){
160 - if (str_contains($result_text, $k_item)) { 154 + if (str_contains($str, $k_item)) {
161 $keywords[] = $k_item; 155 $keywords[] = $k_item;
162 } 156 }
163 } 157 }
@@ -46,6 +46,18 @@ class GeoQuestionResController extends BaseController @@ -46,6 +46,18 @@ class GeoQuestionResController extends BaseController
46 } 46 }
47 47
48 /** 48 /**
  49 + * @remark :获取统计数据
  50 + * @name :getCount
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2025/7/8 17:18
  54 + */
  55 + public function getCount(){
  56 + $data = $this->logic->getCount();
  57 + $this->response('success',Code::SUCCESS,$data);
  58 + }
  59 +
  60 + /**
49 * @remark :获取列表数据 61 * @remark :获取列表数据
50 * @name :getList 62 * @name :getList
51 * @author :lyh 63 * @author :lyh
@@ -22,6 +22,19 @@ class GeoQuestionResLogic extends BaseLogic @@ -22,6 +22,19 @@ class GeoQuestionResLogic extends BaseLogic
22 } 22 }
23 23
24 /** 24 /**
  25 + * @remark :获取类型统计数据
  26 + * @name :getCount
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2025/7/8 17:16
  30 + */
  31 + public function getCount(){
  32 + $type_1 = $this->model->counts(['type'=>1,'project_id'=>$this->user['project_id']]);
  33 + $type_2 = $this->model->counts(['type'=>2,'project_id'=>$this->user['project_id']]);
  34 + return $this->success(['type_1'=>$type_1,'type_2'=>$type_2]);
  35 + }
  36 +
  37 + /**
25 * @remark :获取列表页数据 38 * @remark :获取列表页数据
26 * @name :getResultList 39 * @name :getResultList
27 * @author :lyh 40 * @author :lyh
@@ -754,6 +754,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -754,6 +754,7 @@ Route::middleware(['bloginauth'])->group(function () {
754 Route::any('/getList', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class,'getList'])->name('geo_result_getList'); 754 Route::any('/getList', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class,'getList'])->name('geo_result_getList');
755 Route::any('/getInfo', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class,'getInfo'])->name('geo_result_getInfo'); 755 Route::any('/getInfo', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class,'getInfo'])->name('geo_result_getInfo');
756 Route::any('/getType', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class, 'getType'])->name('geo_result_getType');//geo设置类型 756 Route::any('/getType', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class, 'getType'])->name('geo_result_getType');//geo设置类型
  757 + Route::any('/getCount', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class, 'getCount'])->name('geo_result_getCount');//geo设置类型统计数量
757 }); 758 });
758 }); 759 });
759 //无需登录验证的路由组 760 //无需登录验证的路由组