fix(fixtures): show associated scan plans in fixture management

This commit is contained in:
Codex 2026-11-23 11:14:15 +08:00
parent ff9f9d0072
commit bfb3a6fdaa
9 changed files with 150 additions and 19 deletions

View File

@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.lab.dal.dataobject.master.LabFixtureDO;
import cn.iocoder.yudao.module.lab.dal.dataobject.master.LabSampleDO;
import cn.iocoder.yudao.module.lab.enums.LabMasterStatusEnum;
import cn.iocoder.yudao.module.lab.service.master.LabFixtureService;
import cn.iocoder.yudao.module.lab.service.master.FixtureScanPlanSummaryService;
import cn.iocoder.yudao.module.lab.service.master.LabMasterAttachmentService;
import cn.iocoder.yudao.module.lab.service.master.LabSampleService;
import io.swagger.v3.oas.annotations.Operation;
@ -38,6 +39,8 @@ public class LabFixtureController {
@Resource
private LabFixtureService fixtureService;
@Resource
private FixtureScanPlanSummaryService scanPlans;
@Resource private cn.iocoder.yudao.module.lab.service.master.LabFixtureFrameworkService frameworks;
@Resource private cn.iocoder.yudao.module.lab.service.master.LabFixtureTrajectoryService trajectories;
@Resource
@ -85,7 +88,11 @@ public class LabFixtureController {
@PreAuthorize("@ss.hasPermission('lab:fixture:query')")
public CommonResult<LabFixtureRespVO> get(@RequestParam("id") Long id) {
var vo=convert(fixtureService.getFixture(id), true);
if(vo!=null)fillTrajectories(List.of(vo));
if(vo!=null){
var rows=List.of(vo);
fillTrajectories(rows);
scanPlans.fill(rows);
}
return success(vo);
}
@ -96,6 +103,7 @@ public class LabFixtureController {
PageResult<LabFixtureDO> pageResult = fixtureService.getFixturePage(reqVO);
var result=BeanUtils.toBean(pageResult, LabFixtureRespVO.class, vo -> fill(vo, false));
fillTrajectories(result.getList());
scanPlans.fill(result.getList());
return success(result);
}

View File

@ -22,6 +22,14 @@ public class LabFixtureRespVO {
private String trajectoryStatus;
private String trajectoryFileName;
private Integer trajectoryVersion;
@Schema(description = "默认扫描用例ID")
private String defaultTestCaseId;
@Schema(description = "默认扫描用例名称")
private String defaultTestCaseName;
@Schema(description = "默认扫描用例当前发布版本号")
private Integer defaultVersionNo;
@Schema(description = "默认扫描状态:PUBLISHED、UNPUBLISHED、UNAVAILABLE、UNLINKED")
private String defaultScanStatus;
@ExcelProperty("夹具编号")
private String fixtureCode;
@ExcelProperty("夹具名称")

View File

@ -0,0 +1,81 @@
package cn.iocoder.yudao.module.lab.service.master;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.lab.controller.admin.master.vo.fixture.LabFixtureRespVO;
import cn.iocoder.yudao.module.lab.service.scanonly.FixtureScanDefaults;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** Read-only metadata for the shared default scan cases; never creates task bindings. */
@Service
public class FixtureScanPlanSummaryService {
private final JdbcTemplate jdbc;
public FixtureScanPlanSummaryService(JdbcTemplate jdbc) {
this.jdbc = jdbc;
}
public void fill(List<LabFixtureRespVO> rows) {
if (rows == null || rows.isEmpty()) return;
for (var row : rows) {
if (row == null) continue;
row.setDefaultTestCaseId(null);
row.setDefaultTestCaseName(null);
row.setDefaultVersionNo(null);
row.setDefaultScanStatus("UNLINKED");
}
// These native tables are shared, while fixture pages remain tenant scoped.
if (!Long.valueOf(1L).equals(TenantContextHolder.getTenantId())) return;
var ids = new LinkedHashSet<String>();
for (var row : rows) {
if (row == null) continue;
String id = FixtureScanDefaults.testCaseId(row.getFixtureCode());
if (id == null) continue;
row.setDefaultTestCaseId(id);
row.setDefaultScanStatus("UNAVAILABLE");
ids.add(id);
}
if (ids.isEmpty()) return;
// Native case/item/version models and mappers use physical deletion, with no deleted column.
String sql = "SELECT c.id AS caseId,c.case_name AS caseName,c.enabled AS caseEnabled,"
+ "c.detect_item_id AS caseItemId,d.id AS itemId,d.status AS itemStatus,"
+ "d.published_version_id AS publishedVersionId,v.id AS versionId,"
+ "v.detection_item_id AS versionItemId,v.version_no AS versionNo "
+ "FROM aima_test_case c LEFT JOIN te_detection_item d ON d.id=c.detect_item_id "
+ "LEFT JOIN te_detection_item_version v ON v.id=d.published_version_id "
+ "WHERE c.id IN (" + String.join(",", Collections.nCopies(ids.size(), "?")) + ")";
Map<String, Summary> summaries = new HashMap<>();
jdbc.query(sql, (rs, rowNumber) -> new Summary(rs.getString("caseId"), rs.getString("caseName"),
rs.getString("caseEnabled"), rs.getString("caseItemId"), rs.getString("itemId"),
rs.getString("itemStatus"), rs.getString("publishedVersionId"), rs.getString("versionId"),
rs.getString("versionItemId"), rs.getObject("versionNo", Integer.class)), ids.toArray())
.forEach(summary -> summaries.put(summary.caseId(), summary));
for (var row : rows) {
if (row == null || row.getDefaultTestCaseId() == null) continue;
Summary summary = summaries.get(row.getDefaultTestCaseId());
if (summary == null) continue;
row.setDefaultTestCaseName(summary.caseName());
if (!"0".equals(summary.caseEnabled()) || !"0".equals(summary.itemStatus())
|| summary.itemId() == null || !Objects.equals(summary.caseItemId(), summary.itemId())) continue;
if (summary.publishedVersionId() == null) {
row.setDefaultScanStatus("UNPUBLISHED");
} else if (Objects.equals(summary.publishedVersionId(), summary.versionId())
&& Objects.equals(summary.itemId(), summary.versionItemId())
&& summary.versionNo() != null && summary.versionNo() > 0) {
row.setDefaultVersionNo(summary.versionNo());
row.setDefaultScanStatus("PUBLISHED");
}
}
}
private record Summary(String caseId, String caseName, String caseEnabled, String caseItemId,
String itemId, String itemStatus, String publishedVersionId,
String versionId, String versionItemId, Integer versionNo) {}
}

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.lab.service.scanonly;
import java.util.Map;
/** Suggested scan case only; task preparation may select any other valid released case. */
final class FixtureScanDefaults {
public final class FixtureScanDefaults {
private static final Map<String, String> CASES = Map.of(
"REAL-SCAN-20261028-001-MIDDLE", "c090028d47474d03b7cc2f8d77740abf",
"REAL-SCAN-20261028-001-LARGE", "8b0c888b013347c08df1a7167f721a83",
@ -12,7 +12,7 @@ final class FixtureScanDefaults {
private FixtureScanDefaults() {}
static String testCaseId(String fixtureCode) {
public static String testCaseId(String fixtureCode) {
return fixtureCode == null ? null : CASES.get(fixtureCode);
}
}

View File

@ -38,6 +38,10 @@ export interface LabFixtureVO {
attachments?: LabMasterAttachmentVO[]
updateTime?: Date
createTime?: Date
defaultTestCaseId?: string
defaultTestCaseName?: string
defaultVersionNo?: number
defaultScanStatus?: 'PUBLISHED' | 'UNPUBLISHED' | 'UNAVAILABLE' | 'UNLINKED'
trajectoryStatus?: string
trajectoryFileName?: string
trajectoryVersion?: number

View File

@ -1,5 +1,5 @@
<template>
<Dialog v-model="visible" title="夹具扫描轨迹" width="860px">
<Dialog v-model="visible" title="夹具机械臂轨迹文件" width="860px">
<div class="heading"
><strong>{{ fixture?.fixtureName }}</strong
><el-tag :type="current?.id ? 'success' : 'info'">{{
@ -7,12 +7,12 @@
}}</el-tag></div
>
<p class="hint"
>为此夹具关联一条已有扫描轨迹。文件保存在所选机械臂,更换关联保留历史记录;关联不代表已完成现场运动验证。</p
>为此夹具关联机械臂上已录制的轨迹文件。文件保存在所选机械臂,更换关联保留历史记录;关联不代表已完成现场运动验证。</p
>
<el-alert v-if="error" :title="error" type="error" :closable="false" class="gap" />
<div v-loading="loading">
<el-descriptions v-if="current?.id" :column="2" border>
<el-descriptions-item label="当前文件" :span="2">{{
<el-descriptions-item label="当前机械臂轨迹文件" :span="2">{{
current.fileName
}}</el-descriptions-item>
<el-descriptions-item label="所属机器人">{{ current.robotId }}</el-descriptions-item>
@ -20,7 +20,7 @@
<el-descriptions-item label="录制时长">{{ current.durationS }} 秒</el-descriptions-item>
<el-descriptions-item label="样本数">{{ current.samples }}</el-descriptions-item>
</el-descriptions>
<el-empty v-else-if="loaded" description="此夹具尚未关联扫描轨迹" :image-size="48" />
<el-empty v-else-if="loaded" description="此夹具尚未关联机械臂轨迹文件" :image-size="48" />
<div class="actions">
<el-button
type="primary"
@ -28,7 +28,7 @@
v-hasPermi="['lab:fixture:update']"
:disabled="!editable || !loaded || busy || loading"
@click="pickerVisible = true"
>{{ current?.id ? '选择其他轨迹' : '关联已有轨迹' }}</el-button
>{{ current?.id ? '选择其他轨迹文件' : '关联已有轨迹文件' }}</el-button
>
<el-button
v-if="current?.id"
@ -43,7 +43,7 @@
</div>
<el-alert
v-if="!editable"
title="夹具已停用,仅可查看轨迹关联。"
title="夹具已停用,仅可查看机械臂轨迹文件关联。"
type="info"
:closable="false"
/>
@ -63,12 +63,12 @@
>
<el-button :disabled="busy" @click="selection = undefined">取消选择</el-button>
</div>
<h4 v-if="history.length">关联历史</h4>
<h4 v-if="history.length">轨迹文件关联历史</h4>
<el-table v-if="history.length" :data="history" size="small" max-height="260">
<el-table-column label="版本" width="65"
<el-table-column label="关联版本" width="85"
><template #default="{ row }">V{{ row.versionNo }}</template></el-table-column
>
<el-table-column label="轨迹文件" prop="fileName" min-width="165" show-overflow-tooltip />
<el-table-column label="机械臂轨迹文件" prop="fileName" min-width="165" show-overflow-tooltip />
<el-table-column label="机器人 / 机械臂" min-width="200"
><template #default="{ row }"
><div>{{ row.robotId }}</div
@ -166,7 +166,7 @@ async function save() {
fileName: selection.value.fileName
})
if (request !== generation || !visible.value) return
message.success('夹具扫描轨迹已关联')
message.success('夹具机械臂轨迹文件已关联')
emit('updated')
await load()
} catch (e: any) {
@ -180,7 +180,7 @@ async function unlink() {
const version = current.value.id,
request = generation
try {
await message.confirm('解除此夹具与当前轨迹的关联?机械臂上的轨迹文件和关联历史保留。')
await message.confirm('解除此夹具与当前机械臂轨迹文件的关联?机械臂上的轨迹文件和关联历史保留。')
} catch {
return
}
@ -192,7 +192,7 @@ async function unlink() {
await api.unbind({ fixtureId: fixture.value.id, expectedVersion: version })
if (request !== generation || !visible.value) return
emit('updated')
message.success('已解除关联')
message.success('已解除机械臂轨迹文件关联')
await load()
} catch (e: any) {
if (request === generation && visible.value) error.value = e.message || '解除关联失败,请重试'

View File

@ -31,10 +31,16 @@
<div class="flex items-center gap-12px"><el-tag :type="framework.current?.id ? 'success' : 'warning'">{{ framework.current?.id ? '可复用' : '未配置' }}</el-tag><el-button link type="primary" @click="frameworkRef.open(detail)">查看 / 下载 / 复制</el-button></div>
<p v-if="framework.current?.id" class="text-13px text-[var(--el-text-color-secondary)]">框架点保存时间:{{ formatNullableDate(framework.current.updatedAt) }}</p>
<div class="mb-8px mt-20px font-bold">扫描轨迹</div>
<el-descriptions :column="1" border>
<el-descriptions-item label="默认扫描方案">{{ detail.defaultTestCaseId ? detail.defaultTestCaseName || detail.defaultTestCaseId : '未关联' }}</el-descriptions-item>
<el-descriptions-item label="发布状态"><el-tag :type="scanStatus(detail).type">{{ scanStatus(detail).label }}</el-tag></el-descriptions-item>
</el-descriptions>
<p class="text-13px text-[var(--el-text-color-secondary)]">扫描任务选择此夹具时预选关联方案,准备时仍可手动更换。</p>
<div class="mb-8px mt-20px font-bold">机械臂轨迹文件</div>
<div class="flex items-center gap-12px">
<el-tag :type="detail.trajectoryStatus === 'LINKED' ? 'success' : 'info'">{{ detail.trajectoryStatus === 'LINKED' ? '已关联 · V' + detail.trajectoryVersion : '未关联' }}</el-tag>
<span>{{ detail.trajectoryFileName || '尚未关联扫描轨迹' }}</span>
<el-button link type="primary" @click="trajectoryRef.open(detail)">查看与关联</el-button>
<span>{{ detail.trajectoryFileName || '尚未关联机械臂轨迹文件' }}</span>
<el-button link type="primary" @click="trajectoryRef.open(detail)">查看与关联文件</el-button>
</div>
<div class="mb-8px mt-20px font-bold">附件</div>
<MasterAttachmentPanel v-if="detail.id" biz-type="FIXTURE" :biz-id="detail.id" />
@ -49,6 +55,12 @@ import * as FixtureApi from '@/api/lab/master/fixture'
import MasterAttachmentPanel from '../components/MasterAttachmentPanel.vue'
import FixtureTrajectory from './FixtureTrajectory.vue'
import FixtureFramework from './FixtureFramework.vue'
const scanStatus = (fixture: FixtureApi.LabFixtureVO): { type: 'info' | 'success' | 'warning'; label: string } => {
if (!fixture.defaultTestCaseId) return { type: 'info', label: '未关联' }
if (fixture.defaultScanStatus === 'PUBLISHED' && Number.isInteger(fixture.defaultVersionNo) && (fixture.defaultVersionNo ?? 0) > 0)
return { type: 'success', label: `已关联 · V${fixture.defaultVersionNo}` }
return { type: 'warning', label: fixture.defaultScanStatus === 'UNPUBLISHED' ? '已关联 · 未发布' : '关联方案不可用' }
}
const trajectoryRef = ref()
const frameworkRef=ref(),framework=shallowRef<any>({})

View File

@ -34,7 +34,12 @@
<el-table-column label="夹具编号" prop="fixtureCode" min-width="120" />
<el-table-column label="夹具名称" prop="fixtureName" min-width="140" />
<el-table-column label="框架点" width="100"><template #default="{row}"><el-tag :type="row.frameworkStatus === 'READY' ? 'success' : 'warning'">{{row.frameworkStatus === 'READY' ? '可复用' : '未配置'}}</el-tag></template></el-table-column>
<el-table-column label="扫描轨迹" width="110"><template #default="{row}"><el-tag :type="row.trajectoryStatus === 'LINKED' ? 'success' : 'info'">{{ row.trajectoryStatus === 'LINKED' ? '已关联 · V' + row.trajectoryVersion : '未关联' }}</el-tag></template></el-table-column>
<el-table-column label="扫描轨迹" min-width="240">
<template #default="{ row }">
<div v-if="row.defaultTestCaseId" class="mb-4px">{{ row.defaultTestCaseName || row.defaultTestCaseId }}</div>
<el-tag :type="scanStatus(row).type">{{ scanStatus(row).label }}</el-tag>
</template>
</el-table-column>
<el-table-column label="规格" align="center" prop="fixtureSize" width="90">
<template #default="scope">
<dict-tag :type="DICT_TYPE.LAB_FIXTURE_SIZE" :value="scope.row.fixtureSize" />
@ -52,7 +57,7 @@
<template #default="scope">
<el-button link type="primary" @click="goDetail(scope.row.id)">详情</el-button>
<el-button link type="primary" v-hasPermi="['lab:fixture:query']" @click="frameworkRef.open(scope.row)">夹具框架点</el-button>
<el-button link type="primary" v-hasPermi="['lab:fixture:query']" @click="trajectoryRef.open(scope.row)">扫描轨迹</el-button>
<el-button link type="primary" v-hasPermi="['lab:fixture:query']" @click="trajectoryRef.open(scope.row)">机械臂轨迹文件</el-button>
<el-button link type="primary" v-hasPermi="['lab:fixture:update']" @click="openForm('update', scope.row.id)">编辑</el-button>
<el-button
v-if="scope.row.status === 'ENABLED'"
@ -80,6 +85,12 @@ import * as FixtureApi from '@/api/lab/master/fixture'
import FixtureForm from './FixtureForm.vue'
import FixtureFramework from './FixtureFramework.vue'
import FixtureTrajectory from './FixtureTrajectory.vue'
const scanStatus = (fixture: FixtureApi.LabFixtureVO): { type: 'info' | 'success' | 'warning'; label: string } => {
if (!fixture.defaultTestCaseId) return { type: 'info', label: '未关联' }
if (fixture.defaultScanStatus === 'PUBLISHED' && Number.isInteger(fixture.defaultVersionNo) && (fixture.defaultVersionNo ?? 0) > 0)
return { type: 'success', label: `已关联 · V${fixture.defaultVersionNo}` }
return { type: 'warning', label: fixture.defaultScanStatus === 'UNPUBLISHED' ? '已关联 · 未发布' : '关联方案不可用' }
}
const frameworkRef = ref()
const trajectoryRef = ref()

View File

@ -15,3 +15,10 @@
现场确认空闲后使用既有一键更新流程,同时更新前后端。本机使用 D:/project/cmvr-iot/update-platform.cmd;已接管的原生网关与启动适配保持。发布后核对 deployment.json 和一键启动报告的提交号,不能仅复制网页或 JAR 冒充正式发布。
功能验收可以只在未开始的准备表单选择夹具、手动改选和重新打开已保存任务;不点击保存、预检、获取资源或开始执行即可验证预选行为。实际扫描仍需现场按原流程操作。
## 夹具管理页显示
夹具列表的“扫描轨迹”和夹具详情显示同一默认关联的扫描方案名称与发布状态。已发布时显示当前发布版本;有关联但尚未发布时显示“已关联 · 未发布”;缺失或停用的方案标为不可用。没有配置默认关联的夹具才显示未关联。
此处的默认方案与机械臂上录制的轨迹文件是两种独立关联。原文件绑定入口统一命名为“机械臂轨迹文件”,保留其真实状态、关联版本、历史和权限,不写入或伪造文件关联。列表与详情只读取方案元信息,不加载流程正文、不创建方法映射、不修改旧任务或发布任何流程。其他租户不读取本项目原生方案。