Commit d69a95be0c9cb1710a145a2d15651cf48e99ffe2
1 parent
cc2941d6
perf: socket send message optimize
Showing
3 changed files
with
328 additions
and
95 deletions
... | ... | @@ -174,10 +174,15 @@ |
174 | 174 | if (!chartDom) return |
175 | 175 | chartDom.style.width = `${width}px` |
176 | 176 | chartDom.style.height = `${height}px` |
177 | - const myChart = echarts.init(chartDom); | |
178 | - const option = chartOptionMapping[chartType] ? chartOptionMapping[chartType]() : {} | |
179 | - option && myChart.setOption(option); | |
180 | - chartsInstanceMapping.set(id, myChart) | |
177 | + try { | |
178 | + const myChart = echarts.init(chartDom); | |
179 | + const option = chartOptionMapping[chartType] ? chartOptionMapping[chartType]() : {} | |
180 | + option && myChart.setOption(option); | |
181 | + chartsInstanceMapping.set(id, myChart) | |
182 | + } catch (error) { | |
183 | + | |
184 | + } | |
185 | + | |
181 | 186 | } |
182 | 187 | |
183 | 188 | /** | ... | ... |
... | ... | @@ -13033,18 +13033,56 @@ function previewAction(editorUi, currentPage) { |
13033 | 13033 | class DispatchCenter { |
13034 | 13034 | |
13035 | 13035 | /** |
13036 | - * @description 节点映射 | |
13037 | - * @type {Map<string, Map<string, object>>} | |
13038 | - */ | |
13039 | - nodeMapping | |
13040 | - | |
13041 | - /** | |
13042 | 13036 | * @description cmd ID 与 node 映射关系 |
13043 | 13037 | * @type {Map<number, string>} |
13044 | 13038 | */ |
13045 | 13039 | cmdIdMapping = new Map() |
13046 | 13040 | |
13047 | 13041 | /** |
13042 | + * @type { Map<string, { | |
13043 | + * deviceId: string, | |
13044 | + * dataOrigin: 'dataSources' | 'act', | |
13045 | + * slaveDeviceId: string, | |
13046 | + * nodeId: string, | |
13047 | + * attr: string | |
13048 | + * condition?: { max?: number, min?: number }, | |
13049 | + * additional?: { | |
13050 | + * agg?: string, | |
13051 | + * attrName?: string, | |
13052 | + * dataType?: 'tsSubCmds' | 'historyCmds', | |
13053 | + * deviceName?: string, | |
13054 | + * effectScope?: string, | |
13055 | + * interval?: string, | |
13056 | + * orgName?: string, | |
13057 | + * slaveDeviceName?: string | |
13058 | + * } | |
13059 | + * }[]>} | |
13060 | + */ | |
13061 | + deviceIdMapping = new Map() | |
13062 | + | |
13063 | + /** | |
13064 | + * @type {Map<number, { | |
13065 | + * deviceId: string, | |
13066 | + * slaveDeviceId: string, | |
13067 | + * nodeId: string, | |
13068 | + * attr: string | |
13069 | + * dataOrigin: 'dataSources' | 'act', | |
13070 | + * condition?: { max?: number, min?: number }, | |
13071 | + * additional?: { | |
13072 | + * agg?: string, | |
13073 | + * attrName?: string, | |
13074 | + * dataType?: 'tsSubCmds' | 'historyCmds', | |
13075 | + * deviceName?: string, | |
13076 | + * effectScope?: string, | |
13077 | + * interval?: string, | |
13078 | + * orgName?: string, | |
13079 | + * slaveDeviceName?: string | |
13080 | + * } | |
13081 | + * }[]>} | |
13082 | + */ | |
13083 | + subscribeIdMapping = new Map() | |
13084 | + | |
13085 | + /** | |
13048 | 13086 | * @description |
13049 | 13087 | */ |
13050 | 13088 | editorUi |
... | ... | @@ -13150,7 +13188,6 @@ class DispatchCenter { |
13150 | 13188 | |
13151 | 13189 | |
13152 | 13190 | constructor(editorUi, currentPage) { |
13153 | - this.nodeMapping = new Map() | |
13154 | 13191 | this.editorUi = editorUi |
13155 | 13192 | this.init(editorUi, currentPage) |
13156 | 13193 | } |
... | ... | @@ -13169,6 +13206,7 @@ class DispatchCenter { |
13169 | 13206 | this.dataInteractionInstance = new HandleDataInteraction(this) |
13170 | 13207 | this.dynamicEffectInstance = new HandleDynamicEffect(this) |
13171 | 13208 | this.updateQueueInstance = new UpdateQueue(this) |
13209 | + this.sendSubscribeMessage() | |
13172 | 13210 | } |
13173 | 13211 | |
13174 | 13212 | /** |
... | ... | @@ -13176,7 +13214,7 @@ class DispatchCenter { |
13176 | 13214 | */ |
13177 | 13215 | connectSocket() { |
13178 | 13216 | Ws.instance?.destroy?.() |
13179 | - this.socket = Ws.getInstance({ url: GLOBAL_WS_URL(), onmessageCallback: this.socketOnmessage }) | |
13217 | + this.socket = Ws.getInstance({ url: GLOBAL_WS_URL(), onmessageCallback: this.socketOnMessage.bind(this) }) | |
13180 | 13218 | } |
13181 | 13219 | |
13182 | 13220 | /** |
... | ... | @@ -13185,9 +13223,29 @@ class DispatchCenter { |
13185 | 13223 | * @param event |
13186 | 13224 | * @param ws |
13187 | 13225 | */ |
13188 | - socketOnmessage(message, event, ws) { | |
13189 | - const { subscriptionId, data } = message | |
13190 | - DispatchCenter.instance.publishEvent(subscriptionId, data, message, event, ws) | |
13226 | + socketOnMessage(message, event, ws) { | |
13227 | + const { subscriptionId, errorMsg } = message | |
13228 | + if (errorMsg) return | |
13229 | + const subList = this.subscribeIdMapping.get(subscriptionId) | |
13230 | + subList.forEach(item => { | |
13231 | + const { dataOrigin, additional } = item | |
13232 | + if (dataOrigin === 'dataSources') { | |
13233 | + if (additional) | |
13234 | + this.dataSourceHandlerInstance.updateRealTimeDataSource(message, item) | |
13235 | + else | |
13236 | + this.dataSourceHandlerInstance.updateCommonDataSource(message, item) | |
13237 | + } | |
13238 | + if (dataOrigin === 'act') { | |
13239 | + const { type } = item | |
13240 | + // this.dynamicEffectInstance.videoPlay() | |
13241 | + const handleFunction = this.dynamicEffectInstance.dispatch.call(this.dynamicEffectInstance, type) | |
13242 | + handleFunction(message, item) | |
13243 | + } | |
13244 | + }) | |
13245 | + // this.subscribeEvent(cmdId, this.updateCommonDataSource.bind(this)) | |
13246 | + return | |
13247 | + // const { subscriptionId, data } = message | |
13248 | + // DispatchCenter.instance.publishEvent(subscriptionId, data, message, event, ws) | |
13191 | 13249 | } |
13192 | 13250 | |
13193 | 13251 | /** |
... | ... | @@ -13220,6 +13278,175 @@ class DispatchCenter { |
13220 | 13278 | this.contentData = res |
13221 | 13279 | } |
13222 | 13280 | |
13281 | + sendSubscribeMessage() { | |
13282 | + const message = this.generateSubscribeMessage() | |
13283 | + this.socket.send(JSON.stringify(message)) | |
13284 | + } | |
13285 | + | |
13286 | + /** | |
13287 | + * @description 创建订阅消息 | |
13288 | + */ | |
13289 | + generateSubscribeMessage() { | |
13290 | + | |
13291 | + /** | |
13292 | + * @type {{dataSources: [], act: [], event: [], enabled: boolean}} | |
13293 | + */ | |
13294 | + const data = JSON.parse(JSON.stringify(this.contentData)) | |
13295 | + delete data.enabled | |
13296 | + | |
13297 | + /** | |
13298 | + * | |
13299 | + * @param {'dataSources' | 'act'} key | |
13300 | + * @param {{ | |
13301 | + * id: string, | |
13302 | + * enabled: boolean, | |
13303 | + * deviceId: string, | |
13304 | + * slaveDeviceId: string, | |
13305 | + * nodeId: string, | |
13306 | + * attr: string | |
13307 | + * condition?: { max?: number, min?: number }, | |
13308 | + * additional?: { | |
13309 | + * agg?: string, | |
13310 | + * attrName?: string, | |
13311 | + * dataType?: 'tsSubCmds' | 'historyCmds', | |
13312 | + * deviceName?: string, | |
13313 | + * effectScope?: string, | |
13314 | + * interval?: string, | |
13315 | + * orgName?: string, | |
13316 | + * slaveDeviceName?: string | |
13317 | + * } | |
13318 | + * }} record | |
13319 | + */ | |
13320 | + const setDeviceMapping = (record) => { | |
13321 | + const { deviceId, slaveDeviceId } = record | |
13322 | + if (this.deviceIdMapping.has(slaveDeviceId || deviceId)) { | |
13323 | + const group = this.deviceIdMapping.get(slaveDeviceId || deviceId) | |
13324 | + group.push(record) | |
13325 | + } else { | |
13326 | + this.deviceIdMapping.set(slaveDeviceId || deviceId, [record]) | |
13327 | + } | |
13328 | + } | |
13329 | + | |
13330 | + Object.keys(data).forEach(key => { | |
13331 | + /** | |
13332 | + * @type {{ | |
13333 | + * id: string, | |
13334 | + * nodeId: string, | |
13335 | + * deviceId: string, | |
13336 | + * slaveDeviceId: string, | |
13337 | + * attr: string, | |
13338 | + * enabled: boolean, | |
13339 | + * additional: object, | |
13340 | + * condition: object | |
13341 | + * }[]} | |
13342 | + */ | |
13343 | + const list = data[key] | |
13344 | + if (key === 'dataSources') { | |
13345 | + for (const item of list) { | |
13346 | + setDeviceMapping({ dataOrigin: key, ...item }) | |
13347 | + } | |
13348 | + } | |
13349 | + if (key === 'act') { | |
13350 | + for (const item of list) { | |
13351 | + const { enabled } = item | |
13352 | + if (!enabled) continue | |
13353 | + setDeviceMapping({ dataOrigin: key, ...item }) | |
13354 | + } | |
13355 | + } | |
13356 | + }) | |
13357 | + | |
13358 | + /** | |
13359 | + * @param {{ | |
13360 | + * entityId: string, | |
13361 | + * cmdId: number, | |
13362 | + * keys: string, | |
13363 | + * agg?: string, | |
13364 | + * interval?: number, | |
13365 | + * startTs?: number, | |
13366 | + * endTs?: number | |
13367 | + * }} params | |
13368 | + * @returns {{ entityType: string, entityId: string, scope: string, cmdId: number, keys: string }} | |
13369 | + */ | |
13370 | + const generateMessage = (params) => { | |
13371 | + const getDynamicAttr = (attr) => params[attr] ? { [attr]: params[attr] } : {} | |
13372 | + return { | |
13373 | + entityType: 'DEVICE', | |
13374 | + entityId: params.entityId, | |
13375 | + cmdId: params.cmdId, | |
13376 | + keys: params.keys, | |
13377 | + | |
13378 | + ... (params.interval ? {} : { scope: 'LATEST_TELEMETRY' }), | |
13379 | + ...getDynamicAttr('agg'), | |
13380 | + ...getDynamicAttr('interval'), | |
13381 | + ...getDynamicAttr('startTs'), | |
13382 | + ...getDynamicAttr('endTs'), | |
13383 | + } | |
13384 | + } | |
13385 | + | |
13386 | + const generateGroupMessage = () => { | |
13387 | + /** | |
13388 | + * @type {{ | |
13389 | + * historyCmds: { | |
13390 | + * entityType: 'DEVICE', | |
13391 | + * entityId: string, | |
13392 | + * scope?: 'LATEST_TELEMETRY', | |
13393 | + * cmdId: number, | |
13394 | + * keys: string, | |
13395 | + * startTs?: number | |
13396 | + * endTs?: number | |
13397 | + * }[], | |
13398 | + * tsSubCmds: { | |
13399 | + * entityType: 'DEVICE', | |
13400 | + * entityId: string, | |
13401 | + * scope?: 'LATEST_TELEMETRY', | |
13402 | + * cmdId: number, | |
13403 | + * keys: string, | |
13404 | + * startTs?: number | |
13405 | + * endTs?: number | |
13406 | + * }[]}} | |
13407 | + */ | |
13408 | + const messageList = { tsSubCmds: [], historyCmds: [] } | |
13409 | + let cmdId = 0 | |
13410 | + | |
13411 | + const getKeys = (list) => Array.from(new Set(list)).join(',') | |
13412 | + | |
13413 | + const toNumber = (string, defaultValue = 0) => isNaN(string) ? defaultValue : Number(string) | |
13414 | + | |
13415 | + const setSubscribeMapping = (cmdId, record) => this.subscribeIdMapping.set(cmdId, record) | |
13416 | + | |
13417 | + this.deviceIdMapping.forEach((value, key) => { | |
13418 | + const basicRecord = value.filter(item => !item.additional) | |
13419 | + const moreFilterRecord = value.filter(item => item.additional) | |
13420 | + | |
13421 | + const message = generateMessage({ entityId: key, cmdId, keys: getKeys(basicRecord.map(item => item.attr)) }) | |
13422 | + setSubscribeMapping(cmdId, basicRecord) | |
13423 | + cmdId++ | |
13424 | + moreFilterRecord.forEach(item => { | |
13425 | + const { additional = {} } = item | |
13426 | + const { dataType = 'tsSubCmds', interval, effectScope, agg } = additional | |
13427 | + const message = generateMessage({ | |
13428 | + entityId: key, | |
13429 | + cmdId, | |
13430 | + agg, | |
13431 | + keys: getKeys(moreFilterRecord.map(item => item.attr)), | |
13432 | + interval: toNumber(interval, 1000), | |
13433 | + startTs: Date.now() - toNumber(effectScope), | |
13434 | + ...(dataType === HandleDataSource.enumDataBindType.REAL ? {} : { endTs: Date.now() }) | |
13435 | + }) | |
13436 | + setSubscribeMapping(cmdId, moreFilterRecord) | |
13437 | + messageList[dataType].push(message) | |
13438 | + cmdId++ | |
13439 | + }) | |
13440 | + | |
13441 | + messageList.tsSubCmds.push(message) | |
13442 | + }) | |
13443 | + | |
13444 | + return messageList | |
13445 | + } | |
13446 | + | |
13447 | + return generateGroupMessage() | |
13448 | + } | |
13449 | + | |
13223 | 13450 | /** |
13224 | 13451 | * @description 发送消息去获取实时数据 |
13225 | 13452 | */ |
... | ... | @@ -13242,7 +13469,7 @@ class DispatchCenter { |
13242 | 13469 | /** |
13243 | 13470 | * @description 生成节点映射表 |
13244 | 13471 | * @param dataSources |
13245 | - * @return {{cmdId: number, entityType: string, keys: *, scope: string, entityId: *}[]} | |
13472 | + * @return {{cmdId: number, entityType: string, keys: string, scope: string, entityId: string}[]} | |
13246 | 13473 | */ |
13247 | 13474 | generatorDataSourceMapping(dataSources = []) { |
13248 | 13475 | return dataSources.map((datum) => { |
... | ... | @@ -13264,12 +13491,7 @@ class DispatchCenter { |
13264 | 13491 | * @description 分发事件 |
13265 | 13492 | */ |
13266 | 13493 | publishEvent(eventName, data, message, event, ws) { |
13267 | - // data = data ? data : {} | |
13268 | 13494 | this.eventBus.emit(eventName, message, event, ws) |
13269 | - // console.log(arguments) | |
13270 | - // Object.keys(data).forEach(() => { | |
13271 | - // this.eventBus.emit(eventName, message, event, ws) | |
13272 | - // }) | |
13273 | 13495 | } |
13274 | 13496 | |
13275 | 13497 | /** |
... | ... | @@ -13414,8 +13636,8 @@ class HandleDataSource { |
13414 | 13636 | |
13415 | 13637 | constructor(DispatchInstance) { |
13416 | 13638 | this.DispatchInstance = DispatchInstance |
13417 | - this.generatorCommonDataSourceMapping() | |
13418 | - this.generatorChartDataSourceMapping() | |
13639 | + // this.generatorCommonDataSourceMapping() | |
13640 | + // this.generatorChartDataSourceMapping() | |
13419 | 13641 | } |
13420 | 13642 | |
13421 | 13643 | get graph() { |
... | ... | @@ -13536,10 +13758,12 @@ class HandleDataSource { |
13536 | 13758 | * @description 更新变量值 |
13537 | 13759 | * @param {} message |
13538 | 13760 | */ |
13539 | - updateCommonDataSource(message) { | |
13540 | - const { subscriptionId } = message | |
13541 | - const node = this.getNodeByCmdId(subscriptionId) | |
13542 | - const { attr } = this.getBindData(subscriptionId) | |
13761 | + updateCommonDataSource(message, record) { | |
13762 | + // const { subscriptionId } = message | |
13763 | + const { nodeId, attr } = record | |
13764 | + const node = this.getNodeByCmdId(nodeId) | |
13765 | + | |
13766 | + // const { attr } = this.getBindData(nodeId) | |
13543 | 13767 | node && this.updatePage(() => { |
13544 | 13768 | const { data } = message |
13545 | 13769 | const type = this.getComponentType(node) |
... | ... | @@ -13554,7 +13778,7 @@ class HandleDataSource { |
13554 | 13778 | } |
13555 | 13779 | |
13556 | 13780 | if (type === this.componentType.IMAGE) { |
13557 | - this.handleImageComponent(message) | |
13781 | + this.handleImageComponent(message, record) | |
13558 | 13782 | return |
13559 | 13783 | } |
13560 | 13784 | |
... | ... | @@ -13568,11 +13792,11 @@ class HandleDataSource { |
13568 | 13792 | * @description 处理switch 组件 |
13569 | 13793 | * @param {} message |
13570 | 13794 | */ |
13571 | - handleSwitchComponent(message) { | |
13572 | - const { subscriptionId, data = {} } = message | |
13573 | - const node = this.getNodeByCmdId(subscriptionId) | |
13574 | - const { nodeId, attr } = this.getBindData(subscriptionId) | |
13575 | - const [[timespan, receiveValue] = []] = data[attr] || [] | |
13795 | + handleSwitchComponent(message, record) { | |
13796 | + const { data = {} } = message | |
13797 | + const { nodeId, attr } = record | |
13798 | + const node = this.getNodeByCmdId(nodeId) | |
13799 | + const [[_timespan, receiveValue] = []] = data[attr] || [] | |
13576 | 13800 | const switchConfig = this.DispatchInstance.contentData.act.find(item => item.id === nodeId && item.type === 'SWITCH') |
13577 | 13801 | const { condition = [] } = switchConfig || {} |
13578 | 13802 | let reg = /image=[^;]+/g |
... | ... | @@ -13611,22 +13835,22 @@ class HandleDataSource { |
13611 | 13835 | |
13612 | 13836 | } |
13613 | 13837 | |
13614 | - handleParamSettingButton(message) { | |
13615 | - const { subscriptionId, data = {} } = message | |
13838 | + handleParamSettingButton(message, record) { | |
13839 | + const { data = {} } = message | |
13616 | 13840 | if (!data) return |
13617 | - const node = this.getNodeByCmdId(subscriptionId) | |
13618 | - const { attr } = this.getBindData(subscriptionId) | |
13619 | - const [[timespan, receiveValue] = []] = data[attr] || [] | |
13841 | + const { nodeId, attr } = record | |
13842 | + const node = this.getNodeByCmdId(nodeId) | |
13843 | + const [[_timespan, receiveValue] = []] = data[attr] || [] | |
13620 | 13844 | this.updatePage(() => { |
13621 | 13845 | node.setAttribute('label', `<button class="param-setting-button">${receiveValue}</button>`) |
13622 | 13846 | }, node) |
13623 | 13847 | } |
13624 | 13848 | |
13625 | - handleImageComponent(message) { | |
13626 | - const { subscriptionId, data = {} } = message | |
13627 | - const node = this.getNodeByCmdId(subscriptionId) | |
13628 | - const { attr } = this.getBindData(subscriptionId) | |
13629 | - const [[timespan, receiveValue] = []] = data[attr] || [] | |
13849 | + handleImageComponent(message, record) { | |
13850 | + const { data = {} } = message | |
13851 | + const { nodeId, attr } = record | |
13852 | + const node = this.getNodeByCmdId(nodeId) | |
13853 | + const [[_timespan, receiveValue] = []] = data[attr] || [] | |
13630 | 13854 | this.updatePage(() => { |
13631 | 13855 | node.setAttribute('label', `<img class="basic-component__image" alt="图片" src="${receiveValue}" />`) |
13632 | 13856 | }, node) |
... | ... | @@ -13635,18 +13859,19 @@ class HandleDataSource { |
13635 | 13859 | /** |
13636 | 13860 | * @description 更新实时数据 |
13637 | 13861 | * @param {} message |
13638 | - * @param {} agg 聚合方式 | |
13862 | + * @param {} record 聚合方式 | |
13639 | 13863 | */ |
13640 | - updateRealTimeDataSource(message, agg) { | |
13641 | - const { data = {}, subscriptionId } = message | |
13642 | - const node = this.getNodeByCmdId(subscriptionId) | |
13864 | + updateRealTimeDataSource(message, record) { | |
13865 | + const { data = {} } = message | |
13866 | + const { nodeId, attr, additional = {} } = record | |
13867 | + const { agg } = additional | |
13868 | + const node = this.getNodeByCmdId(nodeId) | |
13643 | 13869 | if (!node) return |
13644 | 13870 | const enumConst = Sidebar.prototype.enumCellBasicAttribute |
13645 | 13871 | const chartInstanceMap = Sidebar.prototype.chartsInstanceMapping |
13646 | 13872 | const chartInstanceId = node.getAttribute(enumConst.CHART_INSTANCE_ID) |
13647 | 13873 | const chartInstanceType = node.getAttribute(enumConst.COMPONENT_TYPE) |
13648 | 13874 | const instance = chartInstanceMap.get(chartInstanceId) |
13649 | - const { attr = [[]], additional } = this.getBindData(subscriptionId) | |
13650 | 13875 | const realDataList = data[attr] || [] |
13651 | 13876 | |
13652 | 13877 | const action = agg === 'NONE' ? 'unshift' : 'push' |
... | ... | @@ -13655,12 +13880,12 @@ class HandleDataSource { |
13655 | 13880 | const isActive = instance.isActive |
13656 | 13881 | if (!isActive) { |
13657 | 13882 | instance.isActive = true |
13658 | - const chartOption = this.getChartComponentOption(chartInstanceType, { chartType: chartInstanceType, attr, dataList: realDataList, action, nodeId: node.id , additional}) | |
13883 | + const chartOption = this.getChartComponentOption(chartInstanceType, { chartType: chartInstanceType, attr, dataList: realDataList, action, nodeId: node.id, additional }) | |
13659 | 13884 | instance.setOption(chartOption) |
13660 | 13885 | |
13661 | 13886 | } else { |
13662 | 13887 | const oldOptions = instance.getOption() |
13663 | - const options = this.getRealTimeUpdateChartOption(chartInstanceType, { oldOptions, dataList: realDataList , additional}) | |
13888 | + const options = this.getRealTimeUpdateChartOption(chartInstanceType, { oldOptions, dataList: realDataList, additional }) | |
13664 | 13889 | if (!instance) clearInterval(interval) |
13665 | 13890 | instance && instance.setOption(options) |
13666 | 13891 | } |
... | ... | @@ -13669,16 +13894,17 @@ class HandleDataSource { |
13669 | 13894 | /** |
13670 | 13895 | * @description 更新历史数据 |
13671 | 13896 | */ |
13672 | - updateHistoryDataSource(message, agg) { | |
13673 | - const { data = {}, subscriptionId } = message | |
13674 | - const node = this.getNodeByCmdId(subscriptionId) | |
13897 | + updateHistoryDataSource(message, record) { | |
13898 | + const { data = {} } = message | |
13899 | + const { nodeId, attr, additional = {} } = record | |
13900 | + const { agg } = additional | |
13901 | + const node = this.getNodeByCmdId(nodeId) | |
13675 | 13902 | if (!node) return |
13676 | 13903 | const enumConst = Sidebar.prototype.enumCellBasicAttribute |
13677 | 13904 | const chartInstanceMap = Sidebar.prototype.chartsInstanceMapping |
13678 | 13905 | const chartInstanceId = node.getAttribute(enumConst.CHART_INSTANCE_ID) |
13679 | 13906 | const chartInstanceType = node.getAttribute(enumConst.COMPONENT_TYPE) |
13680 | 13907 | const instance = chartInstanceMap.get(chartInstanceId) |
13681 | - const { attr = [[]], additional } = this.getBindData(subscriptionId) | |
13682 | 13908 | const historyDataList = data[attr] || [] |
13683 | 13909 | const showNumberOf = 4 |
13684 | 13910 | const action = agg === 'NONE' ? 'unshift' : 'push' |
... | ... | @@ -13965,11 +14191,10 @@ class HandleDataSource { |
13965 | 14191 | /** |
13966 | 14192 | * @description 获取仪表盘配置 |
13967 | 14193 | */ |
13968 | - getRealTimeUpdateDashboardChartOption(params = { dataList: [] , additional: {}}) { | |
14194 | + getRealTimeUpdateDashboardChartOption(params = { dataList: [], additional: {} }) { | |
13969 | 14195 | const { dataList = [], oldOptions, additional } = params |
13970 | 14196 | const { attrName } = additional |
13971 | 14197 | const [timespan, value] = dataList[0] || [] |
13972 | - console.log(value) | |
13973 | 14198 | return { |
13974 | 14199 | series: [ |
13975 | 14200 | { |
... | ... | @@ -13990,8 +14215,7 @@ class HandleDataSource { |
13990 | 14215 | * @param actionType |
13991 | 14216 | * @return {{attr: string, additional: { agg: string, dataType: string, effectScope: string, interval: string, unit: string, orgName: string, deviceName: string, slaveDeviceName: string, attrName: string }}} |
13992 | 14217 | */ |
13993 | - getBindData(subscriptionId) { | |
13994 | - const nodeId = this.getNodeIdByCmdId(subscriptionId) | |
14218 | + getBindData(nodeId) { | |
13995 | 14219 | const temp = this.dataSourceNodeMapping.get(nodeId) || {} |
13996 | 14220 | return temp |
13997 | 14221 | } |
... | ... | @@ -14011,7 +14235,8 @@ class HandleDataSource { |
14011 | 14235 | * @return {string} |
14012 | 14236 | */ |
14013 | 14237 | getNodeIdByCmdId(subscriptionId) { |
14014 | - return this.DispatchInstance.cmdIdMapping.get(subscriptionId) | |
14238 | + // return this.DispatchInstance.cmdIdMapping.get(subscriptionId) | |
14239 | + return this.DispatchInstance.subscribeIdMapping.get(subscriptionId) | |
14015 | 14240 | } |
14016 | 14241 | |
14017 | 14242 | /** |
... | ... | @@ -14019,8 +14244,8 @@ class HandleDataSource { |
14019 | 14244 | * @param subscriptionId |
14020 | 14245 | * @return {*} |
14021 | 14246 | */ |
14022 | - getNodeByCmdId(subscriptionId) { | |
14023 | - const nodeId = this.getNodeIdByCmdId(subscriptionId) | |
14247 | + getNodeByCmdId(nodeId) { | |
14248 | + // const nodeId = this.getNodeIdByCmdId(subscriptionId) | |
14024 | 14249 | return this.contentAllCell.find(item => item.id === nodeId) |
14025 | 14250 | } |
14026 | 14251 | |
... | ... | @@ -14634,7 +14859,7 @@ class HandleDynamicEffect { |
14634 | 14859 | */ |
14635 | 14860 | generatorMappingRelation() { |
14636 | 14861 | this.videoPlay() |
14637 | - const tsSubCmds = [] | |
14862 | + // const tsSubCmds = [] | |
14638 | 14863 | this.enableActList.forEach(each => { |
14639 | 14864 | const { id, type, attr, deviceId, slaveDeviceId } = each |
14640 | 14865 | |
... | ... | @@ -14642,13 +14867,13 @@ class HandleDynamicEffect { |
14642 | 14867 | const temp = this.actNodeMapping.get(id) |
14643 | 14868 | temp.value.set(type, each) |
14644 | 14869 | |
14645 | - const cmdId = this.DispatchInstance.getCmdId(id) | |
14870 | + // const cmdId = this.DispatchInstance.getCmdId(id) | |
14646 | 14871 | |
14647 | - tsSubCmds.push(this.generatorMessage(slaveDeviceId ? slaveDeviceId : deviceId, cmdId, attr)) | |
14872 | + // tsSubCmds.push(this.generatorMessage(slaveDeviceId ? slaveDeviceId : deviceId, cmdId, attr)) | |
14648 | 14873 | |
14649 | - this.subscribeEvent(cmdId, this.dispatch(type)) | |
14874 | + // this.subscribeEvent(cmdId, this.dispatch(type)) | |
14650 | 14875 | }) |
14651 | - if (tsSubCmds.length) this.sendMsg({ tsSubCmds }) | |
14876 | + // if (tsSubCmds.length) this.sendMsg({ tsSubCmds }) | |
14652 | 14877 | } |
14653 | 14878 | |
14654 | 14879 | /** |
... | ... | @@ -14718,15 +14943,16 @@ class HandleDynamicEffect { |
14718 | 14943 | * @param message |
14719 | 14944 | * @param attr |
14720 | 14945 | */ |
14721 | - rotate(message) { | |
14722 | - const { subscriptionId, data } = message | |
14723 | - const node = this.getNodeByCmdId(subscriptionId) | |
14946 | + rotate(message, record) { | |
14947 | + const { data } = message | |
14948 | + const { id } = record | |
14949 | + const node = this.getNodeByCmdId(id) | |
14724 | 14950 | const key = node.id + DispatchCenter.enumDynamicEffectType.ROTATE |
14725 | 14951 | if (!this.validatePriority(node.id)) { |
14726 | 14952 | this.delUpdateFn(key) |
14727 | 14953 | return |
14728 | 14954 | } |
14729 | - const { flag } = this.validate(subscriptionId, DispatchCenter.enumDynamicEffectType.ROTATE, data) | |
14955 | + const { flag } = this.validate(record, DispatchCenter.enumDynamicEffectType.ROTATE, data) | |
14730 | 14956 | let deg = 0 |
14731 | 14957 | const updateFn = () => { |
14732 | 14958 | if (deg === 360) deg = 0 |
... | ... | @@ -14750,11 +14976,12 @@ class HandleDynamicEffect { |
14750 | 14976 | * @param message |
14751 | 14977 | * @param attr |
14752 | 14978 | */ |
14753 | - display(message) { | |
14754 | - const { subscriptionId, data = {} } = message | |
14755 | - const { flag, condition } = this.validate(subscriptionId, HandleDynamicEffect.enumActType.DISPLAY, data) | |
14979 | + display(message, record) { | |
14980 | + const { data = {} } = message | |
14981 | + const { id } = record | |
14982 | + const { flag, condition } = this.validate(record, HandleDynamicEffect.enumActType.DISPLAY, data) | |
14756 | 14983 | if (!flag) return |
14757 | - const node = this.getNodeByCmdId(subscriptionId) | |
14984 | + const node = this.getNodeByCmdId(id) | |
14758 | 14985 | let isShow = false |
14759 | 14986 | if (condition.type === HandleDynamicEffect.enumDisplayType.SHOW) { |
14760 | 14987 | isShow = true |
... | ... | @@ -14784,15 +15011,16 @@ class HandleDynamicEffect { |
14784 | 15011 | * @param message |
14785 | 15012 | * @param attr |
14786 | 15013 | */ |
14787 | - flash(message) { | |
14788 | - const { subscriptionId, data } = message | |
14789 | - const node = this.getNodeByCmdId(subscriptionId) | |
15014 | + flash(message, record) { | |
15015 | + const { data } = message | |
15016 | + const { id } = record | |
15017 | + const node = this.getNodeByCmdId(id) | |
14790 | 15018 | const key = node.id + DispatchCenter.enumDynamicEffectType.FLASH |
14791 | - if (!this.validatePriority(node.id)) { | |
15019 | + if (!this.validatePriority(id)) { | |
14792 | 15020 | this.delUpdateFn(key) |
14793 | 15021 | return |
14794 | 15022 | } |
14795 | - const { flag, condition } = this.validate(subscriptionId, HandleDynamicEffect.enumActType.FLASH, data) | |
15023 | + const { flag } = this.validate(record, HandleDynamicEffect.enumActType.FLASH, data) | |
14796 | 15024 | let flashFlag = false |
14797 | 15025 | const updateFn = () => { |
14798 | 15026 | node.setVisible(flashFlag) |
... | ... | @@ -14810,10 +15038,11 @@ class HandleDynamicEffect { |
14810 | 15038 | /** |
14811 | 15039 | * @description 处理变量图片 |
14812 | 15040 | */ |
14813 | - varImage(message) { | |
14814 | - const { subscriptionId, data } = message | |
14815 | - const node = this.getNodeByCmdId(subscriptionId) | |
14816 | - const { flag, condition } = this.validate(subscriptionId, HandleDynamicEffect.enumActType.IMAGE, data) | |
15041 | + varImage(message, record) { | |
15042 | + const { data } = message | |
15043 | + const { id } = record | |
15044 | + const node = this.getNodeByCmdId(id) | |
15045 | + const { flag, condition } = this.validate(record, HandleDynamicEffect.enumActType.IMAGE, data) | |
14817 | 15046 | if (flag && node) { |
14818 | 15047 | const { imagePath } = condition |
14819 | 15048 | this.insertOnceUpdateFn( |
... | ... | @@ -14822,7 +15051,7 @@ class HandleDynamicEffect { |
14822 | 15051 | node.setStyle(`image;image=${imagePath};imageAspect=0;`) |
14823 | 15052 | }) |
14824 | 15053 | } else if (!flag && node) { |
14825 | - const { condition = [], attr } = this.getBindData(subscriptionId, HandleDynamicEffect.enumActType.IMAGE) | |
15054 | + const { condition = [], attr } = record | |
14826 | 15055 | const flag = HandleDynamicEffect.enumVarImageConst.DEFAULT_IMAGE_FLAG |
14827 | 15056 | const defaultBindData = condition.find(item => item[flag]) |
14828 | 15057 | if (defaultBindData) { |
... | ... | @@ -14837,11 +15066,12 @@ class HandleDynamicEffect { |
14837 | 15066 | } |
14838 | 15067 | } |
14839 | 15068 | |
14840 | - running(message) { | |
14841 | - const { subscriptionId, data = {} } = message | |
14842 | - const { flag, condition } = this.validate(subscriptionId, HandleDynamicEffect.enumActType.RUNNING, data) | |
15069 | + running(message, record) { | |
15070 | + const { id } = record | |
15071 | + const { data = {} } = message | |
15072 | + const { flag, condition } = this.validate(record, HandleDynamicEffect.enumActType.RUNNING, data) | |
14843 | 15073 | if (!flag) return |
14844 | - const node = this.getNodeByCmdId(subscriptionId) | |
15074 | + const node = this.getNodeByCmdId(id) | |
14845 | 15075 | let isRun = false |
14846 | 15076 | if (condition.type === HandleDynamicEffect.enumRunningType.RUN) { |
14847 | 15077 | isRun = true |
... | ... | @@ -14897,7 +15127,7 @@ class HandleDynamicEffect { |
14897 | 15127 | const { geometry = {} } = cell |
14898 | 15128 | const { width, height } = geometry |
14899 | 15129 | const idEl = getIdEl() |
14900 | - graph.getModel().beginUpdate() | |
15130 | + graph.getModel().beginUpdate() | |
14901 | 15131 | try { |
14902 | 15132 | let type |
14903 | 15133 | if (videoUrl.replace(reg, '') === 'm3u8') type = 'application/x-mpegURL' |
... | ... | @@ -14939,13 +15169,13 @@ class HandleDynamicEffect { |
14939 | 15169 | |
14940 | 15170 | /** |
14941 | 15171 | * @description 验证是否满足条件列表中的任意一条 |
14942 | - * @param subscriptionId | |
15172 | + * @param record | |
14943 | 15173 | * @param type |
14944 | 15174 | * @param value |
14945 | 15175 | * @return {{flag: boolean, condition: {}}} |
14946 | 15176 | */ |
14947 | - validate(subscriptionId, type, value) { | |
14948 | - const { condition = [], attr } = this.getBindData(subscriptionId, type) | |
15177 | + validate(record, type, value) { | |
15178 | + const { condition = [], attr } = record | |
14949 | 15179 | const result = { condition: {}, flag: false } |
14950 | 15180 | for (let i = 0; i < condition.length; i++) { |
14951 | 15181 | const { min, max } = condition[i] |
... | ... | @@ -14996,8 +15226,7 @@ class HandleDynamicEffect { |
14996 | 15226 | * @param subscriptionId |
14997 | 15227 | * @return {*} |
14998 | 15228 | */ |
14999 | - getNodeByCmdId(subscriptionId) { | |
15000 | - const nodeId = this.getNodeIdByCmdId(subscriptionId) | |
15229 | + getNodeByCmdId(nodeId) { | |
15001 | 15230 | return this.contentAllCell.find(item => item.id === nodeId) |
15002 | 15231 | } |
15003 | 15232 | ... | ... |