区段运行方向生成逻辑修改
This commit is contained in:
parent
637616e30f
commit
0d97067e0b
@ -1 +1 @@
|
||||
Subproject commit 117442931af0643cf4a01e24c74301167e1425f0
|
||||
Subproject commit 89944562247f061937fde4c8a67285f64c55aefa
|
@ -20,8 +20,8 @@ const sectionCode = computed(() => {
|
||||
const formRef = ref<InstanceType<typeof QForm> | null>(null);
|
||||
const direction = ref(0);
|
||||
const directionOptions = [
|
||||
{ label: 'A端方向', value: graphicData.Section.RunningDirection.A },
|
||||
{ label: 'B端方向', value: graphicData.Section.RunningDirection.B },
|
||||
{ label: 'A到B', value: graphicData.Section.RunningDirection.AtoB },
|
||||
{ label: 'B到A', value: graphicData.Section.RunningDirection.BtoA },
|
||||
];
|
||||
|
||||
async function onSubmit() {
|
||||
@ -36,6 +36,11 @@ async function onSubmit() {
|
||||
direction: graphicData.Section.RunningDirection;
|
||||
}[] = [{ node: section, direction: direction.value }];
|
||||
|
||||
const reverseDirection = (d: graphicData.Section.RunningDirection) =>
|
||||
d === graphicData.Section.RunningDirection.AtoB
|
||||
? graphicData.Section.RunningDirection.BtoA
|
||||
: graphicData.Section.RunningDirection.AtoB;
|
||||
|
||||
const traverse = (
|
||||
current: Section | Turnout,
|
||||
direction: graphicData.Section.RunningDirection
|
||||
@ -43,72 +48,63 @@ async function onSubmit() {
|
||||
if (visited.includes(current.datas.id)) return;
|
||||
visited.push(current.datas.id);
|
||||
if (current instanceof Section) {
|
||||
if (current.datas.paRef) {
|
||||
queue.push({
|
||||
node: current.queryStore.queryById<Section | Turnout>(
|
||||
current.datas.paRef.id
|
||||
),
|
||||
direction,
|
||||
[
|
||||
[current.datas.paRef?.id, 'A'],
|
||||
[current.datas.pbRef?.id, 'B'],
|
||||
]
|
||||
.filter((item): item is [string, 'A' | 'B'] => !!item[0])
|
||||
.forEach(([id, port], idx) => {
|
||||
const target = current.queryStore.queryById<Section | Turnout>(id);
|
||||
if (target instanceof Turnout) {
|
||||
queue.push({
|
||||
node: target,
|
||||
direction,
|
||||
});
|
||||
} else {
|
||||
const isPortDiffrent =
|
||||
(port === 'B' && target.datas.paRef?.id === current.datas.id) ||
|
||||
(port === 'A' && target.datas.pbRef?.id === current.datas.id);
|
||||
queue.push({
|
||||
node: target,
|
||||
direction: isPortDiffrent
|
||||
? direction
|
||||
: reverseDirection(direction),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (current.datas.pbRef) {
|
||||
queue.push({
|
||||
node: current.queryStore.queryById<Section | Turnout>(
|
||||
current.datas.pbRef.id
|
||||
),
|
||||
direction,
|
||||
});
|
||||
}
|
||||
const data = current.datas.clone();
|
||||
data.normalRunningDirection = direction;
|
||||
current.updateData(data);
|
||||
} else {
|
||||
if (current.datas.paRef) {
|
||||
queue.push({
|
||||
node: current.queryStore.queryById<Section | Turnout>(
|
||||
current.datas.paRef.id
|
||||
),
|
||||
direction,
|
||||
[
|
||||
current.datas.paRef?.id,
|
||||
current.datas.pbRef?.id,
|
||||
current.datas.pcRef?.id,
|
||||
]
|
||||
.filter((id): id is string => !!id)
|
||||
.forEach((id, idx) => {
|
||||
const target = current.queryStore.queryById<Section | Turnout>(id);
|
||||
if (
|
||||
target instanceof Turnout &&
|
||||
target.datas.pcRef?.id === current.datas.id &&
|
||||
idx === 2
|
||||
) {
|
||||
queue.push({
|
||||
node: target,
|
||||
direction: reverseDirection(direction),
|
||||
});
|
||||
} else {
|
||||
queue.push({
|
||||
node: target,
|
||||
direction,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (current.datas.pbRef) {
|
||||
queue.push({
|
||||
node: current.queryStore.queryById<Section | Turnout>(
|
||||
current.datas.pbRef.id
|
||||
),
|
||||
direction,
|
||||
});
|
||||
}
|
||||
if (current.datas.pcRef) {
|
||||
const target = current.queryStore.queryById<Section | Turnout>(
|
||||
current.datas.pcRef.id
|
||||
);
|
||||
if (
|
||||
target instanceof Turnout &&
|
||||
target.datas.pcRef?.id === current.datas.id
|
||||
) {
|
||||
queue.push({
|
||||
node: target,
|
||||
direction:
|
||||
direction === graphicData.Section.RunningDirection.A
|
||||
? graphicData.Section.RunningDirection.B
|
||||
: graphicData.Section.RunningDirection.A,
|
||||
});
|
||||
} else {
|
||||
queue.push({
|
||||
node: target,
|
||||
direction,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
do {
|
||||
const { node, direction } = queue.shift()!;
|
||||
console.log(
|
||||
...queue.map(({ node, direction }) => [node.datas.code, direction])
|
||||
);
|
||||
traverse(node, direction);
|
||||
} while (queue.length > 0);
|
||||
}
|
||||
|
@ -151,19 +151,12 @@ const sectionTypeText = computed(() => {
|
||||
|
||||
const runningDirectionOptions = computed(() => [
|
||||
{
|
||||
label: 'A',
|
||||
value: graphicData.Section.RunningDirection.A,
|
||||
label: 'A到B',
|
||||
value: graphicData.Section.RunningDirection.AtoB,
|
||||
},
|
||||
{
|
||||
label: 'B',
|
||||
value: graphicData.Section.RunningDirection.B,
|
||||
},
|
||||
{
|
||||
label: 'C',
|
||||
value: graphicData.Section.RunningDirection.C,
|
||||
disable:
|
||||
sectionModel.sectionType !==
|
||||
graphicData.Section.SectionType.TurnoutPhysical,
|
||||
label: 'B到A',
|
||||
value: graphicData.Section.RunningDirection.BtoA,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -125,12 +125,12 @@ export class Section extends JlGraphic implements ILineGraphic {
|
||||
if (location.pathname.includes('painting')) {
|
||||
if (
|
||||
this.datas.normalRunningDirection ===
|
||||
graphicData.Section.RunningDirection.A
|
||||
graphicData.Section.RunningDirection.BtoA
|
||||
) {
|
||||
this.lineGraphic.lineStyle(SectionConsts.lineWidth, '#f00');
|
||||
} else if (
|
||||
this.datas.normalRunningDirection ===
|
||||
graphicData.Section.RunningDirection.B
|
||||
graphicData.Section.RunningDirection.AtoB
|
||||
) {
|
||||
this.lineGraphic.lineStyle(SectionConsts.lineWidth, '#0f0');
|
||||
}
|
||||
|
@ -3976,7 +3976,7 @@ export namespace graphicData {
|
||||
pb_1.Message.setField(this, 13, value);
|
||||
}
|
||||
get normalRunningDirection() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 14, Section.RunningDirection.A) as Section.RunningDirection;
|
||||
return pb_1.Message.getFieldWithDefault(this, 14, Section.RunningDirection.AtoB) as Section.RunningDirection;
|
||||
}
|
||||
set normalRunningDirection(value: Section.RunningDirection) {
|
||||
pb_1.Message.setField(this, 14, value);
|
||||
@ -4127,7 +4127,7 @@ export namespace graphicData {
|
||||
writer.writeInt32(12, this.segmentsCount);
|
||||
if (this.centralizedStations.length)
|
||||
writer.writeRepeatedString(13, this.centralizedStations);
|
||||
if (this.normalRunningDirection != Section.RunningDirection.A)
|
||||
if (this.normalRunningDirection != Section.RunningDirection.AtoB)
|
||||
writer.writeEnum(14, this.normalRunningDirection);
|
||||
if (this.isTurnBackZone != false)
|
||||
writer.writeBool(15, this.isTurnBackZone);
|
||||
@ -4197,9 +4197,8 @@ export namespace graphicData {
|
||||
TurnoutPhysical = 2
|
||||
}
|
||||
export enum RunningDirection {
|
||||
A = 0,
|
||||
B = 1,
|
||||
C = 2
|
||||
AtoB = 0,
|
||||
BtoA = 1
|
||||
}
|
||||
}
|
||||
export class RelatedRef extends pb_1.Message {
|
||||
|
Loading…
Reference in New Issue
Block a user