作者 李宇航

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

Lyh server



查看合并请求 !2680
@@ -119,16 +119,12 @@ class TicketCount extends Command @@ -119,16 +119,12 @@ class TicketCount extends Command
119 } 119 }
120 //超时工单数量 120 //超时工单数量
121 $timeout_num = $ticketLogModel 121 $timeout_num = $ticketLogModel
122 - ->where('engineer_id', $item['manage_id'])  
123 - ->where('is_engineer', 1)  
124 - ->where('status','!=',9) 122 + ->where('engineer_id', $item['manage_id'])->where('is_engineer', 1)->where('status','!=',9)
125 ->where(function ($query) { 123 ->where(function ($query) {
126 $query->where(function ($q) { 124 $query->where(function ($q) {
127 - $q->whereNotNull('end_at')  
128 - ->whereColumn('plan_end_at', '<', 'end_at'); 125 + $q->whereNotNull('end_at')->whereColumn('plan_end_at', '<', 'end_at');
129 })->orWhere(function ($q) { 126 })->orWhere(function ($q) {
130 - $q->whereNull('end_at')  
131 - ->where('plan_end_at', '<', now()); 127 + $q->whereNull('end_at')->where('plan_end_at', '<', now());
132 }); 128 });
133 }) 129 })
134 ->count(); 130 ->count();
@@ -146,7 +142,8 @@ class TicketCount extends Command @@ -146,7 +142,8 @@ class TicketCount extends Command
146 'timeout_num'=>$timeout_num,//超时工单数量 142 'timeout_num'=>$timeout_num,//超时工单数量
147 'complete_num'=>$complete_num,//完成工单数量 143 'complete_num'=>$complete_num,//完成工单数量
148 'dept_id'=>$item['dept_id'], 144 'dept_id'=>$item['dept_id'],
149 - 'timeout_ratio'=>$timeout_ratio ?? null 145 + 'timeout_ratio'=>$timeout_ratio ?? null,
  146 + 'complete_ratio'=>round($timeCount / $complete_num, 2)
150 ]; 147 ];
151 //查询当前用户是否当日已有记录 148 //查询当前用户是否当日已有记录
152 $ticketManageInfo = $ticketManageCountModel->read(['date'=>$date,'manage_id'=>$item['id']],['id']); 149 $ticketManageInfo = $ticketManageCountModel->read(['date'=>$date,'manage_id'=>$item['id']],['id']);
@@ -12,7 +12,11 @@ namespace App\Http\Controllers\Aside\Ticket; @@ -12,7 +12,11 @@ namespace App\Http\Controllers\Aside\Ticket;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 use App\Http\Logic\Aside\Ticket\TicketLogic; 14 use App\Http\Logic\Aside\Ticket\TicketLogic;
  15 +use App\Models\Ticket\TicketDailyCount;
  16 +use App\Models\Ticket\TicketMonthDeptCount;
  17 +use App\Models\Ticket\TicketWeekDeptCount;
15 use Illuminate\Http\Request; 18 use Illuminate\Http\Request;
  19 +use Illuminate\Support\Carbon;
