whj пре 4 година
родитељ
комит
8c6a60d1ee
5 измењених фајлова са 123 додато и 14 уклоњено
  1. 11 13
      app/Admin/Controllers/HomeController.php
  2. 43 0
      app/Admin/Controllers/Sta.php
  3. 1 0
      composer.json
  4. 61 1
      composer.lock
  5. 7 0
      config/echarts.php

+ 11 - 13
app/Admin/Controllers/HomeController.php

xqd
@@ -7,28 +7,26 @@ use Encore\Admin\Controllers\Dashboard;
 use Encore\Admin\Layout\Column;
 use Encore\Admin\Layout\Content;
 use Encore\Admin\Layout\Row;
+use Encore\Admin\Widgets\Box;
+use Encore\Admin\Widgets\Echarts\Echarts;
 
 class HomeController extends Controller
 {
     public function index(Content $content)
     {
         return $content
-//            ->title('Dashboard')
-//            ->description('Description...')
+            ->title('首页')
+            ->description('欢迎来到!')
 //            ->row(Dashboard::title())
             ->row(function (Row $row) {
 
-//                $row->column(4, function (Column $column) {
-//                    $column->append(Dashboard::environment());
-//                });
-//
-//                $row->column(4, function (Column $column) {
-//                    $column->append(Dashboard::extensions());
-//                });
-//
-//                $row->column(4, function (Column $column) {
-//                    $column->append(Dashboard::dependencies());
-//                });
+                $row->column(12, function (Column $column) {
+                    $sta = Sta::getDeviceChart();
+                    $echarts = (new Echarts('设备状态', '当前设备状态', 'device'))
+                        ->setData($sta['d'])->setSeriesType('pie')
+                        ->bindLegend($sta['h']);
+                    $column->append(new Box('', $echarts));
+                });
             });
     }
 }

+ 43 - 0
app/Admin/Controllers/Sta.php

xqd
@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Http\Controllers\Controller;
+use App\Model\AgentApply;
+use App\Model\Appeals;
+use App\Model\WithdrawInfo;
+use App\Model\Communities;
+use App\Model\DeliverInfo;
+use App\Model\DeviceInfo;
+use App\Model\FeedBack;
+use App\Model\RechargeInfo;
+use App\Model\UserInfo;
+
+/** 统计模块
+ * Class StatisticsController
+ * @package App\Admin\Controllers
+ */
+class Sta extends Controller
+{
+
+    /**
+    * 获得设备状态图表
+    * @return array
+    */
+    public static function getDeviceChart()
+    {
+        $ds = DeviceInfo::all(['status'])->toArray();
+        $data = [];
+        $arr = ['在营', '离线','禁用','未激活'];
+        foreach ($ds as $d) {
+
+            if (isset($data[$d['status']]))
+                $data[$d['status']]['num']++;
+            else
+                $data[$d['status']] = ['name' => $arr[$d['status']] ?? "未知", 'num' => 1];
+
+        }
+        return ['h' => ['name' => '类型', 'num' => '数量'], 'd' => array_values($data)];
+    }
+
+}

+ 1 - 0
composer.json

xqd
@@ -10,6 +10,7 @@
     "require": {
         "php": "^7.2",
         "alibabacloud/iot": "^1.8",
+        "cyd622/laravel-admin-ext-echarts": "^1.0",
         "encore/laravel-admin": "^1.8",
         "fideloper/proxy": "^4.0",
         "jaeger/querylist": "^4.2",

+ 61 - 1
composer.lock

xqd xqd xqd
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "74de7f484812561039041ac2afdf743b",
+    "content-hash": "1545f8a7db7eba587d85838702310386",
     "packages": [
         {
             "name": "adbario/php-dot-notation",
@@ -458,6 +458,65 @@
             ],
             "time": "2020-07-20T20:39:25+00:00"
         },
+        {
+            "name": "cyd622/laravel-admin-ext-echarts",
+            "version": "v1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/cyd622/laravel-admin-ext-echarts.git",
+                "reference": "4311388d499a9f1c68f5c645a6e9352f36fa6e92"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/cyd622/laravel-admin-ext-echarts/zipball/4311388d499a9f1c68f5c645a6e9352f36fa6e92",
+                "reference": "4311388d499a9f1c68f5c645a6e9352f36fa6e92",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "encore/laravel-admin": "~1.6",
+                "php": ">=7.0.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~6.0"
+            },
+            "type": "library",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "Encore\\Admin\\Widgets\\Echarts\\EchartsServiceProvider"
+                    ]
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Encore\\Admin\\Widgets\\Echarts\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "cyd622",
+                    "email": "luffywang622@gmail.com"
+                }
+            ],
+            "description": "Use Echarts in laravel-admin",
+            "homepage": "https://github.com/cyd622/laravel-admin-ext-echarts",
+            "keywords": [
+                "echarts",
+                "extension",
+                "laravel-admin"
+            ],
+            "time": "2019-04-10T08:24:24+00:00"
+        },
         {
             "name": "danielstjules/stringy",
             "version": "3.1.0",
@@ -6149,6 +6208,7 @@
                 "faker",
                 "fixtures"
             ],
+            "abandoned": true,
             "time": "2019-12-12T13:22:17+00:00"
         },
         {

+ 7 - 0
config/echarts.php

xqd
@@ -0,0 +1,7 @@
+<?php
+
+return [
+    'view' => 'echarts::index',
+    'water_mark_text' => '定时定点统计',
+    'theme' => 'shine',
+];