一键关联集中站

This commit is contained in:
joylink_zhaoerwei 2023-12-21 15:50:06 +08:00
parent c06a9d7e85
commit 693e1de289
6 changed files with 44 additions and 27 deletions

View File

@ -125,7 +125,7 @@ onMounted(() => {
.queryStore.queryByType<Station>(Station.Type);
centralizedStations.value = [{ label: '', value: 0 }];
stations.forEach((station) => {
if (station.datas.concentrationStations) {
if (station.datas.concentrationStations || station.datas.depots) {
centralizedStations.value.push({
label: station.datas.name,
value: station.datas.id,

View File

@ -156,7 +156,7 @@ onMounted(() => {
.queryStore.queryByType<Station>(Station.Type);
centralizedStations.value = [{ label: '', value: 0 }];
stations.forEach((station) => {
if (station.datas.concentrationStations) {
if (station.datas.concentrationStations || station.datas.depots) {
centralizedStations.value.push({
label: station.datas.name,
value: station.datas.id,

View File

@ -120,7 +120,7 @@ onMounted(() => {
.queryStore.queryByType<Station>(Station.Type);
centralizedStations.value = [{ label: '', value: 0 }];
stations.forEach((station) => {
if (station.datas.concentrationStations) {
if (station.datas.concentrationStations || station.datas.depots) {
centralizedStations.value.push({
label: station.datas.name,
value: station.datas.id,

View File

@ -139,7 +139,7 @@ onMounted(() => {
.queryStore.queryByType<Station>(Station.Type);
centralizedStations.value = [{ label: '', value: 0 }];
stations.forEach((station) => {
if (station.datas.concentrationStations) {
if (station.datas.concentrationStations || station.datas.depots) {
centralizedStations.value.push({
label: station.datas.name,
value: station.datas.id,

View File

@ -8,6 +8,8 @@ import { TurnoutData } from 'src/drawApp/graphics/TurnoutInteraction';
import { SectionData } from 'src/drawApp/graphics/SectionInteraction';
import { SignalData } from 'src/drawApp/graphics/SignalInteraction';
import { Signal } from '../signal/Signal';
import { Platform } from '../platform/Platform';
import { PlatformData } from 'src/drawApp/graphics/PlatformInteraction';
//判断线段与线段有木有交点
export function isSegmentsIntersect(
@ -155,22 +157,23 @@ export function findContainDevice(
export function handleCentralizedStationsData(
devices: JlGraphic[],
centralizedStations: number[]
centralizedStation: number
) {
interface GraphicData {
centralizedStations: number[];
centralizedStation: number;
}
const dataMap = new Map<string, GraphicDataBase>([
[Turnout.Type, new TurnoutData()],
[Section.Type, new SectionData()],
[Signal.Type, new SignalData()],
[Platform.Type, new PlatformData()],
]);
devices.forEach((device) => {
const data = dataMap.get(device.type);
if (data) {
data.copyFrom(device.saveData());
const dataCopy = data as GraphicDataBase & GraphicData;
dataCopy.centralizedStations = centralizedStations;
dataCopy.centralizedStation = centralizedStation;
device.updateData(data);
}
});

View File

@ -246,10 +246,10 @@ const leftMenuConfig = [
{ label: '一键生成分隔符', click: oneClickSeparator },
{ label: '一键生成计轴', click: oneClickAxleCounting },
{ label: '一键生成道岔区段', click: oneClickTurnoutSection },
/* {
{
label: '一键关联设备所属的集中站',
click: oneClickRelateCentralizedStation,
}, */
},
];
onMounted(() => {
@ -343,7 +343,6 @@ function saveAllDrawDatas() {
function buildRelations() {
const app = getDrawApp();
app?.detectRelations();
console.log(app);
}
function oneClickGeneration() {
@ -372,7 +371,7 @@ function oneClickTurnoutSection() {
SDA.generateTurnoutSection();
}
/* function oneClickRelateCentralizedStation() {
function oneClickRelateCentralizedStation() {
const drawApp = drawStore.getDrawApp();
const concentrationDividingLines = drawApp.queryStore
.queryByType<ConcentrationDividingLine>(ConcentrationDividingLine.Type)
@ -427,10 +426,10 @@ function oneClickTurnoutSection() {
containDeviceIds = Array.from(new Set(containDeviceIds));
});
if (rightDatas.refRightStationId) {
handleContainDevices(containDeviceIds, [rightDatas.refRightStationId]);
handleContainDevices(containDeviceIds, rightDatas.refRightStationId);
}
}
//
//
const leftBoundary = concentrationDividingLines[0];
handleLeftBoundary(leftBoundary);
const rightBoundary =
@ -485,7 +484,7 @@ function oneClickTurnoutSection() {
function handleContainDevices(
containDeviceIds: number[],
centralizedStations: number
centralizedStation: number
) {
const containDevices = containDeviceIds.map((id) => {
return drawApp.queryStore.queryById(id);
@ -495,13 +494,26 @@ function oneClickTurnoutSection() {
.filter((g) =>
containDeviceIds.includes(g.datas.refDevice?.id as number)
);
const allSetCentralizedStationsDevice = [...containDevices, ...signals];
let platforms: Platform[] = [];
if (centralizedStation !== 0) {
const station = drawApp.queryStore.queryById<Station>(centralizedStation);
platforms = drawApp.queryStore
.queryByType<Platform>(Platform.Type)
.filter((g) =>
station.datas.manageStations.includes(g.datas.refStation)
);
}
const allSetCentralizedStationsDevice = [
...containDevices,
...signals,
...platforms,
];
allSetCentralizedStationsDevice.forEach(
(g) => ((g as Signal).datas.centralizedStation = [])
(g) => ((g as Signal).datas.centralizedStation = 0)
);
handleCentralizedStationsData(
allSetCentralizedStationsDevice,
centralizedStations
centralizedStation
);
}
function handleLeftBoundary(leftBoundary: ConcentrationDividingLine) {
@ -529,11 +541,12 @@ function oneClickTurnoutSection() {
containDeviceIds = Array.from(new Set(containDeviceIds));
});
if (!leftBoundary.datas.refLeftStationId) {
handleContainDevices(containDeviceIds, []);
handleContainDevices(containDeviceIds, 0);
} else {
handleContainDevices(containDeviceIds, [
leftBoundary.datas.refLeftStationId,
]);
handleContainDevices(
containDeviceIds,
leftBoundary.datas.refLeftStationId
);
}
}
function handleRightBoundary(rightBoundary: ConcentrationDividingLine) {
@ -560,15 +573,16 @@ function oneClickTurnoutSection() {
);
containDeviceIds = Array.from(new Set(containDeviceIds));
});
if (rightBoundary.datas.refRightStationId) {
handleContainDevices(containDeviceIds, []);
if (!rightBoundary.datas.refRightStationId) {
handleContainDevices(containDeviceIds, 0);
} else {
handleContainDevices(containDeviceIds, [
rightBoundary.datas.refRightStationId,
]);
handleContainDevices(
containDeviceIds,
rightBoundary.datas.refRightStationId
);
}
}
}
} */
function backConfirm() {
router.go(-1);