feat(scan): preselect scan plans for selected fixtures
This commit is contained in:
parent
33c7d52d8c
commit
ff9f9d0072
@ -0,0 +1,18 @@
|
||||
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 {
|
||||
private static final Map<String, String> CASES = Map.of(
|
||||
"REAL-SCAN-20261028-001-MIDDLE", "c090028d47474d03b7cc2f8d77740abf",
|
||||
"REAL-SCAN-20261028-001-LARGE", "8b0c888b013347c08df1a7167f721a83",
|
||||
"REAL-SCAN-20261028-001-SMALL", "88913757c6564826aa5d05946ccb702e"
|
||||
);
|
||||
|
||||
private FixtureScanDefaults() {}
|
||||
|
||||
static String testCaseId(String fixtureCode) {
|
||||
return fixtureCode == null ? null : CASES.get(fixtureCode);
|
||||
}
|
||||
}
|
||||
@ -693,7 +693,7 @@ public class ScanOnlyTaskServiceImpl implements ScanOnlyTaskService {
|
||||
else if(c.getWeightKg()!=null&&f.getMaxWeightKg()!=null&&c.getWeightKg().compareTo(f.getMaxWeightKg())>0)reason="样件重量超过夹具承重";
|
||||
boolean recommended=reason==null&&complete;
|
||||
String basis=complete?"尺寸匹配,请现场确认装夹及承重":"尺寸未填全,可手动选择,请现场确认装夹及承重";
|
||||
result.add(map("id",f.getId(),"fixtureCode",f.getFixtureCode(),"fixtureName",f.getFixtureName(),"fixtureSize",f.getFixtureSize(),"compatible",reason==null,"recommended",recommended,"reason",reason==null?basis:reason,
|
||||
result.add(map("id",f.getId(),"fixtureCode",f.getFixtureCode(),"fixtureName",f.getFixtureName(),"fixtureSize",f.getFixtureSize(),"defaultTestCaseId",FixtureScanDefaults.testCaseId(f.getFixtureCode()),"compatible",reason==null,"recommended",recommended,"reason",reason==null?basis:reason,
|
||||
"maxLengthMm",f.getMaxLengthMm(),"maxWidthMm",f.getMaxWidthMm(),"maxHeightMm",f.getMaxHeightMm(),"maxWeightKg",f.getMaxWeightKg()));
|
||||
}
|
||||
result.sort(Comparator.comparing(row->!Boolean.TRUE.equals(row.get("compatible"))));return result;
|
||||
|
||||
@ -61,6 +61,7 @@ export interface FixtureOption {
|
||||
id: Id
|
||||
fixtureCode: string
|
||||
fixtureName: string
|
||||
defaultTestCaseId?: string
|
||||
fixtureSize?: string
|
||||
compatible: boolean
|
||||
recommended?: boolean
|
||||
|
||||
@ -172,7 +172,7 @@
|
||||
filterable
|
||||
clearable
|
||||
class="!w-full"
|
||||
@change="dimensionsChanged"
|
||||
@change="fixtureChanged"
|
||||
@visible-change="open => { if (open) recommendFixtures() }"
|
||||
><el-option
|
||||
v-for="fixture in recommendations"
|
||||
@ -390,12 +390,13 @@
|
||||
type="primary"
|
||||
:loading="busy"
|
||||
v-hasPermi="['lab:execution:precheck']"
|
||||
:disabled="preparationLoading"
|
||||
@click="savePreparation"
|
||||
>保存准备配置</el-button
|
||||
>
|
||||
<el-button
|
||||
:loading="busy"
|
||||
:disabled="terminal || detail.config.stopPending"
|
||||
:disabled="terminal || detail.config.stopPending || preparationLoading"
|
||||
v-hasPermi="['lab:execution:precheck']"
|
||||
@click="runPrecheck"
|
||||
>{{ dirty ? '保存并预检' : '执行前预检' }}</el-button
|
||||
@ -753,6 +754,7 @@ const caseOptions = computed(() => {
|
||||
})
|
||||
const versions = ref<any[]>([])
|
||||
const versionLoading = ref(false)
|
||||
const preparationLoading = computed(() => catalogLoading.value || versionLoading.value)
|
||||
const recommendations = ref<ScanApi.FixtureOption[]>([])
|
||||
const fixtureLoading = ref(false)
|
||||
const uploading = ref(false)
|
||||
@ -938,6 +940,18 @@ const applySchema = (inputConfig: any, flowData: any, values: Record<string, any
|
||||
form.runParams = parameterDefaults(fields.value, values)
|
||||
}
|
||||
let pageGeneration = 0
|
||||
let fixtureSelectionRequest = 0
|
||||
let versionRequest = 0
|
||||
let schemaRequest = 0
|
||||
const invalidateCaseRequests = () => {
|
||||
fixtureSelectionRequest++
|
||||
versionRequest++
|
||||
schemaRequest++
|
||||
versionLoading.value = false
|
||||
}
|
||||
watch([locked, busy, executionMode], ([isLocked, isBusy, mode]) => {
|
||||
if (isLocked || isBusy || mode === 'plan') invalidateCaseRequests()
|
||||
}, { flush: 'sync' })
|
||||
let activeRefresh: Promise<void> | undefined
|
||||
const refresh = async (replaceForm = false, refreshVersions = true) => {
|
||||
if (activeRefresh) {
|
||||
@ -958,6 +972,7 @@ const refresh = async (replaceForm = false, refreshVersions = true) => {
|
||||
(result.config.startedAt && previousStartedAt !== result.config.startedAt)
|
||||
) {
|
||||
const config = result.config
|
||||
invalidateCaseRequests()
|
||||
Object.assign(form, {
|
||||
testCaseId: config.selectedTestCaseId,
|
||||
versionId: config.versionId || '',
|
||||
@ -1012,39 +1027,84 @@ const manualRefresh = async () => {
|
||||
await refresh(true)
|
||||
}
|
||||
defineExpose({ refresh: manualRefresh })
|
||||
let versionRequest = 0
|
||||
const canChangeCase = () => !locked.value && !busy.value && executionMode.value === 'single'
|
||||
const fixtureChanged = async () => {
|
||||
const request = ++fixtureSelectionRequest
|
||||
dimensionsChanged()
|
||||
const fixtureId = String(form.fixtureId || '')
|
||||
const defaultId = selectedFixture.value?.defaultTestCaseId
|
||||
if (!fixtureId || !defaultId || !canChangeCase()) return
|
||||
const generation = pageGeneration
|
||||
const current = () =>
|
||||
request === fixtureSelectionRequest &&
|
||||
generation === pageGeneration &&
|
||||
String(form.fixtureId || '') === fixtureId &&
|
||||
canChangeCase()
|
||||
await loadCatalog()
|
||||
if (!current() || !catalogLoaded) return
|
||||
const testCase = cases.value.find((item) => String(item.id) === String(defaultId))
|
||||
if (!testCase || String(testCase.enabled) !== '0' || !testCase.detectItemId) {
|
||||
message.warning('夹具关联的扫描方案不存在、已停用或未关联流程,请手动选择其他方案')
|
||||
return
|
||||
}
|
||||
form.testCaseId = String(testCase.id)
|
||||
await changeCase()
|
||||
}
|
||||
const loadVersions = async (selectPublished = false) => {
|
||||
const currentCase = cases.value.find((item) => String(item.id) === form.testCaseId)
|
||||
const request = ++versionRequest
|
||||
const generation = pageGeneration
|
||||
const caseId = form.testCaseId
|
||||
const selectedVersion = form.versionId
|
||||
const allowSelection = canChangeCase()
|
||||
const current = () =>
|
||||
request === versionRequest &&
|
||||
generation === pageGeneration &&
|
||||
form.testCaseId === caseId
|
||||
const currentCase = cases.value.find((item) => String(item.id) === caseId)
|
||||
const itemId = currentCase?.detectItemId
|
||||
if (!itemId) {
|
||||
const config = detail.value?.config
|
||||
versions.value =
|
||||
config?.selectedTestCaseId === form.testCaseId && config?.versionId
|
||||
? [
|
||||
{
|
||||
id: config.versionId,
|
||||
versionNo: config.versionNo,
|
||||
publishNote: '本任务保存的发布版本'
|
||||
}
|
||||
]
|
||||
config?.selectedTestCaseId === caseId && config?.versionId
|
||||
? [{
|
||||
id: config.versionId,
|
||||
versionNo: config.versionNo,
|
||||
publishNote: '本任务保存的发布版本'
|
||||
}]
|
||||
: []
|
||||
versionLoading.value = false
|
||||
return
|
||||
}
|
||||
const request = ++versionRequest
|
||||
versionLoading.value = true
|
||||
try {
|
||||
const [list, detection] = await Promise.all([flowVersionList(itemId), getDetect(itemId)])
|
||||
if (request !== versionRequest) return
|
||||
if (!current()) return
|
||||
versions.value = list.data || []
|
||||
if (selectPublished || !form.versionId) {
|
||||
form.versionId = detection.data?.publishedVersionId || ''
|
||||
if (form.versionId) await changeVersion()
|
||||
if (allowSelection && canChangeCase() && form.versionId === selectedVersion && (selectPublished || !form.versionId)) {
|
||||
const publishedId = String(detection.data?.publishedVersionId || '')
|
||||
if (!publishedId) {
|
||||
form.versionId = ''
|
||||
message.warning('关联扫描方案尚未发布,请先发布或手动选择其他方案')
|
||||
return
|
||||
}
|
||||
const published = versions.value.find((version) => String(version.id) === publishedId)
|
||||
if (!published) {
|
||||
form.versionId = ''
|
||||
message.warning('扫描方案的当前发布版本不可用,请刷新或手动选择其他方案')
|
||||
return
|
||||
}
|
||||
form.versionId = published.id
|
||||
await loadVersionSchema()
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (current()) message.warning(error.message || '扫描方案发布版本加载失败,请重新选择或刷新重试')
|
||||
} finally {
|
||||
if (request === versionRequest) versionLoading.value = false
|
||||
}
|
||||
}
|
||||
const changeCase = async () => {
|
||||
invalidateCaseRequests()
|
||||
if (!canChangeCase()) return
|
||||
form.versionId = ''
|
||||
form.runtimeAssignments = []
|
||||
form.runParams = {}
|
||||
@ -1052,26 +1112,51 @@ const changeCase = async () => {
|
||||
fields.value = []
|
||||
roles.value = []
|
||||
versions.value = []
|
||||
frameworkNeeded.value = false
|
||||
scannerSettings.value = { visible: false, available: false }
|
||||
markDirty()
|
||||
await loadVersions(true)
|
||||
}
|
||||
const changeVersion = async () => {
|
||||
if (!form.versionId) return
|
||||
const loadVersionSchema = async () => {
|
||||
const request = ++schemaRequest
|
||||
const generation = pageGeneration
|
||||
const caseId = form.testCaseId
|
||||
const id = form.versionId
|
||||
const current = () =>
|
||||
request === schemaRequest &&
|
||||
generation === pageGeneration &&
|
||||
form.testCaseId === caseId &&
|
||||
form.versionId === id &&
|
||||
canChangeCase()
|
||||
if (!id || !canChangeCase()) return
|
||||
versionLoading.value = true
|
||||
try {
|
||||
const result = await flowVersionDetail(id)
|
||||
if (id !== form.versionId) return
|
||||
applySchema(result.data?.config, result.data?.flowData)
|
||||
if (!current()) return
|
||||
const itemId = cases.value.find((item) => String(item.id) === caseId)?.detectItemId
|
||||
if (!result.data || (result.data.detectionItemId != null && String(result.data.detectionItemId) !== String(itemId))) {
|
||||
throw new Error('发布版本与当前扫描方案不一致,请重新选择')
|
||||
}
|
||||
applySchema(result.data.config, result.data.flowData)
|
||||
form.runtimeAssignments = []
|
||||
resourceRevision.value++
|
||||
markDirty()
|
||||
} catch (error: any) {
|
||||
if (current()) {
|
||||
form.versionId = ''
|
||||
message.warning(error.message || '扫描方案参数加载失败,请重新选择发布版本')
|
||||
}
|
||||
} finally {
|
||||
if (id === form.versionId) versionLoading.value = false
|
||||
if (request === schemaRequest) versionLoading.value = false
|
||||
}
|
||||
}
|
||||
const changeVersion = async () => {
|
||||
invalidateCaseRequests()
|
||||
await loadVersionSchema()
|
||||
}
|
||||
let fixtureRequest = 0
|
||||
const recommendFixtures = async () => {
|
||||
const generation = pageGeneration
|
||||
const request = ++fixtureRequest
|
||||
fixtureLoading.value = true
|
||||
try {
|
||||
@ -1082,9 +1167,9 @@ const recommendFixtures = async () => {
|
||||
heightMm: form.heightMm,
|
||||
weightKg: form.weightKg
|
||||
})
|
||||
if (request === fixtureRequest) recommendations.value = result
|
||||
if (request === fixtureRequest && generation === pageGeneration) recommendations.value = result
|
||||
} catch {
|
||||
if (request === fixtureRequest) recommendations.value = []
|
||||
if (request === fixtureRequest && generation === pageGeneration) recommendations.value = []
|
||||
} finally {
|
||||
if (request === fixtureRequest) fixtureLoading.value = false
|
||||
}
|
||||
@ -1165,8 +1250,12 @@ const save = async () => {
|
||||
dirty.value = false
|
||||
await refresh(true)
|
||||
}
|
||||
const action = async (work: () => Promise<void>) => {
|
||||
const action = async (work: () => Promise<void>, requirePreparationReady = false) => {
|
||||
if (busy.value) return
|
||||
if (requirePreparationReady && preparationLoading.value) {
|
||||
message.warning('扫描方案与发布版本正在加载,请等待完成后再保存或预检')
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
try {
|
||||
await work()
|
||||
@ -1182,7 +1271,7 @@ const savePreparation = () =>
|
||||
action(async () => {
|
||||
await save()
|
||||
message.success('准备配置已保存')
|
||||
})
|
||||
}, true)
|
||||
const runPrecheck = () =>
|
||||
action(async () => {
|
||||
if (dirty.value) await save()
|
||||
@ -1191,7 +1280,7 @@ const runPrecheck = () =>
|
||||
precheckResult.value.passed ? '预检通过,可以开始逐件执行' : '预检存在阻断项,请按提示处理'
|
||||
)
|
||||
if (precheckResult.value.passed) activeTab.value = 'units'
|
||||
})
|
||||
}, true)
|
||||
const cancelTask = () =>
|
||||
action(async () => {
|
||||
const result = await ElMessageBox.prompt(
|
||||
@ -1361,7 +1450,8 @@ let timer: ReturnType<typeof setInterval> | undefined
|
||||
let pollingSuspended = false
|
||||
let catalogLoaded=false,catalogPending:Promise<void>|undefined
|
||||
const loadCatalog=async()=>{
|
||||
if(!detail.value||locked.value||catalogLoaded||catalogPending||!props.active||activeTab.value!=='prepare')return
|
||||
if(catalogPending)return catalogPending
|
||||
if(!detail.value||locked.value||catalogLoaded||!props.active||activeTab.value!=='prepare')return
|
||||
const generation=pageGeneration
|
||||
catalogLoading.value=true
|
||||
const pending=(async()=>{
|
||||
@ -1380,7 +1470,9 @@ const initialize = async () => {
|
||||
logVisible.value = false
|
||||
logSelection.value = undefined
|
||||
pageGeneration++
|
||||
versionRequest++
|
||||
invalidateCaseRequests()
|
||||
fixtureRequest++
|
||||
fixtureLoading.value = false
|
||||
catalogLoaded=false;catalogPending=undefined;catalogLoading.value=false
|
||||
dirty.value = false
|
||||
selectedUnitId.value = ''
|
||||
@ -1431,8 +1523,8 @@ onBeforeRouteLeave(async () => {
|
||||
onUnmounted(() => {
|
||||
pollingSuspended = true
|
||||
pageGeneration++
|
||||
pageGeneration++
|
||||
versionRequest++
|
||||
invalidateCaseRequests()
|
||||
fixtureRequest++
|
||||
clearInterval(timer)
|
||||
})
|
||||
</script>
|
||||
|
||||
17
deploy/windows11/RELEASE-20261123-fixture-scan-defaults.md
Normal file
17
deploy/windows11/RELEASE-20261123-fixture-scan-defaults.md
Normal file
@ -0,0 +1,17 @@
|
||||
# 夹具默认扫描方案
|
||||
|
||||
在扫描任务准备页实际选择夹具时,先预选该夹具关联的扫描方案,之后仍可手动改选。仅作为默认值,不建立方案白名单,不自动保存任务或启动扫描。
|
||||
|
||||
| 夹具编号 | 默认扫描方案 ID | 扫描方案 |
|
||||
| --- | --- | --- |
|
||||
| REAL-SCAN-20261028-001-MIDDLE | c090028d47474d03b7cc2f8d77740abf | 中型夹具扫描路径 全流程 |
|
||||
| REAL-SCAN-20261028-001-LARGE | 8b0c888b013347c08df1a7167f721a83 | 大型夹具扫描路径 全流程 |
|
||||
| REAL-SCAN-20261028-001-SMALL | 88913757c6564826aa5d05946ccb702e | 小型夹具扫描路径 全流程 |
|
||||
|
||||
默认关系由后端按完整夹具编号返回,不按尺寸名称猜测。选择方案后使用原有发布版本、参数和设备角色加载流程;未发布则版本留空并提示先发布或改选。该修改不发布任何扫描流程,不增加数据库字段或数据迁移。
|
||||
|
||||
清空夹具、选择其他未关联夹具、轮询或重新打开任务不覆盖保存过的方案;执行方案模式和已经锁定的任务不套用单方案默认值。仍保留更换原因、任务修订并发检查和开始任务时的方案/版本冻结。
|
||||
|
||||
现场确认空闲后使用既有一键更新流程,同时更新前后端。本机使用 D:/project/cmvr-iot/update-platform.cmd;已接管的原生网关与启动适配保持。发布后核对 deployment.json 和一键启动报告的提交号,不能仅复制网页或 JAR 冒充正式发布。
|
||||
|
||||
功能验收可以只在未开始的准备表单选择夹具、手动改选和重新打开已保存任务;不点击保存、预检、获取资源或开始执行即可验证预选行为。实际扫描仍需现场按原流程操作。
|
||||
Loading…
Reference in New Issue
Block a user