|
|
@@ -120,7 +120,17 @@ export const useDeviceStatusStore = defineStore('deviceStatusStore', () => {
|
|
|
tags: Object.keys(tagSets).filter((key) => tagSets[key].has(code)),
|
|
|
})
|
|
|
}
|
|
|
- const offline = devices.filter((device) => String((device && device.status) || '').toUpperCase() === 'OFFLINE').length
|
|
|
+ // 在线/离线按台账状态**显式入桶**,不用「总数-离线」倒推:那样任何没有状态
|
|
|
+ // (UNKNOWN/空)的设备都会被算成在线,把「不知道」冒充成「在线」。
|
|
|
+ let online = 0
|
|
|
+ let offline = 0
|
|
|
+ let unknownState = 0
|
|
|
+ for (const device of devices) {
|
|
|
+ const state = String((device && device.status) || '').toUpperCase()
|
|
|
+ if (state === 'ONLINE') online += 1
|
|
|
+ else if (state === 'OFFLINE') offline += 1
|
|
|
+ else unknownState += 1
|
|
|
+ }
|
|
|
return {
|
|
|
available: true,
|
|
|
total: devices.length,
|
|
|
@@ -130,8 +140,10 @@ export const useDeviceStatusStore = defineStore('deviceStatusStore', () => {
|
|
|
ALARM: tagSets.ALARM.size,
|
|
|
WARNING: tagSets.WARNING.size,
|
|
|
WORK_ORDER: tagSets.WORK_ORDER.size,
|
|
|
- NORMAL: devices.length - offline,
|
|
|
+ NORMAL: online,
|
|
|
OFFLINE: offline,
|
|
|
+ // 台账没给状态(或给了认不出的值)的台数:不并入在线,也不并入离线。
|
|
|
+ UNKNOWN_STATE: unknownState,
|
|
|
UNASSOCIATED: tagSets.UNASSOCIATED.size,
|
|
|
},
|
|
|
}
|