diff --git a/src/api/Simulation.ts b/src/api/Simulation.ts index e8f54c0..4a89350 100644 --- a/src/api/Simulation.ts +++ b/src/api/Simulation.ts @@ -23,6 +23,7 @@ export async function destroySimulation(data: { simulationId: string }) { /** * 添加列车 * @param simulationId 仿真id + * @param mapId 发布图id * @param up 是否上行 * @param id 区段或者道岔的索引 * @param devicePort 道岔的端口 @@ -31,6 +32,7 @@ export async function destroySimulation(data: { simulationId: string }) { */ export async function addTrain(data: { simulationId: string; + mapId: number; up: boolean; id: string; devicePort?: string; @@ -47,6 +49,7 @@ export async function addTrain(data: { */ export async function removeTrain(data: { simulationId: string; + mapId: number; trainId: string; }) { const response = await api.post(`${UriBase}/train/remove`, data); @@ -55,6 +58,7 @@ export async function removeTrain(data: { export async function setSwitchPosition(data: { simulationId: string; + mapId: number; switchIndex: string; turnNormal: boolean; turnReverse: boolean; diff --git a/src/components/line-app/states/TurnoutState.vue b/src/components/line-app/states/TurnoutState.vue index d266d7a..dfb33ef 100644 --- a/src/components/line-app/states/TurnoutState.vue +++ b/src/components/line-app/states/TurnoutState.vue @@ -83,6 +83,7 @@ function submitState() { if (lineStore.simulationId) { setSwitchPosition({ simulationId: lineStore.simulationId, + mapId: lineStore.mapId as number, switchIndex: turnoutState.value.index + '', turnNormal: turnoutState.value.normal, turnReverse: turnoutState.value.reverse, diff --git a/src/drawApp/graphics/SectionInteraction.ts b/src/drawApp/graphics/SectionInteraction.ts index f6cdce9..40de6b3 100644 --- a/src/drawApp/graphics/SectionInteraction.ts +++ b/src/drawApp/graphics/SectionInteraction.ts @@ -170,6 +170,7 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin
if (!section) return; this.app.updateSelected(section); const simulationId = useLineStore().simulationId || ''; + const mapId = useLineStore().mapId as number; addTrainConfig.handler = () => { const relations = section.relationManage.getRelationsOfGraphicAndOtherType( @@ -201,6 +202,7 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => { const params = { simulationId, + mapId, up: !!data.dir, id: section.datas.index + '', headOffset: data.offset, diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index df42dce..caeac06 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -174,9 +174,11 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin { this.app.updateSelected(train); const lineStore = useLineStore(); const simulationId = lineStore.simulationId || ''; + const mapId = lineStore.mapId as number; removeTrainConfig.handler = () => { removeTrain({ simulationId, + mapId, trainId: train.code, }) .then(() => { diff --git a/src/drawApp/graphics/TurnoutInteraction.ts b/src/drawApp/graphics/TurnoutInteraction.ts index b48fcb1..4b3e418 100644 --- a/src/drawApp/graphics/TurnoutInteraction.ts +++ b/src/drawApp/graphics/TurnoutInteraction.ts @@ -92,9 +92,11 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { if (!turnout) return; this.app.updateSelected(turnout); const simulationId = useLineStore().simulationId || ''; + const mapId = useLineStore().mapId as number; const setPosition = async (normal: boolean) => { setSwitchPosition({ simulationId, + mapId, switchIndex: turnout.datas.index + '', turnNormal: normal, turnReverse: !normal, @@ -150,6 +152,7 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { }).onOk((data: { offset: number; dir: 1 | 0 }) => { addTrain({ simulationId, + mapId, up: !!data.dir, id: turnout.datas.index + '', devicePort: port, diff --git a/src/drawApp/lineScene.ts b/src/drawApp/lineScene.ts index 7ac154e..fb0dd42 100644 --- a/src/drawApp/lineScene.ts +++ b/src/drawApp/lineScene.ts @@ -229,6 +229,7 @@ export function initLineScene(lineApp: IGraphicApp) { function handleSubscribe(lineScene: IGraphicScene, lineApp: IGraphicApp) { const lineStore = useLineStore(); const simulationId = lineStore.simulationId; + const mapId = lineStore.mapId; const app = lineScene; lineApp?.enableWsMassaging({ @@ -238,7 +239,7 @@ function handleSubscribe(lineScene: IGraphicScene, lineApp: IGraphicApp) { }); app.subscribe({ // destination: `/simulation/${simulationId}/devices/status`, - destination: `simulation-${simulationId}-devices-status`, + destination: `simulation-${simulationId}_${mapId}-devices-status`, messageConverter: (message: Uint8Array) => { // console.log('收到消息', message); const states: GraphicState[] = [];