fcc-core
Version:
Fusion communication center.
48 lines (44 loc) • 1.25 kB
JavaScript
// import { XWPrivate } from '../../core/XW'
export default async function (xw, params) {
await xw.validate(params, { // 入参校验
resId: { type: 'string', required: true },
controlCode: { type: 'string', required: true },
controlValue: { type: 'string', required: true }
})
const resId = await getDeviceCode(params.resId, xw)
return new Promise((resolve, reject) => {
xw.exe.emit('PtzControl', {
// 调用exe监控接口
winId: '0000',
resId,
controlCode: params.controlCode,
controlValue: params.controlValue
})
const timer = setTimeout(() => {
reject(new xw.BaseException(562))
}, xw.timeout)
xw.exe.once('OnPtzControl', res => {
if (res.resultCode === 0) {
clearTimeout(timer)
resolve()
} else {
reject(new xw.BaseException(561))
}
})
})
}
async function getDeviceCode (deviceId, xw) {
const params = {
service: 'E1404406',
OBJ_ID: deviceId,
OBJ_TYPE: '2'
}
let deviceCode = await xw.ajaxRequest([params]).then(res => {
if (res.code === '0') {
return res.data[0].FACILITY_NUMBER
} else {
return ''
}
})
return deviceCode
}