|
@@ -0,0 +1,102 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace Modules\Log\Http\Controllers;
|
|
|
|
+
|
|
|
|
+use Illuminate\Contracts\Support\Renderable;
|
|
|
|
+use Illuminate\Http\Request;
|
|
|
|
+use Illuminate\Routing\Controller;
|
|
|
|
+use DB;
|
|
|
|
+use Modules\Admin\Auxiliary\View\TableAuxiliary;
|
|
|
|
+use Modules\Admin\Http\Controllers\BaseController;
|
|
|
|
+
|
|
|
|
+class LogController extends BaseController
|
|
|
|
+{
|
|
|
|
+ /**
|
|
|
|
+ * Display a listing of the resource.
|
|
|
|
+ * @return Renderable
|
|
|
|
+ */
|
|
|
|
+ public function index(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $this->menusActive[0] = 'adminLog';
|
|
|
|
+
|
|
|
|
+ //查询当前登录用户权限内的区域
|
|
|
|
+ $user = DB::table('users')->where('staff_num',$request->user()->staff_num)->first();
|
|
|
|
+ $mine_array = explode(';',$user->mine_role);//权限内的矿区
|
|
|
|
+ $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();//所有区域
|
|
|
|
+ $mine_use = [];//权限内矿区下所有区域
|
|
|
|
+ foreach($mine_all as $k=>$v){
|
|
|
|
+ if(in_array(explode('|',$v->degree)[0],$mine_array)){
|
|
|
|
+ $mine_use[] = $v->id;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $log_list = DB::table('log')
|
|
|
|
+ ->select('log.*','mine_list.title','mine_list.degree','camera_list.camera_name')
|
|
|
|
+ ->leftJoin('mine_list','mine_list.id','=','log.mine_id')
|
|
|
|
+ ->leftJoin('camera_list','camera_list.id','=','log.camera_id')
|
|
|
|
+ ->whereIn('log.mine_id',$mine_use)
|
|
|
|
+ ->orderBy('log.created_at', 'desc');
|
|
|
|
+
|
|
|
|
+ if ($request->has('mine_id') && $request->input('mine_id')) {
|
|
|
|
+ $log_list = $log_list->where('mine_list.degree','like',$request->input('mine_id').'|%');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($request->has('camera_name') && $request->input('camera_name')) {
|
|
|
|
+ $log_list = $log_list->where('camera_list.camera_name','like','%'.$request->input('camera_name').'%');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($request->has('status') && $request->input('status')) {
|
|
|
|
+ if($request->input('status') == 1){
|
|
|
|
+ $log_list = $log_list->where('log.status',0);
|
|
|
|
+ }elseif($request->input('status') == 2){
|
|
|
|
+ $log_list = $log_list->where('log.status',1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($request->has('created_at') && $request->input('created_at')) {
|
|
|
|
+ $log_list = $log_list->where('log.created_at','like','%'.$request->input('created_at').'%');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $log_list = $log_list->paginate(10);
|
|
|
|
+
|
|
|
|
+ if(count($log_list)>0){
|
|
|
|
+ for($i=0;$i<count($log_list);$i++){
|
|
|
|
+ $degree = explode('|',$log_list[$i]->degree);
|
|
|
|
+ $mine = DB::table('mine_list')->where('id',$degree[0])->get();
|
|
|
|
+ $log_list[$i]->mine_name = $mine[0]->title;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //权限内矿区列表
|
|
|
|
+ $mine_list = DB::table('mine_list')->whereIn('id',$mine_array)->get()->toArray();
|
|
|
|
+ $mine_search = [];
|
|
|
|
+ foreach($mine_list as $k=>$v){
|
|
|
|
+ $mine_search[$v->id] = $v->title;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //摄像头状态
|
|
|
|
+ $status = [1=>'正常',2=>'异常'];
|
|
|
|
+
|
|
|
|
+ $tableObj = new TableAuxiliary('log', $log_list);
|
|
|
|
+ $tableObj->topActions = [];
|
|
|
|
+ $tableObj->actionBtns = [];
|
|
|
|
+ $tableObj->search('select', 'mine_id', '选择矿区', $mine_search);
|
|
|
|
+ $tableObj->search('input', 'camera_name', '摄像头名称');
|
|
|
|
+ $tableObj->search('select', 'status', '摄像头状态', $status);
|
|
|
|
+ $tableObj->search('date', 'created_at', '操作时间');
|
|
|
|
+ $tableObj->column('mine_name', '矿区名称');
|
|
|
|
+ $tableObj->column('title', '区域名称');
|
|
|
|
+ $tableObj->column('camera_name', '摄像头名称');
|
|
|
|
+ $tableObj->column('status', '状态',function ($state, $item) {
|
|
|
|
+ if ($item->status == 0) {
|
|
|
|
+ $state = '正常';
|
|
|
|
+ }else{
|
|
|
|
+ $state = '异常';
|
|
|
|
+ }
|
|
|
|
+ return $state;
|
|
|
|
+ });
|
|
|
|
+ $tableObj->column('log', '返回信息');
|
|
|
|
+ $tableObj->column('created_at', '操作时间');
|
|
|
|
+ return $this->tableList($tableObj);
|
|
|
|
+ }
|
|
|
|
+}
|