浏览代码

访问记录(金家渠)

任敬轩 3 年之前
父节点
当前提交
bad6797752
共有 34 个文件被更改,包括 501 次插入1 次删除
  1. 12 0
      Modules/Camera/Services/CameraServices.php
  2. 0 0
      Modules/Log/Config/.gitkeep
  3. 5 0
      Modules/Log/Config/config.php
  4. 0 0
      Modules/Log/Console/.gitkeep
  5. 0 0
      Modules/Log/Database/Migrations/.gitkeep
  6. 36 0
      Modules/Log/Database/Migrations/2022_06_28_110228_create_log_table.php
  7. 0 0
      Modules/Log/Database/Seeders/.gitkeep
  8. 21 0
      Modules/Log/Database/Seeders/LogDatabaseSeeder.php
  9. 0 0
      Modules/Log/Database/factories/.gitkeep
  10. 0 0
      Modules/Log/Entities/.gitkeep
  11. 0 0
      Modules/Log/Http/Controllers/.gitkeep
  12. 102 0
      Modules/Log/Http/Controllers/LogController.php
  13. 0 0
      Modules/Log/Http/Middleware/.gitkeep
  14. 0 0
      Modules/Log/Http/Requests/.gitkeep
  15. 0 0
      Modules/Log/Providers/.gitkeep
  16. 125 0
      Modules/Log/Providers/LogServiceProvider.php
  17. 69 0
      Modules/Log/Providers/RouteServiceProvider.php
  18. 0 0
      Modules/Log/Resources/assets/.gitkeep
  19. 0 0
      Modules/Log/Resources/assets/js/app.js
  20. 0 0
      Modules/Log/Resources/assets/sass/app.scss
  21. 0 0
      Modules/Log/Resources/lang/.gitkeep
  22. 0 0
      Modules/Log/Resources/views/.gitkeep
  23. 9 0
      Modules/Log/Resources/views/index.blade.php
  24. 19 0
      Modules/Log/Resources/views/layouts/master.blade.php
  25. 0 0
      Modules/Log/Routes/.gitkeep
  26. 18 0
      Modules/Log/Routes/api.php
  27. 16 0
      Modules/Log/Routes/web.php
  28. 0 0
      Modules/Log/Tests/Feature/.gitkeep
  29. 0 0
      Modules/Log/Tests/Unit/.gitkeep
  30. 23 0
      Modules/Log/composer.json
  31. 13 0
      Modules/Log/module.json
  32. 17 0
      Modules/Log/package.json
  33. 14 0
      Modules/Log/webpack.mix.js
  34. 2 1
      modules_statuses.json

+ 12 - 0
Modules/Camera/Services/CameraServices.php

@@ -836,6 +836,18 @@ class CameraServices
         //请求流媒体服务器拉流
         //请求流媒体服务器拉流
         $curl_res = curl_request($curl);
         $curl_res = curl_request($curl);
 
 
+        //访问记录
+        $log['mine_id'] = $query->mine_id;
+        $log['camera_id'] = $camera_id;
+        $log['log'] = $curl_res;
+        if(strstr($curl_res,'Pull stream err')){
+            $log['status'] = 1;//异常
+        }else{
+            $log['status'] = 0;//正常
+        }
+        $log['created_at'] = date('Y-m-d H:i:s');
+        $log['updated_at'] = date('Y-m-d H:i:s');
+        DB::table('log')->insert($log);
 
 
         // DB::table('camera_list')->where('id',$camera_id)->update($res);
         // DB::table('camera_list')->where('id',$camera_id)->update($res);
         // dd($res);
         // dd($res);

+ 0 - 0
Modules/Log/Config/.gitkeep


+ 5 - 0
Modules/Log/Config/config.php

@@ -0,0 +1,5 @@
+<?php
+
+return [
+    'name' => 'Log'
+];

+ 0 - 0
Modules/Log/Console/.gitkeep


+ 0 - 0
Modules/Log/Database/Migrations/.gitkeep


+ 36 - 0
Modules/Log/Database/Migrations/2022_06_28_110228_create_log_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('log', function (Blueprint $table) {
+            $table->bigIncrements('id')->comment('ID');
+            $table->integer('mine_id')->index()->comment('区域id');
+            $table->integer('camera_id')->index()->comment('摄像头id');
+            $table->string('log', 255)->nullable()->comment('返回记录');
+            $table->string('user_id', 10)->nullable()->comment('操作人ID');
+            $table->integer('status')->index()->comment('状态:0正常,1异常');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('log');
+    }
+}

+ 0 - 0
Modules/Log/Database/Seeders/.gitkeep


+ 21 - 0
Modules/Log/Database/Seeders/LogDatabaseSeeder.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace Modules\Log\Database\Seeders;
+
+use Illuminate\Database\Seeder;
+use Illuminate\Database\Eloquent\Model;
+
+class LogDatabaseSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        Model::unguard();
+
+        // $this->call("OthersTableSeeder");
+    }
+}

