作者 李宇航

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

Lyh server



查看合并请求 !2396
@@ -98,6 +98,10 @@ class GeoQuestionRes extends Command @@ -98,6 +98,10 @@ class GeoQuestionRes extends Command
98 $data = $geo_service->getDeepSeekResult($question); 98 $data = $geo_service->getDeepSeekResult($question);
99 $result = $this->dealDeepSeek($data); 99 $result = $this->dealDeepSeek($data);
100 break; 100 break;
  101 + case 'gpt-4o-mini':
  102 + $data = $geo_service->getDeepSeekResult($question,'gpt-4o-mini');
  103 + $result = $this->dealDeepSeek($data,'gpt-4o-mini');
  104 + break;
101 default: 105 default:
102 $result = $geo_service->getAiPlatformResult($question, $platform); 106 $result = $geo_service->getAiPlatformResult($question, $platform);
103 break; 107 break;
@@ -215,10 +219,10 @@ class GeoQuestionRes extends Command @@ -215,10 +219,10 @@ class GeoQuestionRes extends Command
215 * @method :post 219 * @method :post
216 * @time :2025/7/15 10:58 220 * @time :2025/7/15 10:58
217 */ 221 */
218 - public function dealDeepSeek($data){ 222 + public function dealDeepSeek($data,$model = 'DeepSeek'){
219 $result = [ 223 $result = [
220 'code' => 200, 224 'code' => 200,
221 - 'model' => 'DeepSeek', 225 + 'model' => $model,
222 'text' => '', 226 'text' => '',
223 ]; 227 ];
224 $texts = []; 228 $texts = [];
@@ -33,9 +33,11 @@ use App\Models\Project\ProcessRecords; @@ -33,9 +33,11 @@ use App\Models\Project\ProcessRecords;
33 use App\Models\Project\Project; 33 use App\Models\Project\Project;
34 use App\Models\Project\ProjectUpdateTdk; 34 use App\Models\Project\ProjectUpdateTdk;
35 use App\Models\Project\RenewLog; 35 use App\Models\Project\RenewLog;
  36 +use App\Models\ProjectAssociation\ProjectAssociation;
36 use App\Models\RankData\RankData; 37 use App\Models\RankData\RankData;
37 use App\Models\Task\Task; 38 use App\Models\Task\Task;
38 use App\Models\WebSetting\WebLanguage; 39 use App\Models\WebSetting\WebLanguage;
  40 +use App\Models\WorkOrder\TicketProject;
39 use Illuminate\Http\Request; 41 use Illuminate\Http\Request;
40 use Illuminate\Support\Facades\DB; 42 use Illuminate\Support\Facades\DB;
41 43
@@ -70,23 +72,13 @@ class ProjectController extends BaseController @@ -70,23 +72,13 @@ class ProjectController extends BaseController
70 if(!empty($lists) && !empty($lists['list'])){ 72 if(!empty($lists) && !empty($lists['list'])){
71 foreach ($lists['list'] as $k => $v){ 73 foreach ($lists['list'] as $k => $v){
72 $v = $this->handleParam($v); 74 $v = $this->handleParam($v);
73 -  
74 - // 组装 工单UUID  
75 - $ticketProject = null;  
76 - $ticketProject = DB::table('gl_ticket_projects')  
77 - ->where('table_id', $v['id'])  
78 - ->where('project_cate', 2)  
79 - ->first();  
80 - $v['uuid'] = $ticketProject ? $ticketProject->uuid : null;  
81 // 组装 工单UUID END 75 // 组装 工单UUID END
82 -  
83 $lists['list'][$k] = $v; 76 $lists['list'][$k] = $v;
84 } 77 }
85 } 78 }
86 $this->response('success',Code::SUCCESS,$lists); 79 $this->response('success',Code::SUCCESS,$lists);
87 } 80 }
88 81
89 -  
90 /** 82 /**
91 * 需要查询的字段 83 * 需要查询的字段
92 * @return array 84 * @return array
@@ -458,6 +450,8 @@ class ProjectController extends BaseController @@ -458,6 +450,8 @@ class ProjectController extends BaseController
458 $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN); 450 $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
459 $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]); 451 $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]);
460 $item['collect_time'] = $item['is_upgrade'] ? UpdateLog::getProjectUpdate($item['id']) : ''; 452 $item['collect_time'] = $item['is_upgrade'] ? UpdateLog::getProjectUpdate($item['id']) : '';
  453 + $item['uuid'] = TicketProject::where('table_id', $item['id'])->where('project_cate', 2)->value('uuid') ?? null;
  454 + $item['friend_id'] = ProjectAssociation::where('project_id', $item['id'])->where('status', ProjectAssociation::STATUS_NORMAL)->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)->value('friend_id') ?? null;
461 return $item; 455 return $item;
462 } 456 }
463 457
@@ -92,4 +92,17 @@ class GeoQuestionResController extends BaseController @@ -92,4 +92,17 @@ class GeoQuestionResController extends BaseController
92 $data = $this->logic->getResultInfo(); 92 $data = $this->logic->getResultInfo();
93 $this->response('success',Code::SUCCESS,$data); 93 $this->response('success',Code::SUCCESS,$data);
94 } 94 }
  95 +
  96 + /**
  97 + * @remark :统计数量
  98 + * @name :countQuantity
  99 + * @author :lyh
  100 + * @method :post
  101 + * @time :2025/7/21 10:58
  102 + */
  103 + public function countQuantity(){
  104 + $data = $this->logic->countQuantity();
  105 + $data['platform'] = $this->logic->platformHitCount();
  106 + $this->response('success',Code::SUCCESS,$data);
  107 + }
