完善扫描流式预览、成果归档与PLY/STL查看、补扫历史、执行步骤及日志展示,支持局域网访问和改名节点的原始组件识别。修复试运行终止后的占用释放及未采集时重复暂停SDK的问题,增加终止中交互与回归验证。 验证:后端1114项通过、18项既有跳过;前端109项通过,类型检查及构建通过;Python脚本54项通过;模拟扫描设备7组试运行/终止接口回归通过。
186 lines
6.5 KiB
TypeScript
186 lines
6.5 KiB
TypeScript
import request from '@/config/axios'
|
|
import type { LabTestTaskVO } from '@/api/lab/task'
|
|
import type { LabExecutionVO } from '@/api/lab/execution'
|
|
|
|
export type Id = string | number
|
|
export interface RuntimeAssignment {
|
|
roleKey: string
|
|
members: { memberKey: string; robotId: string; devices: Record<string, string> }[]
|
|
}
|
|
export interface ScanTaskRow extends LabTestTaskVO {
|
|
caseName?: string
|
|
testCaseId?: string
|
|
quantity: number
|
|
completedCount: number
|
|
processType: string
|
|
}
|
|
export interface ScanConfig {
|
|
taskId: Id
|
|
importedTestCaseId: string
|
|
selectedTestCaseId: string
|
|
versionId?: string
|
|
versionNo?: number
|
|
caseName?: string
|
|
revision: number
|
|
sampleReceived: boolean
|
|
fixtureId?: Id
|
|
fixtureConfirmed: boolean
|
|
lengthMm?: number
|
|
widthMm?: number
|
|
heightMm?: number
|
|
weightKg?: number
|
|
requireFixture: boolean
|
|
runParams: Record<string, any>
|
|
runtimeAssignments: RuntimeAssignment[]
|
|
robotId?: string
|
|
startedAt?: string
|
|
stopPending: boolean
|
|
reservationMode?: 'IMMEDIATE' | 'SCHEDULED'
|
|
expectedMinutes?: number
|
|
plannedStartAt?: string | number
|
|
plannedEndAt?: string | number
|
|
resourcesAcquiredAt?: string
|
|
laboratoryId?: Id
|
|
requireLaboratory?: boolean
|
|
}
|
|
export interface ScanUnit {
|
|
id: Id
|
|
unitNo: string
|
|
status: string
|
|
attemptNo: number
|
|
currentExecutionId?: Id
|
|
physicalSerial?: string
|
|
outputPath?: string
|
|
attempts: LabExecutionVO[]
|
|
}
|
|
export interface FixtureOption {
|
|
id: Id
|
|
fixtureCode: string
|
|
fixtureName: string
|
|
fixtureSize?: string
|
|
compatible: boolean
|
|
reason: string
|
|
maxLengthMm?: number
|
|
maxWidthMm?: number
|
|
maxHeightMm?: number
|
|
maxWeightKg?: number
|
|
}
|
|
export interface ScanAttachment {
|
|
id: Id
|
|
fileName: string
|
|
fileUrl: string
|
|
fileType?: string
|
|
createTime?: string
|
|
}
|
|
export interface ScanTaskDetail {
|
|
task: LabTestTaskVO
|
|
config: ScanConfig
|
|
units: ScanUnit[]
|
|
flowData?: string | Record<string, any>
|
|
inputConfig?: string | Record<string, any>[]
|
|
recommendations: FixtureOption[]
|
|
attachments: ScanAttachment[]
|
|
resourceState?: ResourceState
|
|
}
|
|
export interface ResourceState {
|
|
resources: { type: string; id: Id; name: string; robotId?: string }[]
|
|
bookings: Record<string, any>[]
|
|
leases: Record<string, any>[]
|
|
laboratories: { id: Id; lab_code: string; lab_name: string; exclusive_use: boolean }[]
|
|
message?: string
|
|
expired: boolean
|
|
}
|
|
export interface PrepareScanTask extends Omit<
|
|
ScanConfig,
|
|
| 'importedTestCaseId'
|
|
| 'selectedTestCaseId'
|
|
| 'revision'
|
|
| 'startedAt'
|
|
| 'stopPending'
|
|
| 'resourcesAcquiredAt'
|
|
> {
|
|
expectedRevision: number
|
|
testCaseId: string
|
|
changeReason?: string
|
|
}
|
|
export interface ScanPrecheck {
|
|
passed: boolean
|
|
items: { code: string; passed: boolean; message: string }[]
|
|
}
|
|
const base = '/lab/scan-task'
|
|
export interface SupplementOption { available: boolean; parentExecutionId?: Id; parentExecutionNo?: string; projectId?: string; physicalSerial?: string; message?: string }
|
|
export const getSupplementOption = (taskId: Id, unitId: Id) => request.get<SupplementOption>({ url: base + '/supplement-option', params: { taskId, unitId } })
|
|
export const startSupplement = (data: { taskId: Id; unitId: Id; parentExecutionId: Id; expectedRevision: number; durationSeconds: number; reason: string; idempotencyKey: string; sampleConfirmed: boolean; fixtureConfirmed: boolean; loadedConfirmed: boolean }) => request.post<Id>({ url: base + '/supplement', data })
|
|
export const finishSupplement = (taskId: Id, executionId: Id) => request.post({ url: base + '/finish-supplement', data: { taskId, executionId } })
|
|
export const acquireResources = (taskId: Id, expectedRevision: number) =>
|
|
request.post<ScanConfig>({ url: base + '/acquire-resources', data: { taskId, expectedRevision } })
|
|
export const releaseResources = (taskId: Id, reason: string) =>
|
|
request.post<ScanConfig>({
|
|
url: base + '/release-resources',
|
|
data: { taskId, reason, unloadedConfirmed: true }
|
|
})
|
|
export const extendResources = (taskId: Id, endAt: string) =>
|
|
request.post<ScanConfig>({ url: base + '/extend-resources', data: { taskId, endAt } })
|
|
export const getOccupations = () =>
|
|
request.get<Record<string, any>[]>({ url: base + '/resource-occupations' })
|
|
export const clearOccupation = (ownerKey: string, reason: string) =>
|
|
request.post({ url: base + '/clear-occupation', data: { ownerKey, reason } })
|
|
export const getPage = (params: {
|
|
pageNo: number
|
|
pageSize: number
|
|
taskNo?: string
|
|
status?: string
|
|
}) => request.get<{ list: ScanTaskRow[]; total: number }>({ url: base + '/page', params })
|
|
export const getDetail = (taskId: Id) =>
|
|
request.get<ScanTaskDetail>({ url: base + '/get', params: { taskId } })
|
|
export const prepare = (data: PrepareScanTask) =>
|
|
request.put<ScanConfig>({ url: base + '/prepare', data })
|
|
export const precheck = (taskId: Id) =>
|
|
request.post<ScanPrecheck>({ url: base + '/precheck', data: { taskId } })
|
|
export const startUnit = (data: {
|
|
taskId: Id
|
|
unitId: Id
|
|
expectedRevision: number
|
|
loadedConfirmed: true
|
|
idempotencyKey: string
|
|
physicalSerial?: string
|
|
reason?: string
|
|
}) => request.post<Id>({ url: base + '/start-unit', data })
|
|
export const cancel = (taskId: Id, reason: string) =>
|
|
request.post({ url: base + '/cancel', data: { taskId, reason } })
|
|
export const confirmStop = (taskId: Id, reason: string) =>
|
|
request.post({ url: base + '/confirm-stop', data: { taskId, reason } })
|
|
export const pause = (taskId: Id) => request.post({ url: base + '/pause', data: { taskId } })
|
|
export const resume = (taskId: Id) => request.post({ url: base + '/resume', data: { taskId } })
|
|
export const updateFixtureRange = (data: {
|
|
fixtureId: Id
|
|
maxLengthMm: number
|
|
maxWidthMm: number
|
|
maxHeightMm: number
|
|
maxWeightKg?: number
|
|
}) => request.put({ url: base + '/fixture-range', data })
|
|
export const fixtureOptions = (params: {
|
|
taskId: Id
|
|
lengthMm?: number
|
|
widthMm?: number
|
|
heightMm?: number
|
|
}) => request.get<FixtureOption[]>({ url: base + '/fixture-options', params })
|
|
export const getAttachments = (taskId: Id) =>
|
|
request.get<ScanAttachment[]>({ url: base + '/attachments', params: { taskId } })
|
|
export const addAttachment = (data: {
|
|
taskId: Id
|
|
fileName: string
|
|
fileUrl: string
|
|
fileType?: string
|
|
}) => request.post({ url: base + '/attachment', data })
|
|
export const deleteAttachment = (taskId: Id, id: Id) =>
|
|
request.delete({ url: base + '/attachment', params: { taskId, id } })
|
|
export const getCmvrBinding = (executionId: Id, signal?: AbortSignal) =>
|
|
request.get<{
|
|
cmvrTaskId: string
|
|
cmvrInstId: string
|
|
versionNo: number
|
|
flowData: string
|
|
testCaseId: string
|
|
}>({ url: '/lab/execution/cmvr-binding', params: { executionId }, signal })
|