历史温度暂时提交

feasure-livedata
lld 2026-03-19 14:00:26 +08:00
parent 5d4d8312d0
commit d94d0f7a82
4 changed files with 162 additions and 24 deletions

View File

@ -8,5 +8,12 @@ export function findDtuDataByInfo(query) {
params: query params: query
}) })
} }
export function getHistoryData(query) {
return request({
url: '/system/data/getHistoryData',
method: 'get',
params: query
})
}

View File

@ -1,5 +1,21 @@
<template> <template>
<view class="charts-box"> <view class="charts-box">
<view>
<uni-row class="demo-uni-row" >
<uni-col :span="8">
<uni-data-select v-model="imei" :localdata="agriList" @change="changeAgri"></uni-data-select>
</uni-col>
<uni-col :span="16">
<uni-datetime-picker v-model="dateRange" type="datetimerange" @change="changeDate"/>
</uni-col>
</uni-row>
</view>
<qiun-data-charts <qiun-data-charts
type="line" type="line"
:opts="opts" :opts="opts"
@ -14,8 +30,13 @@
</template> </template>
<script> <script>
import { getHistoryData} from "../../api/system/data";
import {listAgri} from "../../api/system/assets/agri";
import store from "../../store";
import {parseTime} from "../../utils/agri";
export default { export default {
data() { data: function () {
return { return {
chartData: {}, chartData: {},
// opts type="line" config-ucharts.js ['line'] opts // opts type="line" config-ucharts.js ['line'] opts
@ -73,37 +94,118 @@ export default {
format: "" format: ""
} }
] ]
}, }
},
} dateRange:[],
end:Date.now(),
agriList:[],
imei:null
}; };
}, },
onReady() { onReady() {
this.getServerData(); this.getAgriList();
}, },
methods: { methods: {
getServerData() { getServerData() {
const param = {
imei: this.imei,
startTime: this.dateRange[0],
endTime: this.dateRange[1]
}
console.info("查询参数",param)
// //
setTimeout(() => { getHistoryData(param).then(response => {
// if (response.code === 200 && response.data) {
let res = { var data = response.data;
categories: ["00:00","00:05","00:10","00:15","00:20","00:25","00:30","00:35","00:40","00:45","00:50","00:55","01:00","01:05","01:10","01:15","01:20","01:25","01:30","01:35","01:40","01:45","01:50","01:55","02:00","02:05","02:10","02:15","02:20","02:25","02:30","02:35","02:40","02:45","02:50","02:55","03:00","03:05","03:10","03:15","03:20","03:25","03:30","03:35","03:40","03:45","03:50","03:55","04:00","04:05","04:10","04:15","04:20","04:25","04:30","04:35","04:40","04:45","04:50","04:55","05:00","05:05","05:10","05:15","05:20","05:25","05:30","05:35","05:40","05:45","05:50","05:55","06:00","06:05","06:10","06:15","06:20","06:25","06:30","06:35","06:40","06:45","06:50","06:55","07:00","07:05","07:10","07:15","07:20","07:25","07:30","07:35","07:40","07:45","07:50","07:55","08:00","08:05","08:10","08:15","08:20","08:25","08:30","08:35","08:40","08:45","08:50","08:55","09:00","09:05","09:10","09:15","09:20","09:25","09:30","09:35","09:40","09:45","09:50","09:55","10:00","10:05","10:10","10:15","10:20","10:25","10:30","10:35","10:40","10:45","10:50","10:55","11:00","11:05","11:10","11:15","11:20","11:25","11:30","11:35","11:40","11:45","11:50","11:55","12:00","12:05","12:10","12:15","12:20","12:25","12:30","12:35","12:40","12:45","12:50","12:55","13:00","13:05","13:10","13:15","13:20","13:25","13:30","13:35","13:40","13:45","13:50","13:55","14:00","14:05","14:10","14:15","14:20","14:25","14:30","14:35","14:40","14:45","14:50","14:55","15:00","15:05","15:10","15:15","15:20","15:25","15:30","15:35","15:40","15:45","15:50","15:55","16:00","16:05","16:10","16:15","16:20","16:25","16:30","16:35","16:40","16:45","16:50","16:55","17:00","17:05","17:10","17:15","17:20","17:25","17:30","17:35","17:40","17:45","17:50","17:55","18:00","18:05","18:10","18:15","18:20","18:25","18:30","18:35","18:40","18:45","18:50","18:55","19:00","19:05","19:10","19:15","19:20","19:25","19:30","19:35","19:40","19:45","19:50","19:55","20:00","20:05","20:10","20:15","20:20","20:25","20:30","20:35","20:40","20:45","20:50","20:55","21:00","21:05","21:10","21:15","21:20","21:25","21:30","21:35","21:40","21:45","21:50","21:55","22:00","22:05","22:10","22:15","22:20","22:25","22:30","22:35","22:40","22:45","22:50","22:55","23:00","23:05","23:10","23:15","23:20","23:25","23:30","23:35","23:40","23:45","23:50","23:55"], var res = {
series: [ categories: data.timeList,
{ series: [
name: "温度(℃)", {
index: 0, name: "温度1",
data: [18.2,17.9,17.5,17.1,16.8,16.5,16.3,16.1,15.9,15.8,15.7,15.6,15.5,15.4,15.3,15.2,15.1,15,14.9,14.8,14.7,14.6,14.5,14.4,14.3,14.2,14.1,14,13.9,13.8,13.7,13.6,13.5,13.4,13.3,13.2,13.1,13,12.9,12.8,12.7,12.6,12.5,12.4,12.3,12.2,12.1,12,12.1,12.2,12.3,12.4,12.5,12.6,12.7,12.8,12.9,13,13.2,13.4,13.6,13.8,14,14.3,14.6,14.9,15.2,15.5,15.8,16.1,16.4,16.7,17,17.3,17.6,17.9,18.2,18.5,18.8,19.1,19.4,19.7,20,20.3,20.6,20.9,21.2,21.5,21.8,22.1,22.4,22.7,23,23.2,23.4,23.6,23.8,24,24.2,24.4,24.6,24.8,25,25.1,25.2,25.3,25.4,25.5,25.6,25.7,25.8,25.9,26,26.1,26.2,26.3,26.4,26.5,26.6,26.7,26.8,26.9,27,27.1,27.2,27.3,27.4,27.5,27.6,27.7,27.8,27.9,28,28.1,28.2,28.3,28.4,28.5,28.6,28.7,28.8,28.9,29,29.1,29.2,29.3,29.4,29.5,29.6,29.7,29.8,29.9,30,29.8,29.6,29.4,29.2,29,28.8,28.6,28.4,28.2,28,27.8,27.6,27.4,27.2,27,26.8,26.6,26.4,26.2,26,25.8,25.6,25.4,25.2,25,24.8,24.6,24.4,24.2,24,23.8,23.6,23.4,23.2,23,22.8,22.6,22.4,22.2,22,21.8,21.6,21.4,21.2,21,20.8,20.6,20.4,20.2,20,19.8,19.6,19.4,19.2,19,18.8,18.6,18.4,18.2,18,17.8,17.6,17.4,17.2,17,16.8,16.6,16.4,16.2,16,15.8,15.6,15.4,15.2,15,14.8,14.6,14.4,14.2,14,13.8,13.6,13.4,13.2,13,12.8,12.6,12.4,12.2,12,11.8,11.6,11.4,11.2,11,10.8,10.6,10.4,10.2,10,10.2,10.4,10.6,10.8,11,11.2,11.4,11.6,11.8,12,12.2,12.4,12.6,12.8,13,13.2,13.4,13.6,13.8,14,14.2,14.4,14.6,14.8,15,15.2,15.4,15.6,15.8,16,16.2,16.4,16.6,16.8,17] index: 0,
}, data: data.temp1List
{ },
name: "湿度(%)", {
index: 1, name: "温度2",
data: [78.5,79.1,79.8,80.3,80.9,81.4,81.9,82.3,82.7,83,83.3,83.5,83.7,83.9,84,84.1,84.2,84.2,84.2,84.1,84,83.9,83.7,83.5,83.2,82.9,82.6,82.2,81.8,81.3,80.8,80.2,79.6,78.9,78.2,77.4,76.5,75.6,74.6,73.5,72.4,71.2,69.9,68.6,67.2,65.7,64.2,62.6,61,59.3,57.6,55.8,54,52.1,50.2,48.3,46.3,44.3,42.3,40.3,38.3,36.3,34.3,32.3,30.4,28.5,26.6,24.8,23,21.3,19.6,18,16.4,15,13.6,12.3,11.1,10,9,8.1,7.3,6.6,6,5.5,5.1,4.8,4.6,4.5,4.5,4.6,4.8,5.1,5.5,6,6.6,7.3,8.1,9,10,11.1,12.3,13.6,15,16.4,18,19.6,21.3,23,24.8,26.6,28.5,30.4,32.3,34.3,36.3,38.3,40.3,42.3,44.3,46.3,48.3,50.2,52.1,54,55.8,57.6,59.3,61,62.6,64.2,65.7,67.2,68.6,69.9,71.2,72.4,73.5,74.6,75.6,76.5,77.4,78.2,78.9,79.6,80.2,80.8,81.3,81.8,82.2,82.6,82.9,83.2,83.5,83.8,84,84.2,84.3,84.4,84.4,84.4,84.3,84.2,84,83.8,83.5,83.2,82.8,82.4,81.9,81.4,80.8,80.2,79.5,78.8,78,77.2,76.3,75.4,74.4,73.3,72.2,71,69.8,68.5,67.2,65.8,64.3,62.8,61.3,59.7,58,56.3,54.6,52.8,51,49.2,47.3,45.4,43.5,41.5,39.5,37.5,35.5,33.5,31.5,29.5,27.5,25.6,23.7,21.9,20.1,18.4,16.8,15.2,13.7,12.3,11,9.8,8.7,7.7,6.8,6,5.3,4.7,4.2,3.8,3.5,3.3,3.2,3.2,3.3,3.5,3.8,4.2,4.7,5.3,6,6.8,7.7,8.7,9.8,11,12.3,13.7,15.2,16.8,18.4,20.1,21.9,23.7,25.6,27.5,29.5,31.5,33.5,35.5,37.5,39.5,41.5,43.5,45.4,47.3,49.2,51,52.8,54.6,56.3,58,59.7,61.3,62.8,64.3,65.8,67.2,68.5,69.8,71,72.2,73.3,74.4,75.4,76.3,77.2,78,78.8,79.5,80.2,80.8] index: 0,
} data: data.temp2List
] },
}; {
name: "温度3",
index: 0,
data: data.temp3List
},
{
name: "温度4",
index: 0,
data: data.temp4List
},
{
name: "湿度1",
index: 1,
data: data.humi1List
},
{
name: "湿度2",
index: 1,
data: data.humi2List
},
{
name: "湿度3",
index: 1,
data: data.humi3List
},
{
name: "湿度4",
index: 1,
data: data.humi4List
}
]
};
}
this.chartData = JSON.parse(JSON.stringify(res)); this.chartData = JSON.parse(JSON.stringify(res));
}, 500); })
}, },
getAgriList() {
listAgri().then(response => {
if (response.code === 200) {
this.agriList = response.rows.map(item => ({
agriId: item.id,
text: item.agriName,
value: item.imei //
}));
if (store.getters && store.getters.name === 'admin') {
this.agriList.push(
{
text:"八方南棚",
value:"A"
},
{
text:"九方春棚",
value:"B"
},
{
text:"十二方棚",
value:"C"
}
)
}
this.imei = this.agriList[0].value;
this.getServerData();
}
})
},
changeAgri(imei) {
console.info("大棚下拉选择",imei)
},
changeDate(date) {
// date[0]-date[1]
console.info("日期选择器:",date)
if (this.imei) {
this.getServerData();
}
}
} }
}; };
</script> </script>