+ 0 - 0
Modules/Log/Database/factories/.gitkeep


+ 0 - 0
Modules/Log/Entities/.gitkeep


+ 0 - 0
Modules/Log/Http/Controllers/.gitkeep


+ 102 - 0
Modules/Log/Http/Controllers/LogController.php

@@ -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);
+    }
+}

+ 0 - 0
Modules/Log/Http/Middleware/.gitkeep


+ 0 - 0
Modules/Log/Http/Requests/.gitkeep


+ 0 - 0
Modules/Log/Providers/.gitkeep


+ 125 - 0
Modules/Log/Providers/LogServiceProvider.php

@@ -0,0 +1,125 @@
+<?php
+
+namespace Modules\Log\Providers;
+
+use Illuminate\Support\ServiceProvider;
+use Illuminate\Database\Eloquent\Factory;
+
+class LogServiceProvider extends ServiceProvider
+{
+    /**
+     * @var string $moduleName
+     */
+    protected $moduleName = 'Log';
+
+    /**
+     * @var string $moduleNameLower
+     */
+    protected $moduleNameLower = 'log';
+
+    /**
+     * Boot the application events.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        $this->registerTranslations();
+        $this->registerConfig();
+        $this->registerViews();
+        $this->registerFactories();
+        $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
+    }
+
+    /**
+     * Register the service provider.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        $this->app->register(RouteServiceProvider::class);
+    }
+
+    /**
+     * Register config.
+     *
+     * @return void
+     */
+    protected function registerConfig()
+    {
+        $this->publishes([
+            module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
+        ], 'config');
+        $this->mergeConfigFrom(
+            module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
+        );
+    }
+
+    /**
+     * Register views.
+     *
+     * @return void
+     */
+    public function registerViews()
+    {
+        $viewPath = resource_path('views/modules/' . $this->moduleNameLower);
+
+        $sourcePath = module_path($this->moduleName, 'Resources/views');
+
+        $this->publishes([
+            $sourcePath => $viewPath
+        ], ['views', $this->moduleNameLower . '-module-views']);
+
+        $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
+    }
+
+    /**
+     * Register translations.
+     *
+     * @return void
+     */
+    public function registerTranslations()
+    {
+        $langPath = resource_path('lang/modules/' . $this->moduleNameLower);
+
+        if (is_dir($langPath)) {
+            $this->loadTranslationsFrom($langPath, $this->moduleNameLower);
+        } else {
+            $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
+        }
+    }
+
+    /**
+     * Register an additional directory of factories.
+     *
+     * @return void
+     */
+    public function registerFactories()
+    {
+        if (! app()->environment('production') && $this->app->runningInConsole()) {
+            app(Factory::class)->load(module_path($this->moduleName, 'Database/factories'));
+        }
+    }
+
+    /**
+     * Get the services provided by the provider.
+     *
+     * @return array
+     */
+    public function provides()
+    {
+        return [];
+    }
+
+    private function getPublishableViewPaths(): array
+    {
+        $paths = [];
+        foreach (\Config::get('view.paths') as $path) {
+            if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
+                $paths[] = $path . '/modules/' . $this->moduleNameLower;
+            }
+        }
+        return $paths;
+    }
+}

+ 69 - 0
Modules/Log/Providers/RouteServiceProvider.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace Modules\Log\Providers;
+
+use Illuminate\Support\Facades\Route;
+use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+
+class RouteServiceProvider extends ServiceProvider
+{
+    /**
+     * The module namespace to assume when generating URLs to actions.
+     *
+     * @var string
+     */
+    protected $moduleNamespace = 'Modules\Log\Http\Controllers';
+
+    /**
+     * Called before routes are registered.
+     *
+     * Register any model bindings or pattern based filters.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        parent::boot();
+    }
+
+    /**
+     * Define the routes for the application.
+     *
+     * @return void
+     */
+    public function map()
+    {
+        $this->mapApiRoutes();
+
+        $this->mapWebRoutes();
+    }
+
+    /**
+     * Define the "web" routes for the application.
+     *
+     * These routes all receive session state, CSRF protection, etc.
+     *
+     * @return void
+     */
+    protected function mapWebRoutes()
+    {
+        Route::middleware('web')
+            ->namespace($this->moduleNamespace)
+            ->group(module_path('Log', '/Routes/web.php'));
+    }
+
+    /**
+     * Define the "api" routes for the application.
+     *
+     * These routes are typically stateless.
+     *
+     * @return void
+     */
+    protected function mapApiRoutes()
+    {
+        Route::prefix('api')
+            ->middleware('api')
+            ->namespace($this->moduleNamespace)
+            ->group(module_path('Log', '/Routes/api.php'));
+    }
+}

