|
...
|
...
|
@@ -14,7 +14,9 @@ use App\Models\Manage\ManageHr; |
|
|
|
use App\Models\Ticket\TicketDailyCount;
|
|
|
|
use App\Models\Ticket\TicketDailyDeptCount;
|
|
|
|
use App\Models\Ticket\TicketDailyManageCount;
|
|
|
|
use App\Models\Ticket\TicketMonthDeptCount;
|
|
|
|
use App\Models\Ticket\TicketMonthManageCount;
|
|
|
|
use App\Models\Ticket\TicketWeekDeptCount;
|
|
|
|
use App\Models\Ticket\TicketWeekManageCount;
|
|
|
|
use App\Models\WorkOrder\TicketLog;
|
|
|
|
use App\Models\WorkOrder\TicketProject;
|
|
...
|
...
|
@@ -70,6 +72,16 @@ class TicketCount extends Command |
|
|
|
if($action == 'dept_action'){
|
|
|
|
$this->dept_action();
|
|
|
|
}
|
|
|
|
if($action == 'dept_week_action'){
|
|
|
|
$startOfLastWeek = Carbon::now()->subWeek()->startOfWeek(); // 上周一 00:00:00
|
|
|
|
$endOfLastWeek = Carbon::now()->subWeek()->endOfWeek(); // 上周日 23:59:59
|
|
|
|
$this->dept_week_month_action($startOfLastWeek,$endOfLastWeek,(new TicketWeekDeptCount()));
|
|
|
|
}
|
|
|
|
if($action == 'dept_month_action'){
|
|
|
|
$startOfLastMonth = Carbon::now()->subMonth()->startOfMonth(); // 上个月 1号 00:00:00
|
|
|
|
$endOfLastMonth = Carbon::now()->subMonth()->endOfMonth(); // 上个月最后一天 23:59:59
|
|
|
|
$this->dept_week_month_action($startOfLastMonth,$endOfLastMonth,(new TicketMonthDeptCount()));
|
|
|
|
}
|
|
|
|
if($action == 'yesterday_daily_action'){
|
|
|
|
$this->yesterday_daily_action();
|
|
|
|
}
|
|
...
|
...
|
@@ -161,6 +173,7 @@ class TicketCount extends Command |
|
|
|
$manageList = $manageHrModel->list(['status'=>1,'dept_id'=>['in',[1,2]]],'id',['id','dept_id','manage_id','name','nickname']);
|
|
|
|
$ticketLogModel = new TicketLog();
|
|
|
|
foreach ($manageList as $item){
|
|
|
|
$timeout_ratio = $average_time = null;
|
|
|
|
$this->output('按人员统计:执行的人员名称/id:'.$item['name'].'/'.$item['manage_id']);
|
|
|
|
//上一周新增工单总数
|
|
|
|
$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 |
|
|
|
$ticketDailyDeptModel = new TicketDailyDeptCount();
|
|
|
|
$date = Carbon::yesterday()->toDateString(); // "2025-08-07"
|
|
|
|
foreach ($groupList as $item){
|
|
|
|
$average_time = null;
|
|
|
|
$timeout_ratio = null;
|
|
|
|
$timeout_ratio = $average_time = null;
|
|
|
|
$this->output('组统计:执行的组/id:'.$item['name'].'/'.$item['id']);
|
|
|
|
$manageIdArr = $manageHrModel->selectField(['belong_group'=>$item['id'],'status'=>['!=',9],'status'=>1,'dept_id'=>1],'manage_id');
|
|
|
|
$ticket_num = $ticketLogModel->counts(['engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
|
|
...
|
...
|
@@ -260,6 +272,66 @@ class TicketCount extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :技术组按周统计
|
|
|
|
* @name :dept_week_month_action
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/8/30 14:01
|
|
|
|
*/
|
|
|
|
public function dept_week_month_action($startOfLast,$endOfLast,$model){
|
|
|
|
$belongingGroupModel = new BelongingGroup();
|
|
|
|
$groupList = $belongingGroupModel->list(['id'=>['in',[1,2,3,4,5,6,7,8,9]]],'id',['id','name']);
|
|
|
|
$manageHrModel = new ManageHr();
|
|
|
|
$ticketLogModel = new TicketLog();
|
|
|
|
foreach ($groupList as $item){
|
|
|
|
$timeout_ratio = $average_time = null;
|
|
|
|
$this->output('组统计:执行的组/id:'.$item['name'].'/'.$item['id']);
|
|
|
|
$manageIdArr = $manageHrModel->selectField(['belong_group'=>$item['id'],'status'=>['!=',9],'status'=>1,'dept_id'=>1],'manage_id');
|
|
|
|
//本周新增工单
|
|
|
|
$add_num = $ticketLogModel->counts(['created_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
|
|
|
|
$complete_num = $ticketLogModel->counts(['end_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
|
|
|
|
//超期工单数量
|
|
|
|
$timeout_num = $ticketLogModel
|
|
|
|
->whereIn('engineer_id', $manageIdArr)
|
|
|
|
->where('is_engineer', 1)
|
|
|
|
->where('status','!=',9)//排除掉作废工单
|
|
|
|
->where(function ($query) use ($startOfLast,$endOfLast) {
|
|
|
|
$query->where(function ($q) use ($startOfLast,$endOfLast) {
|
|
|
|
$q->whereBetween('plan_end_at',[$startOfLast,$endOfLast])->whereNotNull('end_at')->whereColumn('plan_end_at', '<', 'end_at');
|
|
|
|
})->orWhere(function ($q) {
|
|
|
|
$q->whereNull('end_at')->where('plan_end_at', '<', now());
|
|
|
|
});
|
|
|
|
})
|
|
|
|
->count();
|
|
|
|
//预期结束时间在本周的所有工单
|
|
|
|
$ticket_num = $ticketLogModel->counts(['plan_end_at'=>['between',[$startOfLast,$endOfLast]],'engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'status'=>['!=',9]]);
|
|
|
|
if(!empty($timeout_num)){
|
|
|
|
$timeout_ratio = round($timeout_num / $ticket_num, 3);
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'dept_id'=>$item['id'],
|
|
|
|
'dept_name'=>$item['name'],
|
|
|
|
'add_num'=>$add_num ?? 0,
|
|
|
|
'complete_num'=>$complete_num ?? 0,
|
|
|
|
'average_time'=>$average_time ?? null,
|
|
|
|
'timeout_ratio'=>$timeout_ratio ?? null,
|
|
|
|
'timeout_num'=>$timeout_num,
|
|
|
|
'start_at'=>$startOfLast,
|
|
|
|
'end_at'=>$endOfLast
|
|
|
|
];
|
|
|
|
//查询当前用户是否当日已有记录
|
|
|
|
$ticketManageInfo = $model->read(['start_at'=>$startOfLast,'end_at'=>$endOfLast,'dept_id'=>$item['id']],['id']);
|
|
|
|
if($ticketManageInfo === false){
|
|
|
|
//TODO::执行新增
|
|
|
|
$model->addReturnId($data);
|
|
|
|
}else{
|
|
|
|
//TODO::执行编辑
|
|
|
|
$model->edit($data,['id'=>$ticketManageInfo['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :技术组所有工单记录
|
|
|
|
* @name :daily_action
|
|
|
|
* @author :lyh
|
...
|
...
|
|