作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -100,6 +100,9 @@ class AiBlogAutoPublish extends Command
//2、未达标的项目,开启AIblog, 并立即推送三篇;
//3、其他项目等下下周 1 (2025-03-17)开始推送第一篇, 之后按照正频率发送;
if (!$last_task) {
if(strpos($frequency[0],'/')){
$frequency = [1,1];//默认每天执行
}
if(!$compliance) {
for ($i = 0; $i < 3; $i++) {
$this->createTask($keywords, $project->id, $frequency);
... ... @@ -110,7 +113,18 @@ class AiBlogAutoPublish extends Command
}
}
} else {
$this->createTask($keywords, $project->id, $frequency);
if($frequency[0] == '1/2'){//一天2篇
$aiBlogTaskModel = new AiBlogTaskModel();
$frequency = explode('/', $frequency[0]);
//查询当前已发布几篇
$count = $aiBlogTaskModel->counts(['next_auto_date' => date('Y-m-d'),'project_id' => $project->id]);
while ($count < ($frequency[1] ?? 2)){
$this->createTask($keywords, $project->id, [$frequency[0],$frequency[0]]);
$count++;
}
}else{
$this->createTask($keywords, $project->id, $frequency);
}
}
}catch (\Exception $e){
(new DingService())->handle([
... ... @@ -133,7 +147,7 @@ class AiBlogAutoPublish extends Command
$result = $aiBlogService->createTask($keyword);
if ($result['status'] == 200) {
$aiBlogTaskModel = new AiBlogTaskModel();
$next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0],$frequency[1]) . 'days')); //每3-6天自动发布
$next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0] ?? 3, $frequency[1] ?? 6) . 'days')); //每3-6天自动发布
$aiBlogTaskModel->addReturnId(['project_id' => $project_id, 'type' => 2, 'task_id' => $result['data']['task_id'], 'status' => 1, 'next_auto_date' => $next_auto_date]);
ProjectServer::useProject($project_id);
$aiBlogModel = new AiBlog();
... ... @@ -141,7 +155,6 @@ class AiBlogAutoPublish extends Command
$end = strtotime('16:00:00');
$randomTimestamp = mt_rand($start, $end);
$created_at = date("Y-m-d H:i:s", $randomTimestamp);
$aiBlogModel->addReturnId(['keyword' => $keyword, 'status' => 1, 'task_id' => $result['data']['task_id'], 'project_id' => $project_id, 'created_at' => $created_at]);
DB::disconnect('custom_mysql');
$this->output("任务创建成功");
... ...
... ... @@ -293,6 +293,9 @@ class AiBlogTask extends Command
$domainModel = new DomainInfo();
$project_model = new Project();
foreach ($routes as $project_id => $route){
if($project_id == 4339){
continue;
}
$route[] = 'top-blog';
$domain = $domainModel->getProjectIdDomain($project_id);
if (empty($domain)) {
... ...
... ... @@ -118,7 +118,7 @@ class RemainDay extends Command
*/
public function seoRemainDay($deploy_build,$item){
//白帽版本的系统
if($deploy_build['seo_plan'] == 1){
if($deploy_build['seo_plan'] != 0){
if($deploy_build['seo_service_duration'] != 0){
if(in_array($item['id'],$this->bm_projectId) || (in_array( 19,$item['level']))){
$compliance_day = (int)$item['bm_finish_remain_day'];
... ...
... ... @@ -119,24 +119,23 @@ class GeoQuestionRes extends Command
$hit_data = array_merge($url, $title, $hit_data);
}
$hit = 0;
//todo::与预期结果是否复合
if(!empty($taskInfo['expect_result'])){
$str = "客户提出的问题:{$question},客户得到的回复:{$result['text']},客户需要预期:{$taskInfo['expect_result']},请分析得到的回复和预期是否一致,仅回复我是或者否";
$strResult = $geo_service->getChatResult($str, 'gpt-4o-mini');
if(isset($strResult['text']) && !empty($strResult['text'])){
switch ($strResult['text']){
case '是':
$is_match = 1;
$hit++;
break;
case '否':
$is_match = 2;
break;
default:
$is_match = 0;
break;
}
$is_match = 0;
$cosine = 0;
$similarity = [];
// TODO 有预期结果,分析答案和预期结果
if(FALSE == empty($taskInfo['expect_result'])){
$cosine_result = $geo_service->cosineSimilarity($taskInfo['expect_result'], $result['text']);
// 语义是否一致
if (FALSE == empty($cosine_result['judgement'])) {
$is_match = $cosine_result['judgement'] == '语义相近' ? 1 : 2;
$hit++;
}
// 余弦相似度
if (FALSE == empty($cosine_result['similarity']))
$cosine = intval($cosine_result['similarity'] * 10000) / 100;
// 语句拆解结果
if (FALSE == empty($cosine_result['split_results']))
$similarity = $cosine_result['split_results'];
}
$hit_keyword = $this->getKeywords($taskInfo['keywords'],$hit_data);
if (!empty($hit_keyword['keywords'])) {
... ... @@ -165,6 +164,8 @@ class GeoQuestionRes extends Command
'url_num'=>$url_num ?? [],
'is_match'=>$is_match ?? 0,
'label'=>$taskInfo['label'] ?? null,
'cosine' => $cosine,
'similarity' => json_encode($similarity, true),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
... ... @@ -315,17 +316,6 @@ class GeoQuestionRes extends Command
}
/**
* @remark :预期结果对比
* @name :getExpectResult
* @author :lyh
* @method :post
* @time :2025/8/12 13:51
*/
public function getExpectResult($question,$answer,$expect){
$str = "客户提出的问题:{$question},客户得到的回复:{$answer},客户需要预期:{$expect},请分析得到的回复和预期是否一致,仅回复我是或者否";
}
/**
* 获取待执行任务ID
* @return mixed
*/
... ...
... ... @@ -33,6 +33,7 @@ class CreateProject extends Command
protected $description = '创建项目';
public function handle(){
dd(1);
return $this->sync();
}
... ... @@ -42,10 +43,12 @@ class CreateProject extends Command
* @throws \Exception
*/
public function sync($is_update = 0){
$company = '济南市莱芜凤城铝合金有限公司';
$mobile = '13806340552';
$plan = '标准版';
$cooperate_date = '2019-11-19';
$company = '山东临磨数控机床装备有限公司(自建站)';
$mobile = '18663004388';
$lead_name = '18663004388';
$plan = '商务版';
$cooperate_date = '2025-08-21';
// $channel = '{"user_id": "732", "zone_id": "1", "channel_id": "95"}';
$channel = '{"user_id": "1989", "zone_id": "4", "channel_id": "13"}';
$title = date('Ymd') . '-' . $company;
... ... @@ -53,7 +56,7 @@ class CreateProject extends Command
'project'=>[
'title' => $title,
'company' => $company,
'lead_name' => $mobile,
'lead_name' => $lead_name,
'mobile' => $mobile,
'mysql_id'=>Project::MYSQL_ID,
'serve_id'=>9,
... ... @@ -61,7 +64,7 @@ class CreateProject extends Command
'channel' => $channel,
'requirement' => '',
'cooperate_date' => $cooperate_date,
'from_order_id' => '',
'from_order_id' => uniqid(),
'type' => $is_update,
'is_upgrade'=>$is_update,
],
... ...
... ... @@ -101,6 +101,19 @@ class SyncProject extends Command
if($data['data']['order_type'] == '续费'){
$this->renewSync($data['data']);
}
// TODO 如果是续费项目 并且有GEO版本,需要处理GEO版本
if (($data['data']['order_type'] == '续费') && !empty($data['data']['geo_plan']) && ($data['data']['geo_plan'] != '无')) {
// 续费单,并且有GEO版本, 正常版本不创建 初始化正常版本
$data['data']['plan_marketing'] = '无';
//创建对应的GEO版本
$projectModel = new Project();
$seo_plan = $this->versionSeoData($data['data']['geo_plan'] ?? '');
$projectInfo = $projectModel->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')->where('gl_project.company', $data['data']['company_name'])->where('gl_project_deploy_build.seo_plan',$seo_plan)->select(['gl_project.id AS id'])->first();
if (empty($projectInfo)) {
// 创建对应GEO项目
$this->sync($data['data'],$is_update);
}
}
$item->status = NoticeLog::STATUS_SUCCESS;
$item->save();
echo 'success:' . $item['id'] . '执行时间:' . date('Y-m-d H:i:s') . PHP_EOL;
... ... @@ -136,7 +149,7 @@ class SyncProject extends Command
* @time :2023/8/11 15:33
*/
public function renewSync($param){
$title = date('Ymd') . '-' . $param['company_name'];;
$title = date('Ymd') . '-' . $param['company_name'];
$data = [
'title' => '【续费单】'.$title,
'company' => $param['company_name'],
... ... @@ -146,7 +159,7 @@ class SyncProject extends Command
'channel' => json_encode(Channel::getProjectChannel($param['company_id'], $param['username_sales'])),
'requirement' => $param['remark'],
'cooperate_date' => date('Y-m-d', $param['create_time']),
// 'api_no' => $param['id'], //改手动填
'api_no' => $param['id'], //改手动填
'amount' => $param['plan_price'],
'contract' => json_encode($param['files']),
'bill' => json_encode($param['images']),
... ...
... ... @@ -32,60 +32,29 @@ class SyncTimeFiles extends Command
{
$fileModel = new File();
// $imagesModel = new Image();
$start = '2024-11-07 15:00:00';
$end = '2024-11-07 15:25:00';
$start = '2025-08-20 00:00:00';
$end = '2025-08-28 00:00:00';
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
foreach ($lists as $v){
$path = $v['path'];
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
echo date('Y-m-d H:i:s') . ' | 图片链接:' . $path . PHP_EOL;
$code = $this->synchronizationFile($path);
if(200 != (int)$code){
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
// $errorFileModel = new ErrorFile();
// $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
public function synchronizationFile($path_name){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
}
... ...
... ... @@ -47,16 +47,11 @@ class SyncTimeMinuteFile extends Command
}
foreach ($lists as $v){
$path = $v['path'];
if (file_exists($dir.$path)) {
echo date('Y-m-d H:i:s') . ' | file_ok:' . $dir.$path . PHP_EOL;
continue;
}
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
// if (file_exists($dir.$path)) {
// echo date('Y-m-d H:i:s') . ' | file_ok:' . $dir.$path . PHP_EOL;
// continue;
// }
$code = $this->synchronizationFile($path);
if(200 != (int)$code){
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
$errorFileModel = new ErrorFile();
... ... @@ -67,6 +62,14 @@ class SyncTimeMinuteFile extends Command
return true;
}
public function synchronizationFile($path_name){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
/**
* @remark :获取图片文件链接
* @name :getUrl
... ...
... ... @@ -30,12 +30,7 @@ class SyncVideo extends Command
public function handle()
{
$path = $this->argument('path');
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
$code = $this->synchronizationFile($path);
echo date('Y-m-d H:i:s') . ' | ' . $code . PHP_EOL;
if(200 != (int)$code){
echo date('Y-m-d H:i:s') . ' | ' . $code . PHP_EOL;
... ... @@ -45,6 +40,14 @@ class SyncVideo extends Command
return true;
}
public function synchronizationFile($path_name){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
/**
* @remark :获取图片文件链接
* @name :getUrl
... ...
... ... @@ -199,7 +199,7 @@ class TicketCount extends Command
)
->groupBy('p.project_cate')
->pluck('ticket_count', 'project_cate');
$timeout_num = $ticketModel->counts(['end_at'=>null,'plan_end_at'=>['>',date('Y-m-d H:i:s')]]);
$timeout_num = $ticketModel->counts(['plan_end_at'=>['>',date('Y-m-d H:i:s')]]);
$timeout_ratio = null;
if(!empty($timeout_num)){
$timeout_ratio = round($timeout_num / $ticket_num, 3);
... ...
... ... @@ -60,7 +60,29 @@ class FetchTicketProjects extends Command
$postids = [];
while (true) {
$response = Http::get('https://www.quanqiusou.cn/extend_api/webs/globalso_all.php?page=' . $page);
try {
$maxRetries = 3;
$retryCount = 0;
while ($retryCount < $maxRetries) {
try {
$response = Http::get('https://www.quanqiusou.cn/extend_api/webs/globalso_all.php?page=' . $page);
break; // 如果请求成功,跳出重试循环
} catch (\Exception $e) {
$retryCount++;
if ($retryCount >= $maxRetries) {
// 如果达到最大重试次数,抛出异常
throw $e;
}
// 等待一段时间再重试
sleep(2);
}
}
}catch (\Exception $e){
echo now() . " | ERROR | " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
break;
}
if ($response->status() == 200) {
$resp_json = $response->json();
$items = $resp_json['data'] ?? [];
... ...
... ... @@ -200,6 +200,7 @@ class OptimizeController extends BaseController
'gl_project.is_translate AS is_translate',
'gl_project.is_translate_tag AS is_translate_tag',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.project_type AS project_type',
'gl_project.site_status AS site_status',
'gl_project_online_check.id AS online_check_id',
'gl_project_online_check.question AS question',
... ...
... ... @@ -161,6 +161,7 @@ class RenewProjectController extends BaseController
$data = APublicModel::getNumByProjectId($item['id']);
}
$plan = Project::planMap();
$seoPlan = Project::seoMap();
$item = [
'id' => $item['id'],
'title' => $item['title'],
... ... @@ -178,8 +179,10 @@ class RenewProjectController extends BaseController
'optimize_tech' => $manageModel->getName($item['deploy_optimize']['tech_mid']), //售后技术
'type' => $item['type'],
'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
'plan' =>$plan[$item['deploy_build']['plan']] ?? '白帽seo版本',
'plan' =>$plan[$item['deploy_build']['plan']] ?? '无',
'seo_plan' =>$seoPlan[$item['deploy_build']['seo_plan']] ?? '无',
'plan_id' =>$item['deploy_build']['plan'],
'seo_plan_id' =>$item['deploy_build']['seo_plan'],
'domain' => !empty($item['deploy_optimize']['domain']) ? $domainModel->getDomain($item['deploy_optimize']['domain']) : '',
'created_at' => date('Y年m月d日', strtotime($item['created_at'])),
'autologin_code' => getAutoLoginCode($item['id']),
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Template\ATemplateLogic;
use App\Http\Requests\Aside\Template\ATemplateRequest;
use App\Models\Manage\Manage;
use App\Models\Template\TemplateLabel;
/**
... ... @@ -26,12 +27,14 @@ class ATemplateController extends BaseController
public function lists(ATemplateLogic $aTemplateLogic){
$templateLabel = new TemplateLabel();
$this->map = $this->searchLabelName($templateLabel);
$filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
$filed = ['id','name','image','url','status','upload_id','sort','deleted_status','test_model','created_at','project_id'];
$lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists) && !empty($lists['list'])){
$manageModel = new Manage();
foreach ($lists['list'] as $k => $v){
$v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>1],'id',['id','name'],'desc',5);
$v['image_link'] = getImageUrl($v['image']);
$v['upload_name'] = $manageModel->getName($v['upload_id']);
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -89,6 +89,9 @@ class AsideTicketController extends BaseController
$q->whereIn('engineer_id', $manageIdArr);
});
}
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
return $query->whereBetween('created_at',[$this->param['start_at'],$this->param['end_at']]);
}
// 添加排序功能
$query->orderBy('status', 'asc');
// $query->orderBy('id', 'desc');
... ...
... ... @@ -472,7 +472,9 @@ class ProjectLogic extends BaseLogic
}
$param['confirm_file'] = Arr::a2s($param['confirm_file'] ?? []);
$remain_day = $param['deploy_build']['service_duration'] - $param['finish_remain_day'];
$seo_remain_day = $param['deploy_build']['seo_service_duration'] - $param['bm_finish_remain_day'];
$param['remain_day'] = ($remain_day > 0) ? $remain_day : 0;
$param['seo_remain_day'] = ($seo_remain_day > 0) ? $seo_remain_day : 0;
//文件上传默认值
if($param['is_upload_manage']){
$param['upload_config'] = [
... ...
... ... @@ -42,7 +42,7 @@ class TicketLogic extends BaseLogic
$date = date('Y-m-d');//今日时间
$data['add_num'] = $ticketModel->counts(['created_at'=>['between',[$date.' 00:00:00',$date.' 23:59:59']]]);//今日新增工单
$data['processed_num'] = $ticketModel->counts(['end_at'=>['between',[$date.' 00:00:00',$date.' 23:59:59']]]);//今日已处理工单
$data['untreated_num'] = $ticketModel->counts(['end_at'=>null]);//今日未处理工单
$data['untreated_num'] = $ticketModel->counts(['end_at'=>null,'plan_end_at'=>['like','%'.date('Y-m-d').'%']]);//今日未处理工单
$submit_a_side = $ticketModel->formatQuery(['submit_side'=>1])->sum('submit_side');
$submit_b_side = $ticketModel->formatQuery(['submit_side'=>2])->sum('submit_side');
$data['source'] = ['a'=>$submit_a_side,'b'=>$submit_b_side];
... ...
... ... @@ -48,7 +48,7 @@ class GeoQuestionResLogic extends BaseLogic
*/
public function getResultList($map = [],$page = 1,$row = 20){
$map['project_id'] = $this->user['project_id'];
$filed = ['id','project_id','question_id','platform','is_match','question','en_question','keywords','url','label','created_at','updated_at'];
$filed = ['id','project_id','question_id','platform','is_match','question','en_question','keywords','url','label','cosine','created_at','updated_at'];
if(!empty($map['created_at'])){
$map['created_at'] = ['between',[$map['created_at'].' 00:00:00',$map['created_at'].' 23:59:59']];
$this->model = new GeoQuestionLog();
... ... @@ -93,32 +93,50 @@ class GeoQuestionResLogic extends BaseLogic
$core_question_count = $questionTotalCount = $urlTotalCount = $keywordsTotalCount = 0;
$keywordArr = [];
$questionLogModel = new GeoQuestionLog();
$keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]);
$coreKeywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'label'=>['like','%核心问题%'],'hit'=>['!=',0]]);
foreach ($list as $item){
$questionTotalCount += count($item['question'] ?? []);
//核心问题数
if(strpos($item['label'],'核心问题') !== false){
$core_question_count += count($item['question'] ?? []);
if($this->user['project_id'] == 4533){
$keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'is_match'=>1,'hit'=>['!=',0]]);
foreach ($list as $item){
$questionTotalCount += count($item['question'] ?? []);
//核心问题数
if(strpos($item['label'],'核心问题') !== false){
$core_question_count += count($item['question'] ?? []);
}
foreach ($item['keywords'] as $keyWordItem){
if (!array_key_exists($keyWordItem, $keywordArr)) {
$keywordArr[$keyWordItem] = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'is_match'=>1,'keywords'=>['like','%"'.$keyWordItem.'"%']]);
}
}
}
$keywordsTotalCount += count($item['keywords'] ?? []);
$urlTotalCount += count($item['url'] ?? []);
foreach ($item['keywords'] as $keyWordItem){
if (!array_key_exists($keyWordItem, $keywordArr)) {
$keywordArr[$keyWordItem] = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'keywords'=>['like','%"'.$keyWordItem.'"%']]);
$coreKeywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'label'=>['like','%核心问题%'],'is_match'=>1,'hit'=>['!=',0]]);
$data = [
'question_count'=>$questionTotalCount,//问题总数
'core_question_count'=>$core_question_count,//核心问题总数
'keywords_url_count'=>$keywordUrlCount,
'keywords_arr' => $keywordArr,
'core_keyword_url_count'=>$coreKeywordUrlCount ?? 0
];
return $this->success($data);
}else{
$keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]);
foreach ($list as $item){
$questionTotalCount += count($item['question'] ?? []);
$keywordsTotalCount += count($item['keywords'] ?? []);
$urlTotalCount += count($item['url'] ?? []);
foreach ($item['keywords'] as $keyWordItem){
if (!array_key_exists($keyWordItem, $keywordArr)) {
$keywordArr[$keyWordItem] = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'keywords'=>['like','%"'.$keyWordItem.'"%']]);
}
}
}
$data = [
'question_count'=>$questionTotalCount,
'keywords_count'=>$keywordsTotalCount,
'url_count'=>$urlTotalCount,
'keywords_url_count'=>$keywordUrlCount,
'keywords_arr' => $keywordArr,
];
return $this->success($data);
}
$data = [
'keywords_count'=>$keywordsTotalCount,
'url_count'=>$urlTotalCount,
'question_count'=>$questionTotalCount,
'keywords_url_count'=>$keywordUrlCount,
'keywords_arr' => $keywordArr,
'core_question_count'=>$core_question_count,
'core_keyword_url_count'=>$coreKeywordUrlCount
];
return $this->success($data);
}
/**
... ... @@ -134,7 +152,11 @@ class GeoQuestionResLogic extends BaseLogic
$list = $platformModel->list(['status'=>1],'id',['name','en_name']);
$questionResModel = new GeoQuestionLog();
foreach ($list as $item){
$data[$item['name']] = $questionResModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0],'platform'=>$item['en_name']]);
if($this->user['project_id'] == 4533){
$data[$item['name']] = $questionResModel->counts(['project_id'=>$this->user['project_id'],'is_match'=>1,'hit'=>['!=',0],'platform'=>$item['en_name']]);
}else{
$data[$item['name']] = $questionResModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0],'platform'=>$item['en_name']]);
}
}
return $this->success($data);
}
... ...
... ... @@ -34,10 +34,8 @@ class SyncImageFileJob implements ShouldQueue
*/
public function handle()
{
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
$code = $this->synchronizationFile($this->param['path'].'/'.$this->param['name']);
echo date('Y-m-d H:i:s') . ' | ' . $code . PHP_EOL;
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
... ... @@ -45,39 +43,12 @@ class SyncImageFileJob implements ShouldQueue
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
public function synchronizationFile($path_name){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
return shell_exec($cmd);
}
}
... ...
... ... @@ -79,6 +79,7 @@ class Project extends Base
3=>'2-4',
4=>'3-5',
5=>'5-7',
6=>'1/2'
];
if($val){
return $arr[$val] ?? '';
... ...
... ... @@ -9,6 +9,8 @@
namespace App\Services\Geo;
use Illuminate\Support\Facades\Http;
class GeoService
{
public $api_key = 'UkzZljFv83Z2qBi5YR1o3f2otAVWtug6';
... ... @@ -108,4 +110,31 @@ class GeoService
$data = http_post($url,json_encode($message,true),$header);
return $data;
}
/**
* 获取语句余弦相似度
* $text 会被拆解语句, 分析预警传$text
* @param string $standard 标准答案
* @param string $text 需要分析的语句
* @param string $embedding_model
* @param string $similarity_method
* @return \Illuminate\Http\Client\Response
*/
public function cosineSimilarity($standard, $text, $embedding_model = 'text-embedding-3-small', $similarity_method = 'cosine')
{
$url = 'http://knowledge_base.zabbix.waimaoq.com/v1/crud/split_similarity';
$header = [
'accept: application/json',
'Content-Type: application/json'
];
$param = [
'text1' => $standard,
'text2' => $text,
'embedding_model' => $embedding_model,
'similarity_method' => $similarity_method
];
$result = Http::post($url, $param);
return $result->json();
}
}
... ...