jsy-app/utils/deviceUtil/js/baseStation.js

106 lines
2.8 KiB
JavaScript
Raw Normal View History

2024-09-26 18:52:14 +08:00
import { getYMDHMS } from "@/utils/deviceUtil/js/common.js"
// 服务商
function facilitator(variate) {
if (variate) {
if (variate.value === "1") {
return "移动"
} else if (variate.value === "2") {
return "电信"
} else if (variate.value === "3") {
return "联通"
}
} else {
return "未知"
}
}
// 鼠标划过要显示的文字
function handleHoverShowText(object, code) {
if (object && object.items) {
let { cs, ns, ls } = object.items
let { b, bb, cc, g, l, mcu, ps, t } = object.items.adcProperty
return [
// ["基站编码:", code],
["充电状态:", cs.value],
["433环境噪声", ls.value],
["4G信号强度(%)", ns.value],
["电池ADC(V)", b],
["电池ADC(%)", Number(bb) > 100 ? 100 : bb],
["433ADC(V)", l],
["MCUADC(V) ", mcu],
["4G供电ADC(V)", g],
["MCU温度ADC(℃)", t],
["充电电流ADC(mA)", cc],
["充电电压ADC(V)", ps],
["数据上报时间:", getYMDHMS(object.time)]
]
} else {
return false
}
}
// 处理单条数据
export function alone(obj, state) {
let { status, deviceName, iotId, privateSeal, deviceTypeId, rolaFrequency } = obj
let { ns, to, cs, adcProperty } = obj.items
return {
online: status !== "" ? status === "online" : state,
signalValue: ns ? Number(ns.value) : 0,
facilitator: facilitator(to),
deviceCode: deviceName,
chargedState: cs ? cs.value === "1" : false,
currentBatteryCapacity: adcProperty ? (parseInt(adcProperty.bb) > 100 ? 100 : parseInt(adcProperty.bb)) : 0,
iotId: iotId,
privateSeal,
deviceTypeId,
rolaFrequency,
text: handleHoverShowText(obj, deviceName)
}
}
export function presentStationData(arr) {
let newArray = []
for (let i = 0; i < arr.length; i++) {
let { status, deviceCode, privateSeal, deviceTypeId, rolaFrequency,deviceVer,softVer,id } = arr[i]
if (arr[i].data && arr[i].data.items) {
let { ns, to, cs, adcProperty } = arr[i].data.items
newArray.push({
online: status === "online",
signalValue: ns ? Number(ns.value) : 0,
facilitator: facilitator(to),
deviceCode: deviceCode,
chargedState: cs ? cs.value === "1" : false,
currentBatteryCapacity: adcProperty ? (parseInt(adcProperty.bb) > 100 ? 100 : parseInt(adcProperty.bb)) : 0,
iotId: arr[i].iotId,
privateSeal,
deviceTypeId,
rolaFrequency,
deviceVer,
softVer,
id,
text: handleHoverShowText(arr[i].data, deviceCode)
})
} else {
newArray.push({
online: status === "online",
signalValue: 0,
facilitator: "未知",
deviceCode: deviceCode,
chargedState: false,
currentBatteryCapacity: 0,
iotId: arr[i].iotId,
privateSeal,
deviceTypeId,
rolaFrequency,
deviceVer,
softVer,
id,
text: handleHoverShowText(arr[i].data, deviceCode)
})
}
}
return newArray
}