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