|
...
|
...
|
@@ -75,8 +75,17 @@ class GeoQuestionRes extends Command |
|
|
|
$result_data = $geoService->setWebSearchChatAction($q_item,$p_item);
|
|
|
|
echo 'success:'.$result_data['code'].PHP_EOL;
|
|
|
|
if(isset($result_data) && $result_data['code'] == 200){
|
|
|
|
$keywords = $this->getKeywords($keywordArr,$result_data['text'] ?? []);
|
|
|
|
$urls = $this->getUrl($urlArr,$result_data['annotations'] ?? []);
|
|
|
|
$result_data_annotations[] = $result_data['text'];
|
|
|
|
if(!empty($result_data['annotations'])){
|
|
|
|
$url = array_column($result_data['annotations'], 'url');
|
|
|
|
$title = array_column($result_data['annotations'], 'title');
|
|
|
|
$result_data_annotations = array_merge($url,$title,$result_data_annotations);
|
|
|
|
dd($result_data['annotations']);
|
|
|
|
}else{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$keywords = $this->getKeywords($keywordArr,$result_data_annotations ?? []);
|
|
|
|
$urls = $this->getUrl($urlArr,$result_data_annotations ?? []);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
echo $e->getMessage().PHP_EOL;
|
|
...
|
...
|
@@ -100,16 +109,9 @@ class GeoQuestionRes extends Command |
|
|
|
}else{
|
|
|
|
$geoResultModel->edit($data,['id'=>$resultInfo['id']]);
|
|
|
|
}
|
|
|
|
$data_log = [
|
|
|
|
'project_id'=>$info['project_id'],
|
|
|
|
'question_id'=>$info['id'],
|
|
|
|
'platform'=>$p_item,
|
|
|
|
'question'=>$q_item,
|
|
|
|
'text'=>json_encode($result_data ?? [],true),
|
|
|
|
'type'=>$info['type'] ?? 1
|
|
|
|
];
|
|
|
|
//日志记录
|
|
|
|
$geoLogModel = new GeoQuestionLog();
|
|
|
|
$geoLogModel->addReturnId($data_log);
|
|
|
|
$geoLogModel->addReturnId($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//更新下次执行时间
|
|
...
|
...
|
@@ -124,22 +126,13 @@ class GeoQuestionRes extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2025/7/3 16:38
|
|
|
|
*/
|
|
|
|
public function getUrl($urlArr = [],$result_annotations = [],$result_text = []){
|
|
|
|
public function getUrl($urlArr = [],$result_annotations = []){
|
|
|
|
$url = [];
|
|
|
|
if(!empty($urlArr)){
|
|
|
|
$str = implode(',',$result_annotations);
|
|
|
|
foreach ($urlArr as $u_item){
|
|
|
|
if(!empty($result_text)){
|
|
|
|
if (str_contains($result_text, $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!empty($result_annotations)){
|
|
|
|
foreach ($result_annotations as $a_item){
|
|
|
|
echo 'url'.$a_item['url_citation']['url'].PHP_EOL.'当前的url:'.$u_item;
|
|
|
|
if (str_contains($a_item['url_citation']['url'], $u_item) || str_contains($a_item['url_citation']['title'], $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (str_contains($str, $u_item)) {
|
|
|
|
$url[] = $u_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -156,8 +149,9 @@ class GeoQuestionRes extends Command |
|
|
|
public function getKeywords($keywordArr = [],$result_text = []){
|
|
|
|
$keywords = [];
|
|
|
|
if(!empty($keywordArr) && !empty($result_text)){
|
|
|
|
$str = implode(',',$result_text);
|
|
|
|
foreach ($keywordArr as $k_item){
|
|
|
|
if (str_contains($result_text, $k_item)) {
|
|
|
|
if (str_contains($str, $k_item)) {
|
|
|
|
$keywords[] = $k_item;
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|