From e8eb0f5ef7146804a1f07d647d080ce724b54d95 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Thu, 10 Oct 2024 10:46:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=E7=BC=96=E8=BE=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/commonApp.ts | 52 +++++++++++++++++++++++++++++++++++++ src/drawApp/iscsApp.ts | 56 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 104 insertions(+), 4 deletions(-) diff --git a/src/drawApp/commonApp.ts b/src/drawApp/commonApp.ts index d8a2123..3da6e1f 100644 --- a/src/drawApp/commonApp.ts +++ b/src/drawApp/commonApp.ts @@ -154,3 +154,55 @@ export function handlerCommonTypeData(data: sync_data_message.UpdataData) { return new IscsTextData(iscsGraphicData.IscsText.deserialize(data.data)); } } + +export function handlerNoEditCommonData( + data: sync_data_message.UpdataData, + storage: ICommonStorage, + operationType: string +) { + switch (data.type) { + case Rect.Type: + const rectData = iscsGraphicData.Rect.deserialize(data.data); + // syncNoEditData(operationType, rectData, storage.rects); + if (operationType === 'graphic-create') { + storage.rects.push(rectData); + } else if (operationType === 'graphic-delete') { + const index = storage.rects.findIndex( + (ele) => ele.common.id === rectData.common.id + ); + storage.rects.splice(index, 1); + } else if (operationType === 'graphic-drag') { + const index = storage.rects.findIndex( + (ele) => ele.common.id === rectData.common.id + ); + storage.rects[index] = rectData; + } + console.log(rectData, storage); + break; + case Arrow.Type: + const arrowData = iscsGraphicData.Arrow.deserialize(data.data); + syncNoEditData(operationType, arrowData, storage.arrows); + break; + case TextContent.Type: + const iscsTextData = iscsGraphicData.IscsText.deserialize(data.data); + syncNoEditData(operationType, iscsTextData, storage.iscsTexts); + break; + } +} + +export function syncNoEditData( + operationType: string, + data: any, + dataArray: any[] +) { + console.log(data, dataArray, '===='); + if (operationType === 'graphic-create') { + dataArray.push(data); + } else if (operationType === 'graphic-delete') { + const index = dataArray.findIndex((ele) => ele.id === data.id); + dataArray.splice(index, 1); + } else if (operationType === 'graphic-drag') { + const index = dataArray.findIndex((ele) => ele.id === data.id); + dataArray[index] = data; + } +} diff --git a/src/drawApp/iscsApp.ts b/src/drawApp/iscsApp.ts index 94bc930..80e740b 100644 --- a/src/drawApp/iscsApp.ts +++ b/src/drawApp/iscsApp.ts @@ -14,6 +14,7 @@ import { loadCommonDrawDatas, saveCommonDrawDatas, saveDrawToServer, + handlerNoEditCommonData, } from './commonApp'; import { CCTVButtonData } from './graphics/CCTV/CCTVButtonInteraction'; import { CCTVButtonDraw } from 'src/graphics/CCTV/cctvButton/CCTVButtonDrawAssistant'; @@ -88,7 +89,7 @@ function handleSubscribe(app: IDrawApp) { destination: `/rtss_simulation/draft/iscs/${drawStore.draftId}`, messageHandle: (message: Uint8Array) => { const syncData = sync_data_message.SyncData.deserialize(message); - console.log(syncData.userId, useAuthStore().userId, 'userID'); + console.log(syncData.userId, useAuthStore().userId, 'userID', syncData); if (syncData.userId === useAuthStore().userId) { console.info('当前用户操作'); return; @@ -120,6 +121,51 @@ function handleSubscribe(app: IDrawApp) { app.deleteGraphics(...graphics); } } else { + storage = iscsGraphicData.IscsGraphicStorage.deserialize( + toUint8Array(base64) + ); + if (syncData.submenu === '火灾报警平面图') { + for (let i = 0; i < storage.fasPlatformAlarmStorages.length; i++) { + const fasPlatformAlarm = storage.fasPlatformAlarmStorages[i]; + if (fasPlatformAlarm.stationName == syncData.station) { + // canvasProperty = fasPlatformAlarm.canvas; + // datas = loadCommonDrawDatas(fasPlatformAlarm); + // break; + syncData.datas.forEach((data) => { + handlerNoEditCommonData( + data, + fasPlatformAlarm, + syncData.operationType + ); + }); + storage.fasPlatformAlarmStorages[i] = fasPlatformAlarm; + console.log(fasPlatformAlarm, 'fasPlatformAlarm'); + } + } + } else if (syncData.submenu === '监控布局图') { + for ( + let i = 0; + i < storage.cctvOfStationControlStorages.length; + i++ + ) { + const ctvOfStationControl = storage.cctvOfStationControlStorages[i]; + if (ctvOfStationControl.stationName == syncData.station) { + // canvasProperty = ctvOfStationControl.canvas; + // datas = loadCommonDrawDatas(ctvOfStationControl); + // ctvOfStationControl.cctvButtons.forEach((cctvButton) => { + // datas.push(new CCTVButtonData(cctvButton)); + // }); + // break; + syncData.datas.forEach((data) => { + handlerNoEditCommonData( + data, + ctvOfStationControl, + syncData.operationType + ); + }); + } + } + } } }, graphicQueryer: (state, store) => { @@ -159,9 +205,11 @@ export async function loadDrawDatas(): Promise { hasLoadData = true; } if (base64) { - storage = iscsGraphicData.IscsGraphicStorage.deserialize( - toUint8Array(base64) - ); + if (!hasLoadData) { + storage = iscsGraphicData.IscsGraphicStorage.deserialize( + toUint8Array(base64) + ); + } let datas = []; let canvasProperty;