diff --git a/README.md b/README.md index 784ee0c..48f9ef9 100644 --- a/README.md +++ b/README.md @@ -322,8 +322,10 @@ interface StandardScenePoint { x: number; y: number; type: number; // 点位类型 + extensionType?: number; // 扩展类型 robots?: Array; // 绑定机器人id集合 actions?: Array; // 绑定动作点id集合 + associatedStorageLocations?: string[]; // 库位名称 config?: object; // 其它属性配置(可按需增加) properties?: unknown; // 附加数据(前端不做任何处理) } @@ -350,6 +352,9 @@ interface StandardSceneArea { type: number; // 区域类型 points?: Array; // 绑定点位id集合 routes?: Array; // 绑定线路id集合 + maxAmr?: number; // 最大可容纳AMR数 + inoutflag?: 1 | 2; // 库区规则 + storageLocations?: Array>; // 动作点对应的库位信息,格式为 [{动作点名称: [库位列表]}] config?: object; // 其它属性配置(可按需增加) properties?: unknown; // 附加数据(前端不做任何处理) } diff --git a/src/apis/scene/type.ts b/src/apis/scene/type.ts index b6c3f71..c695341 100644 --- a/src/apis/scene/type.ts +++ b/src/apis/scene/type.ts @@ -70,7 +70,7 @@ export interface StandardSceneArea { routes?: Array; // 绑定线路id集合 maxAmr?: number; // 最大可容纳AMR数 inoutflag?: 1 | 2; // 库区规则 - storageLocations?: Record; // 动作点对应的库位信息 + storageLocations?: Array>; // 动作点对应的库位信息,格式为 [{动作点名称: [库位列表]}] config?: object; // 其它属性配置(可按需增加) properties?: unknown; // 附加数据(前端不做任何处理) } diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index e6f94c6..c3a4a90 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -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 = {}; + 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 => item !== null); area.inoutflag = inoutflag; }