feat: connect equipment status to current data
This commit is contained in:
@@ -317,6 +317,8 @@ export default {
|
||||
alarmEventRequesting: false,
|
||||
deviceHistoryTimer: null,
|
||||
deviceHistoryRequesting: false,
|
||||
equipmentStatusTimer: null,
|
||||
equipmentStatusRequesting: false,
|
||||
clockTimer: null,
|
||||
resizeHandler: null,
|
||||
alarmPieChart: null,
|
||||
@@ -632,6 +634,7 @@ export default {
|
||||
this.loadStorageMatrixData()
|
||||
this.loadAlarmEventData()
|
||||
this.loadDeviceHistoryData()
|
||||
this.loadEquipmentStatusData()
|
||||
this.clockTimer = setInterval(this.updateTime, 1000)
|
||||
this.lineMonitorTimer = setInterval(() => {
|
||||
this.loadLineMonitorData()
|
||||
@@ -645,6 +648,9 @@ export default {
|
||||
this.deviceHistoryTimer = setInterval(() => {
|
||||
this.loadDeviceHistoryData()
|
||||
}, 60000)
|
||||
this.equipmentStatusTimer = setInterval(() => {
|
||||
this.loadEquipmentStatusData()
|
||||
}, 5000)
|
||||
this.resizeHandler = () => {
|
||||
this.setScale()
|
||||
if (this.alarmPieChart) {
|
||||
@@ -692,6 +698,10 @@ export default {
|
||||
clearInterval(this.deviceHistoryTimer)
|
||||
this.deviceHistoryTimer = null
|
||||
}
|
||||
if (this.equipmentStatusTimer) {
|
||||
clearInterval(this.equipmentStatusTimer)
|
||||
this.equipmentStatusTimer = null
|
||||
}
|
||||
if (this.alarmPieChart) {
|
||||
this.alarmPieChart.dispose()
|
||||
this.alarmPieChart = null
|
||||
@@ -861,6 +871,74 @@ export default {
|
||||
const text = String(value == null ? '' : value).trim()
|
||||
return text.length > 9 ? `${text.slice(0, 9)}...` : text
|
||||
},
|
||||
loadEquipmentStatusData() {
|
||||
if (this.equipmentStatusRequesting) return
|
||||
this.equipmentStatusRequesting = true
|
||||
const data = this.CreateData('11', 'TV_设备实时状态_查询', [])
|
||||
this.ExecDatabase(data)
|
||||
.then((response) => {
|
||||
const list = response && response.data ? response.data : null
|
||||
if (!Array.isArray(list) || list.length === 0) return
|
||||
if (list.length === 1 && list[0] && (list[0].result === '0' || list[0].result === 0)) return
|
||||
this.applyEquipmentStatusData(list)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('TV_设备实时状态_查询失败', error)
|
||||
})
|
||||
.then(() => {
|
||||
this.equipmentStatusRequesting = false
|
||||
})
|
||||
},
|
||||
applyEquipmentStatusData(list) {
|
||||
const processRows = []
|
||||
const assistRows = []
|
||||
list.forEach((item) => {
|
||||
const category = this.formatDisplayValue(this.pickRecordValue(item, ['Category', 'category'])).toLowerCase()
|
||||
const row = this.createEquipmentStatusRow(item)
|
||||
if (category === 'process') {
|
||||
processRows.push(row)
|
||||
}
|
||||
if (category === 'assist') {
|
||||
assistRows.push(row)
|
||||
}
|
||||
})
|
||||
processRows.sort((a, b) => a.sortNo - b.sortNo)
|
||||
assistRows.sort((a, b) => a.sortNo - b.sortNo)
|
||||
if (processRows.length) {
|
||||
this.equipmentList = processRows
|
||||
}
|
||||
if (assistRows.length) {
|
||||
this.assistList = assistRows
|
||||
}
|
||||
},
|
||||
createEquipmentStatusRow(item) {
|
||||
const tag1Text = this.formatDisplayValue(this.pickRecordValue(item, ['Tag1Text', 'tag1Text']))
|
||||
const tag2Text = this.formatDisplayValue(this.pickRecordValue(item, ['Tag2Text', 'tag2Text']))
|
||||
const tags = [
|
||||
{
|
||||
text: tag1Text,
|
||||
type: this.normalizeStatusPillType(this.pickRecordValue(item, ['Tag1Type', 'tag1Type']))
|
||||
},
|
||||
{
|
||||
text: tag2Text,
|
||||
type: this.normalizeStatusPillType(this.pickRecordValue(item, ['Tag2Type', 'tag2Type']))
|
||||
}
|
||||
].filter(tag => tag.text && tag.text !== '--')
|
||||
return {
|
||||
key: this.formatDisplayValue(this.pickRecordValue(item, ['DeviceKey', 'deviceKey'])),
|
||||
name: this.formatDisplayValue(this.pickRecordValue(item, ['DeviceName', 'deviceName'])),
|
||||
actual: this.formatDisplayValue(this.pickRecordValue(item, ['OutputText', 'outputText'])),
|
||||
status: this.formatDisplayValue(this.pickRecordValue(item, ['StatusText', 'statusText'])),
|
||||
type: this.normalizeStatusPillType(this.pickRecordValue(item, ['StatusType', 'statusType'])),
|
||||
sortNo: Number(this.pickRecordValue(item, ['SortNo', 'sortNo'])) || 999,
|
||||
updateTime: this.formatDisplayValue(this.pickRecordValue(item, ['UpdateTime', 'updateTime'])),
|
||||
tags
|
||||
}
|
||||
},
|
||||
normalizeStatusPillType(value) {
|
||||
const type = String(value || '').trim()
|
||||
return ['ok', 'on', 'warn', 'alarm', 'idle'].includes(type) ? type : 'idle'
|
||||
},
|
||||
loadDeviceHistoryData() {
|
||||
if (this.deviceHistoryRequesting) return
|
||||
this.deviceHistoryRequesting = true
|
||||
|
||||
Reference in New Issue
Block a user