95 } 108 }
@@ -10,6 +10,8 @@ @@ -10,6 +10,8 @@
10 namespace App\Http\Logic\Bside\Geo; 10 namespace App\Http\Logic\Bside\Geo;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Geo\GeoPlatform;
  14 +use App\Models\Geo\GeoQuestion;
13 use App\Models\Geo\GeoQuestionResult; 15 use App\Models\Geo\GeoQuestionResult;
14 16
15 class GeoQuestionResLogic extends BaseLogic 17 class GeoQuestionResLogic extends BaseLogic
@@ -64,4 +66,60 @@ class GeoQuestionResLogic extends BaseLogic @@ -64,4 +66,60 @@ class GeoQuestionResLogic extends BaseLogic
64 $data = $this->model->read($this->param); 66 $data = $this->model->read($this->param);
65 return $this->success($data); 67 return $this->success($data);
66 } 68 }
  69 +
  70 + /**
  71 + * @remark :统计数量
  72 + * @name :countQuantity
  73 + * @author :lyh
  74 + * @method :post
  75 + * @time :2025/7/21 11:12
  76 + */
  77 + public function countQuantity(){
  78 + $questionModel = new GeoQuestion();
  79 + $list = $questionModel->list(['project_id',$this->user['project_id']],['question','keywords','url']);
  80 + $questionTotalCount = $urlTotalCount = $keywordsTotalCount = $keywordUrlCount = 0;
  81 + foreach ($list as $item){
  82 + $questionTotalCount += count($item['question'] ?? []);
  83 + $keywordsTotalCount += count($item['keywords'] ?? []);
  84 + $urlTotalCount += count($item['url'] ?? []);
  85 + }
  86 + $keywordArr = [];
  87 + $questionResModel = new GeoQuestionResult();
  88 + $resList = $questionResModel->list(['project_id',$this->user['project_id']],['keywords_num','url_num']);
  89 + foreach ($resList as $resItem){
  90 + $keywordsNumArr = json_decode($resItem['keywords_num'] ?? [], true); // 转为 PHP 关联数组
  91 + $keywordUrlCount += array_sum($keywordsNumArr); // 获取值的总和
  92 + $urlNumArr = json_decode($resItem['url'] ?? [],true);
  93 + $keywordUrlCount += array_sum($urlNumArr); // 获取值的总和
  94 + foreach ($resItem['keywords_num'] as $key => $value) {
  95 + $keywordArr[$key] = ($keywordArr[$key] ?? 0) + $value;
  96 + }
  97 + }
  98 + $data = [
  99 + 'keywords_count'=>$keywordsTotalCount,
  100 + 'url_count'=>$urlTotalCount,
  101 + 'question_count'=>$questionTotalCount,
  102 + 'keywords_url_count'=>$keywordUrlCount,
  103 + 'keywords_arr' => $keywordArr,
  104 + ];
  105 + return $this->success($data);
  106 + }
  107 +
  108 + /**
  109 + * @remark :按平台统计问题数量
  110 + * @name :platformHitCount
  111 + * @author :lyh
  112 + * @method :post
  113 + * @time :2025/7/21 15:00
  114 + */
  115 + public function platformHitCount(){
  116 + $data = [];
  117 + $platformModel = new GeoPlatform();
  118 + $list = $platformModel->list(['status'=>1],'id',['name','en_name']);
  119 + $questionResModel = new GeoQuestionResult();
  120 + foreach ($list as $item){
  121 + $data[$item['name']] = $questionResModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0],'platform'=>$item['en_name']]);
  122 + }
  123 + return $this->success($data);
  124 + }
