|
|
|
@ -2,32 +2,8 @@ import {interfaceRequest} from "@/components/networkRequest/requestSend";
|
|
|
|
|
import {getHistoryData} from "@/api/configuration/equipment";
|
|
|
|
|
import Vue from 'vue'
|
|
|
|
|
|
|
|
|
|
const mappingFunction = async (data, method) => {
|
|
|
|
|
if (data.type === 1) {
|
|
|
|
|
let res2 = await interfaceRequest(data)
|
|
|
|
|
let returnRes = {}
|
|
|
|
|
method?.mappingArr?.forEach(v => {
|
|
|
|
|
let res = res2.data
|
|
|
|
|
for (let i of (v?.region || [])) {
|
|
|
|
|
if (res[i]) {
|
|
|
|
|
res = res[i]
|
|
|
|
|
} else {
|
|
|
|
|
res = null
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (v?.isArray && v?.mapData && Array.isArray(res)) {
|
|
|
|
|
res = res.map(e => e[v.mapData])
|
|
|
|
|
}
|
|
|
|
|
returnRes = {
|
|
|
|
|
...returnRes,
|
|
|
|
|
[v?.name]: res
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return returnRes
|
|
|
|
|
}
|
|
|
|
|
const getDeviceData = async (data) => {
|
|
|
|
|
|
|
|
|
|
if (data.type === 2) {
|
|
|
|
|
let getTime = (e) => {
|
|
|
|
|
if (e === '1') {
|
|
|
|
|
return [(new Date().getTime() - (1000 * 60 * 60 * 24)), (new Date().getTime())]
|
|
|
|
@ -59,38 +35,38 @@ const mappingFunction = async (data, method) => {
|
|
|
|
|
let arr = Array(scope).fill(1).map((v, k) => {
|
|
|
|
|
return parseTime(endTime - (1000 * 60 * 60) * k, '{y}-{m}-{d} {h}:{i}')
|
|
|
|
|
})
|
|
|
|
|
return arr
|
|
|
|
|
return arr.reverse()
|
|
|
|
|
}
|
|
|
|
|
if (e === '2') {
|
|
|
|
|
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60)) || 0
|
|
|
|
|
let arr = Array(scope).fill(1).map((v, k) => {
|
|
|
|
|
return parseTime(endTime - (1000 * 60 * 60) * k, '{y}-{m}-{d} {h}')
|
|
|
|
|
})
|
|
|
|
|
return arr
|
|
|
|
|
return arr.reverse()
|
|
|
|
|
}
|
|
|
|
|
if (e === '3') {
|
|
|
|
|
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24)) || 0
|
|
|
|
|
let arr = Array(scope).fill(1).map((v, k) => {
|
|
|
|
|
return parseTime(endTime - (1000 * 60 * 60 * 24) * k, '{y}-{m}-{d}')
|
|
|
|
|
})
|
|
|
|
|
return arr
|
|
|
|
|
return arr.reverse()
|
|
|
|
|
}
|
|
|
|
|
if (e === '4') {
|
|
|
|
|
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24)) || 0
|
|
|
|
|
let arr = Array(scope).fill(1).map((v, k) => {
|
|
|
|
|
return parseTime(endTime - (1000 * 60 * 60 * 24) * k, '{y}-{m}-{d}')
|
|
|
|
|
})
|
|
|
|
|
return arr
|
|
|
|
|
return arr.reverse()
|
|
|
|
|
}
|
|
|
|
|
if (e === '5') {
|
|
|
|
|
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24 * 30)) || 0
|
|
|
|
|
let arr = Array(scope).fill(1).map((v, k) => {
|
|
|
|
|
return parseTime(endTime - (1000 * 60 * 60 * 24 * 30) * k, '{y}-{m}')
|
|
|
|
|
})
|
|
|
|
|
return arr
|
|
|
|
|
return arr.reverse()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let res2 = await getHistoryData({
|
|
|
|
|
const res2 = await getHistoryData({
|
|
|
|
|
deviceModeId: data.deviceModeId,
|
|
|
|
|
functionIdentifier: data.functionIdentifier,
|
|
|
|
|
interval: data.interval,
|
|
|
|
@ -100,7 +76,6 @@ const mappingFunction = async (data, method) => {
|
|
|
|
|
endTime: data.isRealTime ? getTime(data.interval)?.[1] : data.endTime,
|
|
|
|
|
intervalType: 1 || data.intervalType,
|
|
|
|
|
})
|
|
|
|
|
console.log('datadata', data)
|
|
|
|
|
if (data.isRealTime) {
|
|
|
|
|
if (data.interval === '1') {
|
|
|
|
|
let arr = getTimeList(data.interval, data.isRealTime)
|
|
|
|
@ -163,7 +138,15 @@ const mappingFunction = async (data, method) => {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(res2)
|
|
|
|
|
debugger
|
|
|
|
|
console.log('res2222222', res2)
|
|
|
|
|
debugger
|
|
|
|
|
return res2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mappingFunction = async (data, method) => {
|
|
|
|
|
if (data.type === 1) {
|
|
|
|
|
let res2 = await interfaceRequest(data)
|
|
|
|
|
let returnRes = {}
|
|
|
|
|
method?.mappingArr?.forEach(v => {
|
|
|
|
|
let res = res2.data
|
|
|
|
@ -176,7 +159,6 @@ const mappingFunction = async (data, method) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (v?.isArray && v?.mapData && Array.isArray(res)) {
|
|
|
|
|
console.log(res)
|
|
|
|
|
res = res.map(e => e[v.mapData])
|
|
|
|
|
}
|
|
|
|
|
returnRes = {
|
|
|
|
@ -186,6 +168,34 @@ const mappingFunction = async (data, method) => {
|
|
|
|
|
})
|
|
|
|
|
return returnRes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.type === 2) {
|
|
|
|
|
let res2 = await getDeviceData(data)
|
|
|
|
|
console.log('res2666', res2)
|
|
|
|
|
let returnRes = {}
|
|
|
|
|
method?.mappingArr?.forEach(v => {
|
|
|
|
|
let res = res2.data
|
|
|
|
|
console.log(res)
|
|
|
|
|
for (let i of (v?.region || [])) {
|
|
|
|
|
if (res[i]) {
|
|
|
|
|
res = res[i]
|
|
|
|
|
} else {
|
|
|
|
|
res = null
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (v?.isArray && v?.mapData && Array.isArray(res)) {
|
|
|
|
|
console.log('res10101010101',res)
|
|
|
|
|
res = res.map(e => e[v.mapData]||null)
|
|
|
|
|
}
|
|
|
|
|
console.log('res10101010101--1',res)
|
|
|
|
|
returnRes = {
|
|
|
|
|
...returnRes,
|
|
|
|
|
[v?.name]: res
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return returnRes
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -288,8 +298,9 @@ const clearObjNull = (e, data1) => {
|
|
|
|
|
return Object.keys(obj).length === 0 ? null : obj
|
|
|
|
|
}
|
|
|
|
|
const clearArrNull = (e, data1) => {
|
|
|
|
|
return e
|
|
|
|
|
if (!Array.isArray(e)) {
|
|
|
|
|
return null
|
|
|
|
|
return e
|
|
|
|
|
}
|
|
|
|
|
let arr = []
|
|
|
|
|
e.forEach(v => {
|
|
|
|
@ -401,5 +412,6 @@ export {
|
|
|
|
|
detectingNullValues,
|
|
|
|
|
getFinalData,
|
|
|
|
|
parseTime,
|
|
|
|
|
testColor
|
|
|
|
|
testColor,
|
|
|
|
|
getDeviceData
|
|
|
|
|
}
|
|
|
|
|