作者 李宇航

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

未续费项目增加搜索



查看合并请求 !2678
@@ -14,7 +14,9 @@ use App\Models\Manage\ManageHr; @@ -14,7 +14,9 @@ use App\Models\Manage\ManageHr;
14 use App\Models\Ticket\TicketDailyCount; 14 use App\Models\Ticket\TicketDailyCount;
15 use App\Models\Ticket\TicketDailyDeptCount; 15 use App\Models\Ticket\TicketDailyDeptCount;
16 use App\Models\Ticket\TicketDailyManageCount; 16 use App\Models\Ticket\TicketDailyManageCount;
  17 +use App\Models\Ticket\TicketMonthDeptCount;
17 use App\Models\Ticket\TicketMonthManageCount; 18 use App\Models\Ticket\TicketMonthManageCount;
  19 +use App\Models\Ticket\TicketWeekDeptCount;
18 use App\Models\Ticket\TicketWeekManageCount; 20 use App\Models\Ticket\TicketWeekManageCount;
19 use App\Models\WorkOrder\TicketLog; 21 use App\Models\WorkOrder\TicketLog;
20 use App\Models\WorkOrder\TicketProject; 22 use App\Models\WorkOrder\TicketProject;
@@ -70,6 +72,16 @@ class TicketCount extends Command @@ -70,6 +72,16 @@ class TicketCount extends Command
70 if($action == 'dept_action'){ 72 if($action == 'dept_action'){
71 $this->dept_action(); 73 $this->dept_action();
72 } 74 }
  75 + if($action == 'dept_week_action'){
  76 + $startOfLastWeek = Carbon::now()->subWeek()->startOfWeek(); // 上周一 00:00:00
  77 + $endOfLastWeek = Carbon::now()->subWeek()->endOfWeek(); // 上周日 23:59:59
  78 + $this->dept_week_month_action($startOfLastWeek,$endOfLastWeek,(new TicketWeekDeptCount()));
  79 + }
  80 + if($action == 'dept_month_action'){
  81 + $startOfLastMonth = Carbon::now()->subMonth()->startOfMonth(); // 上个月 1号 00:00:00
  82 + $endOfLastMonth = Carbon::now()->subMonth()->endOfMonth(); // 上个月最后一天 23:59:59
  83 + $this->dept_week_month_action($startOfLastMonth,$endOfLastMonth,(new TicketMonthDeptCount()));
  84 + }
