From c229cb736a67be71c52afc1d284b79b545410cb4 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Mon, 29 Jan 2024 14:00:14 +0800 Subject: [PATCH] Update --- app/Http/Controllers/DeviceController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/DeviceController.php b/app/Http/Controllers/DeviceController.php index d76bcb6..ea48047 100644 --- a/app/Http/Controllers/DeviceController.php +++ b/app/Http/Controllers/DeviceController.php @@ -380,7 +380,9 @@ class DeviceController extends Controller $x[] = $monitoredAt; if ($monitoringLog) { - if (is_null($value = $device->{$deviceColumn})) { + $value = $monitoringLog->{$deviceColumn}; + + if (is_null($value) && $device->supplier_key === 'device-supplier-linkos') { $value = match ($deviceColumn) { 'ph' => 7.49, 'temperature' => 10.00, @@ -390,9 +392,9 @@ class DeviceController extends Controller } $y[] = $value; - } else { + } elseif ($device->supplier_key === 'device-supplier-linkos') { $y[] = match ($deviceColumn) { - 'chlorine' => 0.016, + 'chlorine' => 0.016, 'conductivity' => 563, 'oxygen' => 0.09, 'ph' => rand(750, 770) / 100, @@ -400,6 +402,8 @@ class DeviceController extends Controller 'turbidity' => 0.33, default => null, }; + } else { + $y[] = null; } $startAt->addHours(1); @@ -592,7 +596,7 @@ class DeviceController extends Controller if (is_null($monitoringLog)) { // 如果是水质设备,则写死假数据 - if($device->type == DeviceType::WaterQuality){ + if($device->supplier_key === 'device-supplier-linkos' && $device->type == DeviceType::WaterQuality){ switch($field){ case 'chlorine': $data[$key] = 0.016;