Browse Source

数据对接

master
lijunjie 3 years ago
parent
commit
3338249742
  1. 47
      app/Http/Controllers/IndexController.php
  2. 2
      config/custom.php
  3. BIN
      public/image/lora2/kk1_1.png
  4. BIN
      public/image/lora2/kk1_2.png
  5. BIN
      public/image/lora2/kk2_4.png
  6. 251
      public/script/http/lora2.js
  7. 30
      public/style/http/lora2.css
  8. 29
      resources/views/http/lora2.blade.php

47
app/Http/Controllers/IndexController.php

@ -278,6 +278,11 @@ class IndexController extends BaseController
return $blood;
}
/**
* 上传血压数据
* http://127.0.0.1:8001/storeBlood?node=616162626365&data=0090243050005500
* @return string
*/
public function storeBlood()
{
// echo Cache::get('blood');
@ -443,10 +448,50 @@ class IndexController extends BaseController
{
$request_data = request()->all();
$compare_type = $request_data['compare_type'];
$compare_type = $request_data['compare_type'] ?? 1;
$time = (int)(time() . '000');
$nodes = config("custom.lora_mac");
$return_data = [];
foreach ($nodes as $key => $node){
switch ($compare_type) {
case 1:
$device_data = Cache::get('blood' . $node, '');
break;
case 2:
$device_data = Cache::get('temperature' . $node, '');
break;
case 3:
$device_data = Cache::get('heart' . $node, '');
break;
case 4:
$device_data = Cache::get('heart2' . $node, '');
break;
default:
$device_data = Cache::get('blood' . $node, '');
}
if (empty($device_data)){
continue;
}
$device_id = $key + 1;
$device_name = '设备' . $device_id;
$return_data[$device_name] = [
[
$time,
$device_data
]
];
}
return $return_data;
return [
'设备1' => [
[

2
config/custom.php

@ -5,5 +5,7 @@ return [
"616162626364",
"616162626365",
"616162626366",
"616162626367",
"616162626368",
],
];

BIN
public/image/lora2/kk1_1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
public/image/lora2/kk1_2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1019 B

BIN
public/image/lora2/kk2_4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

251
public/script/http/lora2.js

@ -1,19 +1,23 @@
var device_list = [];
var show_category = 1;
var mac_id = '';
var clear1 = 0;
var clear2 = 0;
var data_blood = [];
var data_temperature = [];
var data_heart = [];
var data_humidity = [];
var data_total = [];
var original2 = '';
const app = {
data() {
return {
device_list: [],
show_category1:false,
show_category2:true,
menu_selected:1,
compare:{
compare1:true,
compare2:false,
compare3:false,
compare4:false,
compare5:false,
},
device_list : [],
show_category : show_category,
mac_id : mac_id,
original2 : original2,
}
},
mounted() {
@ -23,6 +27,8 @@ const app = {
.then(function (response) {
device_list = response.data
_this.device_list = device_list;
_this.mac_id = device_list[0].mac;
mac_id = device_list[0].mac;
})
.catch(function (error) { // 请求失败处理
console.log(error);
@ -38,69 +44,47 @@ const app = {
},
methods: {
toggleCompare(click_compare) {
if (click_compare == 1){
this.show_category = true
} else {
this.show_category = false
}
this.menu_selected = click_compare;
for(key in this.compare){
this.compare[key] = false
this.compare['compare' + click_compare] = true
}
this.show_category = click_compare;
show_category = click_compare;
clear1 = 1;
clear2 = 1;
},
toggleDevice(device_mac){
console.log(device_mac)
toggleDevice(mac){
this.show_category = 1;
show_category = 1;
clear1 = 1;
clear2 = 1;
this.mac_id = mac;
mac_id = mac;
},
//定时刷新设备在线状态
getFxItemlist() {
this.device_list = device_list
this.$forceUpdate();
}
},
computed: {
menuSelected(menu_selected_num) {
return {
'menu-button-selected': true,
}
this.device_list = device_list;
this.data_blood = data_blood;
this.data_temperature = data_temperature;
this.data_heart = data_heart;
this.data_humidity = data_humidity;
this.data_total = data_total;
this.original2 = original2;
this.$forceUpdate();
}
}
}
Vue.createApp(app).mount('#app')
var mac = '616162626363';
var clear = 0;
//默认显示各项对比
var show_type = 1;
//1血氧
var compare_type = 1;
var dom1 = document.getElementById('container1');
var dom2 = document.getElementById('container2');
var dom4 = document.getElementById('container4');
var data_blood = [];
var data_temperature = [];
var data_heart = [];
var data_humidity = [];
var data_total = [];
buildCompare(dom1);
buildRadar(dom2);
buildDevice(dom4);
function hideDiv() {
$("#container1").toggle();
$("#container2").toggle();
$("#container3").toggle();
clear = 1
show_type = (show_type == 1) ? 2 : 1;
}
/**
* 各项对比
* @param dom
@ -348,20 +332,20 @@ function buildCompare(dom) {
setInterval(function () {
if (show_type != 1) {
if (clear == 1) {
if (clear1 == 1) {
data_blood = []
data_temperature = [];
data_heart = [];
data_humidity = [];
data_total = [];
clear = 0;
clear1 = 0;
setData(data_blood, data_temperature, data_heart, data_humidity);
}
if (show_category != 1) {
return;
}
$.get('/loraData2?mac=' + mac).done(function (rawData) {
$.get('/loraData2?node=' + mac_id).done(function (rawData) {
if (!rawData || rawData.length == 0){
return;
}
@ -385,9 +369,18 @@ function buildCompare(dom) {
rawData.blood.forEach(value => data_blood.push(value));
rawData.temperature.forEach(value => data_temperature.push(value));
rawData.heart.forEach(value => data_heart.push(value));
if (rawData.humidity && rawData.humidity.length > 0){
rawData.humidity.forEach(value => data_humidity.push(value));
}
// rawData.total_data.forEach(value => data_total.push(value));
setData(data_blood, data_temperature, data_heart, data_humidity);
});
}, 2000);
function setData(data_blood, data_temperature, data_heart, data_humidity){
myChart.setOption({
series: [
{
@ -409,9 +402,7 @@ function buildCompare(dom) {
// }
]
});
});
}, 2000);
}
}
/**
@ -460,7 +451,7 @@ function buildRadar(dom) {
setInterval(buildData, 1000 * 5);
function buildData() {
if (show_type != 1 || data_blood.length == 0) {
if (show_category != 1 || data_blood.length == 0) {
return;
}
@ -497,6 +488,10 @@ function buildRadar(dom) {
}
}
/**
* 专项对比
* @param dom
*/
function buildDevice(dom) {
var myChart = echarts.init(dom, 'dark', {
renderer: 'canvas',
@ -555,19 +550,20 @@ function buildDevice(dom) {
window.addEventListener('resize', myChart.resize);
let special_compare_data = [];
setInterval(function () {
// if (show_type != 2) {
// if (clear == 1) {
// special_compare_data = [];
// clear = 0;
// }
//
if (clear2 == 1) {
special_compare_data = [];
clear2 = 0;
}
// if (show_category == 1) {
// return;
// }
let compare_type = show_category - 1;
let chart_data = [];
original2 = '';
let expire = 0;
$.get('/getSpecialCompare?compare_type=' + compare_type).done(function (rawData) {
//追加数据
@ -603,6 +599,10 @@ function buildDevice(dom) {
special_compare_data[key].shift()
}
special_compare_data[key].forEach(function (item) {
original2 += item[1] + ' ';
})
chart_data.push({
name: key,
data: special_compare_data[key],
@ -611,8 +611,119 @@ function buildDevice(dom) {
})
}
let yAxis = [];
switch (compare_type) {
case 1:
yAxis = [
{
name: '血氧',
min: 0,
max: 100,
nameTextStyle: {
align: 'right',
color: '#2ec7c9',
fontSize: 16
},
axisLine: {
show: true,
lineStyle: {
color: '#2ec7c9'
}
},
axisLabel: {
formatter: '{value}%',
color: '#2ec7c9',
fontSize: 16
},
},
];
break;
case 2:
yAxis = [
{
type: 'value',
name: '温度',
min: 30,
max: 45,
nameTextStyle: {
align: 'right',
color: '#5ab1ef',
fontSize: 16
},
axisLine: {
show: true,
lineStyle: {
color: '#5ab1ef'
}
},
axisLabel: {
formatter: '{value}°C',
color: '#5ab1ef',
fontSize: 16
},
}
];
break;
case 3:
yAxis = [
{
type: 'value',
name: '心率',
min: 0,
max: 150,
nameTextStyle: {
align: 'right',
color: '#f5994e',
fontSize: 16
},
axisLine: {
show: true,
lineStyle: {
color: '#f5994e'
}
},
axisLabel: {
formatter: '{value}次',
color: '#f5994e',
fontSize: 16
},
}
];
break;
case 4:
yAxis = [
{
type: 'value',
name: '湿度',
min: 0,
max: 100,
nameTextStyle: {
align: 'right',
color: '#c05050',
fontSize: 16
},
axisLine: {
show: true,
lineStyle: {
color: '#c05050'
}
},
axisLabel: {
formatter: '{value}%',
color: '#c05050',
fontSize: 16
},
}
];
break;
default:
};
myChart.setOption({
series: chart_data
series: chart_data,
yAxis: yAxis,
});
});

30
public/style/http/lora2.css

@ -54,8 +54,7 @@ html {
}
.menu{
position:absolute;
left: 0;
right: 0;
width: 11.8rem;
margin:auto;
height: 0.64rem;
background-image:url("/image/lora2/top.png");
@ -63,19 +62,21 @@ html {
background-repeat: no-repeat;
display: -webkit-flex;
display: flex;
padding-left: 4rem;
padding-left: 2.07rem;
margin-left: 2.8rem;
}
.menu-button{
width: 1.2rem;
width: 1.17rem;
height: auto;
padding-left: 0.1rem;
padding-right: 0.1rem;
text-align: center;
line-height:0.64rem;
font-size: 0.18rem;
font-size: 0.2rem;
font-family: Source Han Sans CN;
font-weight: 400;
color: #FFFFFF;
opacity: 0.8;
cursor:pointer;
}
.menu-button-selected{
@ -84,12 +85,11 @@ html {
background-repeat: no-repeat;
}
.menu-middle{
width: 5.6rem;
width: 4.27rem;
height: auto;
text-align: center;
line-height:0.64rem;
font-size: 0.25rem;
font-size: 0.28rem;
font-family: Source Han Sans CN;
font-weight: 400;
color: #FFFFFF;
@ -145,7 +145,11 @@ html {
background: linear-gradient(90deg, rgba(0,250,255,0.5), rgba(0,250,255,0.1));
border-radius: 0.32rem;
}
.device-border{
.device-border1{
display: -webkit-flex;
display: flex;
}
.device-border2{
width: 100%;
height: 100%;
background: #101010;
@ -171,6 +175,10 @@ html {
display: -webkit-flex;
display: flex;
}
.device-online-chunk{
display: -webkit-flex;
display: flex;
}
.device-online{
width: 0.12rem;
height: 0.12rem;
@ -354,7 +362,7 @@ html {
margin-top: 0.32rem;
width: 1.88rem;
height: auto;
background-image:url("/image/lora2/kk1_4.png");
background-image:url("/image/lora2/kk2_4.png");
background-size: 100% 100%;
background-repeat: repeat-x;
}
@ -463,7 +471,7 @@ html {
margin-top: 0.32rem;
width: 1.88rem;
height: auto;
background-image:url("/image/lora2/kk1_4.png");
background-image:url("/image/lora2/kk2_4.png");
background-size: 100% 100%;
background-repeat: repeat-x;
}

29
resources/views/http/lora2.blade.php

@ -19,22 +19,22 @@
</div>
</div>
<div class="menu">
<div @click="toggleCompare(1)" :class="menuSelected" class="menu-button">
<div @click="toggleCompare(1)" :class="{ 'menu-button-selected': show_category==1 }" class="menu-button">
数据对比
</div>
<div @click="toggleCompare(2)" :class="{ 'menu-button-selected': compare.compare2 }" class="menu-button">
<div @click="toggleCompare(2)" :class="{ 'menu-button-selected': show_category==2 }" class="menu-button">
血氧对比
</div>
<div class="menu-middle">
LoRa手环数据分析
</div>
<div @click="toggleCompare(3)" :class="{ 'menu-button-selected': compare.compare3 }" class="menu-button">
<div @click="toggleCompare(3)" :class="{ 'menu-button-selected': show_category==3 }" class="menu-button">
体温对比
</div>
<div @click="toggleCompare(4)" :class="{ 'menu-button-selected': compare.compare4 }" class="menu-button">
<div @click="toggleCompare(4)" :class="{ 'menu-button-selected': show_category==4 }" class="menu-button">
心跳对比
</div>
<div @click="toggleCompare(5)" :class="{ 'menu-button-selected': compare.compare5 }" class="menu-button">
<div @click="toggleCompare(5)" :class="{ 'menu-button-selected': show_category==5 }" class="menu-button">
脉搏对比
</div>
</div>
@ -47,8 +47,10 @@
<div class="device">
<div class="device-frame">
<div v-for="device in device_list">
<div class="device-cell1 device-cell" v-if="device.online == 1" @click="toggleDevice(device.mac)">
<div :class="['device-cell' ,device.mac == mac_id ? 'device-cell1' : 'device-cell2']" @click="toggleDevice(device.mac)">
<div :class="['device-border' ,device.mac == mac_id ? 'device-border1' : 'device-border2']">
<div class="device-info1">@{{device.name}}</div>
<div class="device-online-chunk" v-if="device.online == 1">
<div class="device-info2">
<div class="device-online"></div>
@ -56,21 +58,22 @@
<div class="device-info3">在线</div>
</div>
<div class="device-cell2 device-cell" v-else @click="toggleDevice(device.mac)">
<div class="device-border">
<div class="device-info1">@{{device.name}}</div>
<div class="device-online-chunk" v-else>
<div class="device-info2">
<div class="device-online2"></div>
</div>
<div class="device-info3">离线</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div v-show="show_category1" class="diagram">
<div v-show="show_category==1" class="diagram">
<div class="compare">
<div id="container1"></div>
<div class="compare-left"></div>
@ -103,7 +106,7 @@
<div class="radar-right"></div>
</div>
<div class="original">
<div id="container3">0000000000000000000000 000000000000000</div>
<div id="container3">@{{data_blood}}</div>
<div class="original-left"></div>
<div class="original-left2"></div>
<div class="original-middle">
@ -122,7 +125,7 @@
</div>
{{-- 不同设备对比--}}
<div v-show="show_category2" class="diagram">
<div v-show="show_category!=1" class="diagram">
<div class="compare">
<div id="container4"></div>
<div class="compare-left"></div>
@ -140,7 +143,7 @@
</div>
<div class="compare2">
<div class="original2">
<div id="container5">00000000000000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000 00000000000000</div>
<div id="container5">@{{ original2 }}</div>
<div class="original-left"></div>
<div class="original2-left2"></div>
<div class="original-middle">

Loading…
Cancel
Save