feat: connect line monitor to database
This commit is contained in:
@@ -309,6 +309,8 @@ export default {
|
|||||||
cameraSyncTimer: null,
|
cameraSyncTimer: null,
|
||||||
iframeReadyTimer: null,
|
iframeReadyTimer: null,
|
||||||
dmtIframeReady: false,
|
dmtIframeReady: false,
|
||||||
|
lineMonitorTimer: null,
|
||||||
|
lineMonitorRequesting: false,
|
||||||
clockTimer: null,
|
clockTimer: null,
|
||||||
resizeHandler: null,
|
resizeHandler: null,
|
||||||
alarmPieChart: null,
|
alarmPieChart: null,
|
||||||
@@ -349,6 +351,7 @@ export default {
|
|||||||
},
|
},
|
||||||
lineMonitorRows: [
|
lineMonitorRows: [
|
||||||
{
|
{
|
||||||
|
unitKey: 'longRail',
|
||||||
name: '加工中心单元',
|
name: '加工中心单元',
|
||||||
status: '执行中',
|
status: '执行中',
|
||||||
type: 'on',
|
type: 'on',
|
||||||
@@ -374,6 +377,7 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
unitKey: 'shortRail',
|
||||||
name: '车床加工单元',
|
name: '车床加工单元',
|
||||||
status: '准备就绪',
|
status: '准备就绪',
|
||||||
type: 'ok',
|
type: 'ok',
|
||||||
@@ -399,6 +403,7 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
unitKey: 'joint',
|
||||||
name: '插齿机单元',
|
name: '插齿机单元',
|
||||||
status: '异常中断',
|
status: '异常中断',
|
||||||
type: 'alarm',
|
type: 'alarm',
|
||||||
@@ -424,6 +429,7 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
unitKey: 'grinder',
|
||||||
name: '磨床加工单元',
|
name: '磨床加工单元',
|
||||||
status: '预制待命',
|
status: '预制待命',
|
||||||
type: 'ok',
|
type: 'ok',
|
||||||
@@ -608,7 +614,11 @@ export default {
|
|||||||
this.updateTime()
|
this.updateTime()
|
||||||
this.setScale()
|
this.setScale()
|
||||||
this.$nextTick(this.initAlarmPieChart)
|
this.$nextTick(this.initAlarmPieChart)
|
||||||
|
this.loadLineMonitorData()
|
||||||
this.clockTimer = setInterval(this.updateTime, 1000)
|
this.clockTimer = setInterval(this.updateTime, 1000)
|
||||||
|
this.lineMonitorTimer = setInterval(() => {
|
||||||
|
this.loadLineMonitorData()
|
||||||
|
}, 5000)
|
||||||
this.resizeHandler = () => {
|
this.resizeHandler = () => {
|
||||||
this.setScale()
|
this.setScale()
|
||||||
if (this.alarmPieChart) {
|
if (this.alarmPieChart) {
|
||||||
@@ -640,6 +650,10 @@ export default {
|
|||||||
clearTimeout(this.iframeReadyTimer)
|
clearTimeout(this.iframeReadyTimer)
|
||||||
this.iframeReadyTimer = null
|
this.iframeReadyTimer = null
|
||||||
}
|
}
|
||||||
|
if (this.lineMonitorTimer) {
|
||||||
|
clearInterval(this.lineMonitorTimer)
|
||||||
|
this.lineMonitorTimer = null
|
||||||
|
}
|
||||||
if (this.alarmPieChart) {
|
if (this.alarmPieChart) {
|
||||||
this.alarmPieChart.dispose()
|
this.alarmPieChart.dispose()
|
||||||
this.alarmPieChart = null
|
this.alarmPieChart = null
|
||||||
@@ -655,6 +669,116 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
loadLineMonitorData() {
|
||||||
|
if (this.lineMonitorRequesting) return
|
||||||
|
this.lineMonitorRequesting = 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.applyLineMonitorData(list)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('TV_线体任务联动状态_查询失败', error)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.lineMonitorRequesting = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
applyLineMonitorData(list) {
|
||||||
|
const rowMap = {}
|
||||||
|
list.forEach((item) => {
|
||||||
|
const row = this.createLineMonitorRow(item)
|
||||||
|
if (row.unitKey) {
|
||||||
|
rowMap[row.unitKey] = row
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.lineMonitorRows = this.lineMonitorRows.map((row) => {
|
||||||
|
if (row.unitKey && rowMap[row.unitKey]) {
|
||||||
|
return Object.assign({}, row, rowMap[row.unitKey])
|
||||||
|
}
|
||||||
|
return row
|
||||||
|
})
|
||||||
|
},
|
||||||
|
createLineMonitorRow(item) {
|
||||||
|
const getValue = (...keys) => {
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const value = item[keys[i]]
|
||||||
|
if (value !== undefined && value !== null) {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
const unitKey = this.normalizeUnitKey(getValue('UnitKey', 'unitKey'))
|
||||||
|
const statusType = this.normalizeStatusType(getValue('StatusType', 'statusType'))
|
||||||
|
const taskNo = this.formatTaskNo(getValue('TaskNo', 'taskNo'))
|
||||||
|
const startPos = this.formatDisplayValue(getValue('StartPos', 'startPos'))
|
||||||
|
const endPos = this.formatDisplayValue(getValue('EndPos', 'endPos'))
|
||||||
|
const recipeCode = this.formatDisplayValue(getValue('RecipeCode', 'recipeCode'))
|
||||||
|
const palletType = this.formatDisplayValue(getValue('PalletType', 'palletType'))
|
||||||
|
return {
|
||||||
|
unitKey,
|
||||||
|
name: this.formatDisplayValue(getValue('UnitName', 'unitName')),
|
||||||
|
status: this.formatDisplayValue(getValue('StatusText', 'statusText')),
|
||||||
|
type: statusType,
|
||||||
|
taskNo,
|
||||||
|
startPos,
|
||||||
|
endPos,
|
||||||
|
taskInfo: [
|
||||||
|
{ label: '配方号', value: recipeCode },
|
||||||
|
{ label: '托盘', value: palletType }
|
||||||
|
],
|
||||||
|
lineSignals: [
|
||||||
|
{ label: 'PCS运行', state: this.getSignalState(getValue('PCSRun', 'pcsRun')) },
|
||||||
|
{ label: '允许接收', state: this.getSignalState(getValue('AllowTask', 'allowTask')) },
|
||||||
|
{ label: '自动模式', state: this.getSignalState(getValue('AutoMode', 'autoMode')) },
|
||||||
|
{ label: '急停', state: this.getSignalState(getValue('EmergencyStop', 'emergencyStop'), true) }
|
||||||
|
],
|
||||||
|
handshakes: [
|
||||||
|
{ label: '启动', state: this.getSignalState(getValue('StartFlag', 'startFlag')) },
|
||||||
|
{ label: '准备好', state: this.getSignalState(getValue('ReadyFlag', 'readyFlag')) },
|
||||||
|
{ label: '忙碌', state: this.getSignalState(getValue('BusyFlag', 'busyFlag')) },
|
||||||
|
{ label: '错误', state: this.getSignalState(getValue('ErrorFlag', 'errorFlag'), true) },
|
||||||
|
{ label: '完成', state: this.getSignalState(getValue('CompleteFlag', 'completeFlag')) }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
normalizeUnitKey(value) {
|
||||||
|
const key = String(value || '').trim()
|
||||||
|
if (key) return key
|
||||||
|
return ''
|
||||||
|
},
|
||||||
|
normalizeStatusType(value) {
|
||||||
|
const type = String(value || '').trim()
|
||||||
|
return ['on', 'ok', 'alarm'].includes(type) ? type : 'ok'
|
||||||
|
},
|
||||||
|
formatDisplayValue(value) {
|
||||||
|
const text = String(value == null ? '' : value).trim()
|
||||||
|
if (!text || text.toUpperCase() === 'NULL') {
|
||||||
|
return '--'
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
},
|
||||||
|
formatTaskNo(value) {
|
||||||
|
const text = this.formatDisplayValue(value)
|
||||||
|
if (text === '--' || text === '0') {
|
||||||
|
return '无任务'
|
||||||
|
}
|
||||||
|
return text.indexOf('TASK') === 0 ? text : `TASK ${text}`
|
||||||
|
},
|
||||||
|
isSignalOn(value) {
|
||||||
|
const text = String(value == null ? '' : value).trim().toUpperCase()
|
||||||
|
return ['1', 'TRUE', 'ON', 'YES', '是'].includes(text)
|
||||||
|
},
|
||||||
|
getSignalState(value, alarmWhenOn = false) {
|
||||||
|
if (!this.isSignalOn(value)) {
|
||||||
|
return 'off'
|
||||||
|
}
|
||||||
|
return alarmWhenOn ? 'alarm' : 'on'
|
||||||
|
},
|
||||||
getHistorySegmentStyle(segment) {
|
getHistorySegmentStyle(segment) {
|
||||||
const start = Math.max(0, Math.min(24, segment.start))
|
const start = Math.max(0, Math.min(24, segment.start))
|
||||||
const end = Math.max(start, Math.min(24, segment.end))
|
const end = Math.max(start, Math.min(24, segment.end))
|
||||||
|
|||||||
Reference in New Issue
Block a user