+ 0 - 0
Modules/Log/Resources/assets/.gitkeep


+ 0 - 0
Modules/Log/Resources/assets/js/app.js


+ 0 - 0
Modules/Log/Resources/assets/sass/app.scss


+ 0 - 0
Modules/Log/Resources/lang/.gitkeep


+ 0 - 0
Modules/Log/Resources/views/.gitkeep


+ 9 - 0
Modules/Log/Resources/views/index.blade.php

@@ -0,0 +1,9 @@
+@extends('log::layouts.master')
+
+@section('content')
+    <h1>Hello World</h1>
+
+    <p>
+        This view is loaded from module: {!! config('log.name') !!}
+    </p>
+@endsection

+ 19 - 0
Modules/Log/Resources/views/layouts/master.blade.php

@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <meta charset="utf-8">
+        <meta http-equiv="X-UA-Compatible" content="IE=edge">
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+        <title>Module Log</title>
+
+       {{-- Laravel Mix - CSS File --}}
+       {{-- <link rel="stylesheet" href="{{ mix('css/log.css') }}"> --}}
+
+    </head>
+    <body>
+        @yield('content')
+
+        {{-- Laravel Mix - JS File --}}
+        {{-- <script src="{{ mix('js/log.js') }}"></script> --}}
+    </body>
+</html>

+ 0 - 0
Modules/Log/Routes/.gitkeep


+ 18 - 0
Modules/Log/Routes/api.php

@@ -0,0 +1,18 @@
+<?php
+
+use Illuminate\Http\Request;
+
+/*
+|--------------------------------------------------------------------------
+| API Routes
+|--------------------------------------------------------------------------
+|
+| Here is where you can register API routes for your application. These
+| routes are loaded by the RouteServiceProvider within a group which
+| is assigned the "api" middleware group. Enjoy building your API!
+|
+*/
+
+Route::middleware('auth:api')->get('/log', function (Request $request) {
+    return $request->user();
+});

+ 16 - 0
Modules/Log/Routes/web.php

@@ -0,0 +1,16 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Web Routes
+|--------------------------------------------------------------------------
+|
+| Here is where you can register web routes for your application. These
+| routes are loaded by the RouteServiceProvider within a group which
+| contains the "web" middleware group. Now create something great!
+|
+*/
+
+Route::prefix('admin')->group(function() {
+    Route::get('/log', 'LogController@index');
+});

+ 0 - 0
Modules/Log/Tests/Feature/.gitkeep


+ 0 - 0
Modules/Log/Tests/Unit/.gitkeep


+ 23 - 0
Modules/Log/composer.json

@@ -0,0 +1,23 @@
+{
+    "name": "nwidart/log",
+    "description": "",
+    "authors": [
+        {
+            "name": "Nicolas Widart",
+            "email": "n.widart@gmail.com"
+        }
+    ],
+    "extra": {
+        "laravel": {
+            "providers": [],
+            "aliases": {
+
+            }
+        }
+    },
+    "autoload": {
+        "psr-4": {
+            "Modules\\Log\\": ""
+        }
+    }
+}

+ 13 - 0
Modules/Log/module.json

@@ -0,0 +1,13 @@
+{
+    "name": "Log",
+    "alias": "log",
+    "description": "",
+    "keywords": [],
+    "order": 0,
+    "providers": [
+        "Modules\\Log\\Providers\\LogServiceProvider"
+    ],
+    "aliases": {},
+    "files": [],
+    "requires": []
+}

+ 17 - 0
Modules/Log/package.json

@@ -0,0 +1,17 @@
+{
+    "private": true,
+    "scripts": {
+        "dev": "npm run development",
+        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
+        "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
+        "watch-poll": "npm run watch -- --watch-poll",
+        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
+        "prod": "npm run production",
+        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
+    },
+    "devDependencies": {
+        "cross-env": "^7.0",
+        "laravel-mix": "^5.0.1",
+        "laravel-mix-merge-manifest": "^0.1.2"
+    }
+}

+ 14 - 0
Modules/Log/webpack.mix.js

@@ -0,0 +1,14 @@
+const dotenvExpand = require('dotenv-expand');
+dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
+
+const mix = require('laravel-mix');
+require('laravel-mix-merge-manifest');
+
+mix.setPublicPath('../../public').mergeManifest();
+
+mix.js(__dirname + '/Resources/assets/js/app.js', 'js/log.js')
+    .sass( __dirname + '/Resources/assets/sass/app.scss', 'css/log.css');
+
+if (mix.inProduction()) {
+    mix.version();
+}

+ 2 - 1
modules_statuses.json

@@ -3,5 +3,6 @@
     "Admin": true,
     "Admin": true,
     "Mine": true,
     "Mine": true,
     "Camera": true,
     "Camera": true,
-    "OpcData": true
+    "OpcData": true,
+    "Log": true
 }
 }