Files
ProxyPanel/app/Console/Commands/AutoReportNode.php
兔姬桑 ce9618236f 2.5.a 管理路由全面改写 与 代码拆分
1. 全面改写项目-管理面板的路由;
2. 拆分过于Contoller;
3. 优化了按钮过多的图表的显示;
4. 初步应用 Laravel的 表单验证功能;
5. 初步应用 Laravel的 component 功能 拆分/模块化前端代码;
6. 优化部分系统的判断逻辑;
7. 针对2.4.0以前的面板,追加辅助矫正数据库的sql文件;
2020-10-01 12:34:19 +08:00

46 lines
1.5 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Components\PushNotification;
use App\Models\Node;
use App\Models\NodeDailyDataFlow;
use Illuminate\Console\Command;
use Log;
class AutoReportNode extends Command
{
protected $signature = 'autoReportNode';
protected $description = '自动报告节点昨日使用情况';
public function handle(): void
{
$jobStartTime = microtime(true);
if (sysConfig('node_daily_report')) {
$nodeList = Node::whereStatus(1)->get();
if ($nodeList->isNotEmpty()) {
$msg = "|节点|上行流量|下行流量|合计|\r\n| :------ | :------ | :------ |\r\n";
foreach ($nodeList as $node) {
$log = NodeDailyDataFlow::whereNodeId($node->id)
->whereDate('created_at', date("Y-m-d", strtotime('-1 days')))
->first();
if ($log) {
$msg .= '|'.$node->name.'|'.flowAutoShow($log->u).'|'.flowAutoShow($log->d).'|'.$log->traffic."\r\n";
} else {
$msg .= '|'.$node->name.'|'.flowAutoShow(0).'|'.flowAutoShow(0)."|0B\r\n";
}
}
PushNotification::send('节点昨日使用情况', $msg);
}
}
$jobEndTime = microtime(true);
$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
}