Parcourir la source

统计与测试页面更新

whj il y a 4 ans
Parent
commit
c4e1a052ca

+ 51 - 2
app/Admin/Controllers/HomeController.php

xqd xqd
@@ -3,12 +3,14 @@
 namespace App\Admin\Controllers;
 
 use App\Http\Controllers\Controller;
+use App\Model\SystemConfig;
 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;
+use Encore\Admin\Widgets\InfoBox;
 
 class HomeController extends Controller
 {
@@ -17,16 +19,63 @@ class HomeController extends Controller
         return $content
             ->title('首页')
             ->description('欢迎来到!')
-//            ->row(Dashboard::title())
             ->row(function (Row $row) {
+                $row->column(12,function (Column $column){
+                    $column->append('<div style="height: 53px;"></div>');
+                });
+            })
+            ->row(function (Row $row) {
+
+                $row->column(3, function (Column $column) {
+                    $column->append(infoBox('设备总数', 'dropbox', '/admin/device_info', 'green', Sta::getDeviceCount()));
+                });
+
+                $row->column(3, function (Column $column) {
+                    $column->append(infoBox('在营设备', 'user-plus', '/admin/device_info?status=0', 'green', Sta::getDeviceCount(0)));
+                });
 
-                $row->column(12, function (Column $column) {
+                $row->column(3, function (Column $column) {
+                    $column->append(infoBox('设备最新版本号', 'user-plus', '/admin/setting_form', 'green', SystemConfig::get('lock_config','soft_version')));
+                });
+
+                $row->column(3, function (Column $column) {
+                    $column->append(infoBox('物联网卡数', 'user-plus', '/admin/phone_infos', 'green', Sta::getPhoneCount()));
+                });
+            })
+            ->row(function (Row $row) {
+                $row->column(6, function (Column $column) {
                     $sta = Sta::getDeviceChart();
                     $echarts = (new Echarts('设备状态', '当前设备状态', 'device'))
                         ->setData($sta['d'])->setSeriesType('pie')
                         ->bindLegend($sta['h']);
                     $column->append(new Box('', $echarts));
                 });
+
+                $row->column(6, function (Column $column) {
+                    $sta = Sta::getDeviceTypeChart();
+                    $echarts = (new Echarts('设备类型', '当前设备状态', 'device_type'))
+                        ->setData($sta['d'])->setSeriesType('pie')
+                        ->bindLegend($sta['h']);
+                    $column->append(new Box('', $echarts));
+                });
             });
     }
+
+
+}
+
+
+/**
+ * 消息框
+ * @param $name
+ * @param $icon
+ * @param $link
+ * @param $color
+ * @param $info
+ * @return string HTML
+ */
+
+function infoBox($name, $icon, $link, $color, $info)
+{
+    return (new InfoBox($name, $icon, $color, $link, $info))->render();
 }

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

xqd xqd
@@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
 use App\Http\Controllers\Controller;
 use App\Model\AgentApply;
 use App\Model\Appeals;
+use App\Model\PhoneInfo;
 use App\Model\WithdrawInfo;
 use App\Model\Communities;
 use App\Model\DeliverInfo;
@@ -40,4 +41,37 @@ class Sta extends Controller
         return ['h' => ['name' => '类型', 'num' => '数量'], 'd' => array_values($data)];
     }
 
+    /**
+     * 获得设备状态图表
+     * @return array
+     */
+    public static function getDeviceTypeChart()
+    {
+        $ds = DeviceInfo::all(['device_type'])->toArray();
+        $data = [];
+        $arr = DeviceInfo::getTypes();
+        foreach ($ds as $d) {
+
+            if (isset($data[$d['device_type']]))
+                $data[$d['device_type']]['num']++;
+            else
+                $data[$d['device_type']] = ['name' => $arr[$d['device_type']] ?? "未设置", 'num' => 1];
+
+        }
+        return ['h' => ['name' => '类型', 'num' => '数量'], 'd' => array_values($data)];
+    }
+
+    public static function getDeviceCount($type='')
+    {
+        if($type !== 0 && empty($type)) return DeviceInfo::count();
+        $count = DeviceInfo::where(['status'=>$type])->count();
+        return $count;
+    }
+
+    public static function getPhoneCount()
+    {
+        return PhoneInfo::count();
+    }
+
+
 }

Fichier diff supprimé car celui-ci est trop grand
+ 36 - 0
public/testweb/icon.css


+ 4 - 2
public/testweb/upgrade.html

xqd xqd xqd
@@ -228,6 +228,7 @@
                             console.log(res)
                             if (res.data.status == 200) {
                                 if (res.data.data.phone != null && res.data.data.device_type != null && res.data.data.is_last == 0) {
+                                    console.log("进来了")
                                     this.isInstall = false
                                     this.isbox = true
                                     this.equipment = res.data.data.id
@@ -235,7 +236,8 @@
                                     this.versionNum = res.data.data.version
                                     this.isnew = res.data.data.is_last
                                     this.typevalue = res.data.data.device_type
-                                } else if (res.data.data.phone == null && res.data.data.device_type == null || res.data.data.is_last != 0) {
+                                } else if (res.data.data.phone == null && res.data.data.device_type == null) {
+                                    console.log("进来了")
                                     this.isInstall = false
                                     this.isshezhi = true
                                     this.equipment = res.data.data.id
@@ -246,7 +248,7 @@
                                     if (this.typevalue == null) {
                                         this.typevalue = "0"
                                     }
-                                } else {
+                                } else if (res.data.data.phone != null && res.data.data.device_type != null && res.data.data.is_last == 1) {
                                     alert('当前设备已是最新版本,已有箱体和已绑定手机号无需设置升级')
                                 }
 

+ 4 - 4
resources/views/test_opreation.blade.php

xqd xqd xqd xqd
@@ -154,7 +154,7 @@
             },
             startbtn(e) {
                 //开始测试
-                axios.get("/send_protocol?id="+this.value+"&type=" + this.type).then(res => {
+                axios.get("http://172.31.31.199/send_protocol?id="+this.value+"&type=" + this.type).then(res => {
                     if (res.data.code == 603) {
                         alert(res.data.msg)
                     } else {
@@ -186,7 +186,7 @@
                         this.allbtn = false
                     }
                 }, 1000)
-                axios.get("/send_protocol?id="+this.value+"&type=" + this.dingshitype).then(res => {
+                axios.get("http://172.31.31.199/send_protocol?id="+this.value+"&type=" + this.dingshitype).then(res => {
                     if (res.data.code == 603) {
                         alert(res.data.msg)
                     }
@@ -202,7 +202,7 @@
                         }, 20000);
                     }
                 });
-                axios.get("/send_protocol?id="+this.value+"&type=" + this.alltype + "&box_name=" + e.id).then(res => {
+                axios.get("http://172.31.31.199/send_protocol?id="+this.value+"&type=" + this.alltype + "&box_name=" + e.id).then(res => {
                     if (res.data.code == 603) {
                         alert(res.data.msg)
                     } else {
@@ -211,7 +211,7 @@
                 })
             },
             getData: function (id) {
-                axios.get("/get_boxname?id="+this.value).then(res => {
+                axios.get("http://172.31.31.199/get_boxname?id="+this.value).then(res => {
                     console.log(res)
                     if (res.data.code == 200) {
                         let type = res.data.data.device_type

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff