From 31a296f98a4b2beb05ca98117c390352d341c028 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 7 Sep 2023 12:29:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8A=A5=E8=AD=A6=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DeviceWarningService.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/Services/DeviceWarningService.php b/app/Services/DeviceWarningService.php index daf5487..34d0b7f 100644 --- a/app/Services/DeviceWarningService.php +++ b/app/Services/DeviceWarningService.php @@ -147,17 +147,18 @@ class DeviceWarningService $msg = $fieldNameMap[$column].'达到'.($log->$column ?? 0).$fieldUnitMap[$column].'值'; } } - - $notices[] = [ - 'device_id' => $device->id, - 'lv' => $lv, - 'content' => '【'.$device->name.'】【'.WarningNotice::lvMap()[$lv].'】'.$msg, - 'reported_at' => $reportedAt, - 'created_at' => now(), - 'updated_at' => now(), - 'loggable_type' => $log::class, - 'loggable_id' => $log->id, - ]; + if($msg){ + $notices[] = [ + 'device_id' => $device->id, + 'lv' => $lv, + 'content' => '【'.$device->name.'】【'.WarningNotice::lvMap()[$lv].'】'.$msg, + 'reported_at' => $reportedAt, + 'created_at' => now(), + 'updated_at' => now(), + 'loggable_type' => $log::class, + 'loggable_id' => $log->id, + ]; + } } count($notices) > 0 && WarningNotice::insert($notices);