suyuan/app/adminapi/logic/WorkbenchLogic.php

170 lines
4.6 KiB
PHP
Raw Normal View History

2023-11-21 11:51:27 +08:00
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic;
use app\common\logic\BaseLogic;
use app\common\service\ConfigService;
use app\common\service\FileService;
/**
* 工作台
* Class WorkbenchLogic
* @package app\adminapi\logic
*/
class WorkbenchLogic extends BaseLogic
{
/**
* @notes 工作套
* @param $adminInfo
* @return array
* @author 段誉
* @date 2021/12/29 15:58
*/
public static function index()
{
return [
// 今日数据
'today' => self::today(),
2023-11-27 16:41:48 +08:00
// 快捷入口
2023-11-21 11:51:27 +08:00
'menu' => self::menu(),
2023-11-27 16:41:48 +08:00
// 图表数据
2023-11-21 11:51:27 +08:00
'visitor' => self::visitor(),
];
}
/**
2023-11-27 16:41:48 +08:00
* @notes 快捷入口
2023-11-21 11:51:27 +08:00
* @return array[]
* @author 段誉
* @date 2021/12/29 16:40
*/
public static function menu(): array
{
return [
[
2023-11-27 16:41:48 +08:00
'name' => '土地列表',
2023-11-21 11:51:27 +08:00
'image' => FileService::getFileUrl(config('project.default_image.menu_dict')),
2023-11-27 16:41:48 +08:00
'url' => '/land/land'
2023-11-21 11:51:27 +08:00
],
[
2023-11-27 16:41:48 +08:00
'name' => '产品列表',
2023-11-21 11:51:27 +08:00
'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
2023-11-27 16:41:48 +08:00
'url' => '/land/product'
2023-11-21 11:51:27 +08:00
],
[
2023-11-27 16:41:48 +08:00
'name' => '设备列表',
2023-11-21 11:51:27 +08:00
'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
2023-11-27 16:41:48 +08:00
'url' => '/device/device'
2023-11-21 11:51:27 +08:00
],
2023-11-27 16:41:48 +08:00
[
'name' => '监控报警',
'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
'url' => '/device/monitor_alarm'
2023-11-21 11:51:27 +08:00
]
];
}
/**
* @notes 今日数据
* @return int[]
* @author 段誉
* @date 2021/12/29 16:15
*/
public static function today(): array
{
return [
'time' => date('Y-m-d H:i:s'),
2023-11-27 16:41:48 +08:00
// 土地数
'today_land' => 3,
// 今日新增
'total_land' => 10,
// 产品数
'today_product' => 2,
// 今日新增
'total_product' => 100,
// 设备数
'today_device' => 2,
// 今日新增
'total_device' => 12,
// 报警数
'today_alarm' => 5,
// 今日新增
'total_alarm' => 35,
2023-11-21 11:51:27 +08:00
];
}
/**
* @notes 访问数
* @return array
* @author 段誉
* @date 2021/12/29 16:57
*/
public static function visitor(): array
{
2023-11-27 16:41:48 +08:00
$land = $device = $product = $alarm = [];
2023-11-21 11:51:27 +08:00
$date = [];
for ($i = 0; $i < 15; $i++) {
$where_start = strtotime("- " . $i . "day");
$date[] = date('Y/m/d', $where_start);
2023-11-27 16:41:48 +08:00
$land[$i] = rand(0, 100);
$product[$i] = rand(0, 100);
$device[$i] = rand(0, 100);
$alarm[$i] = rand(0, 100);
2023-11-21 11:51:27 +08:00
}
return [
'date' => $date,
'list' => [
2023-11-27 16:41:48 +08:00
['name' => '土地数', 'data' => $land],
['name' => '产品数', 'data' => $product],
['name' => '设备数', 'data' => $device],
['name' => '报警数', 'data' => $alarm],
2023-11-21 11:51:27 +08:00
]
];
}
/**
* @notes 服务支持
* @return array[]
* @author 段誉
* @date 2022/7/18 11:18
*/
public static function support()
{
return [
[
'image' => FileService::getFileUrl(config('project.default_image.qq_group')),
'title' => '官方公众号',
'desc' => '关注官方公众号',
],
[
'image' => FileService::getFileUrl(config('project.default_image.customer_service')),
'title' => '添加企业客服微信',
'desc' => '想了解更多请添加客服',
]
];
}
}