67 } 125 }
@@ -69,4 +69,34 @@ class GeoQuestionResult extends Base @@ -69,4 +69,34 @@ class GeoQuestionResult extends Base
69 } 69 }
70 return $value; 70 return $value;
71 } 71 }
  72 +
  73 + /**
  74 + * @remark :命中的关键词数量
  75 + * @name :getKeywordsNumAttribute
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2025/7/21 11:33
  79 + */
  80 + public function getKeywordsNumAttribute($value)
  81 + {
  82 + if($value){
  83 + $value = Arr::s2a($value);
  84 + }
  85 + return $value;
  86 + }
  87 +
  88 + /**
  89 + * @remark :命中的url数量
  90 + * @name :getUrlNumAttribute
  91 + * @author :lyh
  92 + * @method :post
  93 + * @time :2025/7/21 11:34
  94 + */
  95 + public function getUrlNumAttribute($value)
  96 + {
  97 + if($value){
  98 + $value = Arr::s2a($value);
  99 + }
  100 + return $value;
  101 + }
72 } 102 }
@@ -76,7 +76,7 @@ class GeoService @@ -76,7 +76,7 @@ class GeoService
76 * @method :post 76 * @method :post
77 * @time :2025/7/15 10:59 77 * @time :2025/7/15 10:59
78 */ 78 */
79 - public function getDeepSeekResult($content){ 79 + public function getDeepSeekResult($content,$model = 'deepseek-r1'){
80 $url = $this->api_url . 'v1/chat'; 80 $url = $this->api_url . 'v1/chat';
81 $header = [ 81 $header = [
82 'accept: application/json', 82 'accept: application/json',
@@ -91,7 +91,7 @@ class GeoService @@ -91,7 +91,7 @@ class GeoService
91 'role'=>'user' 91 'role'=>'user'
92 ], 92 ],
93 ], 93 ],
94 - 'model' => 'deepseek-r1', 94 + 'model' => $model,
95 "supplier"=> "bailian", 95 "supplier"=> "bailian",
96 'security_check' => true 96 'security_check' => true
97 ]; 97 ];
@@ -755,6 +755,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -755,6 +755,7 @@ Route::middleware(['bloginauth'])->group(function () {
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 Route::any('/getCount', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class, 'getCount'])->name('geo_result_getCount');//geo设置类型统计数量
  758 + Route::any('/countQuantity', [\App\Http\Controllers\Bside\Geo\GeoQuestionResController::class, 'countQuantity'])->name('geo_result_countQuantity');//geo统计
758 }); 759 });
759 }); 760 });
760 //无需登录验证的路由组 761 //无需登录验证的路由组