From 6f013e709e2ca5c9097a6826d2d1210282c18a3c Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 28 Jun 2024 17:21:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E8=A6=86=E7=9B=96=E9=A9=B1=E9=87=87?= =?UTF-8?q?=E6=97=B6=E5=A2=9E=E5=8A=A0=E6=A0=A1=E9=AA=8C=EF=BC=9A=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E9=A9=B1=E9=87=87=E7=9A=84=E7=BB=A7=E7=94=B5=E5=99=A8?= =?UTF-8?q?id=E6=94=B9=E5=8F=98=EF=BC=8C=E5=8F=98=E4=B8=BA=E6=96=B0?= =?UTF-8?q?=E7=9A=84id=EF=BC=9B=E5=A6=82=E6=9E=9C=E9=A9=B1=E9=87=87?= =?UTF-8?q?=E7=9A=84=E7=BB=A7=E7=94=B5=E5=99=A8=E6=B2=A1=E6=9C=89=E7=94=9F?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E5=88=A0=E9=99=A4=E9=92=88=E5=AF=B9=E8=AF=A5?= =?UTF-8?q?=E7=BB=A7=E7=94=B5=E5=99=A8=E7=9A=84=E9=A9=B1=E9=87=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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; +}