This commit is contained in:
高云鹏 2024-12-02 11:09:17 +08:00
commit 4919824e14
3 changed files with 51 additions and 35 deletions

View File

@ -12,6 +12,7 @@ export const historyReq = (data: any) => {
url: '/api/data/history', url: '/api/data/history',
method: 'post', method: 'post',
data: data, data: data,
timeout: 60 * 1000,
}) })
} }

View File

@ -442,50 +442,54 @@ const queryHistoryData = () => {
startTime: new Date(timeRange.value[0]).getTime(), startTime: new Date(timeRange.value[0]).getTime(),
endTime: new Date(timeRange.value[1]).getTime(), endTime: new Date(timeRange.value[1]).getTime(),
} as any } as any
historyReq(requestData).then((res) => { historyReq(requestData)
if (res.code == 200) { .then((res) => {
const result = res.data if (res.code == 200) {
if (Object.keys(result)?.length) { const result = res.data
const realResult = result[windBlowerValue.value] if (Object.keys(result)?.length) {
let tableData = [] as any const realResult = result[windBlowerValue.value]
attributeCodes.forEach((item: any) => { let tableData = [] as any
if (Object.keys(realResult).includes(item)) { attributeCodes.forEach((item: any) => {
tableData.push({ if (Object.keys(realResult).includes(item)) {
name: item, tableData.push({
times: realResult[item].times, name: item,
value: realResult[item].values.map((val: any) => (val === 0 ? 0 : val.toFixed(2))), times: realResult[item].times,
value: realResult[item].values.map((val: any) => (val === 0 ? 0 : val?.toFixed(2))),
})
}
})
const processedData = new Map()
idCounter.value = 0
if (tableData.length) {
tableData.forEach(({ name, times, value }: any) => {
times.forEach((time: number, index: number) => {
if (!processedData.has(time)) {
processedData.set(time, { id: idCounter.value++, time: timestampToTime(time) })
}
const values = value[index]
processedData.get(time)[name] = enumStore.keys.includes(name) ? enumStore.data?.[name]?.[values] : values
})
}) })
} }
}) reportTableData.value = Array.from(processedData.values())
const processedData = new Map() if (!reportTableData.value.length) {
idCounter.value = 0 ElMessage.warning('查询数据为空!')
if (tableData.length) { reportTableData.value = []
tableData.forEach(({ name, times, value }: any) => { }
times.forEach((time: number, index: number) => { reportLoading.value = false
if (!processedData.has(time)) { } else {
processedData.set(time, { id: idCounter.value++, time: timestampToTime(time) })
}
const values = value[index]
processedData.get(time)[name] = enumStore.keys.includes(name) ? enumStore.data?.[name]?.[values] : values
})
})
}
reportTableData.value = Array.from(processedData.values())
if (!reportTableData.value.length) {
ElMessage.warning('查询数据为空!') ElMessage.warning('查询数据为空!')
reportTableData.value = [] reportTableData.value = []
reportLoading.value = false
} }
reportLoading.value = false
} else { } else {
ElMessage.warning('查询数据为空!')
reportTableData.value = []
reportLoading.value = false reportLoading.value = false
ElMessage.warning('查询失败')
} }
} else { })
.finally(() => {
reportLoading.value = false reportLoading.value = false
ElMessage.warning('查询失败') })
}
})
} }
// //

View File

@ -135,6 +135,9 @@ const switchTime = (index: number) => {
} }
times.splice(index, 1) times.splice(index, 1)
customName.splice(index, 1) customName.splice(index, 1)
customName.forEach((item: any, index: number, arr: any) => {
arr[index] = statAnalysisSelect.attributes + String(index + 1)
})
} }
const timechange = (value: any) => { const timechange = (value: any) => {
if (times.length) { if (times.length) {
@ -148,11 +151,18 @@ const timechange = (value: any) => {
return return
} else { } else {
times.push(value) times.push(value)
customName.push(statAnalysisSelect.attributes + times.length) customName.push(statAnalysisSelect.attributes + times.length)
customName.forEach((item: any, index: number, arr: any) => {
arr[index] = statAnalysisSelect.attributes + String(index + 1)
})
} }
} else { } else {
times.push(value) times.push(value)
customName.push(statAnalysisSelect.attributes + times.length) customName.push(statAnalysisSelect.attributes + times.length)
customName.forEach((item: any, index: number, arr: any) => {
arr[index] = statAnalysisSelect.attributes + String(index + 1)
})
} }
} }
@ -160,6 +170,7 @@ const showTime = ref(false)
const clearList = () => { const clearList = () => {
times.length = 0 times.length = 0
time.value = [] time.value = []
customName.length = 0
} }
const iotModelId = ref('') const iotModelId = ref('')