refactor: 更新库位名称为关联库位,调整相关接口和组件以支持新字段
This commit is contained in:
parent
c3181d4d37
commit
3fdd2db521
@ -28,7 +28,7 @@ export interface MapPointInfo {
|
|||||||
actions?: Array<string>; // 绑定动作点id集合
|
actions?: Array<string>; // 绑定动作点id集合
|
||||||
isBlock?: boolean; // 是否禁行
|
isBlock?: boolean; // 是否禁行
|
||||||
isForbidAvoid?: boolean; // 是否禁止避让
|
isForbidAvoid?: boolean; // 是否禁止避让
|
||||||
locationNames?: string[]; // 库位名称
|
associatedStorageLocations?: string[]; // 库位名称
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -49,6 +49,7 @@ export interface MapAreaInfo {
|
|||||||
routes?: Array<string>; // 绑定线路id集合
|
routes?: Array<string>; // 绑定线路id集合
|
||||||
maxAmr?: number; // 最大可容纳AMR数
|
maxAmr?: number; // 最大可容纳AMR数
|
||||||
inoutflag?: 1 | 2; // 库区规则
|
inoutflag?: 1 | 2; // 库区规则
|
||||||
|
storageLocations?: Record<string, string[]>; // 动作点ID对应的库位信息(内部使用)
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export interface StandardScenePoint {
|
|||||||
type: number; // 点位类型
|
type: number; // 点位类型
|
||||||
robots?: Array<string>; // 绑定机器人id集合
|
robots?: Array<string>; // 绑定机器人id集合
|
||||||
actions?: Array<string>; // 绑定动作点id集合
|
actions?: Array<string>; // 绑定动作点id集合
|
||||||
locationNames?: string[]; // 库位名称
|
associatedStorageLocations?: string[]; // 库位名称
|
||||||
config?: object; // 其它属性配置(可按需增加)
|
config?: object; // 其它属性配置(可按需增加)
|
||||||
properties?: unknown; // 附加数据(前端不做任何处理)
|
properties?: unknown; // 附加数据(前端不做任何处理)
|
||||||
}
|
}
|
||||||
@ -69,6 +69,7 @@ export interface StandardSceneArea {
|
|||||||
routes?: Array<string>; // 绑定线路id集合
|
routes?: Array<string>; // 绑定线路id集合
|
||||||
maxAmr?: number; // 最大可容纳AMR数
|
maxAmr?: number; // 最大可容纳AMR数
|
||||||
inoutflag?: 1 | 2; // 库区规则
|
inoutflag?: 1 | 2; // 库区规则
|
||||||
|
storageLocations?: Record<string, string[]>; // 动作点对应的库位信息
|
||||||
config?: object; // 其它属性配置(可按需增加)
|
config?: object; // 其它属性配置(可按需增加)
|
||||||
properties?: unknown; // 附加数据(前端不做任何处理)
|
properties?: unknown; // 附加数据(前端不做任何处理)
|
||||||
}
|
}
|
||||||
|
@ -101,10 +101,10 @@ const storageStatus = computed<string>(() => {
|
|||||||
<a-typography-text>{{ coArea1 || $t('暂无') }}</a-typography-text>
|
<a-typography-text>{{ coArea1 || $t('暂无') }}</a-typography-text>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
<a-list-item v-if="MapPointType.动作点 === point.type && point.locationNames?.length">
|
<a-list-item v-if="MapPointType.动作点 === point.type && point.associatedStorageLocations?.length">
|
||||||
<a-flex :gap="8" vertical>
|
<a-flex :gap="8" vertical>
|
||||||
<a-typography-text type="secondary">{{ $t('库位') }}</a-typography-text>
|
<a-typography-text type="secondary">{{ $t('库位') }}</a-typography-text>
|
||||||
<a-typography-text>{{ point.locationNames.join('、') }}</a-typography-text>
|
<a-typography-text>{{ point.associatedStorageLocations.join('、') }}</a-typography-text>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
<a-list-item
|
<a-list-item
|
||||||
|
@ -60,19 +60,19 @@ const coArea2 = computed<MapPen[]>(() => editor.value.getBoundAreas(props.id, 'p
|
|||||||
|
|
||||||
function onAddLocation() {
|
function onAddLocation() {
|
||||||
const p = point.value!;
|
const p = point.value!;
|
||||||
if (!p.locationNames) p.locationNames = [];
|
if (!p.associatedStorageLocations) p.associatedStorageLocations = [];
|
||||||
p.locationNames.push('');
|
p.associatedStorageLocations.push('');
|
||||||
editor.value.updatePen(props.id!, { point: { ...p } }, false);
|
editor.value.updatePen(props.id!, { point: { ...p } }, false);
|
||||||
}
|
}
|
||||||
function onRemoveLocation(i: number) {
|
function onRemoveLocation(i: number) {
|
||||||
const p = point.value!;
|
const p = point.value!;
|
||||||
p.locationNames?.splice(i, 1);
|
p.associatedStorageLocations?.splice(i, 1);
|
||||||
editor.value.updatePen(props.id!, { point: { ...p } }, false);
|
editor.value.updatePen(props.id!, { point: { ...p } }, false);
|
||||||
}
|
}
|
||||||
function onChangeLocation(i: number, v: string) {
|
function onChangeLocation(i: number, v: string) {
|
||||||
const p = point.value!;
|
const p = point.value!;
|
||||||
if (p.locationNames) {
|
if (p.associatedStorageLocations) {
|
||||||
p.locationNames[i] = v;
|
p.associatedStorageLocations[i] = v;
|
||||||
editor.value.updatePen(props.id!, { point: { ...p } }, false);
|
editor.value.updatePen(props.id!, { point: { ...p } }, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ function onChangeLocation(i: number, v: string) {
|
|||||||
|
|
||||||
<a-collapse-panel v-if="MapPointType.动作点 === point.type" :header="$t('库位')">
|
<a-collapse-panel v-if="MapPointType.动作点 === point.type" :header="$t('库位')">
|
||||||
<a-flex vertical :gap="8">
|
<a-flex vertical :gap="8">
|
||||||
<a-flex v-for="(l, i) in point.locationNames" :key="i" :gap="8" align="center">
|
<a-flex v-for="(l, i) in point.associatedStorageLocations" :key="i" :gap="8" align="center">
|
||||||
<a-input
|
<a-input
|
||||||
style="flex: 1"
|
style="flex: 1"
|
||||||
:value="l"
|
:value="l"
|
||||||
|
@ -153,10 +153,35 @@ export class EditorService extends Meta2d {
|
|||||||
if (!areas?.length) return;
|
if (!areas?.length) return;
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
areas.map(async (v) => {
|
areas.map(async (v) => {
|
||||||
const { id, name, desc, x, y, w, h, type, points, routes, maxAmr, inoutflag, properties } = v;
|
const { id, name, desc, x, y, w, h, type, points, routes, maxAmr, inoutflag, storageLocations, properties } = v;
|
||||||
await this.addArea({ x, y }, { x: x + w, y: y + h }, type, id);
|
await this.addArea({ x, y }, { x: x + w, y: y + h }, type, id);
|
||||||
|
|
||||||
|
// 对于库区类型,需要将点位名称数组转换为点位ID数组,并更新动作点的库位信息
|
||||||
|
let processedPoints = points;
|
||||||
|
if (type === MapAreaType.库区 && points?.length) {
|
||||||
|
// 将点位名称数组转换为点位ID数组
|
||||||
|
const actionPoints = this.find('point').filter(
|
||||||
|
(pen: MapPen) => pen.point?.type === MapPointType.动作点 && points.includes(pen.label || pen.id!),
|
||||||
|
);
|
||||||
|
|
||||||
|
processedPoints = actionPoints.map((pen) => pen.id!);
|
||||||
|
|
||||||
|
// 如果有storageLocations数据,更新对应动作点的库位信息
|
||||||
|
if (storageLocations) {
|
||||||
|
actionPoints.forEach((pen) => {
|
||||||
|
const pointName = pen.label || pen.id!;
|
||||||
|
if (storageLocations[pointName]) {
|
||||||
|
this.setValue(
|
||||||
|
{ id: pen.id, point: { ...pen.point, associatedStorageLocations: storageLocations[pointName] } },
|
||||||
|
{ render: false, history: false, doEvent: false },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.setValue(
|
this.setValue(
|
||||||
{ id, label: name, desc, properties, area: { type, points, routes, maxAmr, inoutflag } },
|
{ id, label: name, desc, properties, area: { type, points: processedPoints, routes, maxAmr, inoutflag } },
|
||||||
{ render: false, history: false, doEvent: false },
|
{ render: false, history: false, doEvent: false },
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -166,7 +191,7 @@ export class EditorService extends Meta2d {
|
|||||||
#mapScenePoint(pen?: MapPen): StandardScenePoint | null {
|
#mapScenePoint(pen?: MapPen): StandardScenePoint | null {
|
||||||
if (!pen?.id || isEmpty(pen?.point)) return null;
|
if (!pen?.id || isEmpty(pen?.point)) return null;
|
||||||
const { id, label, desc, properties } = pen;
|
const { id, label, desc, properties } = pen;
|
||||||
const { type, robots, actions, locationNames } = pen.point;
|
const { type, robots, actions, associatedStorageLocations } = pen.point;
|
||||||
const { x = 0, y = 0 } = this.getPointRect(pen) ?? {};
|
const { x = 0, y = 0 } = this.getPointRect(pen) ?? {};
|
||||||
|
|
||||||
// 进行坐标转换:左上角原点 -> 中心点原点,同时应用ratio缩放
|
// 进行坐标转换:左上角原点 -> 中心点原点,同时应用ratio缩放
|
||||||
@ -189,7 +214,7 @@ export class EditorService extends Meta2d {
|
|||||||
point.actions = actions?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.动作点);
|
point.actions = actions?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.动作点);
|
||||||
}
|
}
|
||||||
if (MapPointType.动作点 === type) {
|
if (MapPointType.动作点 === type) {
|
||||||
point.locationNames = locationNames;
|
point.associatedStorageLocations = associatedStorageLocations;
|
||||||
}
|
}
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
@ -255,7 +280,22 @@ export class EditorService extends Meta2d {
|
|||||||
area.maxAmr = maxAmr;
|
area.maxAmr = maxAmr;
|
||||||
}
|
}
|
||||||
if (MapAreaType.库区 === type) {
|
if (MapAreaType.库区 === type) {
|
||||||
area.points = points?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.动作点);
|
// 获取库区内的动作点
|
||||||
|
const actionPoints =
|
||||||
|
points
|
||||||
|
?.map((id) => this.getPenById(id))
|
||||||
|
.filter((pen): pen is MapPen => !!pen && pen.point?.type === MapPointType.动作点) ?? [];
|
||||||
|
|
||||||
|
// 保存动作点名称
|
||||||
|
area.points = actionPoints.map((pen) => pen.label || pen.id!);
|
||||||
|
|
||||||
|
// 构建storageLocations映射:动作点名称 -> 库位列表
|
||||||
|
area.storageLocations = {};
|
||||||
|
actionPoints.forEach((pen) => {
|
||||||
|
const pointName = pen.label || pen.id!;
|
||||||
|
area.storageLocations![pointName] = pen.point?.associatedStorageLocations ?? [];
|
||||||
|
});
|
||||||
|
|
||||||
area.inoutflag = inoutflag;
|
area.inoutflag = inoutflag;
|
||||||
}
|
}
|
||||||
if ([MapAreaType.互斥区, MapAreaType.非互斥区, MapAreaType.约束区].includes(type)) {
|
if ([MapAreaType.互斥区, MapAreaType.非互斥区, MapAreaType.约束区].includes(type)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user