From 914d3a0ed0859c41eb7d04c2d5a8974c959e9192 Mon Sep 17 00:00:00 2001 From: xudan Date: Wed, 16 Jul 2025 18:52:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=A0=87=E5=87=86?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E7=B1=BB=E5=9E=8B=E5=92=8C=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=94=AF=E6=8C=81=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E6=9C=8D=E5=8A=A1=E4=BB=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=96=B0=E7=9A=84=E5=BA=93=E4=BD=8D=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ src/apis/scene/type.ts | 2 +- src/services/editor.service.ts | 29 ++++++++++++++++++++--------- 3 files changed, 26 insertions(+), 10 deletions(-) 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; }