diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 9d00532..6b6c223 100644 --- a/app/Http/Controllers/IndexController.php +++ b/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' => [ [ diff --git a/config/custom.php b/config/custom.php index 5d8c8c0..fb02393 100644 --- a/config/custom.php +++ b/config/custom.php @@ -5,5 +5,7 @@ return [ "616162626364", "616162626365", "616162626366", + "616162626367", + "616162626368", ], ]; diff --git a/public/image/lora2/kk1_1.png b/public/image/lora2/kk1_1.png index 60c6183..0d717f5 100644 Binary files a/public/image/lora2/kk1_1.png and b/public/image/lora2/kk1_1.png differ diff --git a/public/image/lora2/kk1_2.png b/public/image/lora2/kk1_2.png index e3d7464..03903e2 100644 Binary files a/public/image/lora2/kk1_2.png and b/public/image/lora2/kk1_2.png differ diff --git a/public/image/lora2/kk2_4.png b/public/image/lora2/kk2_4.png new file mode 100644 index 0000000..75df325 Binary files /dev/null and b/public/image/lora2/kk2_4.png differ diff --git a/public/script/http/lora2.js b/public/script/http/lora2.js index 48b647d..9fea516 100644 --- a/public/script/http/lora2.js +++ b/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) { - data_blood = [] - data_temperature = []; - data_heart = []; - data_humidity = []; - data_total = []; - clear = 0; - } - + if (clear1 == 1) { + data_blood = [] + data_temperature = []; + data_heart = []; + data_humidity = []; + data_total = []; + 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,33 +369,40 @@ 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)); - rawData.humidity.forEach(value => data_humidity.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); - myChart.setOption({ - series: [ - { - name: '血氧', - data: data_blood - }, { - name: '温度', - data: data_temperature - }, { - name: '心率', - data: data_heart - }, { - name: '湿度', - data: data_humidity - }, - // { - // name: '总体', - // data: data_total - // } - ] - }); }); }, 2000); + + function setData(data_blood, data_temperature, data_heart, data_humidity){ + myChart.setOption({ + series: [ + { + name: '血氧', + data: data_blood + }, { + name: '温度', + data: data_temperature + }, { + name: '心率', + data: data_heart + }, { + name: '湿度', + data: data_humidity + }, + // { + // name: '总体', + // data: data_total + // } + ] + }); + } } /** @@ -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, }); }); diff --git a/public/style/http/lora2.css b/public/style/http/lora2.css index 81c68a7..e7c4a03 100644 --- a/public/style/http/lora2.css +++ b/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; } diff --git a/resources/views/http/lora2.blade.php b/resources/views/http/lora2.blade.php index 991ccd1..b723b66 100644 --- a/resources/views/http/lora2.blade.php +++ b/resources/views/http/lora2.blade.php @@ -19,22 +19,22 @@