diff --git a/app/Admin/Controllers/CustomRegionController.php b/app/Admin/Controllers/CustomRegionController.php index d5edf19..f7ef3cc 100644 --- a/app/Admin/Controllers/CustomRegionController.php +++ b/app/Admin/Controllers/CustomRegionController.php @@ -66,17 +66,17 @@ class CustomRegionController extends AdminController [//有气象设备才有 'title' => '气象数据', 'value' => 'qixiang', - 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=qixiang')) + 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-meteorological?id='.$region['id'])) ], [//有水质设备才有 'title' => '水质数据', 'value' => 'shuizi', - 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=shuizi')) + 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-water?id='.$region['id'])) ], [//有土壤设备才有 'title' => '土壤数据', 'value' => 'turang', - 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=turang')) + 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-soil?id='.$region['id'])) ], [//有通风设备才有 'title' => '通风设备', diff --git a/app/Admin/Controllers/DeviceController.php b/app/Admin/Controllers/DeviceController.php index 88a4435..34e9425 100644 --- a/app/Admin/Controllers/DeviceController.php +++ b/app/Admin/Controllers/DeviceController.php @@ -84,14 +84,14 @@ class DeviceController extends AdminController ], ] ]) - // ->filter([ - // 'title' => '指定位置', - // 'body' => [ - // \amisMake()->TableControl()->name('name')->label('点位名称')->size('sm')->actions([ - // ["type"=> "submit","level"=> "primary","label"=> "查询"] - // ]) - // ] - // ]) + ->filter([ + 'title' => '搜索条件', + 'body' => [ + \amisMake()->TextControl()->name('name')->label('点位名称')->size('sm'), + amis('submit')->label(__('admin.search'))->level('primary'), + ] + ]) + ->actions([]) ->itemClassName('col-sm-4') ->card([ 'header' => [], @@ -100,4 +100,326 @@ class DeviceController extends AdminController ->src('${src}') ]); } + + /** + * 气象图表 + */ + public function meteorologicalChart(){ + $randArr = function () { + $_arr = []; + for ($i = 0; $i < 7; $i++) { + $_arr[] = random_int(10, 200); + } + return '[' . implode(',', $_arr) . ']'; + }; + + $random1 = $randArr(); + $random2 = $randArr(); + + return $this->basePage()->title('')->body([ + \amisMake()->grid()->columns([ + \amisMake()->Form()->title('搜索条件')->mode('inline')->body([ + \amisMake()->TextControl()->label('设备名称'), + \amisMake()->DateRangeControl()->label('时间范围'), + amis('submit')->label(__('admin.search'))->level('primary'), + ]), + ]), + \amisMake()->grid()->columns([ + amisMake()->Flex()->items([ + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '空气温度', subtext: '℃'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name:'空气温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '空气湿度', subtext: '%RH'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '光照强度LUX', }, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->body( + amisMake()->Chart()->config("{ + title:{ text: '光照强度LUX', }, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + ]), + ]), + \amisMake()->grid()->columns([ + amisMake()->Flex()->items([ + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '空气温度', subtext: '℃'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name:'空气温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '空气湿度', subtext: '%RH'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '光照强度LUX', }, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->body( + amisMake()->Chart()->config("{ + title:{ text: '光照强度LUX', }, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + ]), + ]), + ]); + } + + /** + * 水质图表 + */ + public function waterChart(){ + $randArr = function () { + $_arr = []; + for ($i = 0; $i < 7; $i++) { + $_arr[] = random_int(10, 200); + } + return '[' . implode(',', $_arr) . ']'; + }; + + $random1 = $randArr(); + $random2 = $randArr(); + + return $this->basePage()->title('')->body([ + \amisMake()->grid()->columns([ + \amisMake()->Form()->title('搜索条件')->mode('inline')->body([ + \amisMake()->TextControl()->label('设备名称'), + \amisMake()->DateRangeControl()->label('时间范围'), + amis('submit')->label(__('admin.search'))->level('primary'), + ]), + ]), + \amisMake()->grid()->columns([ + amisMake()->Flex()->items([ + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '氯', subtext: 'mg/L'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name:'氯', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '电导率', subtext: 'us/cm'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '电导率', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '氧气', subtext: 'mg/L'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->body( + amisMake()->Chart()->config("{ + title:{ text: 'PH'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + ]), + ]), + \amisMake()->grid()->columns([ + amisMake()->Flex()->items([ + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '温度', subtext: '℃'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name:'温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->body( + amisMake()->Chart()->config("{ + title:{ text: '浊度', subtext: 'NTU'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ) + ]), + ]), + ]); + } + + /** + * 土壤图表 + */ + public function soilChart(){ + $randArr = function () { + $_arr = []; + for ($i = 0; $i < 7; $i++) { + $_arr[] = random_int(10, 200); + } + return '[' . implode(',', $_arr) . ']'; + }; + + $random1 = $randArr(); + $random2 = $randArr(); + + return $this->basePage()->title('')->body([ + \amisMake()->grid()->columns([ + \amisMake()->Form()->title('搜索条件')->mode('inline')->body([ + \amisMake()->TextControl()->label('设备名称'), + \amisMake()->DateRangeControl()->label('时间范围'), + amis('submit')->label(__('admin.search'))->level('primary'), + ]), + ]), + \amisMake()->grid()->columns([ + amisMake()->Flex()->items([ + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '氯', subtext: 'mg/L'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name:'氯', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '电导率', subtext: 'us/cm'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '电导率', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '氧气', subtext: 'mg/L'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->body( + amisMake()->Chart()->config("{ + title:{ text: 'PH'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + ]), + ]), + \amisMake()->grid()->columns([ + amisMake()->Flex()->items([ + amisMake()->Card()->className('m-r')->body( + amisMake()->Chart()->config("{ + title:{ text: '温度', subtext: '℃'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name:'温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ), + amisMake()->Card()->body( + amisMake()->Chart()->config("{ + title:{ text: '浊度', subtext: 'NTU'}, + tooltip: { trigger: 'axis' }, + xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, + yAxis: { type: 'value' }, + grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, + series: [ + { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, + ]}") + ) + ]), + ]), + ]); + } } diff --git a/app/Admin/routes.php b/app/Admin/routes.php index f4fea58..3b164ed 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -41,7 +41,18 @@ Route::group([ //特殊菜单 $router->get('custom-region/{type}', '\App\Admin\Controllers\CustomRegionController@regionIndex'); $router->post('custom-region-detail', '\App\Admin\Controllers\CustomRegionController@regionDetail'); + + $router->get('custom-region-monitor', '\App\Admin\Controllers\DeviceController@monitorList'); $router->post('custom-region-monitor', '\App\Admin\Controllers\DeviceController@monitorList'); + $router->get('custom-region-meteorological', '\App\Admin\Controllers\DeviceController@meteorologicalChart'); + $router->post('custom-region-meteorological', '\App\Admin\Controllers\DeviceController@meteorologicalChart'); + + $router->get('custom-region-water', '\App\Admin\Controllers\DeviceController@waterChart'); + $router->post('custom-region-water', '\App\Admin\Controllers\DeviceController@waterChart'); + + $router->get('custom-region-soil', '\App\Admin\Controllers\DeviceController@soilChart'); + $router->post('custom-region-soil', '\App\Admin\Controllers\DeviceController@soilChart'); + $router->resource('system/settings', \App\Admin\Controllers\SettingController::class); }); diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php index 532ef36..78257bc 100644 --- a/database/seeders/AdminMenuSeeder.php +++ b/database/seeders/AdminMenuSeeder.php @@ -50,6 +50,14 @@ class AdminMenuSeeder extends Seeder ], ['title' => '设备管理', 'icon' => 'icon-park:devices', 'url' => '/devices'], + ['title' => '设备数据', 'icon' => 'icon-park:data-switching', 'url' => '', + 'children' => [ + ['title' => '视频监控', 'icon'=>'icon-park:videocamera', 'url'=> '/custom-region-monitor'], + ['title' => '气象数据', 'icon'=>'icon-park:brightness', 'url'=> '/custom-region-meteorological'], + ['title' => '土壤数据', 'icon'=>'icon-park:floor-tile', 'url'=> '/custom-region-water'], + ['title' => '水质数据', 'icon'=>'icon-park:diving-bottle', 'url'=> '/custom-region-soil'], + ] + ], ['title' => '友情链接', 'icon' => 'icon-park:copy-link', 'url' => '/friend-links'], ['title' => '系统管理', 'icon' => 'icon-park:setting', 'url' => '/system', 'children' => [