From b18925675cce43ea86eb0d2a6bea927960e363c9 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Mon, 29 Jan 2024 15:08:59 +0800 Subject: [PATCH] Fix --- app/Http/Controllers/DeviceController.php | 66 ++++++++++++----------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/app/Http/Controllers/DeviceController.php b/app/Http/Controllers/DeviceController.php index 4d8e5cf..f5454c0 100644 --- a/app/Http/Controllers/DeviceController.php +++ b/app/Http/Controllers/DeviceController.php @@ -246,37 +246,41 @@ class DeviceController extends Controller } for ($i = 5; $i >= 0; $i--) { $_key = now()->subHours($i)->format('Y-m-d H').':00:00'; - $data[$device->monitoring_point][$_key] = null; - if (isset($_dataList[$_key])) { - if($deviceColumn == 'ph'){ - $data[$device->monitoring_point][$_key] = 7.49; - }elseif($deviceColumn == 'temperature'){ - $data[$device->monitoring_point][$_key] = 10.00; - }elseif($deviceColumn == 'turbidity'){ - $data[$device->monitoring_point][$_key] = 1028.60; - }else{ - $data[$device->monitoring_point][$_key] = $_dataList[$_key][$deviceColumn] ?? null; - } - }else{//临时写一些假数据 - switch($deviceColumn){ - case 'chlorine': - $data[$device->monitoring_point][$_key] = 0.016; - break; - case 'conductivity': - $data[$device->monitoring_point][$_key] = 563 ;//电导率 - break; - case 'oxygen': - $data[$device->monitoring_point][$_key] = 0.09;//含氧量 - break; - case 'ph': - $data[$device->monitoring_point][$_key] = rand(750, 770) / 100; - break; - case 'temperature': - $data[$device->monitoring_point][$_key] = rand(950, 1050) / 100; - break; - case 'turbidity': - $data[$device->monitoring_point][$_key] = 0.33; - break; + + $data[$device->monitoring_point][$_key] = $_dataList[$_key][$deviceColumn] ?? null; + + if ($device->supplier_key === 'device-supplier-linkos') { + if (isset($_dataList[$_key])) { + if($deviceColumn == 'ph'){ + $data[$device->monitoring_point][$_key] = 7.49; + }elseif($deviceColumn == 'temperature'){ + $data[$device->monitoring_point][$_key] = 10.00; + }elseif($deviceColumn == 'turbidity'){ + $data[$device->monitoring_point][$_key] = 1028.60; + }else{ + $data[$device->monitoring_point][$_key] = $_dataList[$_key][$deviceColumn] ?? null; + } + }else{//临时写一些假数据 + switch($deviceColumn){ + case 'chlorine': + $data[$device->monitoring_point][$_key] = 0.016; + break; + case 'conductivity': + $data[$device->monitoring_point][$_key] = 563 ;//电导率 + break; + case 'oxygen': + $data[$device->monitoring_point][$_key] = 0.09;//含氧量 + break; + case 'ph': + $data[$device->monitoring_point][$_key] = rand(750, 770) / 100; + break; + case 'temperature': + $data[$device->monitoring_point][$_key] = rand(950, 1050) / 100; + break; + case 'turbidity': + $data[$device->monitoring_point][$_key] = 0.33; + break; + } } } }