16 20
17 class TicketController extends BaseController 21 class TicketController extends BaseController
18 { 22 {
@@ -37,7 +41,79 @@ class TicketController extends BaseController @@ -37,7 +41,79 @@ class TicketController extends BaseController
37 } 41 }
38 42
39 /** 43 /**
40 - * @remark :技术组 44 + * @remark :获取最近一个月的数据
  45 + * @name :getMonthList
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2025/8/30 17:26
  49 + */
  50 + public function getMonthList(){
  51 + $this->request->validate([
  52 + 'start'=>'required',
  53 + 'end'=>'required'
  54 + ],[
  55 + 'start.required' => 'start不能为空',
  56 + 'end.required' => 'end不能为空',
  57 + ]);
  58 + $dailyModel = new TicketDailyCount();
  59 + $dailyList = $dailyModel->list(['date'=>['between',[$this->param['start'],$this->param['end']]]],'date',['*'],'desc',30);//取最近5条数据
  60 + $this->response('success',Code::SUCCESS,$dailyList);
  61 + }
  62 + /**
  63 + * @remark :获取搜索时间
  64 + * @name :getTIme
  65 + * @author :lyh
  66 + * @method :post
  67 + * @time :2025/8/30 15:39
  68 + */
  69 + public function getTime(){
  70 + $weekModel = new TicketWeekDeptCount();
  71 + $weekData = $weekModel->where('dept_id',1)->select('start_at', 'end_at')->distinct()->get()->toArray();
  72 + $monthModel = new TicketMonthDeptCount();
  73 + $monthData = $monthModel->where('dept_id',1)->select('start_at', 'end_at')->distinct()->get()->toArray();
  74 + $this->response('success',Code::SUCCESS,['week_data'=>$weekData,'month_data'=>$monthData]);
  75 + }
  76 +
  77 + /**
  78 + * @remark :周记录数据(默认上一周)
  79 + * @name :weekManageList
  80 + * @author :lyh
  81 + * @method :post
  82 + * @time :2025/8/30 15:31
  83 + */
  84 + public function weekManageList(){
  85 + $this->request->validate([
  86 + 'start'=>'required',
  87 + 'end'=>'required'
  88 + ],[
  89 + 'start.required' => 'start不能为空',
  90 + 'end.required' => 'end不能为空',
  91 + ]);
  92 + $data = $this->logic->getWeekManageList($this->param['start'],$this->param['end']);
  93 + $this->response('success',Code::SUCCESS,$data);
  94 + }
  95 +
  96 + /**
  97 + * @remark :按月统计数据(默认上一月)
  98 + * @name :monthManageList
  99 + * @author :lyh
  100 + * @method :post
  101 + * @time :2025/8/30 15:35
  102 + */
  103 + public function monthManageList(){
  104 + $this->request->validate([
  105 + 'start'=>'required',
  106 + 'end'=>'required'
  107 + ],[
  108 + 'start.required' => 'start不能为空',
  109 + 'end.required' => 'end不能为空',
  110 + ]);
  111 + $data = $this->logic->getMOnthManageList($this->param['start'],$this->param['end']);
  112 + $this->response('success',Code::SUCCESS,$data);
  113 + }
  114 +
  115 + /**
  116 + * @remark :技术组总统计
41 * @name :manageTicketCount 117 * @name :manageTicketCount
42 * @author :lyh 118 * @author :lyh
43 * @method :post 119 * @method :post
@@ -261,7 +261,8 @@ class AsideTicketController extends BaseController @@ -261,7 +261,8 @@ class AsideTicketController extends BaseController
261 $ticket->status = $request->input('status'); 261 $ticket->status = $request->input('status');
262 if ($request->input('num')) 262 if ($request->input('num'))
263 $ticket->num = $request->input('num',0); 263 $ticket->num = $request->input('num',0);
264 -// $ticket->logs()->where('status', '<', TicketLog::STATUS_COMPLETED)->where('is_engineer', 1)->update(['plan_end_at' => $ticket->plan_end_at]); 264 + //同步更改工单时间
  265 + $ticket->logs()->where('status', '<', TicketLog::STATUS_COMPLETED)->where('is_engineer', 1)->update(['plan_end_at' => $ticket->plan_end_at]);
265 if ($ticket->status == Tickets::STATUS_COMPLETED) 266 if ($ticket->status == Tickets::STATUS_COMPLETED)
266 { 267 {
267 // 完成工单,把子任务里面未完成的工单改为完成 268 // 完成工单,把子任务里面未完成的工单改为完成
@@ -15,6 +15,10 @@ use App\Models\Project\Project; @@ -15,6 +15,10 @@ use App\Models\Project\Project;
15 use App\Models\Ticket\TicketDailyCount; 15 use App\Models\Ticket\TicketDailyCount;
16 use App\Models\Ticket\TicketDailyDeptCount; 16 use App\Models\Ticket\TicketDailyDeptCount;
17 use App\Models\Ticket\TicketDailyManageCount; 17 use App\Models\Ticket\TicketDailyManageCount;
  18 +use App\Models\Ticket\TicketMonthDeptCount;
  19 +use App\Models\Ticket\TicketMonthManageCount;
  20 +use App\Models\Ticket\TicketWeekDeptCount;
  21 +use App\Models\Ticket\TicketWeekManageCount;
18 use App\Models\WorkOrder\TicketLog; 22 use App\Models\WorkOrder\TicketLog;
19 use App\Models\WorkOrder\TicketProject; 23 use App\Models\WorkOrder\TicketProject;
20 use App\Models\WorkOrder\Tickets; 24 use App\Models\WorkOrder\Tickets;
@@ -110,4 +114,41 @@ class TicketLogic extends BaseLogic @@ -110,4 +114,41 @@ class TicketLogic extends BaseLogic
110 return $this->success($manageList); 114 return $this->success($manageList);
111 } 115 }
112 116
  117 + /**
  118 + * @remark :按月统计数据
  119 + * @name :getWeekManageList
  120 + * @author :lyh
  121 + * @method :post
  122 + * @time :2025/8/30 16:02
  123 + */
  124 + public function getWeekManageList($start,$end){
  125 + if(empty($start) || empty($end)){
  126 + $start = Carbon::now()->subWeek()->startOfWeek(); // 上周一 00:00:00
  127 + $end = Carbon::now()->subWeek()->endOfWeek(); // 上周日 23:59:59
  128 + }
  129 + $manageWeekModel = new TicketWeekManageCount();
  130 + $manageWeekList = $manageWeekModel->list(['start_at'=>$start,'end_at'=>$end]);
  131 + $deptWeekModel = new TicketWeekDeptCount();
  132 + $deptWeekList = $deptWeekModel->list(['start_at'=>$start,'end_at'=>$end]);
  133 + return $this->success(['manage'=>$manageWeekList,'dept'=>$deptWeekList]);
  134 + }
  135 +
  136 + /**
  137 + * @remark :按月统计数据
  138 + * @name :getMonthManageList
  139 + * @author :lyh
  140 + * @method :post
  141 + * @time :2025/8/30 16:27
  142 + */
  143 + public function getMonthManageList($start,$end){
  144 + if(empty($start) || empty($end)){
  145 + $start = Carbon::now()->subMonth()->startOfMonth(); // 上个月 1号 00:00:00
  146 + $end = Carbon::now()->subMonth()->endOfMonth(); // 上个月最后一天 23:59:59
  147 + }
  148 + $manageWeekModel = new TicketMonthManageCount();
  149 + $manageWeekList = $manageWeekModel->list(['start_at'=>$start,'end_at'=>$end]);
  150 + $deptWeekModel = new TicketMonthDeptCount();
  151 + $deptWeekList = $deptWeekModel->list(['start_at'=>$start,'end_at'=>$end]);
  152 + return $this->success(['manage'=>$manageWeekList,'dept'=>$deptWeekList]);
  153 + }
