根据段数动态生成洗车机继电器(考虑3段以上情况)

This commit is contained in:
joylink_zhaoerwei 2024-04-02 16:37:47 +08:00
parent a07c75db68
commit a3c639b414
4 changed files with 101 additions and 132 deletions

View File

@ -702,7 +702,7 @@ const garageDoorCjList = [
const floodGateCjList = garageDoorCjList; const floodGateCjList = garageDoorCjList;
//洗车机 //洗车机
const threecarWashingCjList = [ const carWashingCjList = [
{ {
code: 'XCJ1', code: 'XCJ1',
refDeviceCodesAndPos: [ refDeviceCodesAndPos: [
@ -718,18 +718,6 @@ const threecarWashingCjList = [
position: PostionType.Q, position: PostionType.Q,
}, },
], ],
[
{
code: 'TWJ2',
position: PostionType.Q,
},
],
[
{
code: 'TWJ3',
position: PostionType.Q,
},
],
[ [
{ {
code: 'TGQJ', code: 'TGQJ',
@ -777,30 +765,6 @@ const threecarWashingCjList = [
position: PostionType.H, position: PostionType.H,
}, },
], ],
[
{
code: 'CFJ2',
position: PostionType.Q,
},
],
[
{
code: 'CFJ2',
position: PostionType.H,
},
],
[
{
code: 'CFJ3',
position: PostionType.Q,
},
],
[
{
code: 'CFJ3',
position: PostionType.H,
},
],
[ [
{ {
code: 'JTJ', code: 'JTJ',
@ -829,24 +793,6 @@ const threecarWashingCjList = [
}, },
]; ];
const twocarWashingCjList = threecarWashingCjList.map((cjData) => ({
code: cjData.code,
refDeviceCodesAndPos: cjData.refDeviceCodesAndPos
.map((device) =>
device.filter((item) => item.code !== 'TWJ3' && item.code !== 'CFJ3')
)
.filter((item) => item.length > 0),
}));
const onecarWashingCjList = twocarWashingCjList.map((cjData) => ({
code: cjData.code,
refDeviceCodesAndPos: cjData.refDeviceCodesAndPos
.map((device) =>
device.filter((item) => item.code !== 'TWJ2' && item.code !== 'CFJ2')
)
.filter((item) => item.length > 0),
}));
const DeviceType = graphicData.RelatedRef.DeviceType; const DeviceType = graphicData.RelatedRef.DeviceType;
export const ciCjMap = new Map<string, CjData[]>([ export const ciCjMap = new Map<string, CjData[]>([
[ [
@ -890,8 +836,6 @@ export const ciCjMap = new Map<string, CjData[]>([
[`${DeviceType.Breakers}+undefined`, breakersCjList], [`${DeviceType.Breakers}+undefined`, breakersCjList],
[`${DeviceType.PowerScreen}+undefined`, powerScreenCjList], [`${DeviceType.PowerScreen}+undefined`, powerScreenCjList],
[`${DeviceType.GarageDoor}+undefined`, garageDoorCjList], [`${DeviceType.GarageDoor}+undefined`, garageDoorCjList],
[`${DeviceType.CarWashing}+3`, threecarWashingCjList], [`${DeviceType.CarWashing}+undefined`, carWashingCjList],
[`${DeviceType.CarWashing}+2`, twocarWashingCjList],
[`${DeviceType.CarWashing}+1`, onecarWashingCjList],
[`${DeviceType.FloodGate}+undefined`, floodGateCjList], [`${DeviceType.FloodGate}+undefined`, floodGateCjList],
]); ]);

View File

@ -105,21 +105,7 @@ const garageDoorQdList = [
const floodGateQdList = garageDoorQdList; const floodGateQdList = garageDoorQdList;
const threecarWashingQdList = [ const carWashingQdList = [
{
code: 'XCJ1',
refDeviceCodes: [['XQJ'], ['TWJ1'], ['TWJ2'], ['TWJ3'], ['TGQJ']],
},
];
const twocarWashingQdList = [
{
code: 'XCJ1',
refDeviceCodes: [['XQJ'], ['TWJ1'], ['TWJ2'], ['TGQJ']],
},
];
const onecarWashingQdList = [
{ {
code: 'XCJ1', code: 'XCJ1',
refDeviceCodes: [['XQJ'], ['TWJ1'], ['TGQJ']], refDeviceCodes: [['XQJ'], ['TWJ1'], ['TGQJ']],
@ -191,8 +177,6 @@ export const ciQdMap = new Map<string, QdData[]>([
[`${DeviceType.ScreenDoor}+down`, downScreenDoorQdList], [`${DeviceType.ScreenDoor}+down`, downScreenDoorQdList],
[`${DeviceType.ScreenDoor}+up`, upScreenDoorQdList], [`${DeviceType.ScreenDoor}+up`, upScreenDoorQdList],
[`${DeviceType.GarageDoor}+undefined`, garageDoorQdList], [`${DeviceType.GarageDoor}+undefined`, garageDoorQdList],
[`${DeviceType.CarWashing}+3`, threecarWashingQdList], [`${DeviceType.CarWashing}+undefined`, carWashingQdList],
[`${DeviceType.CarWashing}+2`, twocarWashingQdList],
[`${DeviceType.CarWashing}+1`, onecarWashingQdList],
[`${DeviceType.FloodGate}+undefined`, floodGateQdList], [`${DeviceType.FloodGate}+undefined`, floodGateQdList],
]); ]);

View File

@ -468,7 +468,7 @@ const garageDoorCombinations = [
const floodGateCombinations = garageDoorCombinations; const floodGateCombinations = garageDoorCombinations;
//洗车机 //洗车机
const threeCarWashingCombinations = [ const carWashingCombinations = [
{ {
code: 'XCJ1', code: 'XCJ1',
refDeviceCodesAndModel: [ refDeviceCodesAndModel: [
@ -480,14 +480,6 @@ const threeCarWashingCombinations = [
code: 'TWJ1', code: 'TWJ1',
model: RelayModelType.JWXC_1700, model: RelayModelType.JWXC_1700,
}, },
{
code: 'TWJ2',
model: RelayModelType.JWXC_1700,
},
{
code: 'TWJ3',
model: RelayModelType.JWXC_1700,
},
{ {
code: 'TGQJ', code: 'TGQJ',
model: RelayModelType.JWXC_1700, model: RelayModelType.JWXC_1700,
@ -509,14 +501,6 @@ const threeCarWashingCombinations = [
code: 'CFJ1', code: 'CFJ1',
model: RelayModelType.JWXC_1700, model: RelayModelType.JWXC_1700,
}, },
{
code: 'CFJ2',
model: RelayModelType.JWXC_1700,
},
{
code: 'CFJ3',
model: RelayModelType.JWXC_1700,
},
{ {
code: 'JTJ', code: 'JTJ',
model: RelayModelType.JWXC_1700, model: RelayModelType.JWXC_1700,
@ -529,24 +513,6 @@ const threeCarWashingCombinations = [
}, },
]; ];
const twoCarWashingCombinations = threeCarWashingCombinations.map(
(combination) => ({
code: combination.code,
refDeviceCodesAndModel: combination.refDeviceCodesAndModel.filter(
(item) => item.code !== 'TWJ3' && item.code !== 'CFJ3'
),
})
);
const oneCarWashingCombinations = twoCarWashingCombinations.map(
(combination) => ({
code: combination.code,
refDeviceCodesAndModel: combination.refDeviceCodesAndModel.filter(
(item) => item.code !== 'TWJ2' && item.code !== 'CFJ2'
),
})
);
const DeviceType = graphicData.RelatedRef.DeviceType; const DeviceType = graphicData.RelatedRef.DeviceType;
export const combinationsMap = new Map<string, Combinationtype[]>([ export const combinationsMap = new Map<string, Combinationtype[]>([
[ [
@ -590,8 +556,6 @@ export const combinationsMap = new Map<string, Combinationtype[]>([
[`${DeviceType.Breakers}`, breakersCombinations], [`${DeviceType.Breakers}`, breakersCombinations],
[`${DeviceType.PowerScreen}`, powerScreenCombinations], [`${DeviceType.PowerScreen}`, powerScreenCombinations],
[`${DeviceType.GarageDoor}`, garageDoorCombinations], [`${DeviceType.GarageDoor}`, garageDoorCombinations],
[`${DeviceType.CarWashing + '+' + '3'}`, threeCarWashingCombinations], [`${DeviceType.CarWashing}`, carWashingCombinations],
[`${DeviceType.CarWashing + '+' + '2'}`, twoCarWashingCombinations],
[`${DeviceType.CarWashing + '+' + '1'}`, oneCarWashingCombinations],
[`${DeviceType.FloodGate}`, floodGateCombinations], [`${DeviceType.FloodGate}`, floodGateCombinations],
]); ]);

View File

@ -260,7 +260,7 @@ import {
import { generateRelayLayout, GenerateRelaysCongig } from './GeneraterDevice'; import { generateRelayLayout, GenerateRelaysCongig } from './GeneraterDevice';
import { getPublishMapInfoById, pageQuery } from 'src/api/PublishApi'; import { getPublishMapInfoById, pageQuery } from 'src/api/PublishApi';
import { ciCjMap, CjData, PostionType } from './GeneraterCiCjConfig'; import { ciCjMap, CjData, PostionType } from './GeneraterCiCjConfig';
import { ciQdMap } from './GeneraterCiQdConfig'; import { ciQdMap, QdData } from './GeneraterCiQdConfig';
const $q = useQuasar(); const $q = useQuasar();
const route = useRoute(); const route = useRoute();
@ -770,16 +770,31 @@ function oneClickGeneraterRelayLayout() {
}); });
// //
storage.carWashings.forEach((carWashing) => { storage.carWashings.forEach((carWashing) => {
const duanNum = carWashing.duanNum || 3; const duanNum = carWashing.duanNum || 1;
const deviceCombinations = combinationsMap.get( const deviceCombinations = combinationsMap.get(
`${DeviceType.CarWashing}+${duanNum}` `${DeviceType.CarWashing}`
); );
let changeDeviceCombinations: Combinationtype[] = JSON.parse(
JSON.stringify(deviceCombinations)
);
if (duanNum > 1) {
for (let i = 2; i <= duanNum; i++) {
changeDeviceCombinations[0].refDeviceCodesAndModel.push({
code: `TWJ${i}`,
model: RelayModelType.JWXC_1700,
});
changeDeviceCombinations[1].refDeviceCodesAndModel.push({
code: `CFJ${i}`,
model: RelayModelType.JWXC_1700,
});
}
}
if ( if (
carWashing.centralizedStations.includes(concentrationStation) && carWashing.centralizedStations.includes(concentrationStation) &&
deviceCombinations changeDeviceCombinations
) { ) {
creatDeviceRelateRelays( creatDeviceRelateRelays(
deviceCombinations, changeDeviceCombinations,
DeviceType.CarWashing, DeviceType.CarWashing,
carWashing.code carWashing.code
); );
@ -817,14 +832,22 @@ function oneClickGeneraterRelayLayout() {
const deviceRelateRelayList = loadDeviceRelateRelayList(); const deviceRelateRelayList = loadDeviceRelateRelayList();
const allCjData: relayCabinetGraphicData.CjData[] = []; const allCjData: relayCabinetGraphicData.CjData[] = [];
deviceRelateRelayList.forEach((deviceRelateRelay) => { deviceRelateRelayList.forEach((deviceRelateRelay) => {
const deviceCiCjConfig = ciCjMap.get( let deviceCiCjConfig;
`${deviceRelateRelay.deviceType}+${allDeviceModelMap.get( if (deviceRelateRelay.deviceType !== DeviceType.CarWashing) {
`${deviceRelateRelay.deviceType}+${deviceRelateRelay.code}` deviceCiCjConfig = ciCjMap.get(
)}` `${deviceRelateRelay.deviceType}+${allDeviceModelMap.get(
); `${deviceRelateRelay.deviceType}+${deviceRelateRelay.code}`
let copyDeviceCiCjConfig: CjData[] = JSON.parse( )}`
JSON.stringify(deviceCiCjConfig) );
); } else {
deviceCiCjConfig = ciCjMap.get(
`${deviceRelateRelay.deviceType}+undefined`
);
}
let copyDeviceCiCjConfig: CjData[] =
deviceCiCjConfig === undefined
? undefined
: JSON.parse(JSON.stringify(deviceCiCjConfig));
//EMP //EMP
if ( if (
deviceRelateRelay.deviceType == DeviceType.station && deviceRelateRelay.deviceType == DeviceType.station &&
@ -870,6 +893,37 @@ function oneClickGeneraterRelayLayout() {
} }
copyDeviceCiCjConfig = handleCopyDeviceCiCjConfig; copyDeviceCiCjConfig = handleCopyDeviceCiCjConfig;
} }
//
if (
deviceRelateRelay.deviceType == DeviceType.CarWashing &&
deviceCiCjConfig
) {
const duanNum = allDeviceModelMap.get(
`${deviceRelateRelay.deviceType}+${deviceRelateRelay.code}`
) as string;
for (let i = 2; i <= +duanNum; i++) {
copyDeviceCiCjConfig[0].refDeviceCodesAndPos.push([
{
code: `TWJ${i}`,
position: PostionType.Q,
},
]);
copyDeviceCiCjConfig[1].refDeviceCodesAndPos.push(
[
{
code: `CFJ${i}`,
position: PostionType.Q,
},
],
[
{
code: `CFJ${i}`,
position: PostionType.H,
},
]
);
}
}
copyDeviceCiCjConfig?.forEach((combinationtype) => { copyDeviceCiCjConfig?.forEach((combinationtype) => {
combinationtype.refDeviceCodesAndPos.forEach((items) => { combinationtype.refDeviceCodesAndPos.forEach((items) => {
const cjData: relayCabinetGraphicData.CjDataItem[] = []; const cjData: relayCabinetGraphicData.CjDataItem[] = [];
@ -898,12 +952,35 @@ function oneClickGeneraterRelayLayout() {
// //
const allQdData: relayCabinetGraphicData.QdData[] = []; const allQdData: relayCabinetGraphicData.QdData[] = [];
deviceRelateRelayList.forEach((deviceRelateRelay) => { deviceRelateRelayList.forEach((deviceRelateRelay) => {
const deviceCiQdConfig = ciQdMap.get( let deviceCiQdConfig: QdData[] | undefined;
`${deviceRelateRelay.deviceType}+${allDeviceModelMap.get( let changeDeviceCiQdConfig: QdData[];
if (deviceRelateRelay.deviceType !== DeviceType.CarWashing) {
deviceCiQdConfig = ciQdMap.get(
`${deviceRelateRelay.deviceType}+${allDeviceModelMap.get(
`${deviceRelateRelay.deviceType}+${deviceRelateRelay.code}`
)}`
);
changeDeviceCiQdConfig =
deviceCiQdConfig === undefined
? undefined
: JSON.parse(JSON.stringify(deviceCiQdConfig));
} else {
deviceCiQdConfig = ciQdMap.get(
`${deviceRelateRelay.deviceType}+undefined`
);
changeDeviceCiQdConfig =
deviceCiQdConfig === undefined
? undefined
: JSON.parse(JSON.stringify(deviceCiQdConfig));
const duanNum = allDeviceModelMap.get(
`${deviceRelateRelay.deviceType}+${deviceRelateRelay.code}` `${deviceRelateRelay.deviceType}+${deviceRelateRelay.code}`
)}` ) as string;
); for (let i = 2; i <= +duanNum; i++) {
deviceCiQdConfig?.forEach((combinationtype) => { changeDeviceCiQdConfig[0].refDeviceCodes.push([`TWJ${i}`]);
}
}
changeDeviceCiQdConfig?.forEach((combinationtype) => {
combinationtype.refDeviceCodes.forEach((items) => { combinationtype.refDeviceCodes.forEach((items) => {
const qdData: number[] = []; const qdData: number[] = [];
items.forEach((relayCode) => { items.forEach((relayCode) => {