diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index f2a456b..737f8af 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -107,24 +107,49 @@ class IndexController extends BaseController } //足底温度图 - $foot_key = "foot"; + $foot = []; + for ($i = 1; $i <= 4; $i++) { + $foot_key = "foot:" . $i; - if ($timer_shaft == 0 ){ - //获取最大时间 - $foot_data = Redis::ZREVRANGE($foot_key, 0, 0); - } else { - //获得指定时间 - $foot_data = Redis::ZREVRANGEBYSCORE($foot_key, $timer_shaft, $timer_shaft - 60); - } + if ($timer_shaft == 0 ){ + //获取最大时间 + $foot_data = Redis::ZREVRANGE($foot_key, 0, 0); + } else { + //获得指定时间 + $foot_data = Redis::ZREVRANGEBYSCORE($foot_key, $timer_shaft, $timer_shaft - 60); + } - $foot = []; - if (!empty($foot_data)){ - $foot_data = $foot_data[0]; - for ($i = 0; $i < strlen($foot_data) / 2; $i++) { - $foot[] = hexdec(substr($foot_data, $i * 2, 2)); + + if (!empty($foot_data)){ + $foot_data = $foot_data[0]; + +// Cache::put('blood' . $request_data['node'], ($blood1 + $blood2) * 100); + + //体温36.1 + $temperature = substr($foot_data, 4, 4); + $foot[] = hexdec($temperature) / 100; +// Cache::put('temperature' . $request_data['node'], $temperature); +// + //血氧80.1 + $blood = substr($foot_data, 0, 4); + $blood1 = hexdec(substr($blood, 0, 2)); + $blood2 = substr($blood, 2, 2); + $blood2 = CommonService::customHex2dec($blood2); + + $foot[] = $blood1 + $blood2; + +// //心跳70 +// $heart = substr($foot_data, 8, 4); +// $heart = hexdec($heart); +// Cache::put('heart' . $request_data['node'], $heart); +// //脉搏70 +// $heart2 = substr($foot_data, 12, 4); +// $heart2 = hexdec($heart2); +// Cache::put('heart2' . $request_data['node'], $heart2); } } + return [ 'pressure' => $chunk3 ?? '', 'foot' => $foot @@ -153,7 +178,7 @@ class IndexController extends BaseController //删除过期 Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120)); } elseif ($req['type'] == "0002") { - $pelma_key = "foot"; + $pelma_key = "foot:" . hexdec($req['device']); //按时间添加 Redis::zadd($pelma_key, $time, $req['send_data']); diff --git a/public/script/http/index.js b/public/script/http/index.js index 9ba7f15..b22bb91 100644 --- a/public/script/http/index.js +++ b/public/script/http/index.js @@ -132,15 +132,31 @@ function pressure(dom, item) { }) $(".sound-code-chunk-default-content").html(original); } + if (data['foot'][0]){ + $("#foot-content1").html(data['foot'][0] + '℃'); + } + if (data['foot'][1]){ + $("#foot-content2").html(data['foot'][1] + '%'); + } + if (data['foot'][2]){ + $("#foot-content3").html(data['foot'][2] + '℃'); + } + if (data['foot'][3]){ + $("#foot-content4").html(data['foot'][3] + '%'); + } + if (data['foot'][4]){ + $("#foot-content5").html(data['foot'][4] + '℃'); + } + if (data['foot'][5]){ + $("#foot-content6").html(data['foot'][5] + '%'); + } + if (data['foot'][6]){ + $("#foot-content7").html(data['foot'][6] + '℃'); + } + if (data['foot'][7]){ + $("#foot-content8").html(data['foot'][7] + '%'); + } - $("#foot-content1").html(data['foot'][0] + '℃'); - $("#foot-content2").html(data['foot'][1] + '%'); - $("#foot-content3").html(data['foot'][2] + '℃'); - $("#foot-content4").html(data['foot'][3] + '%'); - $("#foot-content5").html(data['foot'][4] + '℃'); - $("#foot-content6").html(data['foot'][5] + '%'); - $("#foot-content7").html(data['foot'][6] + '℃'); - $("#foot-content8").html(data['foot'][7] + '%'); } timer = setTimeout(() => { diff --git a/resources/views/http/index.blade.php b/resources/views/http/index.blade.php index 4654e38..5260c35 100644 --- a/resources/views/http/index.blade.php +++ b/resources/views/http/index.blade.php @@ -130,10 +130,8 @@
- 36.2℃
- 80%
@@ -144,10 +142,8 @@
- 36.2℃
- 80%
@@ -161,10 +157,8 @@
- 36.2℃
- 80%
@@ -175,10 +169,8 @@
- 36.2℃
- 80%