不覆盖驱采时增加校验:如果驱采的继电器id改变,变为新的id;如果驱采的继电器没有生成,删除针对该继电器的驱采数据
This commit is contained in:
parent
7cb3586ad5
commit
6f013e709e
@ -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<string, number[]>
|
||||
) {
|
||||
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<string, number[]>
|
||||
) {
|
||||
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;
|
||||
|
@ -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<QForm | null>(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;
|
||||
|
||||
|
213
src/layouts/RelayCabinetLayout/checkCiCjQdData.ts
Normal file
213
src/layouts/RelayCabinetLayout/checkCiCjQdData.ts
Normal file
@ -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<string, number>
|
||||
) {
|
||||
const needChangeCjDataMap = new Map<
|
||||
string,
|
||||
{
|
||||
posInCiCjListindex: number;
|
||||
relayId: number;
|
||||
}[]
|
||||
>();
|
||||
const needDeleteCjDataMap = new Map<string, number[]>();
|
||||
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<string, number[]>();
|
||||
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<Relay>(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<Relay>(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<string, number>();
|
||||
refRelaysListMap.forEach((value, key) => {
|
||||
const refDeviceData = value;
|
||||
const relay = relayCabinetStore
|
||||
.getDrawApp()
|
||||
.queryStore.queryById<Relay>(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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user