diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/Record.php b/plugs/think-plugs-inspection/src/controller/api/auth/Record.php index 417408b..ecb4ab2 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/Record.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/Record.php @@ -115,4 +115,10 @@ class Record extends Auth $this->success("成功"); } + public function count() + { + $total = $this->staff->records()->where('status', 0)->count(); + $this->success('获取记录数量成功', compact('total')); + } + } \ No newline at end of file diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php b/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php index 0dd16a7..265ca2c 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php @@ -142,4 +142,13 @@ class Ticket extends Auth $ticket->save(); $this->success('工单维修成功'); } + + public function count() + { + $view_count = $this->staff->views()->where('status', '=', 0)->count(); + $repair_count = $this->staff->repairs()->where('status', '=', 0)->count(); + $verify_count = $this->staff->verifys()->where('status', '=', 0)->count(); + $total = $view_count + $repair_count + $verify_count; + $this->success('获取工单统计', compact('view_count', 'repair_count', 'verify_count', 'total')); + } } \ No newline at end of file diff --git a/plugs/think-plugs-inspection/src/model/InspectionStaff.php b/plugs/think-plugs-inspection/src/model/InspectionStaff.php index 6402930..f76b5a4 100644 --- a/plugs/think-plugs-inspection/src/model/InspectionStaff.php +++ b/plugs/think-plugs-inspection/src/model/InspectionStaff.php @@ -2,6 +2,9 @@ namespace plugin\inspection\model; +use plugin\ticket\model\TicketRepair; +use plugin\ticket\model\TicketVerify; +use plugin\ticket\model\TicketView; use think\admin\Model; /** @@ -15,6 +18,21 @@ class InspectionStaff extends Model return $this->hasMany(InspectionStaffToken::class, 'staff_id', 'id'); } + public function views() + { + return $this->hasMany(TicketView::class, 'staff_id', 'id'); + } + + public function repairs() + { + return $this->hasMany(TicketRepair::class, 'staff_id', 'id'); + } + + public function verifys() + { + return $this->hasMany(TicketVerify::class, 'staff_id', 'id'); + } + public function records() { return $this->hasMany(InspectionRecord::class, 'staff_id', 'id');