| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Module\System\AdminMetrics;
- use UCore\DcatAdmin\Metrics\Sys\JobRun;
- use App\Console\Commands\GuidanceJisuan;
- use App\Module\Transfer\Enums\TStatus;
- use App\Module\Transfer\Enums\TType;
- use App\Module\Transfer\Model\TransferOrder;
- use Carbon\Carbon;
- use UCore\Helper\Cache;
- use UCore\Helper\Bc;
- use Illuminate\Http\Request;
- /**
- * 系统报警
- * Class Alarm
- *
- */
- class Alarm extends \UCore\DcatAdmin\Metrics\Examples\ListDataColor
- {
- protected $title = '运行情况';
- /**
- * 初始化卡片内容
- */
- protected function init()
- {
- parent::init();
- $this->title('运行情况');
- $this->chart = null;
- }
- protected function getData()
- {
- return Cache::cacheCall([ __CLASS__, __FUNCTION__, 2 ], function () {
- $now = time();
- $data = [];
- // Cron分钟的任务
- /**
- * @var \App\Module\Job\Model\JobRun $last
- */
- $last = \App\Module\Job\Model\JobRun::query()->where('queue', '=', 'Console')->orderByDesc('id')->first();
- if ($last) {
- $va = [
- 'title' => 'Cron分钟任务',
- 'value' => $last->created_at->format('H:i:s'),
- 'type' => self::TYPE_OK
- ];
- if ($now - $last->created_at->timestamp > 300) {
- $va['type'] = self::TYPE_ERROR;
- }
- if ($now - $last->created_at->timestamp > 60) {
- $va['type'] = self::TYPE_WARNING;
- }
- $data[] = $va;
- }
- $lastGJ = \App\Module\Job\Model\JobRun::query()
- ->where('queue', '=', 'Console')
- ->where('runclass', '=', GuidanceJisuan::class)
- ->orderByDesc('id')->first();
- if ($lastGJ) {
- $va = [
- 'title' => '计算指导价格',
- 'value' => $lastGJ->created_at->format('m-d H:i:s'),
- 'type' => self::TYPE_OK
- ];
- if ($now - $lastGJ->created_at->timestamp > (3600*24)) {
- $va['type'] = self::TYPE_ERROR;
- }
- $data[] = $va;
- }
- return $data;
- }, [], 10);
- }
- }
|