113 } 154 }
@@ -636,6 +636,10 @@ Route::middleware(['aloginauth'])->group(function () { @@ -636,6 +636,10 @@ Route::middleware(['aloginauth'])->group(function () {
636 //ticket 636 //ticket
637 Route::prefix('ticket_count')->group(function () { 637 Route::prefix('ticket_count')->group(function () {
638 Route::any('/ticketCount', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'ticketCount'])->name('ticket_count_ticketCount'); 638 Route::any('/ticketCount', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'ticketCount'])->name('ticket_count_ticketCount');
  639 + Route::any('/getMonthList', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'getMonthList'])->name('ticket_count_getMonthList');//获取最近一个总统计的数据
  640 + Route::any('/getTime', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'getTime'])->name('ticket_count_getTime');//获取周/月时间
  641 + Route::any('/weekManageList', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'weekManageList'])->name('ticket_count_weekManageList');//周统计数据
  642 + Route::any('/monthManageList', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'monthManageList'])->name('ticket_count_monthManageList');//月统计数据
639 Route::any('/manageTicketCount', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'manageTicketCount'])->name('ticket_count_manageTicketCount'); 643 Route::any('/manageTicketCount', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'manageTicketCount'])->name('ticket_count_manageTicketCount');
640 }); 644 });
641 }); 645 });