作者 赵彬吉
... ... @@ -87,6 +87,9 @@ class CountProject extends Command
//剩余服务时常
$arr['service_day'] = $projectInfo['remain_day'];
$arr = $this->inquiry($arr,$domain, $project_id,$projectInfo['is_upgrade'] ?? 0);
if($arr === false){
continue;
}
//查询当天数据是否存在 存在则更新
$info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]);
if($info === false){
... ... @@ -146,7 +149,7 @@ class CountProject extends Command
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
return $arr;
}
// echo date('Y-m-d H:i:s') . '拉取询盘状态:' .json_encode($inquiry_list) . PHP_EOL;
if($inquiry_list['status'] == self::STATUS_ERROR){
... ...
... ... @@ -113,12 +113,32 @@ class GeoQuestionRes extends Command
}
// 命中文案
$hit_data[] = $result['text'];
if(!empty($result['annotations'])){
$url = array_column(array_column($result['annotations'], 'url_citation'), 'url');
$title = array_column(array_column($result['annotations'], 'url_citation'), 'title');
$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;
}
}
}
$hit_keyword = $this->getKeywords($taskInfo['keywords'],$hit_data);
if (!empty($hit_keyword['keywords'])) {
$hit++;
... ... @@ -144,6 +164,7 @@ class GeoQuestionRes extends Command
'hit' => $hit ?? 0,
'keywords_num'=>$keyword_num ?? [],
'url_num'=>$url_num ?? [],
'is_match'=>$is_match ?? 0,
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
... ... @@ -294,6 +315,17 @@ 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
*/
... ...
... ... @@ -50,17 +50,22 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
echo 'start.'. PHP_EOL;
$ticketModel = new Tickets();
$list = $ticketModel->list(['id'=>['!=',0]],'id',['id','plan_end_at']);
foreach ($list as $item){
echo '执行数据id:'.$item['id'].PHP_EOL;
$ticketLogModel = new TicketLog();
$ticketLogModel->edit(['plan_end_at'=>$item['plan_end_at']],['ticket_id'=>$item['id']]);
}
return $this->getExpectResult();
return true;
}
public function getExpectResult(){
$geo_service = new GeoService();
$question = 'Top AI Coffee Robot';
$answer = "Top AI Coffee Robot\" refers to advanced robotic systems that combine **precision automation, artificial intelligence, and specialty coffee expertise** to create high-quality beverages with minimal human intervention. Here's a breakdown of key features, leading examples, and benefits:\n\n### Core Features of Top AI Coffee Robots:\n1. **AI-Driven Customization** \n - Analyzes user preferences (strength, milk type, sweetness) via app profiles or voice commands. \n - Learns from feedback to refine future orders (e.g., \"less bitter than last time\"). \n2. **Robotic Precision Brewing** \n - Industrial arms handle grinding, tamping, steaming milk, and latte art with sub-millimeter accuracy. \n - Sensors monitor temperature, extraction time, and pressure for optimal flavor.";
$expect = "While I don't have specific information on the RobotAnno coffee machine, in general";
$str = "客户提出的问题:{$question},客户得到的回复:{$answer},客户需要预期:{$expect},请分析得到的回复和预期是否一致,仅回复我是或者否";
$data = $geo_service->getChatResult($str, 'gpt-4o-mini');
if(isset($data['text']) && $data['text'] == '是'){
}
}
/**
* @remark :查看路由是否为空
* @name :_actionRoute
... ...
... ... @@ -19,6 +19,7 @@ use App\Models\WorkOrder\TicketProject;
use App\Models\WorkOrder\Tickets;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class TicketCount extends Command
... ... @@ -75,6 +76,7 @@ class TicketCount extends Command
$date = Carbon::yesterday()->toDateString(); // 昨日时间
$ticketManageCountModel = new TicketDailyManageCount();
foreach ($manageList as $item){
$average_time = '';
$this->output('按人员统计:执行的人员名称/id:'.$item['name'].'/'.$item['manage_id']);
$ticketLogModel = new TicketLog();
$ticket_num = $ticketLogModel->counts(['engineer_id'=>$item['manage_id'],'is_engineer'=>1]);
... ... @@ -128,6 +130,7 @@ class TicketCount extends Command
$ticketDailyDeptModel = new TicketDailyDeptCount();
$date = Carbon::yesterday()->toDateString(); // "2025-08-07"
foreach ($groupList as $item){
$average_time = '';
$this->output('组统计:执行的组/id:'.$item['name'].'/'.$item['id']);
$manageIdArr = $manageHrModel->selectField(['belong_group'=>$item['id'],'status'=>1,'dept_id'=>1],'manage_id');
$ticket_num = $ticketLogModel->counts(['engineer_id'=>['in',$manageIdArr],'is_engineer'=>1]);
... ... @@ -140,7 +143,7 @@ class TicketCount extends Command
'dept_id'=>$item['id'],
'dept_name'=>$item['name'],
'ticket_num'=>$ticket_num ?? 0,
'average_time'=>$average_time ?? 0
'average_time'=>$average_time ?? ''
];
$deptInfo = $ticketDailyDeptModel->read(['date'=>$date,'dept_id'=>$item['id']],['id']);
if($deptInfo === false){
... ... @@ -173,6 +176,13 @@ class TicketCount extends Command
$processed_num = $ticketModel->counts(['end_at'=>['between',[$date.' 00:00:00',$date.' 23:59:59']]]);
$submit_a_side = $ticketModel->formatQuery(['submit_side'=>1])->sum('submit_side');
$submit_b_side = $ticketModel->formatQuery(['submit_side'=>2])->sum('submit_side');
$dbResult = DB::table('gl_ticket_projects as p')->leftJoin('gl_tickets as t', 'p.id', '=', 't.project_id')
->select(
'p.project_cate',
DB::raw('COUNT(t.id) as ticket_count')
)
->groupBy('p.project_cate')
->pluck('ticket_count', 'project_cate');
$data = [
'date' => $date,
'ticket_num'=>$ticket_num,
... ... @@ -181,6 +191,7 @@ class TicketCount extends Command
'processed_num'=>$processed_num,
'average_time'=>$average_time ?? '',
'source'=>json_encode(['a'=>$submit_a_side,'b'=>$submit_b_side],true),
'source_type'=>json_encode($dbResult,true)
];
$ticketDailyModel = new TicketDailyCount();
$ticketDailyInfo = $ticketDailyModel->read(['date'=>$date],['id']);
... ...
... ... @@ -37,7 +37,7 @@ class BaseController extends Controller
$info = Cache::get(Common::MANAGE_TOKEN . $this->token);
if(!empty($this->token) && !empty($info)){
$this->manage = $info;
Cache::put(Common::MANAGE_TOKEN . $this->token, $info, 3600 * 6);//更新缓存时间
Cache::put(Common::MANAGE_TOKEN . $this->token, $info, 3600 * 12);//更新缓存时间
$this->uid = $info['id'];
}
}
... ...
... ... @@ -32,6 +32,7 @@ class TicketController extends BaseController
public function ticketCount(){
$data['daily'] = $this->logic->getTicketCount();
$data['list'] = $this->logic->getDailyTicketCount();
$data['ticket'] = $this->logic->getTicketList();
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -67,7 +67,14 @@ class AsideTicketController extends BaseController
});
});
});
//TODO::用户部门搜索
if(isset($this->param['dept_id']) && !empty($this->param['dept_id'])){
$manageHrModel = new ManageHr();
$manageIdArr = $manageHrModel->selectField(['dept_id'=>$this->param['dept_id']],'manage_id');
$query->whereHas('logs', function ($q) use ($manageIdArr) {
$q->whereIn('engineer_id', $manageIdArr);
});
}
// 添加排序功能
$query->orderBy('status', 'asc');
// $query->orderBy('id', 'desc');
... ... @@ -178,6 +185,7 @@ class AsideTicketController extends BaseController
$ticket->star = $request->input('star', 3);
$ticket->plan_end_at = $request->input('plan_end_at', null);
$ticket->close_wechat = $request->input('close_wechat', false);
$ticket->num = $request->input('num', 0);
$ticket->save();
// 分配工单参与人
... ...
... ... @@ -41,13 +41,20 @@ class WebSettingImageController extends BaseController
public function save(WebSettingImage $webSettingImage){
try {
foreach ($this->param['data'] as $v){
if(isset($v['id']) && !empty($v['id'])){
$v['image'] = str_replace_url($v['image']);
$webSettingImage->edit($v,['id'=>$v['id']]);
}else{
$v['project_id'] = $this->user['project_id'];
$v['image'] = str_replace_url($v['image']);
$webSettingImage->add($v);
$info = $webSettingImage->read(['type'=>$v['type']],'id');
if($info === false){
$v['project_id'] = $this->user['project_id'];
$v['image'] = str_replace_url($v['image']);
$webSettingImage->add($v);
}else{
$v['image'] = str_replace_url($v['image']);
$webSettingImage->edit($v,['id'=>$info['id']]);
}
}
}
}catch (\Exception $e){
... ...
... ... @@ -10,9 +10,13 @@
namespace App\Http\Logic\Aside\Ticket;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\ManageHr;
use App\Models\Project\Project;
use App\Models\Ticket\TicketDailyCount;
use App\Models\Ticket\TicketDailyDeptCount;
use App\Models\Ticket\TicketDailyManageCount;
use App\Models\WorkOrder\TicketLog;
use App\Models\WorkOrder\TicketProject;
use App\Models\WorkOrder\Tickets;
use Illuminate\Support\Carbon;
... ... @@ -39,6 +43,9 @@ class TicketLogic extends BaseLogic
$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]);//今日未处理工单
$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];
return $this->success($data);
}
... ... @@ -52,16 +59,42 @@ class TicketLogic extends BaseLogic
public function getDailyTicketCount(){
$date = Carbon::yesterday()->toDateString(); //昨日时间
$dailyModel = new TicketDailyCount();
$dailyList = $dailyModel->list(['date'=>$date],'average_time',['*'],'desc',5);//取最近5条数据
$dailyList = $dailyModel->list([],'date',['*'],'desc',5);//取最近5条数据
$manageModel = new TicketDailyManageCount();
$manageList = $manageModel->list(['date'=>$date],'average_time',['*'],'desc',5);//取最近5条数据
$manageList = $manageModel->list(['date'=>$date,'ticket_num'=>['!=',0],'average_time'=>['!=','']],'average_time',['*'],'asc',5);//取最近5条数据
$deptModel = new TicketDailyDeptCount();
$deptList = $deptModel->list(['date'=>$date],'average_time',['*'],'desc',5);
$deptList = $deptModel->list(['date'=>$date,'ticket_num'=>['!=',0]],'average_time',['*'],'asc',5);
$data = ['daily'=>$dailyList,'manage'=>$manageList,'dept'=>$deptList];
return $this->success($data);
}
/**
* @remark :获取随机工单列表(20条)
* @name :ticketList
* @author :lyh
* @method :post
* @time :2025/8/12 11:06
*/
public function getTicketList(){
$ticketsList = Tickets::select(['project_id','title','end_at','end_time','id'])->inRandomOrder()->limit(20)->get();
$projectModel = new TicketProject();
$ticketLogModel = new TicketLog();
$manageModel = new ManageHr();
foreach ($ticketsList as $key => $item){
$item['project_name'] = $projectModel->getValue(['id'=>$item['project_id']],'title');
$engineer_id = $ticketLogModel->getValue(['ticket_id'=>$item['id'],'is_engineer'=>1],'engineer_id');
if(!empty($engineer_id)){
$item['manage_name'] = $manageModel->getValue(['manage_id'=>$engineer_id],'name');
}else{
$item['manage_name'] = '未分配';
}
$ticketsList[$key] = $item;
$item['status'] = (empty($item['end_at']) ? '未完成' : '完成');
}
return $this->success($ticketsList);
}
/**
* @remark :根据技术组获取
* @name :getManageTicketCount
* @author :lyh
... ...
... ... @@ -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','question','en_question','keywords','url','created_at','updated_at'];
$filed = ['id','project_id','question_id','platform','is_match','question','en_question','keywords','url','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();
... ...
... ... @@ -292,12 +292,14 @@ class UserLoginLogic
$info['project_location'] = $project['project_location'];
$info['file_cdn'] = $project['deploy_build']['file_cdn'];
$info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
$info['seo_service_duration'] = $project['deploy_build']['seo_service_duration'] ?? 0;
$info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0;
$info['is_ai_blog_send'] = $project['deploy_optimize']['is_ai_blog_send'] ?? 0;
$info['tech_leader'] = $project['deploy_optimize']['tech_leader'] ?? 0;
$manageModel = new ManageHr();
$info['tech_leader_name'] = $manageModel->getName($project['deploy_optimize']['tech_leader'] ?? 0);
$info['remain_day'] = $project['remain_day'] ?? 0;
$info['seo_remain_day'] = $project['seo_remain_day'] ?? 0;
$info['project_created_at'] = $project['created_at'];
$info['type'] = $project['type'] ?? 1;
if($info['is_customized'] == 1){
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Models\Ticket;
use App\Helper\Arr;
use App\Models\Base;
/**
... ... @@ -21,4 +22,14 @@ use App\Models\Base;
class TicketDailyCount extends Base
{
protected $table = 'gl_ticket_daily_count';
public function getSourceAttribute($value)
{
return Arr::s2a($value);
}
public function getSourceTypeAttribute($value)
{
return Arr::s2a($value);
}
}
... ...