From 9124d4b745900ca4902baaf858f462a7bb830c24 Mon Sep 17 00:00:00 2001 From: fengrong Date: Tue, 29 Oct 2024 16:48:27 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/backend/realData/index.vue | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/ui/dasadmin/src/views/backend/realData/index.vue b/ui/dasadmin/src/views/backend/realData/index.vue index a6692899..826c189c 100644 --- a/ui/dasadmin/src/views/backend/realData/index.vue +++ b/ui/dasadmin/src/views/backend/realData/index.vue @@ -123,7 +123,8 @@ const tableItem0: any = [ prop: 'code', align: 'center', custom: 'default', - name:'' + name:'', + title: '风机列表' }] const tableItem1: any = [ { @@ -331,17 +332,24 @@ const selectList=ref([]) const getSel = () => { debugger selectList.value=[] - tableColumn.value.forEach(item => { - if (item.prop) { - if(item.prop!='code'){ - selectList.value.push({ - attributeName: item.title, - attributeCode: item.name, - }); - } + try { + if (tableColumn.value && Array.isArray(tableColumn.value)) { + for (const item of tableColumn.value) { + if (item && item.prop && item.prop !== 'code') { + if(item.title!==undefined){ + selectList.value.push({ + attributeName: item.title || '', + attributeCode: item.name || '', + unit: item.unit || '', + }); + } + } + } } - }); + } catch (error) { + console.error('Error in tableColumn processing:', error); + } //tableRef.value.clearSelection() if (selectList.value.length > 0) { //setTimeout(()=>{ @@ -601,14 +609,11 @@ const downFun=(tableColumn,tableData)=>{ onUnmounted(() => { autoUpdateInterval.value && clearInterval(autoUpdateInterval.value) autoUpdateInterval.value = null - //selectList.value=[] }) onMounted(() => { deviceQuery(devicelistData) - //queryListData.pageSize=200 modelAttributeList(queryListData) - //tableRef.value.toggleRowSelection(modalTbleData.value[0], true); }) From 08e62beb264c19109c55ce51bd7ca3f113cd1670 Mon Sep 17 00:00:00 2001 From: geting <13585118195@163.com> Date: Tue, 29 Oct 2024 16:50:24 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/backend/statAnalysis/index.vue | 173 ++++++++---------- 1 file changed, 81 insertions(+), 92 deletions(-) diff --git a/ui/dasadmin/src/views/backend/statAnalysis/index.vue b/ui/dasadmin/src/views/backend/statAnalysis/index.vue index ed17c73a..f14209fa 100644 --- a/ui/dasadmin/src/views/backend/statAnalysis/index.vue +++ b/ui/dasadmin/src/views/backend/statAnalysis/index.vue @@ -48,7 +48,7 @@
- {{ customName }} + {{ index + 1 }} {{ t('statAnalysis.time') }}
-
+
{{ t('statAnalysis.max') }} - 11 + {{ calculate[index]['max'] }}
-
+
{{ t('statAnalysis.min') }} - 22 + {{ calculate[index]['min'] }}
-
+
{{ t('statAnalysis.average') }} - 33 + {{ calculate[index]['average'] }}
@@ -132,26 +132,25 @@ const statAnalysisSelect = reactive({ }) const times = reactive([{ time: '' }]) const addTime = (index) => { - console.log(index) - console.log(times) times.push({ time: '' }) + customName.value.push(index + 2) } const switchTime = (index) => { times.splice(index, 1) + customName.value.splice(index, 1) + calculate.splice(index, 1) } const timechange = (value) => { const count = getTimeIntervals(times[0][0], times[0][1]) const count1 = getTimeIntervals(times[value][0], times[value][1]) if (count !== count1) { times[value] = { time: '' } - value = ElMessage.warning('查询时间点错误,请重新舒服') + value = ElMessage.warning('查询时间点错误,请重新输入') } - console.log('🚀 ~ timechange ~ count:', count) } const isExpand = ref(false) const handleClick = () => { isExpand.value = !isExpand.value - console.log(isExpand) } const iotModelId = ref('') @@ -160,12 +159,9 @@ watch( (newVal) => { if (newVal) { const row = statAnalysisSelectOptions.deviceId.filter((item) => { - console.log(item.value == newVal) return item.value == newVal }) - console.log() iotModelId.value = row[0].iotModelId - console.log('🚀 ~ iotModelId:', iotModelId) } }, { @@ -185,42 +181,30 @@ const handleRadioChange = (value) => { } const selectstatAnalysisAttributes = () => { statAnalysisSelect.attributes = selectedAttrRow.attributeName - console.log('🚀 ~ selectstatAnalysisAttributes ~ selectedAttrRow:', selectedAttrRow) statAnalysisSelect.attributeCode = selectedAttrRow.attributeCode showMeasure.value = false } const chartContainer = ref(null) -const option = { - // dataZoom: [ - // { - // type: 'inside', - // start: 0, - // end: 100, - // }, - // { - // start: 0, - // }, - // ], - tooltip: { - trigger: 'axis', - // axisPointer: { - // type: 'cross', - // label: { - // backgroundColor: '#6a7985', - // }, - // }, - }, +const option = reactive({ + dataZoom: [ + { + type: 'inside', + start: 0, + end: 100, + }, + { + start: 0, + }, + ], + tooltip: {}, legend: { - right: 10, - top: 0, - icon: 'rect', + icon: 'circle', itemGap: 20, itemWidth: 8, itemHeight: 8, data: [], - selected: {}, }, xAxis: { type: 'category', @@ -234,7 +218,7 @@ const option = { left: '3%', right: '3%', }, -} +}) const statAnalysisSelectOptions = reactive({ interval: [ @@ -246,7 +230,7 @@ const statAnalysisSelectOptions = reactive({ ], deviceId: [], }) -const customName = ref('第一条数据') +const customName = ref(['1']) const chart = ref(null) onMounted(() => { if (chartContainer.value) { @@ -270,7 +254,7 @@ const queryWindTurbines = () => { } window.onresize = () => { - chart.resize() + // chart.resize() } const handleSelect = () => {} @@ -333,7 +317,7 @@ const getTimeIntervals = (startTimestamp, endTimestamp) => { count = Math.floor((endDate - startDate) / (1 * 60 * 60 * 1000)) break case '1d': - count = Math.floor((endDate - startDate) / (1 * 24 * 60 * 60 * 1000)) + count = c((endDate - startDate) / (1 * 24 * 60 * 60 * 1000)) break // default: // throw new Error('Invalid interval') @@ -342,9 +326,11 @@ const getTimeIntervals = (startTimestamp, endTimestamp) => { return count } const statAnalysisOperate = () => { - console.log(statAnalysisSelect) - console.log(times) - times.forEach((time) => { + option.tooltip = {} + option.xAxis.data = [] + option.legend.data = [] + option.series = [] + times.forEach((time, index) => { if (time[0] && time[1]) { const requestData = { devices: [ @@ -357,60 +343,63 @@ const statAnalysisOperate = () => { startTime: new Date(time[0]).getTime(), endTime: new Date(time[1]).getTime(), } - historyDataReq(requestData) - console.log(requestData) + historyDataReq(requestData, index) } }) } -const historyDataReq = (data) => { - // historyReq(data).then((res) => { - // console.log(res) - const res = { - //设备ID - '129476828342323': { - //属性名 - power: { - //时间戳列表 - times: [123452435924242, 123452435924342, 123452435924442, 123452435924542], - //值列表 - values: [123.23, 35.21, 34.56, 67], - }, - }, - } - const deviceId = statAnalysisSelect.deviceId - const attributeCode = statAnalysisSelect.attributeCode - const resData = res['129476828342323']['power'] +const calculate = reactive([{ max: '', min: '', average: '' }]) +const historyDataReq = (data, index) => { + historyReq(data).then((res) => { + if (res.code == 200) { + const deviceId = statAnalysisSelect.deviceId + const attributeCode = statAnalysisSelect.attributeCode + const resData = res.data[deviceId][attributeCode] + if (resData) { + const xData = resData['times'] + const yData = resData['values'] - const xData = resData['times'] - const yData = resData['values'] - option.tooltip = { - trigger: 'axis', - show: true, - formatter: function (params) { - console.log('🚀 ~ //historyReq ~ params:', params) - return params - .map((item) => { - return `${item.seriesName} (${xData[item.dataIndex]}): ${item.data}` - }) - .join('
') - }, - } - option.xAxis.data = Array.from({ length: xData.length }, (_, index) => index) + calculate[index] = { + max: Math.max(...yData), + min: Math.min(...yData), + average: Math.floor(yData.reduce((a, b) => a + b, 0) / yData.length), + } - option.series = [ - { - name: '', - type: 'line', - data: yData, - }, - ] - console.log('🚀 ~ //historyReq ~ option:', option) - chart.value.setOption(option) - // }) + option.tooltip = { + show: true, + formatter: function (params) { + const x = timestampToTime(xData[params.dataIndex]) + return `${params.marker} ${params.seriesName} ${x} : ${params.data}` + }, + } + option.xAxis.data = Array.from({ length: xData.length }, (_, index) => index) + const seriesData = { + name: index + 1, + type: 'line', + data: yData, + } + option.legend.data.push(index + 1) + option.series.push(seriesData) + chart.value.setOption(option) + } + } else { + ElMessage.warning('查询失败') + } + }) } const statAnalysisExport = () => {} const statAnalysiImport = () => {} + +const timestampToTime = (timestamp) => { + timestamp = timestamp ? timestamp : null + let date = new Date(timestamp) + let Y = date.getFullYear() + '-' + let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' + let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ' + let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':' + let m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() + return Y + M + D + h + m +} diff --git a/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue b/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue new file mode 100644 index 00000000..bfbe6f56 --- /dev/null +++ b/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue @@ -0,0 +1,493 @@ + + + From a0d6a3cb769db804b3f06768f0f0912434993438 Mon Sep 17 00:00:00 2001 From: houwei Date: Wed, 30 Oct 2024 13:04:20 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=A3=8E=E6=9C=BA?= =?UTF-8?q?=E6=89=80=E5=B1=9E=E7=BA=BF=E8=B7=AF=EF=BC=8C=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- das/src/main/resources/mapper/SysEquipmentMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/das/src/main/resources/mapper/SysEquipmentMapper.xml b/das/src/main/resources/mapper/SysEquipmentMapper.xml index 9f018a07..364fa5ca 100644 --- a/das/src/main/resources/mapper/SysEquipmentMapper.xml +++ b/das/src/main/resources/mapper/SysEquipmentMapper.xml @@ -135,7 +135,7 @@ select * from sys_equipment where code = #{code}