73 if($action == 'yesterday_daily_action'){ 85 if($action == 'yesterday_daily_action'){
74 $this->yesterday_daily_action(); 86 $this->yesterday_daily_action();
75 } 87 }
@@ -161,6 +173,7 @@ class TicketCount extends Command @@ -161,6 +173,7 @@ class TicketCount extends Command
161 $manageList = $manageHrModel->list(['status'=>1,'dept_id'=>['in',[1,2]]],'id',['id','dept_id','manage_id','name','nickname']); 173 $manageList = $manageHrModel->list(['status'=>1,'dept_id'=>['in',[1,2]]],'id',['id','dept_id','manage_id','name','nickname']);
162 $ticketLogModel = new TicketLog(); 174 $ticketLogModel = new TicketLog();
163 foreach ($manageList as $item){ 175 foreach ($manageList as $item){
  176 + $timeout_ratio = $average_time = null;
164 $this->output('按人员统计:执行的人员名称/id:'.$item['name'].'/'.$item['manage_id']); 177 $this->output('按人员统计:执行的人员名称/id:'.$item['name'].'/'.$item['manage_id']);
165 //上一周新增工单总数 178 //上一周新增工单总数
166 $add_num = $ticketLogModel->counts(['created_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>$item['manage_id'],'is_engineer'=>1,'status'=>['!=',9]]); 179 $add_num = $ticketLogModel->counts(['created_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>$item['manage_id'],'is_engineer'=>1,'status'=>['!=',9]]);
@@ -213,8 +226,7 @@ class TicketCount extends Command @@ -213,8 +226,7 @@ class TicketCount extends Command
213 $ticketDailyDeptModel = new TicketDailyDeptCount(); 226 $ticketDailyDeptModel = new TicketDailyDeptCount();
214 $date = Carbon::yesterday()->toDateString(); // "2025-08-07" 227 $date = Carbon::yesterday()->toDateString(); // "2025-08-07"
215 foreach ($groupList as $item){ 228 foreach ($groupList as $item){
216 - $average_time = null;  
217 - $timeout_ratio = null; 229 + $timeout_ratio = $average_time = null;
218 $this->output('组统计:执行的组/id:'.$item['name'].'/'.$item['id']); 230 $this->output('组统计:执行的组/id:'.$item['name'].'/'.$item['id']);
219 $manageIdArr = $manageHrModel->selectField(['belong_group'=>$item['id'],'status'=>['!=',9],'status'=>1,'dept_id'=>1],'manage_id'); 231 $manageIdArr = $manageHrModel->selectField(['belong_group'=>$item['id'],'status'=>['!=',9],'status'=>1,'dept_id'=>1],'manage_id');
220 $ticket_num = $ticketLogModel->counts(['engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]); 232 $ticket_num = $ticketLogModel->counts(['engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
@@ -260,6 +272,66 @@ class TicketCount extends Command @@ -260,6 +272,66 @@ class TicketCount extends Command
260 } 272 }
261 273
262 /** 274 /**
  275 + * @remark :技术组按周统计
  276 + * @name :dept_week_month_action
  277 + * @author :lyh
  278 + * @method :post
  279 + * @time :2025/8/30 14:01
  280 + */
  281 + public function dept_week_month_action($startOfLast,$endOfLast,$model){
  282 + $belongingGroupModel = new BelongingGroup();
  283 + $groupList = $belongingGroupModel->list(['id'=>['in',[1,2,3,4,5,6,7,8,9]]],'id',['id','name']);
  284 + $manageHrModel = new ManageHr();
  285 + $ticketLogModel = new TicketLog();
  286 + foreach ($groupList as $item){
  287 + $timeout_ratio = $average_time = null;
  288 + $this->output('组统计:执行的组/id:'.$item['name'].'/'.$item['id']);
  289 + $manageIdArr = $manageHrModel->selectField(['belong_group'=>$item['id'],'status'=>['!=',9],'status'=>1,'dept_id'=>1],'manage_id');
  290 + //本周新增工单
  291 + $add_num = $ticketLogModel->counts(['created_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
  292 + $complete_num = $ticketLogModel->counts(['end_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
  293 + //超期工单数量
  294 + $timeout_num = $ticketLogModel
  295 + ->whereIn('engineer_id', $manageIdArr)
  296 + ->where('is_engineer', 1)
  297 + ->where('status','!=',9)//排除掉作废工单
  298 + ->where(function ($query) use ($startOfLast,$endOfLast) {
  299 + $query->where(function ($q) use ($startOfLast,$endOfLast) {
  300 + $q->whereBetween('plan_end_at',[$startOfLast,$endOfLast])->whereNotNull('end_at')->whereColumn('plan_end_at', '<', 'end_at');
  301 + })->orWhere(function ($q) {
  302 + $q->whereNull('end_at')->where('plan_end_at', '<', now());
  303 + });
  304 + })
  305 + ->count();
  306 + //预期结束时间在本周的所有工单
  307 + $ticket_num = $ticketLogModel->counts(['plan_end_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
  308 + if(!empty($timeout_num)){
  309 + $timeout_ratio = round($timeout_num / $ticket_num, 3);
  310 + }
  311 + $data = [
  312 + 'dept_id'=>$item['id'],
  313 + 'dept_name'=>$item['name'],
  314 + 'add_num'=>$add_num ?? 0,
  315 + 'complete_num'=>$complete_num ?? 0,
  316 + 'average_time'=>$average_time ?? null,
  317 + 'timeout_ratio'=>$timeout_ratio ?? null,
  318 + 'timeout_num'=>$timeout_num,
  319 + 'start_at'=>$startOfLast,
  320 + 'end_at'=>$endOfLast
  321 + ];
  322 + //查询当前用户是否当日已有记录
  323 + $ticketManageInfo = $model->read(['start_at'=>$startOfLast,'end_at'=>$endOfLast,'dept_id'=>$item['id']],['id']);
  324 + if($ticketManageInfo === false){
  325 + //TODO::执行新增
  326 + $model->addReturnId($data);
  327 + }else{
  328 + //TODO::执行编辑
  329 + $model->edit($data,['id'=>$ticketManageInfo['id']]);
  330 + }
  331 + }
  332 + return true;
  333 + }
  334 + /**
263 * @remark :技术组所有工单记录 335 * @remark :技术组所有工单记录
264 * @name :daily_action 336 * @name :daily_action
265 * @author :lyh 337 * @author :lyh
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketDailyDeptCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/7 17:51
  8 + */
  9 +
  10 +namespace App\Models\Ticket;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :工单月统计:按照技术组统计
  16 + * @name :TicketDailyDeptCount
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/8/7 17:51
  20 + */
  21 +class TicketMonthDeptCount extends Base
  22 +{
  23 + protected $table = 'gl_ticket_month_dept_count';
  24 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketDailyDeptCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/7 17:51
  8 + */
  9 +
  10 +namespace App\Models\Ticket;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :工单周统计:按照技术组统计
  16 + * @name :TicketDailyDeptCount
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/8/7 17:51
  20 + */
  21 +class TicketWeekDeptCount extends Base
  22 +{
  23 + protected $table = 'gl_ticket_week_dept_count';
  24 +}