Browse Source

足底温度数据数据

master
lijunjie 3 years ago
parent
commit
83cdbd8133
  1. 60
      app/Http/Controllers/IndexController.php
  2. 6
      public/script/http/index.js

60
app/Http/Controllers/IndexController.php

@ -18,11 +18,10 @@ class IndexController extends BaseController
public function getPelmaData() public function getPelmaData()
{ {
$request_data = request()->all(); $request_data = request()->all();
$timer_shaft = $request_data['timer_shaft'];
//足底压力图
$pelma_key = "pelma:" . $request_data['item']; $pelma_key = "pelma:" . $request_data['item'];
$timer_shaft = $request_data['timer_shaft'];
if ($timer_shaft == 0 ){ if ($timer_shaft == 0 ){
//获取最大时间 //获取最大时间
@ -32,10 +31,7 @@ class IndexController extends BaseController
$data = Redis::ZREVRANGEBYSCORE($pelma_key, $timer_shaft, $timer_shaft - 60); $data = Redis::ZREVRANGEBYSCORE($pelma_key, $timer_shaft, $timer_shaft - 60);
} }
if (empty($data)){ if(!empty($data)){
return;
}
$pelmaArr = str_split($data[0], 2); $pelmaArr = str_split($data[0], 2);
$vague = 2; $vague = 2;
@ -88,10 +84,25 @@ class IndexController extends BaseController
]; ];
} }
} }
// dd($chunk3); }
//足底温度图
$foot_key = "foot";
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 (!empty($foot_data)){
$foot = $foot_data;
}
return [ return [
'pressure' => $chunk3, 'pressure' => $chunk3 ?? '',
'foot' => [36.2, 80, 36.1, 75, 35.9, 79, 36.3, 80] 'foot' => [36.2, 80, 36.1, 75, 35.9, 79, 36.3, 80]
]; ];
} }
@ -106,21 +117,24 @@ class IndexController extends BaseController
$time = time(); $time = time();
// echo Cache::get('pelma'); // echo Cache::get('pelma');
if ($req['type'] == 1){
$pelma_key = "pelma:" . $req['device']; $pelma_key = "pelma:" . $req['device'];
//按时间添加 //按时间添加
Redis::zadd($pelma_key, $time, $req['pelma']); Redis::zadd($pelma_key, $time, $req['send_data']);
//删除过期 //删除过期
Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120)); Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120));
} elseif ($req['type'] == 2) {
$pelma_key = "foot";
//获取最大时间 //按时间添加
// $data = Redis::ZREVRANGE($pelma_key, 0, 0); Redis::zadd($pelma_key, $time, $req['send_data']);
//获得指定时间
// $data = Redis::ZRANGEBYSCORE($pelma_key, 19, 29);
// var_dump($data);
//删除过期
Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120));
}
// $data = request('pelma'); // $data = request('pelma');
// Cache::put('pelma', $data); // Cache::put('pelma', $data);
@ -141,20 +155,6 @@ class IndexController extends BaseController
return view('http.lora2'); return view('http.lora2');
} }
public function getPelmaStore()
{
echo Cache::get('pelma');
return;
}
public function getBlood()
{
$blood = Cache::get('blood');
return $blood;
}
/** /**
* 上传血压数据 * 上传血压数据
* http://127.0.0.1:8001/storeBlood?node=616162626365&data=0090243050005500 * http://127.0.0.1:8001/storeBlood?node=616162626365&data=0090243050005500

6
public/script/http/index.js

@ -103,7 +103,6 @@ function pressure(dom, item) {
let timer = null let timer = null
$.get('/getPelmaData?item=' + item + "&timer_shaft=" + timer_shaft).done(function (data) { $.get('/getPelmaData?item=' + item + "&timer_shaft=" + timer_shaft).done(function (data) {
if (data) {//根据返回状态判断 if (data) {//根据返回状态判断
console.log('a')
let pressure = data.pressure let pressure = data.pressure
myChart.setOption({ myChart.setOption({
series: [ series: [
@ -113,6 +112,8 @@ function pressure(dom, item) {
] ]
}); });
if (pressure && pressure.length > 0){
//原始数据
var myDate = new Date(); var myDate = new Date();
var mytime = myDate.toLocaleTimeString(); var mytime = myDate.toLocaleTimeString();
let original = mytime + ' '; let original = mytime + ' ';
@ -124,8 +125,9 @@ function pressure(dom, item) {
} }
}) })
$(".sound-code-chunk-default-content").html(original); $(".sound-code-chunk-default-content").html(original);
}
$("#foot-content1").html(data['foot'][0] + '℃'); $("#foot-content1").html(data['foot'][0] + '℃');
$("#foot-content2").html(data['foot'][1] + '%'); $("#foot-content2").html(data['foot'][1] + '%');
$("#foot-content3").html(data['foot'][2] + '℃'); $("#foot-content3").html(data['foot'][2] + '℃');

Loading…
Cancel
Save