From 6eb015d2c102ea8ec9bba9b83c0addc28b337167 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 28 Jun 2024 17:22:51 +0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 6f013e709e2ca5c9097a6826d2d1210282c18a3c Author: joylink_zhaoerwei Date: Fri Jun 28 17:21:33 2024 +0800 不覆盖驱采时增加校验:如果驱采的继电器id改变,变为新的id;如果驱采的继电器没有生成,删除针对该继电器的驱采数据 commit 7cb3586ad5831142e582dd556f4cd27b4cbc2677 Author: joylink_zhaoerwei Date: Thu Jun 27 18:06:32 2024 +0800 拖拽组件添加可变宽高配置(鼠标放置左边和上方移动改变弹框大小) commit 530a6cf1a342f5023564b9809971f03002a3bb6b Author: joylink_zhaoerwei Date: Thu Jun 27 16:40:19 2024 +0800 驱采绘制点击变背景色 commit d4c5e5a4a859394f1563078e471bbf2d87d61b6a Author: joylink_zhaoerwei Date: Thu Jun 27 15:41:42 2024 +0800 继电器增加批量操作 --- src/drawApp/relayCabinetLayoutApp.ts | 76 +++++++ .../RelayCabinetLayout/RelayCabinetLayout.vue | 20 ++ .../RelayCabinetLayout/checkCiCjQdData.ts | 213 ++++++++++++++++++ 3 files changed, 309 insertions(+) create mode 100644 src/layouts/RelayCabinetLayout/checkCiCjQdData.ts diff --git a/src/drawApp/relayCabinetLayoutApp.ts b/src/drawApp/relayCabinetLayoutApp.ts index e8b669c..d72b6a3 100644 --- a/src/drawApp/relayCabinetLayoutApp.ts +++ b/src/drawApp/relayCabinetLayoutApp.ts @@ -125,6 +125,7 @@ export function initDrawApp(): IDrawApp { }) ); app.on('postdataloaded', () => { + refRelaysListMap.clear(); refRelaysList.forEach((device) => { device.combinationtypes.forEach((combinationtype) => { combinationtype.refRelays.forEach((relayId) => { @@ -411,6 +412,44 @@ export function creatCiCjListByCombinationtype( } } +export function checkCiCjListByCombinationtype( + needChangeCjDataMap: Map< + string, + { + posInCiCjListindex: number; + relayId: number; + }[] + >, + needDeleteCjDataMap: Map +) { + ciCjList.cjList.forEach((CjDataSet, i) => { + CjDataSet.bitList.forEach((CjData, j) => { + const newIdInfo = needChangeCjDataMap.get(`${j}-${i}`); + if (newIdInfo) { + newIdInfo.forEach((info) => { + ciCjList.cjList[i].bitList[j].refRelays[ + info.posInCiCjListindex + ].relayId = info.relayId; + }); + } + const deleteIdInfo = needDeleteCjDataMap.get(`${j}-${i}`); + if (deleteIdInfo) { + deleteIdInfo.forEach((index) => { + ciCjList.cjList[i].bitList[j].refRelays[index].relayId = 999999; + }); + } + }); + }); + ciCjList.cjList.forEach((CjDataSet, i) => { + CjDataSet.bitList.forEach((CjData, j) => { + const newRefRelays = CjData.refRelays.filter( + (refRelay) => refRelay.relayId !== 999999 + ); + ciCjList.cjList[i].bitList[j].refRelays = newRefRelays; + }); + }); +} + export function clearCiCjList(rows: number, cols: number) { ciCjList = new relayCabinetGraphicData.CiCj(); ciCjList.dsCount = rows; @@ -528,6 +567,43 @@ export function creatCiQdListByCombinationtype( } } +export function checkCiQdListByCombinationtype( + needChangeCjDataMap: Map< + string, + { + posInCiQdListindex: number; + relayId: number; + }[] + >, + needDeleteCjDataMap: Map +) { + ciQdList.qdList.forEach((qdDataSet, i) => { + qdDataSet.bitList.forEach((qdData, j) => { + const newIdInfo = needChangeCjDataMap.get(`${j}-${i}`); + if (newIdInfo) { + newIdInfo.forEach((info) => { + ciQdList.qdList[i].bitList[j].refRelays[info.posInCiQdListindex] = + info.relayId; + }); + } + const deleteIdInfo = needDeleteCjDataMap.get(`${j}-${i}`); + if (deleteIdInfo) { + deleteIdInfo.forEach((index) => { + ciQdList.qdList[i].bitList[j].refRelays[index] = 999999; + }); + } + }); + }); + ciQdList.qdList.forEach((qdDataSet, i) => { + qdDataSet.bitList.forEach((qdData, j) => { + const newRefRelays = qdData.refRelays.filter( + (refRelayId) => refRelayId !== 999999 + ); + ciQdList.qdList[i].bitList[j].refRelays = newRefRelays; + }); + }); +} + export function clearCiQdList(rows: number, cols: number) { ciQdList = new relayCabinetGraphicData.CiQd(); ciQdList.dsCount = rows; diff --git a/src/layouts/RelayCabinetLayout/RelayCabinetLayout.vue b/src/layouts/RelayCabinetLayout/RelayCabinetLayout.vue index 03a785e..e5e7526 100644 --- a/src/layouts/RelayCabinetLayout/RelayCabinetLayout.vue +++ b/src/layouts/RelayCabinetLayout/RelayCabinetLayout.vue @@ -255,6 +255,8 @@ import { loadDeviceRelateRelayList, creatCiCjListByCombinationtype, creatCiQdListByCombinationtype, + loadCiCjList, + loadCiQdList, } from 'src/drawApp/relayCabinetLayoutApp'; import { GraphicIdGenerator, IDrawApp } from 'jl-graphic'; import { @@ -290,6 +292,12 @@ import { import { ciCjMap, CjData, PostionType } from './GeneraterCiCjConfig'; import { ciQdMap, QdData } from './GeneraterCiQdConfig'; import { ibpGraphicData } from 'src/protos/ibpGraphics'; +import { + checkCiCjData, + getAllShowRelayInfo, + getShowCiCjListRelayInfo, + getShowCiQdListRelayInfo, +} from './checkCiCjQdData'; const $q = useQuasar(); const route = useRoute(); @@ -595,6 +603,10 @@ async function checkIbpSpks(refIbpMapCode: string) { const myForm = ref(null); function oneClickGeneraterRelayLayout() { + const oldCiCjList = loadCiCjList(); + const oldShowCiCjListRelayInfo = getShowCiCjListRelayInfo(oldCiCjList); + const oldCiQdList = loadCiQdList(); + const oldShowCiQdListRelayInfo = getShowCiQdListRelayInfo(oldCiQdList); myForm.value?.validate().then((res) => { if (res && storage) { setUniqueIdPrefix( @@ -1098,6 +1110,14 @@ function oneClickGeneraterRelayLayout() { //生成继电器图并保存数据 generateRelayLayout(generateRelays); + if (!generaterRelayLayout.value.generateCJQD) { + const allShowRelayInfoMap = getAllShowRelayInfo(); + checkCiCjData( + oldShowCiCjListRelayInfo, + oldShowCiQdListRelayInfo, + allShowRelayInfoMap + ); + } saveAllDrawDatas(); generaterRelayLayoutDialog.value = false; diff --git a/src/layouts/RelayCabinetLayout/checkCiCjQdData.ts b/src/layouts/RelayCabinetLayout/checkCiCjQdData.ts new file mode 100644 index 0000000..c4f14e1 --- /dev/null +++ b/src/layouts/RelayCabinetLayout/checkCiCjQdData.ts @@ -0,0 +1,213 @@ +import { Relay } from 'src/graphics/relay/Relay'; +import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics'; +import { + checkCiCjListByCombinationtype, + checkCiQdListByCombinationtype, + refRelaysListMap, +} from 'src/drawApp/relayCabinetLayoutApp'; +import { useRelayCabinetStore } from 'src/stores/relayCabinet-store'; + +const relayCabinetStore = useRelayCabinetStore(); + +//检查校验——构建所有新的继电器显示Map与旧的ciCjQd继电器对应的显示对比 +export function checkCiCjData( + oldShowCiCjListRelayInfo: { + showInfo: string; + posInCiCjList: string; + posInCiCjListindex: number; + relayId: number; + }[], + oldShowCiQdListRelayInfo: { + showInfo: string; + posInCiQdList: string; + posInCiQdListindex: number; + relayId: number; + }[], + allShowRelayInfoMap: Map +) { + const needChangeCjDataMap = new Map< + string, + { + posInCiCjListindex: number; + relayId: number; + }[] + >(); + const needDeleteCjDataMap = new Map(); + oldShowCiCjListRelayInfo.forEach((oldShowRelayInfo) => { + const newShowRelayInfoId = allShowRelayInfoMap.get( + oldShowRelayInfo.showInfo + ); + if (!newShowRelayInfoId) { + const data = needDeleteCjDataMap.get(oldShowRelayInfo.posInCiCjList); + if (!data) { + needDeleteCjDataMap.set(oldShowRelayInfo.posInCiCjList, [ + oldShowRelayInfo.posInCiCjListindex, + ]); + } else { + data.push(oldShowRelayInfo.posInCiCjListindex); + } + } else if ( + newShowRelayInfoId && + oldShowRelayInfo.relayId !== newShowRelayInfoId + ) { + const data = needChangeCjDataMap.get(oldShowRelayInfo.posInCiCjList); + if (!data) { + needChangeCjDataMap.set(oldShowRelayInfo.posInCiCjList, [ + { + posInCiCjListindex: oldShowRelayInfo.posInCiCjListindex, + relayId: newShowRelayInfoId, + }, + ]); + } else { + data.push({ + posInCiCjListindex: oldShowRelayInfo.posInCiCjListindex, + relayId: newShowRelayInfoId, + }); + } + } + }); + if (needChangeCjDataMap.size || needDeleteCjDataMap.size) { + checkCiCjListByCombinationtype(needChangeCjDataMap, needDeleteCjDataMap); + } + + const needChangeQdDataMap = new Map< + string, + { + posInCiQdListindex: number; + relayId: number; + }[] + >(); + const needDeleteQdDataMap = new Map(); + oldShowCiQdListRelayInfo.forEach((oldShowRelayInfo) => { + const newShowRelayInfoId = allShowRelayInfoMap.get( + oldShowRelayInfo.showInfo + ); + if (!newShowRelayInfoId) { + const data = needDeleteQdDataMap.get(oldShowRelayInfo.posInCiQdList); + if (!data) { + needDeleteQdDataMap.set(oldShowRelayInfo.posInCiQdList, [ + oldShowRelayInfo.posInCiQdListindex, + ]); + } else { + data.push(oldShowRelayInfo.posInCiQdListindex); + } + } else if ( + newShowRelayInfoId && + oldShowRelayInfo.relayId !== newShowRelayInfoId + ) { + const data = needChangeQdDataMap.get(oldShowRelayInfo.posInCiQdList); + if (!data) { + needChangeQdDataMap.set(oldShowRelayInfo.posInCiQdList, [ + { + posInCiQdListindex: oldShowRelayInfo.posInCiQdListindex, + relayId: newShowRelayInfoId, + }, + ]); + } else { + data.push({ + posInCiQdListindex: oldShowRelayInfo.posInCiQdListindex, + relayId: newShowRelayInfoId, + }); + } + } + }); + if (needChangeQdDataMap.size) { + checkCiQdListByCombinationtype(needChangeQdDataMap, needDeleteQdDataMap); + } +} +export function getShowCiCjListRelayInfo( + ciCjList: relayCabinetGraphicData.CiCj +) { + const showCiCjListRelayInfo: { + showInfo: string; + posInCiCjList: string; + posInCiCjListindex: number; + relayId: number; + }[] = []; + + ciCjList?.cjList.forEach((cjDataSet, i) => { + cjDataSet.bitList.forEach((cjData, j) => { + cjData.refRelays.map((refRelay, index) => { + const refDeviceData = refRelaysListMap.get(refRelay.relayId); + const relay = relayCabinetStore + .getDrawApp() + .queryStore.queryById(refRelay.relayId); + if (refDeviceData?.device) { + showCiCjListRelayInfo.push({ + showInfo: `${refDeviceData.device}_${refDeviceData?.combinationtype}_${relay.datas.code}`, + posInCiCjList: `${j}-${i}`, + posInCiCjListindex: index, + relayId: relay.id, + }); + } else { + showCiCjListRelayInfo.push({ + showInfo: `${refDeviceData?.combinationtype}_${relay.datas.code}`, + posInCiCjList: `${j}-${i}`, + posInCiCjListindex: index, + relayId: relay.id, + }); + } + }); + }); + }); + return showCiCjListRelayInfo; +} + +export function getShowCiQdListRelayInfo( + ciQdList: relayCabinetGraphicData.CiQd +) { + const showCiQdListRelayInfo: { + showInfo: string; + posInCiQdList: string; + posInCiQdListindex: number; + relayId: number; + }[] = []; + ciQdList?.qdList.forEach((qdDataSet, i) => { + qdDataSet.bitList.forEach((qdData, j) => { + qdData.refRelays.map((refRelayId, index) => { + const refDeviceData = refRelaysListMap.get(refRelayId); + const relay = relayCabinetStore + .getDrawApp() + .queryStore.queryById(refRelayId); + if (refDeviceData?.device) { + showCiQdListRelayInfo.push({ + showInfo: `${refDeviceData.device}_${refDeviceData.combinationtype}_${relay.datas.code}`, + posInCiQdList: `${j}-${i}`, + posInCiQdListindex: index, + relayId: refRelayId, + }); + } else { + showCiQdListRelayInfo.push({ + showInfo: `${refDeviceData?.combinationtype}_${relay.datas.code}`, + posInCiQdList: `${j}-${i}`, + posInCiQdListindex: index, + relayId: refRelayId, + }); + } + }); + }); + }); + return showCiQdListRelayInfo; +} + +export function getAllShowRelayInfo() { + const allShowRelayInfoMap = new Map(); + refRelaysListMap.forEach((value, key) => { + const refDeviceData = value; + const relay = relayCabinetStore + .getDrawApp() + .queryStore.queryById(key); + if (refDeviceData?.device) { + allShowRelayInfoMap.set( + `${refDeviceData.device}_${refDeviceData?.combinationtype}_${relay.datas.code}`, + relay.id + ); + } else { + allShowRelayInfoMap.set( + `${refDeviceData?.combinationtype}_${relay.datas.code}`, + relay.id + ); + } + }); + return allShowRelayInfoMap; +}