正在显示
5 个修改的文件
包含
94 行增加
和
10 行删除
| @@ -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,10 @@ namespace App\Http\Controllers\Aside\Ticket; | @@ -12,7 +12,10 @@ 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\TicketMonthDeptCount; | ||
| 16 | +use App\Models\Ticket\TicketWeekDeptCount; | ||
| 15 | use Illuminate\Http\Request; | 17 | use Illuminate\Http\Request; |
| 18 | +use Illuminate\Support\Carbon; | ||
| 16 | 19 | ||
| 17 | class TicketController extends BaseController | 20 | class TicketController extends BaseController |
| 18 | { | 21 | { |
| @@ -37,7 +40,46 @@ class TicketController extends BaseController | @@ -37,7 +40,46 @@ class TicketController extends BaseController | ||
| 37 | } | 40 | } |
| 38 | 41 | ||
| 39 | /** | 42 | /** |
| 40 | - * @remark :技术组 | 43 | + * @remark :获取搜索时间 |
| 44 | + * @name :getTIme | ||
| 45 | + * @author :lyh | ||
| 46 | + * @method :post | ||
| 47 | + * @time :2025/8/30 15:39 | ||
| 48 | + */ | ||
| 49 | + public function getTime(){ | ||
| 50 | + $weekModel = new TicketWeekDeptCount(); | ||
| 51 | + $weekData = $weekModel->where('dept_id',1)->select('start_at', 'end_at')->distinct()->get()->toArray(); | ||
| 52 | + $monthModel = new TicketMonthDeptCount(); | ||
| 53 | + $monthData = $monthModel->where('dept_id',1)->select('start_at', 'end_at')->distinct()->get()->toArray(); | ||
| 54 | + $this->response('success',Code::SUCCESS,['week_data'=>$weekData,'month_data'=>$monthData]); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @remark :周记录数据(默认上一周) | ||
| 59 | + * @name :weekManageList | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2025/8/30 15:31 | ||
| 63 | + */ | ||
| 64 | + public function weekManageList(){ | ||
| 65 | + $data = $this->logic->getWeekManageList($this->param['start'],$this->param['end']); | ||
| 66 | + $this->response('success',Code::SUCCESS,$data); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * @remark :按月统计数据(默认上一月) | ||
| 71 | + * @name :monthManageList | ||
| 72 | + * @author :lyh | ||
| 73 | + * @method :post | ||
| 74 | + * @time :2025/8/30 15:35 | ||
| 75 | + */ | ||
| 76 | + public function monthManageList(){ | ||
| 77 | + $data = $this->logic->getMOnthManageList($this->param['start'],$this->param['end']); | ||
| 78 | + $this->response('success',Code::SUCCESS,$data); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * @remark :技术组总统计 | ||
| 41 | * @name :manageTicketCount | 83 | * @name :manageTicketCount |
| 42 | * @author :lyh | 84 | * @author :lyh |
| 43 | * @method :post | 85 | * @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,9 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -636,6 +636,9 @@ 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('/getTime', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'getTime'])->name('ticket_count_getTime');//获取周/月时间 | ||
| 640 | + Route::any('/weekManageList', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'weekManageList'])->name('ticket_count_weekManageList');//周统计数据 | ||
| 641 | + 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'); | 642 | Route::any('/manageTicketCount', [\App\Http\Controllers\Aside\Ticket\TicketController::class,'manageTicketCount'])->name('ticket_count_manageTicketCount'); |
| 640 | }); | 643 | }); |
| 641 | }); | 644 | }); |
-
请 注册 或 登录 后发表评论