View File

@ -295,7 +295,12 @@ const cfu = {
fontColor: "#666666", fontColor: "#666666",
lineHeight: 11, lineHeight: 11,
hiddenColor: "#CECECE", hiddenColor: "#CECECE",
itemGap: 10 itemGap: 10,
// 关键开启自动换行uCharts 2.x+ 支持)
wrap: true,
// 控制每行显示数量比如每行4个8个系列分两行
itemWidth: 80,
}, },
extra: { extra: {
line: { line: {

View File

@ -44,6 +44,30 @@ export function parseTime(time, pattern) {
return time_str return time_str
} }
// 获取今天的 LocalDateTime 格式yyyy-MM-dd HH:mm:ss
function getTodayLocalDateTime() {
const now = new Date();
// 年
const year = now.getFullYear();
// 月0 开始,+1 后补零
const month = String(now.getMonth() + 1).padStart(2, '0');
// 日:补零
const day = String(now.getDate()).padStart(2, '0');
// 时补零24小时制
const hours = String(now.getHours()).padStart(2, '0');
// 分:补零
const minutes = String(now.getMinutes()).padStart(2, '0');
// 秒:补零
const seconds = String(now.getSeconds()).padStart(2, '0');
// 拼接成 LocalDateTime 格式
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
// 表单重置 // 表单重置
export function resetForm(refName) { export function resetForm(refName) {
if (this.$refs[refName]) { if (this.$refs[refName]) {