一键关联集中站

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

View File

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

View File

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

View File

@ -139,7 +139,7 @@ onMounted(() => {
.queryStore.queryByType<Station>(Station.Type); .queryStore.queryByType<Station>(Station.Type);
centralizedStations.value = [{ label: '', value: 0 }]; centralizedStations.value = [{ label: '', value: 0 }];
stations.forEach((station) => { stations.forEach((station) => {
if (station.datas.concentrationStations) { if (station.datas.concentrationStations || station.datas.depots) {
centralizedStations.value.push({ centralizedStations.value.push({
label: station.datas.name, label: station.datas.name,
value: station.datas.id, 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 { SectionData } from 'src/drawApp/graphics/SectionInteraction';
import { SignalData } from 'src/drawApp/graphics/SignalInteraction'; import { SignalData } from 'src/drawApp/graphics/SignalInteraction';
import { Signal } from '../signal/Signal'; import { Signal } from '../signal/Signal';
import { Platform } from '../platform/Platform';
import { PlatformData } from 'src/drawApp/graphics/PlatformInteraction';
//判断线段与线段有木有交点 //判断线段与线段有木有交点
export function isSegmentsIntersect( export function isSegmentsIntersect(
@ -155,22 +157,23 @@ export function findContainDevice(
export function handleCentralizedStationsData( export function handleCentralizedStationsData(
devices: JlGraphic[], devices: JlGraphic[],
centralizedStations: number[] centralizedStation: number
) { ) {
interface GraphicData { interface GraphicData {
centralizedStations: number[]; centralizedStation: number;
} }
const dataMap = new Map<string, GraphicDataBase>([ const dataMap = new Map<string, GraphicDataBase>([
[Turnout.Type, new TurnoutData()], [Turnout.Type, new TurnoutData()],
[Section.Type, new SectionData()], [Section.Type, new SectionData()],
[Signal.Type, new SignalData()], [Signal.Type, new SignalData()],
[Platform.Type, new PlatformData()],
]); ]);
devices.forEach((device) => { devices.forEach((device) => {
const data = dataMap.get(device.type); const data = dataMap.get(device.type);
if (data) { if (data) {
data.copyFrom(device.saveData()); data.copyFrom(device.saveData());
const dataCopy = data as GraphicDataBase & GraphicData; const dataCopy = data as GraphicDataBase & GraphicData;
dataCopy.centralizedStations = centralizedStations; dataCopy.centralizedStation = centralizedStation;
device.updateData(data); device.updateData(data);
} }
}); });

View File

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