feat: 更新标准场景接口,添加扩展类型和库位信息支持,调整编辑器服务以处理新的库位数组格式

This commit is contained in:
xudan 2025-07-16 18:52:26 +08:00
parent 9a1cd82a26
commit 914d3a0ed0
3 changed files with 26 additions and 10 deletions

View File

@ -322,8 +322,10 @@ interface StandardScenePoint {
x: number;
y: number;
type: number; // 点位类型
extensionType?: number; // 扩展类型
robots?: Array<string>; // 绑定机器人id集合
actions?: Array<string>; // 绑定动作点id集合
associatedStorageLocations?: string[]; // 库位名称
config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理)
}
@ -350,6 +352,9 @@ interface StandardSceneArea {
type: number; // 区域类型
points?: Array<string>; // 绑定点位id集合
routes?: Array<string>; // 绑定线路id集合
maxAmr?: number; // 最大可容纳AMR数
inoutflag?: 1 | 2; // 库区规则
storageLocations?: Array<Record<string, string[]>>; // 动作点对应的库位信息,格式为 [{动作点名称: [库位列表]}]
config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理)
}

View File

@ -70,7 +70,7 @@ export interface StandardSceneArea {
routes?: Array<string>; // 绑定线路id集合
maxAmr?: number; // 最大可容纳AMR数
inoutflag?: 1 | 2; // 库区规则
storageLocations?: Record<string, string[]>; // 动作点对应的库位信息
storageLocations?: Array<Record<string, string[]>>; // 动作点对应的库位信息,格式为 [{动作点名称: [库位列表]}]
config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理)
}

View File

@ -167,12 +167,20 @@ export class EditorService extends Meta2d {
processedPoints = actionPoints.map((pen) => pen.id!);
// 如果有storageLocations数据更新对应动作点的库位信息
if (storageLocations) {
if (storageLocations && Array.isArray(storageLocations)) {
// 将数组格式转换为对象格式以便查找
const storageLocationsMap: Record<string, string[]> = {};
storageLocations.forEach((item) => {
Object.entries(item).forEach(([pointName, locations]) => {
storageLocationsMap[pointName] = locations;
});
});
actionPoints.forEach((pen) => {
const pointName = pen.label || pen.id!;
if (storageLocations[pointName]) {
if (storageLocationsMap[pointName]) {
this.setValue(
{ id: pen.id, point: { ...pen.point, associatedStorageLocations: storageLocations[pointName] } },
{ id: pen.id, point: { ...pen.point, associatedStorageLocations: storageLocationsMap[pointName] } },
{ render: false, history: false, doEvent: false },
);
}
@ -290,12 +298,15 @@ export class EditorService extends Meta2d {
// 保存动作点名称
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 ?? [];
});
// 构建storageLocations数组[{动作点名称: [库位列表]}]
area.storageLocations = actionPoints
.map((pen) => {
const pointName = pen.label || pen.id!;
const storageLocations = pen.point?.associatedStorageLocations ?? [];
return { [pointName]: storageLocations };
})
.filter((item): item is Record<string, string[]> => item !== null);
area.inoutflag = inoutflag;
}