Browse Source

对接血氧

master
lijunjie 3 years ago
parent
commit
97740b9cf3
  1. 53
      app/Http/Controllers/IndexController.php
  2. 32
      public/script/http/index.js
  3. 8
      resources/views/http/index.blade.php

53
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']);

32
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(() => {

8
resources/views/http/index.blade.php

@ -130,10 +130,8 @@
<div class="foot-chunk-spot foot-chunk-spot1">
<div class="foot-chunk-spot-inside">
<div id="foot-content1" class="foot-chunk-spot-content1">
36.2℃
</div>
<div id="foot-content2" class="foot-chunk-spot-content2">
80%
</div>
</div>
@ -144,10 +142,8 @@
<div class="foot-chunk-spot foot-chunk-spot1">
<div class="foot-chunk-spot-inside">
<div id="foot-content3" class="foot-chunk-spot-content1">
36.2℃
</div>
<div id="foot-content4" class="foot-chunk-spot-content2">
80%
</div>
</div>
@ -161,10 +157,8 @@
<div class="foot-chunk-spot">
<div class="foot-chunk-spot-inside">
<div id="foot-content5" class="foot-chunk-spot-content1">
36.2℃
</div>
<div id="foot-content6" class="foot-chunk-spot-content2">
80%
</div>
</div>
@ -175,10 +169,8 @@
<div class="foot-chunk-spot">
<div class="foot-chunk-spot-inside">
<div id="foot-content7" class="foot-chunk-spot-content1">
36.2℃
</div>
<div id="foot-content8" class="foot-chunk-spot-content2">
80%
</div>
</div>

Loading…
Cancel
Save