Browse Source

解析足底数据

master
lijunjie 3 years ago
parent
commit
0929572e52
  1. 133
      app/Http/Controllers/IndexController.php
  2. 2
      app/Http/Kernel.php
  3. 22
      app/Http/Services/CommonService.php
  4. 3
      config/custom.php
  5. 18
      public/script/http/index.js
  6. 8
      routes/web.php

133
app/Http/Controllers/IndexController.php

@ -11,59 +11,44 @@ use Illuminate\Support\Facades\Redis;
class IndexController extends BaseController
{
public function index()
/**
* 获得足底数据
* @return array[]
*/
public function getPelmaData()
{
return view('http.index');
}
$request_data = request()->all();
public function tabularData()
{
$request_data = request()->all();
$pelma_key = "pelma:" . $request_data['item'];
$timer_shaft = $request_data['timer_shaft'];
if ($timer_shaft == 0 ){
//获取最大时间
$data = Redis::ZREVRANGE($pelma_key, 0, 0);
} else {
//获得指定时间
$data = Redis::ZREVRANGEBYSCORE($pelma_key, $timer_shaft, $timer_shaft - 60);
}
if (empty($data)){
return;
}
$pelmaArr = str_split($data[0], 2);
$vague = 2;
$datas = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 2, 2, 4, 4, 4, 4, 4, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 6, 6, 8, 4, 2, 1, 1, 1, 1, 1,
1, 1, 1, 1, 2, 4, 8, 9, 8, 6, 6, 4, 2, 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 8, 6, 6, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 2, 2, 4, 4, 6, 6, 4, 2, 2, 1, 1, 1, 1, 1, 2, 4, 6, 4, 4, 4, 2, 2, 2, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 4, 4, 4, 2, 1, 1, 1, 1, 1, 1, 2, 2, 4, 4, 2, 2, 2, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
];
//格式化成二维数组
for ($i = 0; $i < 1024; $i++){
$datas2[intval($i / 32)][$i % 32] = $datas[$i];
$datas2[intval($i / 32)][$i % 32] = hexdec($pelmaArr[$i]);
}
// dd($datas2);
foreach ($datas2 as $key1 => $data){
foreach ($data as $key2 => $datum){
if (!empty($datas2[$key1][$key2 - 1])){
if (isset($datas2[$key1][$key2 - 1])){
$num = $datum - $datas2[$key1][$key2 - 1];
$temp = $datum;
for ($i = $vague; $i >= 1; $i--) {
@ -81,7 +66,7 @@ class IndexController extends BaseController
foreach ($data as $key2 => $datum){
$number++;
if (!empty($chunk[$key1 - 1][$key2])){
if (isset($chunk[$key1 - 1][$key2])){
$num = $datum - $chunk[$key1 - 1][$key2];
$temp = $datum;
for ($i = $vague; $i >= 1; $i--) {
@ -103,6 +88,7 @@ class IndexController extends BaseController
];
}
}
// dd($chunk3);
return [
'pressure' => $chunk3,
@ -110,40 +96,23 @@ class IndexController extends BaseController
];
}
public function lora()
{
return view('http.lora');
}
public function lora2()
{
Cache::flush();
return view('http.lora2');
}
public function getPelmaStore()
{
echo Cache::get('pelma');
return;
}
public function store()
/**
* 存储足底数据
* @return string
*/
public function storePelma()
{
$req = request()->all();
$time = time();
// echo Cache::get('pelma');
$pelma_key = "pelma:1";
$pelma_key = "pelma:" . $req['device'];
//按时间添加
// Redis::zadd($pelma_key, $time, 'a' . $time);
// Redis::zadd($pelma_key, 1, 'a' . $time);
Redis::zadd($pelma_key, $time, $req['pelma']);
//删除过期
// Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 60));
Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120));
//获取最大时间
// $data = Redis::ZREVRANGE($pelma_key, 0, 0);
@ -153,12 +122,32 @@ class IndexController extends BaseController
// var_dump($data);
$data = request('pelma');
Cache::put('pelma', $data);
Log::info($data);
// $data = request('pelma');
// Cache::put('pelma', $data);
// Log::info($req);
return 'ok';
}
public function lora()
{
return view('http.lora');
}
public function lora2()
{
Cache::flush();
return view('http.lora2');
}
public function getPelmaStore()
{
echo Cache::get('pelma');
return;
}
public function getBlood()
{
$blood = Cache::get('blood');

2
app/Http/Kernel.php

@ -34,7 +34,7 @@ class Kernel extends HttpKernel
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],

22
app/Http/Services/CommonService.php

@ -37,4 +37,26 @@ class CommonService{
return $dec;
}
/**
* 校验码
* @param $data
* @return string|void
*/
public function getCheckCode($data)
{
if ($data) {
$arr = array();
$arr = str_split($data, 2);
$result = 0;
for ($i = 0; $i < count($arr); $i++) {
//把十六进制转换为十进制
$result = $result + hexdec($arr[$i]);
}
$result = strtoupper('0' . dechex($result)); //转换成大写
$result = substr($result, -2);
return $result;
}
}
}

3
config/custom.php

@ -14,4 +14,7 @@ return [
"616162626371",
"616162626372",
],
//足底压力图
'pelma_device' => [1,2,3,4],
];

18
public/script/http/index.js

@ -101,8 +101,9 @@ function pressure(dom, item) {
function setTimer() {
let timer = null
$.get('/tabularData?item=' + item + "&timer_shaft=" + timer_shaft).done(function (data) {
$.get('/getPelmaData?item=' + item + "&timer_shaft=" + timer_shaft).done(function (data) {
if (data) {//根据返回状态判断
console.log('a')
let pressure = data.pressure
myChart.setOption({
series: [
@ -133,13 +134,14 @@ function pressure(dom, item) {
$("#foot-content6").html(data['foot'][5] + '%');
$("#foot-content7").html(data['foot'][6] + '℃');
$("#foot-content8").html(data['foot'][7] + '%');
timer = setTimeout(() => {
setTimer()
}, 5000)//2秒查一下
} else {
clearTimeout(timer);//清理定时任务
}
timer = setTimeout(() => {
setTimer()
}, 5000)//*秒查一下
// else {
// clearTimeout(timer);//清理定时任务
// }
});
}
@ -157,7 +159,7 @@ function pressure(dom, item) {
visualMap: {
show: false,
min: 0,
max: 1,
max: 30,
calculable: true,
realtime: false,
inRange: {

8
routes/web.php

@ -14,17 +14,19 @@ use Illuminate\Support\Facades\Route;
*/
Route::get('/', [\App\Http\Controllers\IndexController::class, 'index']);
Route::get('/', function (Request $request) {
return view('http.index');
});
Route::get('/lora', [\App\Http\Controllers\IndexController::class, 'lora']);
Route::get('/lora2', [\App\Http\Controllers\IndexController::class, 'lora2']);
Route::get('/tabularData', [\App\Http\Controllers\IndexController::class, 'tabularData']);
Route::get('/getPelmaData', [\App\Http\Controllers\IndexController::class, 'getPelmaData']);
Route::get('/loraData', [\App\Http\Controllers\IndexController::class, 'loraData']);
Route::get('/loraData2', [\App\Http\Controllers\IndexController::class, 'loraData2']);
Route::get('/loraDeviceList', [\App\Http\Controllers\IndexController::class, 'loraDeviceList']);
Route::get('/getSpecialCompare', [\App\Http\Controllers\IndexController::class, 'getSpecialCompare']);
Route::get('/getPelmaStore', [\App\Http\Controllers\IndexController::class, 'getPelmaStore']);
Route::get('/store', [\App\Http\Controllers\IndexController::class, 'store']);
Route::post('/storePelma', [\App\Http\Controllers\IndexController::class, 'storePelma']);
Route::get('/getBlood', [\App\Http\Controllers\IndexController::class, 'getBlood']);
Route::get('/storeBlood', [\App\Http\Controllers\IndexController::class, 'storeBlood']);

Loading…
Cancel
Save