From 6b8fb06600eb9f1760d09387c6cd776c032065e2 Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Wed, 12 Aug 2026 12:21:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=A4=9A=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E9=A1=B9=E9=85=8D=E7=BD=AE=E5=A4=9A=E6=9C=BA=E5=99=A8=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/flowExecution.js | 36 +++++++++++++++++++ .../components/RuntimeAssignmentsEditor.vue | 2 ++ src/views/inspection/runTask/index.vue | 4 +-- .../intelligenceTest/runningTask/index.vue | 4 +-- src/views/test/configs/Run.vue | 4 +-- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/utils/flowExecution.js b/src/utils/flowExecution.js index 44be2b6..5f06015 100644 --- a/src/utils/flowExecution.js +++ b/src/utils/flowExecution.js @@ -59,14 +59,50 @@ export const loadFlowItemRuntimeRoles = async (items = []) => { return mergeResourceRoleDefinitions(roleGroups) } +/** + * Loads runtime roles without merging equal role keys across flow items. + * Task orchestration needs one independent assignment per detection item because + * two items may use different physical robots even when their workflows define + * the same logical role (for example, `default_robot`). + */ +export const loadFlowItemScopedRuntimeRoles = async (items = []) => { + if (items.some((item) => !item?.itemId)) throw new Error('任务编排中存在缺少流程项ID的数据') + if (!items.length) throw new Error('当前任务没有编排任何流程项') + + const occurrences = new Map() + const roleGroups = await Promise.all(items.map(async (item) => { + const occurrence = (occurrences.get(String(item.itemId)) || 0) + 1 + occurrences.set(String(item.itemId), occurrence) + const response = await getDetect(item.itemId) + const graph = parseFlowData(item.itemName || item.itemId, response.data?.flowData) + return getResourceRoles(graph).map((role) => ({ + ...clone([role])[0], + roleKey: `${item.itemId}:${occurrence}:${role.roleKey}`, + sourceRoleKey: role.roleKey, + itemId: item.itemId, + itemName: item.itemName || String(item.itemId), + displayName: `${item.itemName || item.itemId} / ${role.displayName}`, + })) + })) + return roleGroups.flat() +} + export const loadTaskRuntimeRoles = async (taskId) => { if (!taskId) throw new Error('任务没有关联流程编排') const response = await getFlowParamsApi(taskId) return loadFlowItemRuntimeRoles(response.rows || []) } +export const loadTaskScopedRuntimeRoles = async (taskId) => { + if (!taskId) throw new Error('任务没有关联流程编排') + const response = await getFlowParamsApi(taskId) + return loadFlowItemScopedRuntimeRoles(response.rows || []) +} + export const createRuntimeAssignments = (roles = [], primaryRobotId = '') => roles.map((role, index) => ({ roleKey: role.roleKey, + ...(role.sourceRoleKey ? { sourceRoleKey: role.sourceRoleKey } : {}), + ...(role.itemId != null ? { itemId: role.itemId } : {}), members: [{ memberKey: `${role.roleKey}_1`, robotId: index === 0 ? primaryRobotId || role.legacyRobotId || '' : role.legacyRobotId || '', diff --git a/src/views/flow/components/RuntimeAssignmentsEditor.vue b/src/views/flow/components/RuntimeAssignmentsEditor.vue index 3abd07e..0876c1d 100644 --- a/src/views/flow/components/RuntimeAssignmentsEditor.vue +++ b/src/views/flow/components/RuntimeAssignmentsEditor.vue @@ -154,6 +154,8 @@ const initialize = async () => { const existingMember = existingAssignment?.members?.[0] return { roleKey: role.roleKey, + ...(role.sourceRoleKey ? { sourceRoleKey: role.sourceRoleKey } : {}), + ...(role.itemId != null ? { itemId: role.itemId } : {}), members: [{ ...existingMember, memberKey: `${role.roleKey}_1`, diff --git a/src/views/inspection/runTask/index.vue b/src/views/inspection/runTask/index.vue index 61651ea..d066514 100644 --- a/src/views/inspection/runTask/index.vue +++ b/src/views/inspection/runTask/index.vue @@ -168,7 +168,7 @@ import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignments import { createRuntimeAssignments, firstAssignedRobotId, - loadTaskRuntimeRoles, + loadTaskScopedRuntimeRoles, } from '@/utils/flowExecution' const topContainerRef = ref(); @@ -328,7 +328,7 @@ const startTask = async (task) => { return } try { - const roles = await loadTaskRuntimeRoles(taskDefinition.taskConfigId) + const roles = await loadTaskScopedRuntimeRoles(taskDefinition.taskConfigId) runtimeAssignments.value = createRuntimeAssignments(roles, task.robotIdentity) runtimeMapId.value = taskDefinition.mapId || '' runtimeRoles.value = roles diff --git a/src/views/intelligenceTest/runningTask/index.vue b/src/views/intelligenceTest/runningTask/index.vue index c96ef3e..6892a27 100644 --- a/src/views/intelligenceTest/runningTask/index.vue +++ b/src/views/intelligenceTest/runningTask/index.vue @@ -187,7 +187,7 @@ import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignments import { createRuntimeAssignments, firstAssignedRobotId, - loadTaskRuntimeRoles, + loadTaskScopedRuntimeRoles, } from '@/utils/flowExecution' const topContainerRef = ref(); @@ -370,7 +370,7 @@ const startTask = async (task) => { return } try { - const roles = await loadTaskRuntimeRoles(taskDefinition.taskConfigId) + const roles = await loadTaskScopedRuntimeRoles(taskDefinition.taskConfigId) runtimeAssignments.value = createRuntimeAssignments(roles) runtimeRoles.value = roles pendingStartTask.value = task diff --git a/src/views/test/configs/Run.vue b/src/views/test/configs/Run.vue index 209af69..1ac79c6 100644 --- a/src/views/test/configs/Run.vue +++ b/src/views/test/configs/Run.vue @@ -71,7 +71,7 @@ import { taskExecute } from "@/api/test/config" import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignmentsEditor.vue' import { firstAssignedRobotId, - loadFlowItemRuntimeRoles, + loadFlowItemScopedRuntimeRoles, } from '@/utils/flowExecution' const props = defineProps({ @@ -104,7 +104,7 @@ const getFlowParams = async () => { const data = parseConfig(res.rows) formData.value.tableData = data runtimeAssignments.value = [] - roles.value = await loadFlowItemRuntimeRoles(data) + roles.value = await loadFlowItemScopedRuntimeRoles(data) } }; From b692f0c97d8d1cc5cb00ac2fe0d7c8766206c8c4 Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Wed, 12 Aug 2026 13:32:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?style:=20=E6=A0=B7=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/inspection/runTask/index.vue | 20 +++++++++++++------ .../intelligenceTest/runningTask/index.vue | 12 +++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/views/inspection/runTask/index.vue b/src/views/inspection/runTask/index.vue index d066514..e90506c 100644 --- a/src/views/inspection/runTask/index.vue +++ b/src/views/inspection/runTask/index.vue @@ -140,12 +140,14 @@ - +
+ +