Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
6ace9b135e
22
am-backend/sql/freescan/018_inspection_cad_features.sql
Normal file
22
am-backend/sql/freescan/018_inspection_cad_features.sql
Normal file
@ -0,0 +1,22 @@
|
||||
-- Additive, repeatable migration. Execute before starting the new Java service.
|
||||
-- Existing template, scan and immutable report tables are unchanged.
|
||||
CREATE TABLE IF NOT EXISTS lab_inspection_feature_plan (
|
||||
tenant_id BIGINT NOT NULL,
|
||||
scan_id VARCHAR(32) NOT NULL,
|
||||
revision INT NOT NULL,
|
||||
definition_json LONGTEXT NOT NULL,
|
||||
evaluation_json LONGTEXT NULL,
|
||||
update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (tenant_id, scan_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE IF NOT EXISTS lab_inspection_feature_template (
|
||||
id VARCHAR(32) NOT NULL,
|
||||
tenant_id BIGINT NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
revision INT NOT NULL DEFAULT 1,
|
||||
definition_json LONGTEXT NOT NULL,
|
||||
creator VARCHAR(64) NOT NULL DEFAULT '',
|
||||
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id), KEY idx_tenant_name (tenant_id, name)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@ -113,6 +113,7 @@ public class EdgeSystemServiceImpl implements EdgeSystemService {
|
||||
request.getRobotId(), SystemServiceGrpc.SystemServiceBlockingStub.class);
|
||||
stub = stub.withDeadlineAfter((totalTimeoutMs == 0 ? ActionQueueTimeouts.SERVER_DEFAULT_TIMEOUT_MS : totalTimeoutMs) + 5000L, TimeUnit.MILLISECONDS);
|
||||
return stub.executeActionQueue(builder.build());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.lab.controller.admin.inspection;
|
||||
import cn.iocoder.yudao.module.lab.service.inspection.LabFeaturePlanService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@RestController @RequestMapping("/lab/inspection/feature-templates")
|
||||
public class LabFeaturePlanController {
|
||||
@Resource private LabFeaturePlanService service;
|
||||
@GetMapping @PreAuthorize("@ss.hasPermission('lab:task:query') or @ss.hasPermission('lab:result:query')")
|
||||
public CommonResult<Object> list(){return CommonResult.success(service.templates(TenantContextHolder.getRequiredTenantId()));}
|
||||
@GetMapping("/{id}") @PreAuthorize("@ss.hasPermission('lab:task:query') or @ss.hasPermission('lab:result:query')")
|
||||
public CommonResult<Object> get(@PathVariable String id) throws Exception{return CommonResult.success(service.template(TenantContextHolder.getRequiredTenantId(),id));}
|
||||
@PostMapping @PreAuthorize("@ss.hasPermission('lab:result:confirm')")
|
||||
public CommonResult<Object> save(@RequestBody LabFeaturePlanService.Save body) throws Exception{return CommonResult.success(service.saveTemplate(TenantContextHolder.getRequiredTenantId(),body,String.valueOf(getLoginUserId())));}
|
||||
@DeleteMapping("/{id}") @PreAuthorize("@ss.hasPermission('lab:result:confirm')")
|
||||
public CommonResult<Boolean> delete(@PathVariable String id,@RequestParam int revision){service.delete(TenantContextHolder.getRequiredTenantId(),id,revision);return CommonResult.success(true);}
|
||||
@ExceptionHandler(org.springframework.web.server.ResponseStatusException.class)
|
||||
public CommonResult<Object> error(org.springframework.web.server.ResponseStatusException error){return CommonResult.error(error.getStatusCode().value(),error.getReason());}
|
||||
}
|
||||
@ -26,6 +26,7 @@ public class LabInspectionController {
|
||||
@Resource private LabInspectionRepository repository;
|
||||
@Resource private LabDimensionComparisonService comparisons;
|
||||
@Resource private LabInspectionTemplateService templates;
|
||||
@Resource private LabFeaturePlanService featurePlans;
|
||||
@Resource private DimensionService dimensions;
|
||||
@Resource private SecurityFrameworkService security;
|
||||
@Resource private JdbcTemplate jdbc;
|
||||
@ -51,9 +52,11 @@ public class LabInspectionController {
|
||||
Map<String,Object> job=engine==null?null:comparisons.engineJob(engine,method.equals("POST"));
|
||||
boolean binary=path.contains("/files/")||path.matches("/api/plan/templates/[a-zA-Z0-9_.-]+");
|
||||
if(binary&&!security.hasPermission("lab:data:download"))throw new ResponseStatusException(HttpStatus.FORBIDDEN,"没有文件下载权限");
|
||||
if(binary&&job!=null&&job.get("delivery_id")!=null) {
|
||||
if(binary&&job!=null) {
|
||||
String name=path.substring(path.lastIndexOf('/')+1);
|
||||
if(Set.of("report_signed_chromatogram.pdf","report.pdf","platform-result.stl").contains(name)) {
|
||||
if(!"ARCHIVED".equals(job.get("status"))||job.get("delivery_id")==null||job.get("awaiting_revision")!=null)
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT,"当前成果尚未完成归档,请等待归档完成或重试成果归档后下载");
|
||||
long tenant=TenantContextHolder.getRequiredTenantId();
|
||||
var delivery=jdbc.queryForMap("SELECT stl_id,pdf_id FROM lab_dimension_delivery WHERE id=? AND tenant_id=? AND deleted=0",job.get("delivery_id"),tenant);
|
||||
var file=dimensions.download(((Number)delivery.get(name.endsWith(".stl")?"stl_id":"pdf_id")).longValue());
|
||||
@ -63,14 +66,23 @@ public class LabInspectionController {
|
||||
}
|
||||
byte[] body=new byte[0];
|
||||
if(method.equals("POST")) {
|
||||
body=request.getInputStream().readNBytes(2*1024*1024+1);if(body.length>2*1024*1024)throw new ResponseStatusException(HttpStatus.PAYLOAD_TOO_LARGE,"检测计划请求内容过多");
|
||||
int limit=path.contains("/feature-")?32*1024*1024:2*1024*1024;
|
||||
body=request.getInputStream().readNBytes(limit+1);if(body.length>limit)throw new ResponseStatusException(HttpStatus.PAYLOAD_TOO_LARGE,"检测计划请求内容过多");
|
||||
if(path.endsWith("/plan/template")) {
|
||||
@SuppressWarnings("unchecked") Map<String,Object> parameters=mapper.readValue(body,Map.class);
|
||||
String chosen=Objects.toString(parameters.get("template_id"),"");parameters.remove("plan_template_snapshot");
|
||||
if(chosen.startsWith("managed-"))parameters.put("plan_template_snapshot",templates.snapshot(TenantContextHolder.getRequiredTenantId(),chosen.substring(8)));
|
||||
body=mapper.writeValueAsBytes(parameters);
|
||||
}
|
||||
if(engine!=null)comparisons.beginMutation(engine,path.substring(("/api/tasks/"+engine+"/").length()));
|
||||
if(path.endsWith("/feature-template")) {
|
||||
@SuppressWarnings("unchecked") Map<String,Object> parameters=mapper.readValue(body,Map.class);
|
||||
if(!(parameters.get("definition") instanceof Map<?,?> definition))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"请选择有效的特征模板");
|
||||
parameters.put("definition",featurePlans.templateDefinition(definition));body=mapper.writeValueAsBytes(parameters);
|
||||
}
|
||||
if(engine!=null) {
|
||||
@SuppressWarnings("unchecked") Map<String,Object> parameters=body.length==0?Map.of():mapper.readValue(body,Map.class);
|
||||
comparisons.beginMutation(engine,path.substring(("/api/tasks/"+engine+"/").length()),parameters);
|
||||
}
|
||||
}
|
||||
java.net.http.HttpResponse<InputStream> upstream;
|
||||
try{upstream=gateway.forward(path,method,body);}catch(ResponseStatusException failure) {
|
||||
@ -81,6 +93,8 @@ public class LabInspectionController {
|
||||
var json=repository.scan(TenantContextHolder.getRequiredTenantId(),engine).get("plan_json");
|
||||
if(json!=null)return CommonResult.success(mapper.readValue(json.toString(),Object.class));
|
||||
}
|
||||
if(method.equals("GET")&&path.endsWith("/feature-plan")&&engine!=null&&failure.getStatusCode().value()>=500)
|
||||
return CommonResult.success(featurePlans.saved(TenantContextHolder.getRequiredTenantId(),engine));
|
||||
throw failure;
|
||||
}
|
||||
if(binary&&upstream.statusCode()<400) {
|
||||
|
||||
@ -12,8 +12,10 @@ import java.util.zip.ZipFile;
|
||||
public class LabComparisonResults {
|
||||
@Resource private LabInspectionGateway gateway;
|
||||
@Resource private LabInspectionProperties settings;
|
||||
private final com.fasterxml.jackson.databind.ObjectMapper mapper=new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
private static final long RESERVE=512L*1024*1024;
|
||||
public record Pair(Path mesh,Path report,Path directory) implements AutoCloseable {
|
||||
public record Pair(Path mesh,Path report,Path directory,Map<String,Object> featureDocument) implements AutoCloseable {
|
||||
public Pair(Path mesh,Path report,Path directory){this(mesh,report,directory,Map.of());}
|
||||
@Override public void close() throws IOException {
|
||||
try(var paths=Files.list(directory)){for(Path path:paths.toList())Files.deleteIfExists(path);}Files.deleteIfExists(directory);
|
||||
}
|
||||
@ -48,6 +50,14 @@ public class LabComparisonResults {
|
||||
boolean success=false;
|
||||
try {
|
||||
Set<String> names=new LinkedHashSet<>();declaredMeshNames(state,names);
|
||||
if(names.isEmpty()&&state.get("stl_export") instanceof Map<?,?> export&&"done".equals(export.get("status"))) {
|
||||
names.add("cleaned_source.stl");
|
||||
}
|
||||
if(names.size()==1&&names.contains("cleaned_source.stl")) {
|
||||
if(!(state.get("stl_export") instanceof Map<?,?> export)||!"done".equals(export.get("status")))throw new IOException("处理后STL尚未就绪,请重新生成");
|
||||
Object input=export.get("input_revision");
|
||||
if((input instanceof Number||input instanceof String text&&text.matches("[0-9]{1,10}"))&&!Objects.toString(input).equals(Objects.toString(state.get("revision"))))throw new IOException("处理后STL版本已变化,请重新生成");
|
||||
}
|
||||
if(names.size()==1)mesh=download(engineId,names.iterator().next(),directory.resolve("result.stl"));
|
||||
pdf=download(engineId,"report_signed_chromatogram.pdf",directory.resolve("report.pdf"));
|
||||
if(pdf==null)pdf=download(engineId,"report.pdf",directory.resolve("report.pdf"));
|
||||
@ -73,9 +83,39 @@ public class LabComparisonResults {
|
||||
if(mesh==null||pdf==null)throw new IOException("计算服务尚未返回成套的处理后STL和PDF;可在工作区检查输出后重试归档");
|
||||
try(var in=Files.newInputStream(pdf)){if(!new String(in.readNBytes(5),java.nio.charset.StandardCharsets.US_ASCII).equals("%PDF-"))throw new IOException("计算服务返回的PDF内容无效");}
|
||||
validateMesh(mesh);
|
||||
success=true;return new Pair(mesh,pdf,directory);
|
||||
if(names.size()==1&&names.contains("cleaned_source.stl"))verifyProcessedExport(engineId,state);
|
||||
Map<String,Object> featureDocument=publishedFeatures(engineId,state);
|
||||
success=true;return new Pair(mesh,pdf,directory,featureDocument);
|
||||
} finally {if(!success)new Pair(mesh,pdf,directory).close();}
|
||||
}
|
||||
private void verifyProcessedExport(String engine,Map<?,?> before) throws IOException {
|
||||
String path="/api/tasks/"+engine;
|
||||
Object value=gateway.json(path,"GET",gateway.forward(path,"GET",new byte[0]));
|
||||
if(!(value instanceof Map<?,?> after)||!(before.get("stl_export") instanceof Map<?,?> expected)
|
||||
||!(after.get("stl_export") instanceof Map<?,?> current)||!"done".equals(current.get("status"))
|
||||
||!Objects.equals(expected.get("input_revision"),current.get("input_revision"))
|
||||
||!Objects.equals(before.get("revision"),after.get("revision"))
|
||||
||!LabInspectionGateway.revision(before).equals(LabInspectionGateway.revision(after)))
|
||||
throw new IOException("处理后STL输入或报告版本在下载期间已变化,请重新生成并归档");
|
||||
}
|
||||
private Map<String,Object> publishedFeatures(String engine,Map<?,?> state) throws IOException {
|
||||
if(state.get("feature_evaluation")==null&&state.get("result_snapshot_id")==null)return Map.of();
|
||||
var response=gateway.forward("/api/tasks/"+engine+"/files/feature_results.json","GET",new byte[0]);
|
||||
try(var input=response.body()) {
|
||||
if(response.statusCode()>=400)throw new IOException("报告特征快照尚未就绪,暂不能归档");
|
||||
byte[] bytes=input.readNBytes(32*1024*1024+1);
|
||||
if(bytes.length>32*1024*1024)throw new IOException("报告特征快照过大,暂不能归档");
|
||||
Map<String,Object> graph=mapper.readValue(bytes,new com.fasterxml.jackson.core.type.TypeReference<>(){});
|
||||
if(!"mm".equals(graph.get("unit"))||!(graph.get("features") instanceof List<?>)||!(graph.get("controls") instanceof List<?>)||!(graph.get("datum_systems") instanceof List<?>)||"stale".equals(graph.get("evaluation_state")))
|
||||
throw new IOException("报告特征快照无效或已经失效,暂不能归档");
|
||||
String expected=Objects.toString(state.get("result_snapshot_id"),"");
|
||||
if(!expected.isBlank()&&(!(graph.get("result_snapshot") instanceof Map<?,?> identity)||!expected.equals(identity.get("id"))))
|
||||
throw new IOException("报告测量快照版本不一致,等待重新同步");
|
||||
if(graph.get("report_revision")!=null&&!graph.get("report_revision").toString().equals(LabInspectionGateway.revision(state)))
|
||||
throw new IOException("报告与特征快照成果版本不一致");
|
||||
return graph;
|
||||
}
|
||||
}
|
||||
private static void validateMesh(Path mesh) throws IOException {
|
||||
long size=Files.size(mesh);
|
||||
try(var file=new RandomAccessFile(mesh.toFile(),"r")) {
|
||||
|
||||
@ -29,6 +29,7 @@ public class LabDimensionComparisonService {
|
||||
@Resource private LabInspectionGateway gateway;
|
||||
@Resource private LabInspectionRepository repository;
|
||||
@Resource private LabInspectionTemplateService templates;
|
||||
@Resource private LabFeaturePlanService featurePlans;
|
||||
@Resource private LabComparisonResults results;
|
||||
@Resource private ObjectMapper mapper;
|
||||
private final Semaphore submissions=new Semaphore(2);
|
||||
@ -89,17 +90,26 @@ public class LabDimensionComparisonService {
|
||||
options.put("source_clean",req.isSourceClean()?"1":"0");options.put("review_cleanup",!req.isSourceClean()&&req.isReviewCleanup()?"1":"0");
|
||||
options.put("cleanup_options",mapper.writeValueAsString(req.getCleanupOptions()));
|
||||
var drawing=input.files().get("drawing");
|
||||
var snapshot=templates.resolveUpload(tenant(),req.getPlanTemplateId(),input.files().get("target").name(),drawing==null?"":drawing.name());
|
||||
if(snapshot==null)throw bad("请选择已维护且启用的检测计划");
|
||||
options.put("selected_template_id",req.getPlanTemplateId());
|
||||
options.put("plan_template_id","cad-geometry");
|
||||
options.put("plan_template_snapshot",mapper.writeValueAsString(snapshot));
|
||||
if(req.getPlanTemplateId().startsWith("feature-")) {
|
||||
var snapshot=featurePlans.template(tenant(),req.getPlanTemplateId().substring(8));
|
||||
if(!(snapshot.get("definition") instanceof Map<?,?> definition)||Boolean.FALSE.equals(definition.get("enabled"))||!(definition.get("controls") instanceof List<?> controls)||controls.isEmpty())
|
||||
throw bad("请选择已维护且启用的 CAD 特征计划");
|
||||
if(!gateway.health().containsKey("feature_capabilities"))throw bad("CAD 特征计划需要新版检测 EXE,请安装后刷新状态");
|
||||
options.put("feature_template_id",req.getPlanTemplateId().substring(8));
|
||||
options.put("feature_template_snapshot",mapper.writeValueAsString(snapshot));
|
||||
} else {
|
||||
var snapshot=templates.resolveUpload(tenant(),req.getPlanTemplateId(),input.files().get("target").name(),drawing==null?"":drawing.name());
|
||||
if(snapshot==null)throw bad("请选择已维护且启用的检测计划");
|
||||
options.put("plan_template_snapshot",mapper.writeValueAsString(snapshot));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
private record Intent(Map<String,Object> job,DimensionService.ComparisonInput input,Map<String,String> options,boolean created) {}
|
||||
public Map<String,Object> start(Start req) {
|
||||
tenant();dimensions.checkComparisonAccess(req.getTaskId(),req.getUnitId(),"",false);
|
||||
if(req.getPlanTemplateId()==null||!req.getPlanTemplateId().startsWith("managed-")||req.getPlanTemplateId().length()<=8)
|
||||
if(req.getPlanTemplateId()==null||!req.getPlanTemplateId().matches("(?:managed-|feature-)[a-f0-9]{32}"))
|
||||
throw bad("请选择已维护且启用的检测计划,不能使用默认自动匹配或空计划");
|
||||
if(!Boolean.TRUE.equals(gateway.health().get("available")))throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE,"本机计算服务未就绪,请启动检测EXE后重试");
|
||||
if(!submissions.tryAcquire())throw new ResponseStatusException(HttpStatus.TOO_MANY_REQUESTS,"当前比对提交较多,请稍后重试");
|
||||
@ -148,9 +158,14 @@ public class LabDimensionComparisonService {
|
||||
}finally{submissions.release();}
|
||||
}
|
||||
public void beginMutation(String engine,String action) {
|
||||
beginMutation(engine,action,Map.of());
|
||||
}
|
||||
public void beginMutation(String engine,String action,Map<?,?> parameters) {
|
||||
var job=engineJob(engine,true);
|
||||
if(action.equals("binding-proposals"))return;
|
||||
jdbc.update("UPDATE lab_dimension_comparison SET awaiting_revision=COALESCE(awaiting_revision,COALESCE(engine_revision,'')),status='PROCESSING',last_error=NULL WHERE id=? AND tenant_id=?",job.get("id"),tenant());
|
||||
if(action.equals("binding-proposals")||action.equals("feature-proposals")&&!"apply".equals(parameters.get("mode"))
|
||||
||action.equals("cleanup")&&"export_stl".equals(parameters.get("operation")))return;
|
||||
String status=action.startsWith("feature-")&&!action.equals("feature-report")?"REVIEW":"PROCESSING";
|
||||
jdbc.update("UPDATE lab_dimension_comparison SET awaiting_revision=COALESCE(awaiting_revision,COALESCE(engine_revision,'')),status=?,last_error=NULL WHERE id=? AND tenant_id=?",status,job.get("id"),tenant());
|
||||
}
|
||||
public void observe(String engine,Map<?,?> state) {
|
||||
var list=rows("SELECT * FROM lab_dimension_comparison WHERE engine_id=? AND tenant_id=?",engine,tenant());if(list.isEmpty())return;
|
||||
@ -194,6 +209,12 @@ public class LabDimensionComparisonService {
|
||||
String planPath=path+"/plan";Object plan=gateway.json(planPath,"GET",gateway.forward(planPath,"GET",new byte[0]));String planJson=mapper.writeValueAsString(plan);
|
||||
repository.plan(tenant(),engine,planJson);
|
||||
try(var pair=results.fetch(engine,state)) {
|
||||
if(!pair.featureDocument().isEmpty()) {
|
||||
var published=new LinkedHashMap<String,Object>();
|
||||
if(plan instanceof Map<?,?> oldPlan)oldPlan.forEach((key,value)->published.put(key.toString(),value));else published.put("plan",plan);
|
||||
published.put("featureDocument",pair.featureDocument());published.put("resultSnapshotId",state.get("result_snapshot_id"));
|
||||
planJson=mapper.writeValueAsString(published);
|
||||
}
|
||||
@SuppressWarnings("unchecked") var latest=(Map<String,Object>)gateway.json(path,"GET",gateway.forward(path,"GET",new byte[0]));
|
||||
if(!revision.equals(LabInspectionGateway.revision(latest))||!"done".equals(latest.get("status"))||Boolean.FALSE.equals(latest.get("report_ready"))){observe(engine,latest);return;}
|
||||
if(required(id).get("awaiting_revision")!=null)return;
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
package cn.iocoder.yudao.module.lab.service.inspection;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import java.util.*;
|
||||
|
||||
/** Full, versioned feature graph storage. Never flatten datums or tolerance frames. */
|
||||
@Service
|
||||
public class LabFeaturePlanService {
|
||||
@Resource private JdbcTemplate jdbc;
|
||||
@Resource private ObjectMapper mapper;
|
||||
private static final Set<String> DERIVED=Set.of("measured","extraction_audit","diagnostic","status","scan_region","scan_region_diagnostic","preview_points","measurement_state","assessment_state","reason_code","next_action","workflow_note","workflow_warnings");
|
||||
@SuppressWarnings("unchecked") public void store(long tenant, String scan, Map<?,?> document, boolean evaluated) throws java.io.IOException {
|
||||
if(!(document.get("revision") instanceof Number number)||number.longValue()<0||number.longValue()>Integer.MAX_VALUE)
|
||||
throw new ResponseStatusException(HttpStatus.BAD_GATEWAY,"计算服务返回的特征版本无效");
|
||||
int revision=number.intValue();
|
||||
String value=mapper.writeValueAsString(document);
|
||||
Map<String,Object> definition=mapper.readValue(value,new TypeReference<>(){});definition.remove("evaluation");definition.remove("result_snapshot");
|
||||
for(var f:(List<Map<String,Object>>)definition.getOrDefault("features",List.of())) DERIVED.forEach(f::remove);
|
||||
for(var c:(List<Map<String,Object>>)definition.getOrDefault("controls",List.of())) {c.remove("result");DERIVED.forEach(c::remove);}
|
||||
jdbc.update("INSERT INTO lab_inspection_feature_plan(tenant_id,scan_id,revision,definition_json,evaluation_json) VALUES(?,?,?,?,?) ON DUPLICATE KEY UPDATE definition_json=CASE WHEN revision<=VALUES(revision) THEN VALUES(definition_json) ELSE definition_json END,evaluation_json=CASE WHEN revision<=VALUES(revision) THEN VALUES(evaluation_json) ELSE evaluation_json END,revision=GREATEST(revision,VALUES(revision)),update_time=NOW()",tenant,scan,revision,mapper.writeValueAsString(definition),evaluated?value:null);
|
||||
}
|
||||
public Map<String,Object> saved(long tenant,String scan) throws java.io.IOException {
|
||||
var rows=jdbc.queryForList("SELECT definition_json,evaluation_json FROM lab_inspection_feature_plan WHERE tenant_id=? AND scan_id=?",tenant,scan);
|
||||
if(rows.isEmpty())throw new ResponseStatusException(HttpStatus.NOT_FOUND,"尚无已保存的 CAD 特征计划");
|
||||
var row=rows.get(0);Object json=row.get("evaluation_json");if(json==null)json=row.get("definition_json");
|
||||
return Map.of("document",mapper.readValue(json.toString(),Map.class),"capabilities",Map.of(),"feature_types",Map.of(),"engine_unavailable",true);
|
||||
}
|
||||
public Map<String,Object> templates(long tenant) {
|
||||
return Map.of("list",jdbc.queryForList("SELECT id,name,revision,update_time AS updateTime FROM lab_inspection_feature_template WHERE tenant_id=? ORDER BY update_time DESC",tenant));
|
||||
}
|
||||
public Map<String,Object> template(long tenant,String id) throws Exception {
|
||||
var rows=jdbc.queryForList("SELECT id,name,revision,definition_json FROM lab_inspection_feature_template WHERE tenant_id=? AND id=?",tenant,id);
|
||||
if(rows.isEmpty())throw new ResponseStatusException(HttpStatus.NOT_FOUND,"特征模板不存在");
|
||||
var row=rows.get(0);row.put("definition",mapper.readValue(row.remove("definition_json").toString(),new TypeReference<Map<String,Object>>(){}));return row;
|
||||
}
|
||||
public record Save(String id,String name,Integer revision,Map<String,Object> definition) {}
|
||||
@SuppressWarnings("unchecked") public Map<String,Object> saveTemplate(long tenant, Save request,String creator) throws Exception {
|
||||
if(request==null||request.name()==null || request.name().isBlank() || request.name().length()>100)throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"请输入最多 100 字的模板名称");
|
||||
Map<String,Object> graph=templateDefinition(request.definition());
|
||||
String id=request.id(), json=mapper.writeValueAsString(graph);
|
||||
if(id==null || id.isBlank()) {id=UUID.randomUUID().toString().replace("-","");jdbc.update("INSERT INTO lab_inspection_feature_template(id,tenant_id,name,definition_json,creator) VALUES(?,?,?,?,?)",id,tenant,request.name().trim(),json,creator);}
|
||||
else if(request.revision()==null||jdbc.update("UPDATE lab_inspection_feature_template SET name=?,definition_json=?,revision=revision+1 WHERE tenant_id=? AND id=? AND revision=?",request.name().trim(),json,tenant,id,request.revision())!=1)throw new ResponseStatusException(HttpStatus.CONFLICT,"模板不存在或已修改,请重新加载");
|
||||
return template(tenant,id);
|
||||
}
|
||||
@SuppressWarnings("unchecked") public Map<String,Object> templateDefinition(Map<?,?> definition) throws java.io.IOException {
|
||||
if(definition==null||!Objects.equals(definition.get("schema_version"),2))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"请选择 v2 特征定义");
|
||||
// Descriptors are reusable; task-specific CAD bindings and measured values are not.
|
||||
Map<String,Object> graph=mapper.readValue(mapper.writeValueAsString(definition),new TypeReference<>(){});
|
||||
if(!"mm".equals(graph.get("unit")))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"特征模板单位必须为 mm");
|
||||
for(String group:List.of("features","controls","datum_systems"))if(!(graph.get(group) instanceof List<?> entries) || entries.size()>500 || entries.stream().anyMatch(e->!(e instanceof Map<?,?>)))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"特征、控制和基准体系必须为最多 500 项的列表");
|
||||
Set<String> featureIds=identifiers((List<Map<String,Object>>)graph.get("features")),frameIds=identifiers((List<Map<String,Object>>)graph.get("datum_systems"));
|
||||
identifiers((List<Map<String,Object>>)graph.get("controls"));
|
||||
for(var control:(List<Map<String,Object>>)graph.get("controls")) {
|
||||
if(!featureIds.contains(control.get("feature_id"))||control.get("other_feature_id")!=null&&!featureIds.contains(control.get("other_feature_id"))||control.get("datum_system_id")!=null&&!frameIds.contains(control.get("datum_system_id")))
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"检测控制引用了不存在的特征或基准体系");
|
||||
}
|
||||
Set<Object> datumIds=new HashSet<>();Set<String> labels=new HashSet<>();
|
||||
for(var feature:(List<Map<String,Object>>)graph.get("features"))if(feature.get("datum_label") instanceof String label&&!label.isBlank()) {
|
||||
if(!label.matches("[A-Z]{1,3}")||!labels.add(label))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"基准标签必须唯一且为 1–3 位大写字母");
|
||||
datumIds.add(feature.get("id"));
|
||||
}
|
||||
for(var frame:(List<Map<String,Object>>)graph.get("datum_systems")) {
|
||||
if(!(frame.get("precedence") instanceof List<?> groups)||groups.isEmpty()||groups.size()>3)throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"基准体系需按主、次、第三顺序配置");
|
||||
Set<Object> used=new HashSet<>();
|
||||
for(Object group:groups)if(!(group instanceof List<?> ids)||ids.isEmpty()||ids.stream().anyMatch(id->!datumIds.contains(id)||!used.add(id)))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"基准体系包含重复或失效的基准引用");
|
||||
}
|
||||
graph.remove("evaluation");graph.remove("result_snapshot");Object cad=graph.remove("cad_sha256");if(cad!=null)graph.put("reference_cad_sha256",cad);graph.remove("capability");graph.remove("revision");
|
||||
for(var feature:(List<Map<String,Object>>)graph.getOrDefault("features",List.of())) {
|
||||
DERIVED.forEach(feature::remove);
|
||||
Object source=feature.remove("source");
|
||||
if(source instanceof Map<?,?> s){feature.put("descriptor_source_kind",Objects.toString(s.get("kind"),""));feature.put("reference_binding",s);}
|
||||
if(feature.get("nominal") instanceof Map<?,?> nominal){nominal.remove("patch_mesh");nominal.remove("support_points");}
|
||||
feature.put("binding_status","needs_rematch");
|
||||
}
|
||||
for(var control:(List<Map<String,Object>>)graph.getOrDefault("controls",List.of())) {control.remove("result");DERIVED.forEach(control::remove);}
|
||||
return graph;
|
||||
}
|
||||
private static Set<String> identifiers(List<Map<String,Object>> entries) {
|
||||
Set<String> ids=new HashSet<>();
|
||||
for(var entry:entries)if(!(entry.get("id") instanceof String id)||id.isBlank()||id.length()>100||!ids.add(id))throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"特征、控制与基准体系标识不能为空或重复");
|
||||
return ids;
|
||||
}
|
||||
public void delete(long tenant,String id,int revision) {
|
||||
if(jdbc.update("DELETE FROM lab_inspection_feature_template WHERE tenant_id=? AND id=? AND revision=?",tenant,id,revision)!=1)throw new ResponseStatusException(HttpStatus.CONFLICT,"模板不存在或已修改");
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,7 @@ public class LabInspectionGateway {
|
||||
@Resource private LabInspectionProperties properties;
|
||||
@Resource private LabInspectionRepository repository;
|
||||
@Resource private ObjectMapper mapper;
|
||||
@Resource private LabFeaturePlanService featurePlans;
|
||||
private HttpClient client;
|
||||
private record Availability(boolean available,long checkedAt) {}
|
||||
private volatile Availability availability=new Availability(false,0);
|
||||
@ -42,10 +43,10 @@ public class LabInspectionGateway {
|
||||
}
|
||||
public void authorize(String path,String method) {
|
||||
boolean allowed=method.equals("GET")&&(path.equals("/api/health")||path.matches("/api/plan/templates(?:/[a-zA-Z0-9_.-]+)?"));
|
||||
if(path.matches("/api/tasks/[a-f0-9]{32}(?:/(?:preview|plan-preview|plan|plan/template|plan/import|binding-proposals|cleanup|cleanup/auto|compare|generate-report|auto-measure|files/[a-zA-Z0-9_.-]+))?")) {
|
||||
if(path.matches("/api/tasks/[a-f0-9]{32}(?:/(?:cad-features|feature-plan|feature-evaluate|feature-report|feature-proposals|feature-construct|feature-template|preview|plan-preview|plan|plan/template|plan/import|binding-proposals|cleanup|cleanup/auto|compare|generate-report|auto-measure|files/[a-zA-Z0-9_.-]+))?")) {
|
||||
if(!repository.owns(TenantContextHolder.getRequiredTenantId(),path.split("/")[3]))throw new ResponseStatusException(HttpStatus.NOT_FOUND,"检测任务不存在");
|
||||
allowed|=method.equals("GET")&&path.matches("/api/tasks/[a-f0-9]{32}(?:/(?:preview|plan-preview|plan|files/[a-zA-Z0-9_.-]+))?");
|
||||
allowed|=method.equals("POST")&&path.matches("/api/tasks/[a-f0-9]{32}/(?:plan|plan/template|plan/import|binding-proposals|cleanup|cleanup/auto|compare|generate-report|auto-measure)");
|
||||
allowed|=method.equals("GET")&&path.matches("/api/tasks/[a-f0-9]{32}(?:/(?:cad-features|feature-plan|preview|plan-preview|plan|files/[a-zA-Z0-9_.-]+))?");
|
||||
allowed|=method.equals("POST")&&path.matches("/api/tasks/[a-f0-9]{32}/(?:feature-plan|feature-evaluate|feature-report|feature-proposals|feature-construct|feature-template|plan|plan/template|plan/import|binding-proposals|cleanup|cleanup/auto|compare|generate-report|auto-measure)");
|
||||
}
|
||||
if(!allowed)throw new ResponseStatusException(HttpStatus.NOT_FOUND,"不支持的检测接口,请从任务工作台发起比对");
|
||||
}
|
||||
@ -71,8 +72,12 @@ public class LabInspectionGateway {
|
||||
public Map<String,Object> health() {
|
||||
try {
|
||||
var response=send(request("/api/health",properties.getConnectTimeout()).GET().build());
|
||||
try(var in=response.body()){if(response.statusCode()>=400){availability=new Availability(false,System.currentTimeMillis());return Map.of("available",false,"message","计算服务健康检查失败");}}
|
||||
return Map.of("available",true,"message","");
|
||||
if(response.statusCode()>=400){response.body().close();availability=new Availability(false,System.currentTimeMillis());return Map.of("available",false,"message","计算服务健康检查失败");}
|
||||
Object value=json("/api/health","GET",response);
|
||||
var health=new LinkedHashMap<String,Object>();health.put("available",true);health.put("message","");
|
||||
if(value instanceof Map<?,?> body && body.get("feature_capabilities") instanceof Map<?,?> capabilities)
|
||||
health.put("feature_capabilities",capabilities);
|
||||
return health;
|
||||
}catch(Exception error){return Map.of("available",false,"message","本机计算服务未就绪,请启动检测EXE后重试");}
|
||||
}
|
||||
public HttpResponse<InputStream> forward(String path,String method,byte[] body) {
|
||||
@ -113,6 +118,9 @@ public class LabInspectionGateway {
|
||||
}
|
||||
if(method.equals("POST")&&path.matches("/api/tasks/[a-f0-9]{32}/(?:plan|plan/template|plan/import)")&&value instanceof Map<?,?> result)
|
||||
repository.plan(TenantContextHolder.getRequiredTenantId(),path.split("/")[3],mapper.writeValueAsString(result));
|
||||
if(path.matches("/api/tasks/[a-f0-9]{32}/(?:feature-plan|feature-evaluate|feature-template|feature-proposals|feature-construct)")
|
||||
&& value instanceof Map<?,?> result && result.get("document") instanceof Map<?,?> document)
|
||||
featurePlans.store(TenantContextHolder.getRequiredTenantId(),path.split("/")[3],document,document.containsKey("evaluation")&&!"stale".equals(document.get("evaluation_state")));
|
||||
return value;
|
||||
}
|
||||
public static String revision(Map<?,?> state){return Objects.toString(state.get("report_revision"),Objects.toString(state.get("revision"),""));}
|
||||
|
||||
@ -129,6 +129,7 @@
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/qs": "^6.15.0",
|
||||
"@types/three": "0.181.0",
|
||||
"@unocss/eslint-config": "^66.6.8",
|
||||
"@unocss/eslint-plugin": "66.6.8",
|
||||
"@unocss/transformer-variant-group": "^66.6.8",
|
||||
|
||||
51
am-web/pnpm-lock.yaml
generated
51
am-web/pnpm-lock.yaml
generated
@ -297,6 +297,9 @@ importers:
|
||||
'@types/qs':
|
||||
specifier: ^6.15.0
|
||||
version: 6.15.0
|
||||
'@types/three':
|
||||
specifier: 0.181.0
|
||||
version: 0.181.0
|
||||
'@unocss/eslint-config':
|
||||
specifier: ^66.6.8
|
||||
version: 66.6.8(eslint@10.3.0(jiti@2.6.1)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)
|
||||
@ -800,6 +803,9 @@ packages:
|
||||
resolution: {integrity: sha512-kzyuwOAQnXJNLS9PSyrk0CWk35nWJW/zl/6KvnTBMFK65gm7U1/Z5BqjxeapjZCIhQcM/DsrEmcbRwDyXyXK4A==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
'@dimforge/rapier3d-compat@0.12.0':
|
||||
resolution: {integrity: sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==}
|
||||
|
||||
'@element-plus/icons-vue@2.3.2':
|
||||
resolution: {integrity: sha512-OzIuTaIfC8QXEPmJvB4Y4kw34rSXdCJzxcD1kFStBvr8bK6X1zQAYDo0CNMjojnfTqRQCJ0I7prlErcoRiET2A==}
|
||||
peerDependencies:
|
||||
@ -1771,6 +1777,9 @@ packages:
|
||||
'@transloadit/prettier-bytes@0.0.7':
|
||||
resolution: {integrity: sha512-VeJbUb0wEKbcwaSlj5n+LscBl9IPgLPkHVGBkh00cztv6X4L/TJXK58LzFuBKX7/GAfiGhIwH67YTLTlzvIzBA==}
|
||||
|
||||
'@tweenjs/tween.js@23.1.3':
|
||||
resolution: {integrity: sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||
|
||||
@ -1819,6 +1828,12 @@ packages:
|
||||
'@types/qs@6.15.0':
|
||||
resolution: {integrity: sha512-JawvT8iBVWpzTrz3EGw9BTQFg3BQNmwERdKE22vlTxawwtbyUSlMppvZYKLZzB5zgACXdXxbD3m1bXaMqP/9ow==}
|
||||
|
||||
'@types/stats.js@0.17.4':
|
||||
resolution: {integrity: sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==}
|
||||
|
||||
'@types/three@0.181.0':
|
||||
resolution: {integrity: sha512-MLF1ks8yRM2k71D7RprFpDb9DOX0p22DbdPqT/uAkc6AtQXjxWCVDjCy23G9t1o8HcQPk7woD2NIyiaWcWPYmA==}
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
|
||||
|
||||
@ -1831,6 +1846,9 @@ packages:
|
||||
'@types/web-bluetooth@0.0.21':
|
||||
resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==}
|
||||
|
||||
'@types/webxr@0.5.24':
|
||||
resolution: {integrity: sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==}
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.59.2':
|
||||
resolution: {integrity: sha512-j/bwmkBvHUtPNxzuWe5z6BEk3q54YRyGlBXkSsmfoih7zNrBvl5A9A98anlp/7JbyZcWIJ8KXo/3Tq/DjFLtuQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
@ -2339,6 +2357,9 @@ packages:
|
||||
slate: ^0.123.0
|
||||
snabbdom: ^3.6.0
|
||||
|
||||
'@webgpu/types@0.1.74':
|
||||
resolution: {integrity: sha512-lgiI4hbuLcI9unnm2cL/tvCaQU45dp0xcLWJh5uB/9MBGvIA4F8XIk7nSiBeg+K4xWGYwgZKn80LmERI5CxoTA==}
|
||||
|
||||
'@xmldom/xmldom@0.8.11':
|
||||
resolution: {integrity: sha512-cQzWCtO6C8TQiYl1ruKNn2U6Ao4o4WBBcbL61yJl84x+j5sOWWFU9X7DpND8XZG3daDppSsigMdfAIl2upQBRw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@ -3413,6 +3434,9 @@ packages:
|
||||
picomatch:
|
||||
optional: true
|
||||
|
||||
fflate@0.8.3:
|
||||
resolution: {integrity: sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==}
|
||||
|
||||
file-entry-cache@11.1.2:
|
||||
resolution: {integrity: sha512-N2WFfK12gmrK1c1GXOqiAJ1tc5YE+R53zvQ+t5P8S5XhnmKYVB5eZEiLNZKDSmoG8wqqbF9EXYBBW/nef19log==}
|
||||
|
||||
@ -4189,6 +4213,9 @@ packages:
|
||||
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
meshoptimizer@0.22.0:
|
||||
resolution: {integrity: sha512-IebiK79sqIy+E4EgOr+CAw+Ke8hAspXKzBd0JdgEmPHiAwmvEj2S4h1rfvo+o/BnfEYd/jAOg5IeeIjzlzSnDg==}
|
||||
|
||||
micromatch@4.0.8:
|
||||
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
|
||||
engines: {node: '>=8.6'}
|
||||
@ -6226,6 +6253,8 @@ snapshots:
|
||||
|
||||
'@ctrl/tinycolor@4.2.0': {}
|
||||
|
||||
'@dimforge/rapier3d-compat@0.12.0': {}
|
||||
|
||||
'@element-plus/icons-vue@2.3.2(vue@3.5.34(typescript@6.0.3))':
|
||||
dependencies:
|
||||
vue: 3.5.34(typescript@6.0.3)
|
||||
@ -6981,6 +7010,8 @@ snapshots:
|
||||
|
||||
'@transloadit/prettier-bytes@0.0.7': {}
|
||||
|
||||
'@tweenjs/tween.js@23.1.3': {}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
@ -7028,6 +7059,18 @@ snapshots:
|
||||
|
||||
'@types/qs@6.15.0': {}
|
||||
|
||||
'@types/stats.js@0.17.4': {}
|
||||
|
||||
'@types/three@0.181.0':
|
||||
dependencies:
|
||||
'@dimforge/rapier3d-compat': 0.12.0
|
||||
'@tweenjs/tween.js': 23.1.3
|
||||
'@types/stats.js': 0.17.4
|
||||
'@types/webxr': 0.5.24
|
||||
'@webgpu/types': 0.1.74
|
||||
fflate: 0.8.3
|
||||
meshoptimizer: 0.22.0
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
optional: true
|
||||
|
||||
@ -7037,6 +7080,8 @@ snapshots:
|
||||
|
||||
'@types/web-bluetooth@0.0.21': {}
|
||||
|
||||
'@types/webxr@0.5.24': {}
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.59.2(@typescript-eslint/parser@8.59.2(eslint@10.3.0(jiti@2.6.1)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3))(eslint@10.3.0(jiti@2.6.1)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
@ -7820,6 +7865,8 @@ snapshots:
|
||||
slate: 0.123.0
|
||||
snabbdom: 3.6.3
|
||||
|
||||
'@webgpu/types@0.1.74': {}
|
||||
|
||||
'@xmldom/xmldom@0.8.11': {}
|
||||
|
||||
'@zxcvbn-ts/core@3.0.4':
|
||||
@ -9028,6 +9075,8 @@ snapshots:
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.5
|
||||
|
||||
fflate@0.8.3: {}
|
||||
|
||||
file-entry-cache@11.1.2:
|
||||
dependencies:
|
||||
flat-cache: 6.1.22
|
||||
@ -9777,6 +9826,8 @@ snapshots:
|
||||
|
||||
merge2@1.4.1: {}
|
||||
|
||||
meshoptimizer@0.22.0: {}
|
||||
|
||||
micromatch@4.0.8:
|
||||
dependencies:
|
||||
braces: 3.0.3
|
||||
|
||||
@ -1,11 +1,58 @@
|
||||
import request from '@/config/axios'
|
||||
import { visibleTemplate } from '@/utils/inspectionPresentation'
|
||||
const base = '/lab/inspection',
|
||||
root = `${base}/api`
|
||||
export const health = () => request.get<any>({ url: `${base}/health`, timeout: 10000 })
|
||||
export const comparison = (taskId: string, unitId: string, signal?: AbortSignal) =>
|
||||
request.get<any>({ url: `${base}/comparison`, params: { taskId, unitId }, signal })
|
||||
export const startComparison = (data: any) => request.post<any>({ url: `${base}/comparison/start`, data, timeout: 620000 })
|
||||
export const startComparison = (data: any) =>
|
||||
request.post<any>({ url: `${base}/comparison/start`, data, timeout: 620000 })
|
||||
export const templates = () => request.get({ url: `${base}/templates/options` })
|
||||
export const featureCapabilities = async () => (await health()).feature_capabilities
|
||||
export const featureTemplate = (id: string) =>
|
||||
request.get({ url: `${base}/feature-templates/${id}` })
|
||||
export const featureTemplates = async () => {
|
||||
const response = await request.get({ url: `${base}/feature-templates` })
|
||||
const rows = await Promise.all(
|
||||
response.list.map(async (row: any) => {
|
||||
const detail = await featureTemplate(row.id)
|
||||
return visibleTemplate(detail.definition)
|
||||
? {
|
||||
...row,
|
||||
enabled: detail.definition.enabled !== false,
|
||||
controlCount: detail.definition.controls?.length || 0
|
||||
}
|
||||
: null
|
||||
})
|
||||
)
|
||||
return { ...response, list: rows.filter(Boolean) }
|
||||
}
|
||||
export const saveFeatureTemplate = (data: any) =>
|
||||
request.post({ url: `${base}/feature-templates`, data })
|
||||
export const deleteFeatureTemplate = (id: string, revision: number) =>
|
||||
request.delete({ url: `${base}/feature-templates/${id}`, params: { revision } })
|
||||
export const comparisonTemplates = async () => {
|
||||
const legacy = await templates()
|
||||
try {
|
||||
const features = await featureTemplates()
|
||||
return {
|
||||
...legacy,
|
||||
templates: [
|
||||
...legacy.templates.map((item: any) => ({ ...item, kind: 'legacy' })),
|
||||
...features.list
|
||||
.filter((item: any) => item.enabled && item.controlCount > 0)
|
||||
.map((item: any) => ({
|
||||
id: `feature-${item.id}`,
|
||||
label: item.name,
|
||||
version: item.revision,
|
||||
kind: 'feature'
|
||||
}))
|
||||
]
|
||||
}
|
||||
} catch {
|
||||
return { ...legacy, featureTemplatesUnavailable: true }
|
||||
}
|
||||
}
|
||||
export const templatePage = (params: any) => request.get({ url: `${base}/templates/page`, params })
|
||||
export const templateDetail = (id: string) => request.get({ url: `${base}/templates/${id}` })
|
||||
export const saveTemplate = (data: any) => request.post({ url: `${base}/templates/save`, data })
|
||||
@ -16,11 +63,13 @@ export const record = (id: string) => request.get({ url: `${base}/records/${id}`
|
||||
export const sync = (id: string) =>
|
||||
request.post({ url: `${base}/records/${id}/sync`, timeout: 120000 })
|
||||
export const get = (id: string, action: string) =>
|
||||
request.get({ url: `${root}/tasks/${id}/${action}` })
|
||||
request.get({ url: `${root}/tasks/${id}/${action}`, timeout: 600000 })
|
||||
export const post = (id: string, action: string, data: any = {}) =>
|
||||
request.post({ url: `${root}/tasks/${id}/${action}`, data, timeout: 600000 })
|
||||
export const artifact = (id: string, name: string) =>
|
||||
request.download<Blob>({ url: `${root}/tasks/${id}/files/${name}` })
|
||||
export const processedStl = (id: string) =>
|
||||
request.download<Blob>({ url: `${root}/tasks/${id}/files/cleaned_source.stl`, timeout: 600000 })
|
||||
export const templateFile = (id: string) =>
|
||||
request.download<Blob>({ url: `${root}/plan/templates/${encodeURIComponent(id)}` })
|
||||
export function saveBlob(blob: Blob, name: string) {
|
||||
|
||||
97
am-web/src/utils/inspectionPresentation.ts
Normal file
97
am-web/src/utils/inspectionPresentation.ts
Normal file
@ -0,0 +1,97 @@
|
||||
export function userMessage(error: any, fallback = '操作未完成,请稍后重试') {
|
||||
const message = String(typeof error === 'string' ? error : error?.message || '').trim()
|
||||
if (!message) return fallback
|
||||
if (/access violation|Non-positive solid volume|几何内核|ABViewer|OCP/i.test(message))
|
||||
return '模型读取失败,请检查模型完整性,或重新导出 STEP 后上传。'
|
||||
if (
|
||||
/Python|Java\b|ECONN|Network Error|fetch failed|request failed|连接失败|源码服务|终端日志/i.test(
|
||||
message
|
||||
)
|
||||
)
|
||||
return '检测服务暂不可用,请稍后重试或联系管理员。'
|
||||
if (
|
||||
/schema_version|\bv2\b|\bID\b|\w+_\w+|topology\.log|projection\.log|JSON|Traceback|TypeError|KeyError|ValueError|SyntaxError|[A-Za-z]:[\\/]|\/api\/|feature_id|datum_system_id/.test(
|
||||
message
|
||||
)
|
||||
)
|
||||
return fallback
|
||||
if (/算法待支持|尚未实现|未实现|约束模拟器/.test(message))
|
||||
return '当前测量方式不支持此项配置,请调整特征、基准或测量方式。'
|
||||
if (!/[\u3400-\u9fff]/.test(message)) return fallback
|
||||
return message
|
||||
}
|
||||
|
||||
export const methodLabel = (method: string) =>
|
||||
({
|
||||
minimum_zone_normalized_parallel_planes_envelope: '最小区域平面度',
|
||||
minimum_zone_concentric_circles_envelope: '最小区域圆度',
|
||||
minimum_zone_coaxial_cylinders_envelope: '最小区域圆柱度',
|
||||
minimum_enclosing_line_cylinder_envelope: '包络轴线直线度',
|
||||
least_squares_diameter: '最小二乘直径',
|
||||
least_squares_radius: '最小二乘半径',
|
||||
minimum_zone_parallel_planes_lp: '最小区域平面度',
|
||||
minimum_zone_concentric_circles_powell: '最小区域圆度',
|
||||
minimum_zone_coaxial_cylinders_powell: '最小区域圆柱度',
|
||||
minimum_enclosing_line_cylinder: '包络轴线直线度',
|
||||
least_squares_included_angle_deg: '圆锥角度',
|
||||
defined_circle_arc_length: '指定弧段长度',
|
||||
minimum_circumscribed_sample_cylinder: '外圆包络配合直径',
|
||||
maximum_inscribed_sample_cylinder: '内孔包络配合直径',
|
||||
associated_direction_angle_deg: '方向夹角',
|
||||
parallel_axis_pitch_distance: '平行轴线间距',
|
||||
projected_center_distance: '指定方向距离',
|
||||
center_to_center_distance: '空间中心距',
|
||||
datum_constrained_axis_orientation_at_defined_length: '轴线方向公差',
|
||||
datum_constrained_parallel_plane_zone: '平面方向公差',
|
||||
diametrical_associated_axis_zone: '同轴或同心公差带',
|
||||
datum_axis_radial_range: '径向跳动',
|
||||
datum_axis_radial_circular_range: '径向圆跳动',
|
||||
datum_axis_radial_total_range: '径向全跳动',
|
||||
datum_axis_axial_circular_range: '端面圆跳动',
|
||||
datum_axis_axial_total_range: '端面全跳动',
|
||||
measured_plane_intersections_at_reference_line: '指定位置的平面间距',
|
||||
measured_center_to_plane_distance: '点面距离',
|
||||
parallel_measured_axis_distance: '平行轴距',
|
||||
shortest_measured_skew_axis_distance: '空间轴线最短距离',
|
||||
minimum_sampled_surface_distance: '扫描区域最小点距',
|
||||
full_retained_scan_projected_extent: '扫描区域投影跨度',
|
||||
measured_direction_angle_acute_deg: '较小夹角',
|
||||
measured_direction_angle_directed_deg: '方向夹角',
|
||||
measured_direction_angle_supplementary_deg: '补角',
|
||||
datum_321_associated_axis_position: '轴线位置度',
|
||||
datum_321_associated_center_diametrical_position: '中心位置度',
|
||||
datum_associated_median_plane_symmetry: '中间面对称度',
|
||||
datum_321_bilateral_exact_trimmed_cad_profile: '曲面轮廓度',
|
||||
datum_321_bilateral_analytic_profile: '解析特征轮廓度'
|
||||
})[method] || '其他评价方法'
|
||||
|
||||
export function drawingIssue(issue: any) {
|
||||
return issue.diagnostic
|
||||
? userMessage(issue.diagnostic, '请核对图纸标注与几何位置')
|
||||
: {
|
||||
ambiguous_binding: '存在多个匹配特征,请选择对应位置',
|
||||
unmatched_dimension: '未找到对应尺寸,请补充关联',
|
||||
unmatched_feature: '未找到对应特征,请重新选面',
|
||||
drawing_unreadable: '图纸读取失败,请检查文件',
|
||||
drawing_coverage_unverified: '请核对检测项及基准关系'
|
||||
}[issue.status] || '请核对检测配置'
|
||||
}
|
||||
|
||||
export function visibleTemplate(definition: any) {
|
||||
return definition?.template_usage !== 'verification'
|
||||
}
|
||||
|
||||
export function pendingInspectionCount(state: any): number {
|
||||
if (state?.status !== 'done') return 0
|
||||
const counts = state.result_counts || {}
|
||||
return Math.max(0, Number(counts.pending) || 0, Number(counts.without_value) || 0)
|
||||
}
|
||||
|
||||
export function inspectionCompletionLabel(state: any): string | undefined {
|
||||
if (state?.status !== 'done') return undefined
|
||||
if (state.report_ready === false) return '计划已计算 · 待生成报告'
|
||||
const pending = pendingInspectionCount(state)
|
||||
if (pending) return `计算完成 · 待处理 ${pending} 项`
|
||||
if (state.measurement_complete === false) return '计算完成 · 待复核'
|
||||
return undefined
|
||||
}
|
||||
@ -1,61 +1,195 @@
|
||||
<template>
|
||||
<section class="comparison-panel">
|
||||
<div class="comparison-heading">
|
||||
<div><h3>尺寸比对</h3><span class="secondary">使用选定的三维数模、扫描PLY和检测计划;二维PDF图纸选填。</span></div>
|
||||
<div
|
||||
><h3>尺寸比对</h3
|
||||
><span class="secondary"
|
||||
>使用选定的三维数模、扫描PLY和检测计划;二维PDF图纸选填。</span
|
||||
></div
|
||||
>
|
||||
<div class="comparison-buttons">
|
||||
<el-tag :type="health.available ? 'success' : 'info'">{{ health.available ? '计算服务就绪' : '计算服务未就绪' }}</el-tag>
|
||||
<el-tag :type="health.available ? 'success' : 'info'">{{
|
||||
health.available ? '计算服务就绪' : '计算服务未就绪'
|
||||
}}</el-tag>
|
||||
<el-button :loading="loading" @click="refresh(true)">刷新状态</el-button>
|
||||
<el-button v-hasPermi="['lab:result:query']" @click="router.push('/lab/dimension/inspection-templates')">维护检测计划</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['lab:result:query']"
|
||||
@click="router.push('/lab/dimension/inspection-templates')"
|
||||
>维护检测计划</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
||||
<el-form label-position="top" class="comparison-options" :disabled="busy || savingInputs">
|
||||
<el-form-item label="检测计划" required :error="options.planTemplateId && !selectedPlan ? '该计划已不可用,请重新选择' : ''">
|
||||
<el-select ref="planSelect" v-model="options.planTemplateId" filterable clearable placeholder="请选择检测计划(必填)" class="plan-select">
|
||||
<el-option v-for="item in catalog" :key="item.id" :value="item.id" :label="`${item.label} · V${item.version}`" />
|
||||
<el-form-item
|
||||
label="检测计划"
|
||||
required
|
||||
:error="options.planTemplateId && !selectedPlan ? '该计划已不可用,请重新选择' : ''"
|
||||
>
|
||||
<el-select
|
||||
ref="planSelect"
|
||||
v-model="options.planTemplateId"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择检测计划(必填)"
|
||||
class="plan-select"
|
||||
>
|
||||
<el-option-group v-for="group in planGroups" :key="group.label" :label="group.label">
|
||||
<el-option
|
||||
v-for="item in group.items"
|
||||
:key="item.id"
|
||||
:value="item.id"
|
||||
:label="`${item.label} · V${item.version}`"
|
||||
:disabled="item.kind === 'feature' && !health.feature_capabilities"
|
||||
/>
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
<span v-if="!catalog.length && !loading" class="secondary">暂无可用计划,请先点击“维护检测计划”录入并启用,再刷新状态。</span>
|
||||
<span v-if="!catalog.length && !loading" class="secondary"
|
||||
>暂无可用计划,请先点击“维护检测计划”录入并启用,再刷新状态。</span
|
||||
>
|
||||
</el-form-item>
|
||||
<div class="comparison-fields">
|
||||
<el-form-item label="扫描数据单位"><el-select v-model="options.sourceScale"><el-option v-for="item in units" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item>
|
||||
<el-form-item label="标准数模单位"><el-select v-model="options.targetScale"><el-option v-for="item in units" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item>
|
||||
<el-form-item label="表面偏差阈值(mm)"><el-input-number v-model="options.tolerance" :min="0.001" :max="100" :precision="3" /></el-form-item>
|
||||
<el-form-item label="扫描数据单位"
|
||||
><el-select v-model="options.sourceScale"
|
||||
><el-option
|
||||
v-for="item in units"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value" /></el-select
|
||||
></el-form-item>
|
||||
<el-form-item label="标准数模单位"
|
||||
><el-select v-model="options.targetScale"
|
||||
><el-option
|
||||
v-for="item in units"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value" /></el-select
|
||||
></el-form-item>
|
||||
<el-form-item label="表面偏差阈值(mm)"
|
||||
><el-input-number v-model="options.tolerance" :min="0.001" :max="100" :precision="3"
|
||||
/></el-form-item>
|
||||
</div>
|
||||
<div class="comparison-report"><el-checkbox v-model="options.autoReport">计算后自动生成报告</el-checkbox></div>
|
||||
<div class="comparison-report"
|
||||
><el-checkbox v-model="options.autoReport">计算后自动生成报告</el-checkbox></div
|
||||
>
|
||||
<section class="comparison-preprocessing" aria-label="点云预处理设置">
|
||||
<h4>点云预处理设置</h4>
|
||||
<el-checkbox v-model="options.sourceClean">扫描数据已清理,仅含被测零件</el-checkbox>
|
||||
<el-checkbox v-model="options.reviewCleanup" :disabled="options.sourceClean">对齐前先人工确认点云清理</el-checkbox>
|
||||
<el-checkbox v-model="options.reviewCleanup" :disabled="options.sourceClean"
|
||||
>对齐前先人工确认点云清理</el-checkbox
|
||||
>
|
||||
</section>
|
||||
</el-form>
|
||||
<el-alert v-if="blockers.length" class="comparison-checklist gap" title="暂不能开始尺寸比对,请完成以下事项" type="warning" :closable="false" show-icon>
|
||||
<el-alert
|
||||
v-if="featureTemplatesUnavailable"
|
||||
title="CAD 特征计划暂不可用,请确认已执行增量升级;原有检测计划可继续使用。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="blockers.length"
|
||||
class="comparison-checklist gap"
|
||||
title="暂不能开始尺寸比对,请完成以下事项"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<ul class="comparison-blockers">
|
||||
<li v-for="issue in blockers" :key="issue.key">
|
||||
<span>{{ issue.text }}</span>
|
||||
<el-button v-if="canResolveIssue(issue.action)" type="primary" link :disabled="busy || savingInputs || syncing" @click="resolveIssue(issue.action)">{{ issue.label }}</el-button>
|
||||
<el-button
|
||||
v-if="canResolveIssue(issue.action)"
|
||||
type="primary"
|
||||
link
|
||||
:disabled="busy || savingInputs || syncing"
|
||||
@click="resolveIssue(issue.action)"
|
||||
>{{ issue.label }}</el-button
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</el-alert>
|
||||
<div class="comparison-buttons gap">
|
||||
<el-button type="primary" :loading="busy" :disabled="savingInputs || !ready || blockers.length > 0" v-hasPermi="['lab:data:upload']" @click="start">{{ busy ? '正在提交文件' : '开始尺寸比对' }}</el-button>
|
||||
<el-button v-if="job.engine_id" type="primary" plain @click="expanded = true">打开比对工作区</el-button>
|
||||
<el-button v-if="job.engine_id && ['ARCHIVE_ERROR', 'ARCHIVE_PENDING'].includes(job.status)" :loading="syncing" v-hasPermi="['lab:data:upload']" @click="sync">重试成果归档</el-button>
|
||||
<span v-if="!blockers.length" class="comparison-ready">资料版本已保存,检测计划已选择,可以开始比对。</span>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="busy"
|
||||
:disabled="savingInputs || !ready || blockers.length > 0"
|
||||
v-hasPermi="['lab:data:upload']"
|
||||
@click="start"
|
||||
>{{ busy ? '正在提交文件' : '开始尺寸比对' }}</el-button
|
||||
>
|
||||
<el-button v-if="job.engine_id" type="primary" plain @click="expanded = true"
|
||||
>打开比对工作区</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="job.engine_id && ['ARCHIVE_ERROR', 'ARCHIVE_PENDING'].includes(job.status)"
|
||||
:loading="syncing"
|
||||
v-hasPermi="['lab:data:upload']"
|
||||
@click="sync"
|
||||
>重试成果归档</el-button
|
||||
>
|
||||
<span v-if="!blockers.length" class="comparison-ready"
|
||||
>资料版本已保存,检测计划已选择,可以开始比对。</span
|
||||
>
|
||||
</div>
|
||||
<div v-if="job.id" class="comparison-status">
|
||||
<div class="comparison-heading"><strong>{{ labels[job.status] || job.status }}</strong><span class="secondary">{{ sameInput ? '对应当前输入' : '历史比对,输入版本已更新' }}</span></div>
|
||||
<p class="secondary">创建时间:{{ formatNullableDate(job.create_time) }} · 状态同步时间:{{ formatNullableDate(job.update_time) }}</p>
|
||||
<el-progress v-if="['SUBMITTING','PROCESSING'].includes(job.status)" :percentage="50" :indeterminate="true" :show-text="false" />
|
||||
<div class="comparison-heading"
|
||||
><strong>{{ labels[job.status] || job.status }}</strong
|
||||
><span class="secondary">{{
|
||||
sameInput ? '对应当前输入' : '历史比对,输入版本已更新'
|
||||
}}</span></div
|
||||
>
|
||||
<p class="secondary"
|
||||
>创建时间:{{ formatNullableDate(job.create_time) }} · 状态同步时间:{{
|
||||
formatNullableDate(job.update_time)
|
||||
}}</p
|
||||
>
|
||||
<el-progress
|
||||
v-if="['SUBMITTING', 'PROCESSING'].includes(job.status)"
|
||||
:percentage="50"
|
||||
:indeterminate="true"
|
||||
:show-text="false"
|
||||
/>
|
||||
<p v-if="job.last_error" class="comparison-error">{{ job.last_error }}</p>
|
||||
<p v-else-if="job.status === 'ARCHIVED'">STL与PDF已成套归档,可在下方核对、查看并确认交付。</p>
|
||||
<p v-else-if="job.status === 'ARCHIVED'"
|
||||
>STL与PDF已成套归档,可在下方核对、查看并确认交付。</p
|
||||
>
|
||||
<p v-else-if="job.status === 'REVIEW'">打开工作区确认清理、测量项或生成新版报告。</p>
|
||||
<p v-else-if="job.status === 'UNKNOWN'">提交回执未确认,请核对计算服务记录。系统不会自动重复提交。</p>
|
||||
<p v-if="calculationActive" class="comparison-error">当前计算服务未提供取消计算接口。关闭工作区或离开页面不会停止计算,请等待结果,避免重复提交。</p>
|
||||
<p class="secondary">比对作业 {{ job.id }}<span v-if="job.source_execution_id"> · 来源扫描 {{ job.source_execution_id }}</span><span v-if="job.engine_revision"> · 成果版本 {{ job.engine_revision }}</span></p>
|
||||
<p v-else-if="job.status === 'UNKNOWN'"
|
||||
>提交回执未确认,请核对计算服务记录。系统不会自动重复提交。</p
|
||||
>
|
||||
<p v-if="calculationActive" class="comparison-error"
|
||||
>当前计算服务未提供取消计算接口。关闭工作区或离开页面不会停止计算,请等待结果,避免重复提交。</p
|
||||
>
|
||||
<p class="secondary"
|
||||
>比对作业 {{ job.id
|
||||
}}<span v-if="job.source_execution_id"> · 来源扫描 {{ job.source_execution_id }}</span
|
||||
><span v-if="job.engine_revision"> · 成果版本 {{ job.engine_revision }}</span></p
|
||||
>
|
||||
</div>
|
||||
<el-dialog v-model="expanded" title="尺寸比对工作区" width="min(1600px, 97vw)" top="2vh" destroy-on-close append-to-body :before-close="closeWorkspace">
|
||||
<el-alert v-if="calculationActive" title="计算仍在进行。关闭本窗口不会取消计算;当前计算服务未提供停止接口。" type="info" :closable="false" show-icon />
|
||||
<InspectionWorkbench v-if="job.engine_id" ref="workspace" :key="job.engine_id" :record-id="job.engine_id" @changed="workspaceChanged" @history="closeWorkspace(() => expanded = false)" />
|
||||
<el-dialog
|
||||
v-model="expanded"
|
||||
title="尺寸比对工作区"
|
||||
width="min(1600px, 97vw)"
|
||||
top="2vh"
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
:before-close="closeWorkspace"
|
||||
>
|
||||
<el-alert
|
||||
v-if="calculationActive"
|
||||
title="计算仍在进行。关闭本窗口不会取消计算;当前计算服务未提供停止接口。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
<InspectionWorkbench
|
||||
v-if="job.engine_id"
|
||||
ref="workspace"
|
||||
:key="job.engine_id"
|
||||
:record-id="job.engine_id"
|
||||
@changed="workspaceChanged"
|
||||
@history="closeWorkspace(() => (expanded = false))"
|
||||
/>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
@ -69,23 +203,115 @@ import '@/views/lab/inspection/inspection.scss'
|
||||
import { comparisonPollInterval } from '@/views/lab/scan-task/workbenchPolling.mjs'
|
||||
import { comparisonBlockers } from './comparisonReadiness.mjs'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
const InspectionWorkbench = defineAsyncComponent(() => import('@/views/lab/inspection/InspectionWorkbench.vue'))
|
||||
const props = defineProps<{ taskId: string; unitId: string; revision: number; ready: boolean; dirty: boolean; sourceChanged: boolean; active: boolean; inputs: { modelId: any; drawingId: any; cloudId: any }; selectedInputs?: { modelId: any; drawingId: any; cloudId: any }; savingInputs?: boolean; cloudFileCount?: number }>()
|
||||
const emit = defineEmits<{ changed: []; 'open-materials': []; 'save-inputs': []; 'archive-cloud': [] }>()
|
||||
const router = useRouter(), job = ref<any>({}), health = ref<any>({}), catalog = ref<any[]>([]), error = ref(''), loading = ref(false), busy = ref(false), syncing = ref(false), expanded = ref(false), workspace = ref<any>()
|
||||
const options = reactive({ planTemplateId: '', sourceScale: 1, targetScale: 1, tolerance: 1, autoReport: true, sourceClean: false, reviewCleanup: false })
|
||||
const InspectionWorkbench = defineAsyncComponent(
|
||||
() => import('@/views/lab/inspection/InspectionWorkbench.vue')
|
||||
)
|
||||
const props = defineProps<{
|
||||
taskId: string
|
||||
unitId: string
|
||||
revision: number
|
||||
ready: boolean
|
||||
dirty: boolean
|
||||
sourceChanged: boolean
|
||||
active: boolean
|
||||
inputs: { modelId: any; drawingId: any; cloudId: any }
|
||||
selectedInputs?: { modelId: any; drawingId: any; cloudId: any }
|
||||
savingInputs?: boolean
|
||||
cloudFileCount?: number
|
||||
}>()
|
||||
const emit = defineEmits<{
|
||||
changed: []
|
||||
'open-materials': []
|
||||
'save-inputs': []
|
||||
'archive-cloud': []
|
||||
}>()
|
||||
const router = useRouter(),
|
||||
job = ref<any>({}),
|
||||
health = ref<any>({}),
|
||||
catalog = ref<any[]>([]),
|
||||
error = ref(''),
|
||||
loading = ref(false),
|
||||
busy = ref(false),
|
||||
syncing = ref(false),
|
||||
expanded = ref(false),
|
||||
workspace = ref<any>()
|
||||
const options = reactive({
|
||||
planTemplateId: '',
|
||||
sourceScale: 1,
|
||||
targetScale: 1,
|
||||
tolerance: 1,
|
||||
autoReport: true,
|
||||
sourceClean: false,
|
||||
reviewCleanup: false
|
||||
})
|
||||
const planSelect = ref<any>()
|
||||
const selectedPlan = computed(() => catalog.value.find(plan => plan.id === options.planTemplateId))
|
||||
const units = [{value: 1,label:'毫米 mm'},{value:1000,label:'米 m'},{value:0.001,label:'微米 μm'}]
|
||||
const labels: Record<string,string> = {SUBMITTING:'正在提交资料',UNKNOWN:'提交结果待核对',PROCESSING:'计算处理中',REVIEW:'待人工核对',ARCHIVE_PENDING:'计算完成,正在归档',ARCHIVE_ERROR:'计算完成,成果归档待处理',ARCHIVED:'成果已成套归档',FAILED:'比对失败'}
|
||||
const featureTemplatesUnavailable = ref(false)
|
||||
const planGroups = computed(() =>
|
||||
[
|
||||
{
|
||||
label: 'CAD 特征计划(基准 / 形位公差)',
|
||||
items: catalog.value.filter((item) => item.kind === 'feature')
|
||||
},
|
||||
{ label: '原有检测计划', items: catalog.value.filter((item) => item.kind !== 'feature') }
|
||||
].filter((group) => group.items.length)
|
||||
)
|
||||
const selectedPlan = computed(() =>
|
||||
catalog.value.find((plan) => plan.id === options.planTemplateId)
|
||||
)
|
||||
const units = [
|
||||
{ value: 1, label: '毫米 mm' },
|
||||
{ value: 1000, label: '米 m' },
|
||||
{ value: 0.001, label: '微米 μm' }
|
||||
]
|
||||
const labels: Record<string, string> = {
|
||||
SUBMITTING: '正在提交资料',
|
||||
UNKNOWN: '提交结果待核对',
|
||||
PROCESSING: '计算处理中',
|
||||
REVIEW: '待人工核对',
|
||||
ARCHIVE_PENDING: '计算完成,正在归档',
|
||||
ARCHIVE_ERROR: '计算完成,成果归档待处理',
|
||||
ARCHIVED: '成果已成套归档',
|
||||
FAILED: '比对失败'
|
||||
}
|
||||
const sameInput = computed(() => {
|
||||
// Historical snapshots stored Snowflake IDs as JSON integers; preserve them before parsing.
|
||||
try { const frozen = JSON.parse((job.value.input_json || '{}').replace(/"id"\s*:\s*(\d{16,})(?=\s*[,}])/g, '"id":"$1"')); return String(frozen.model?.id || '') === String(props.inputs.modelId || '') && String(frozen.drawing?.id || '') === String(props.inputs.drawingId || '') && String(frozen.cloud?.id || '') === String(props.inputs.cloudId || '') }
|
||||
catch { return false }
|
||||
try {
|
||||
const frozen = JSON.parse(
|
||||
(job.value.input_json || '{}').replace(/"id"\s*:\s*(\d{16,})(?=\s*[,}])/g, '"id":"$1"')
|
||||
)
|
||||
return (
|
||||
String(frozen.model?.id || '') === String(props.inputs.modelId || '') &&
|
||||
String(frozen.drawing?.id || '') === String(props.inputs.drawingId || '') &&
|
||||
String(frozen.cloud?.id || '') === String(props.inputs.cloudId || '')
|
||||
)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
})
|
||||
const pendingSameInput = computed(() => sameInput.value && ['SUBMITTING','UNKNOWN','PROCESSING','REVIEW','ARCHIVE_PENDING','ARCHIVE_ERROR'].includes(job.value.status))
|
||||
const calculationActive = computed(() => ['SUBMITTING','UNKNOWN','PROCESSING'].includes(job.value.status))
|
||||
const blockers = computed(() => comparisonBlockers({ unitId: props.unitId, inputs: props.selectedInputs || props.inputs, dirty: props.dirty, sourceChanged: props.sourceChanged, planId: options.planTemplateId, plans: catalog.value, healthAvailable: health.value.available, pending: pendingSameInput.value, cloudFileCount: props.cloudFileCount }))
|
||||
const pendingSameInput = computed(
|
||||
() =>
|
||||
sameInput.value &&
|
||||
['SUBMITTING', 'UNKNOWN', 'PROCESSING', 'REVIEW', 'ARCHIVE_PENDING', 'ARCHIVE_ERROR'].includes(
|
||||
job.value.status
|
||||
)
|
||||
)
|
||||
const calculationActive = computed(() =>
|
||||
['SUBMITTING', 'UNKNOWN', 'PROCESSING'].includes(job.value.status)
|
||||
)
|
||||
const blockers = computed(() =>
|
||||
comparisonBlockers({
|
||||
unitId: props.unitId,
|
||||
inputs: props.selectedInputs || props.inputs,
|
||||
dirty: props.dirty,
|
||||
sourceChanged: props.sourceChanged,
|
||||
planId: options.planTemplateId,
|
||||
plans: catalog.value,
|
||||
healthAvailable: health.value.available,
|
||||
featureAvailable: !!health.value.feature_capabilities,
|
||||
pending: pendingSameInput.value,
|
||||
cloudFileCount: props.cloudFileCount
|
||||
})
|
||||
)
|
||||
function canResolveIssue(action: string) {
|
||||
if (['save', 'archive'].includes(action)) return checkPermi(['lab:data:upload'])
|
||||
return action !== 'workspace' || !!job.value.engine_id
|
||||
@ -94,89 +320,263 @@ function resolveIssue(action: string) {
|
||||
if (action === 'save') emit('save-inputs')
|
||||
else if (action === 'archive') emit('archive-cloud')
|
||||
else if (action === 'materials') emit('open-materials')
|
||||
else if (action === 'plan') { planSelect.value?.$el?.scrollIntoView({ block: 'center', behavior: 'smooth' }); planSelect.value?.focus() }
|
||||
else if (action === 'refresh') void refresh(true)
|
||||
else if (action === 'plan') {
|
||||
planSelect.value?.$el?.scrollIntoView({ block: 'center', behavior: 'smooth' })
|
||||
planSelect.value?.focus()
|
||||
} else if (action === 'refresh') void refresh(true)
|
||||
else if (action === 'workspace' && job.value.engine_id) expanded.value = true
|
||||
}
|
||||
let timer: ReturnType<typeof setTimeout> | undefined, generation = 0, abort: AbortController | undefined
|
||||
let timer: ReturnType<typeof setTimeout> | undefined,
|
||||
generation = 0,
|
||||
abort: AbortController | undefined
|
||||
let lastDelivery = ''
|
||||
let suspended=false
|
||||
function schedulePoll(token:number){clearTimeout(timer);const delay=comparisonPollInterval(job.value.status);if(delay&&token===generation&&props.active&&!suspended&&!document.hidden)timer=setTimeout(()=>refresh(),delay)}
|
||||
let suspended = false
|
||||
function schedulePoll(token: number) {
|
||||
clearTimeout(timer)
|
||||
const delay = comparisonPollInterval(job.value.status)
|
||||
if (delay && token === generation && props.active && !suspended && !document.hidden)
|
||||
timer = setTimeout(() => refresh(), delay)
|
||||
}
|
||||
async function refresh(withHealth = false) {
|
||||
if (!props.active || !props.unitId || suspended || document.hidden || loading.value) return
|
||||
const current = generation
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const [currentJob, state, plans] = await Promise.all([Api.comparison(props.taskId,props.unitId,abort?.signal),withHealth ? Api.health() : Promise.resolve(null),withHealth ? Api.templates() : Promise.resolve(null)])
|
||||
const [currentJob, state, plans] = await Promise.all([
|
||||
Api.comparison(props.taskId, props.unitId, abort?.signal),
|
||||
withHealth ? Api.health() : Promise.resolve(null),
|
||||
withHealth ? Api.comparisonTemplates() : Promise.resolve(null)
|
||||
])
|
||||
if (current !== generation) return
|
||||
job.value = currentJob || {}
|
||||
if (state) health.value = state
|
||||
if (plans) catalog.value = plans.templates || []
|
||||
if (plans) {
|
||||
catalog.value = plans.templates || []
|
||||
featureTemplatesUnavailable.value = !!plans.featureTemplatesUnavailable
|
||||
}
|
||||
const delivery = String(job.value.delivery_id || '')
|
||||
if (delivery && lastDelivery && delivery !== lastDelivery) emit('changed')
|
||||
if (delivery && !lastDelivery) emit('changed')
|
||||
lastDelivery = delivery
|
||||
} catch (e: any) { if (current === generation && !abort?.signal.aborted) error.value = e?.message || '读取比对状态失败' }
|
||||
finally { if(current === generation) { loading.value = false;schedulePoll(current) } }
|
||||
} catch (e: any) {
|
||||
if (current === generation && !abort?.signal.aborted)
|
||||
error.value = e?.message || '读取比对状态失败'
|
||||
} finally {
|
||||
if (current === generation) {
|
||||
loading.value = false
|
||||
schedulePoll(current)
|
||||
}
|
||||
}
|
||||
}
|
||||
watch(() => [props.taskId,props.unitId,props.active], async () => {
|
||||
generation++; abort?.abort(); abort = new AbortController(); clearTimeout(timer); loading.value=false;job.value = {}; lastDelivery = ''
|
||||
if (props.active && props.unitId && props.unitId !== '0') await refresh(true)
|
||||
},{immediate:true})
|
||||
watch(
|
||||
() => [props.taskId, props.unitId, props.active],
|
||||
async () => {
|
||||
generation++
|
||||
abort?.abort()
|
||||
abort = new AbortController()
|
||||
clearTimeout(timer)
|
||||
loading.value = false
|
||||
job.value = {}
|
||||
lastDelivery = ''
|
||||
if (props.active && props.unitId && props.unitId !== '0') await refresh(true)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
async function start() {
|
||||
if (busy.value || props.savingInputs || !props.ready) return
|
||||
if (blockers.value.length) { ElMessage.warning(blockers.value[0].text); return }
|
||||
if (blockers.value.length) {
|
||||
ElMessage.warning(blockers.value[0].text)
|
||||
return
|
||||
}
|
||||
const token = generation
|
||||
busy.value = true; error.value = ''
|
||||
busy.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const started = await Api.startComparison({taskId:props.taskId,unitId:props.unitId,revision:props.revision,...options})
|
||||
const started = await Api.startComparison({
|
||||
taskId: props.taskId,
|
||||
unitId: props.unitId,
|
||||
revision: props.revision,
|
||||
...options
|
||||
})
|
||||
if (token !== generation) return
|
||||
job.value = started
|
||||
schedulePoll(token)
|
||||
emit('changed')
|
||||
if (job.value.engine_id) expanded.value = true
|
||||
} catch(e:any) { if(token === generation) { const failure = e?.message || '提交失败,请刷新状态后核对'; await refresh(); if(token === generation) error.value = failure } }
|
||||
finally { busy.value = false }
|
||||
} catch (e: any) {
|
||||
if (token === generation) {
|
||||
const failure = e?.message || '提交失败,请刷新状态后核对'
|
||||
await refresh()
|
||||
if (token === generation) error.value = failure
|
||||
}
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
async function sync() {
|
||||
if (syncing.value || !job.value.engine_id) return
|
||||
syncing.value = true
|
||||
try { await Api.sync(job.value.engine_id); await refresh(); emit('changed'); ElMessage.success('已更新归档状态') }
|
||||
catch(e:any) { error.value = e?.message || '归档尚未完成' }
|
||||
finally { syncing.value = false }
|
||||
try {
|
||||
await Api.sync(job.value.engine_id)
|
||||
await refresh()
|
||||
emit('changed')
|
||||
ElMessage.success('已更新归档状态')
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '归档尚未完成'
|
||||
} finally {
|
||||
syncing.value = false
|
||||
}
|
||||
}
|
||||
async function workspaceChanged() {
|
||||
await refresh()
|
||||
emit('changed')
|
||||
}
|
||||
async function canLeave() {
|
||||
return !expanded.value || !workspace.value || (await workspace.value.confirmLeave())
|
||||
}
|
||||
async function closeWorkspace(done: () => void) {
|
||||
if (await canLeave()) {
|
||||
done()
|
||||
await workspaceChanged()
|
||||
}
|
||||
}
|
||||
async function workspaceChanged() { await refresh(); emit('changed') }
|
||||
async function canLeave() { return !expanded.value || !workspace.value || await workspace.value.confirmLeave() }
|
||||
async function closeWorkspace(done: () => void) { if(await canLeave()) { done(); await workspaceChanged() } }
|
||||
defineExpose({ canLeave })
|
||||
function visibilityChanged(){if(document.hidden)clearTimeout(timer);else if(props.active&&comparisonPollInterval(job.value.status))void refresh()}
|
||||
onMounted(()=>document.addEventListener('visibilitychange',visibilityChanged))
|
||||
onActivated(()=>{suspended=false;if(props.active)void refresh()})
|
||||
onDeactivated(()=>{suspended=true;clearTimeout(timer);generation++;abort?.abort();abort=new AbortController();loading.value=false})
|
||||
onBeforeUnmount(() => { generation++; clearTimeout(timer); abort?.abort();document.removeEventListener('visibilitychange',visibilityChanged) })
|
||||
function visibilityChanged() {
|
||||
if (document.hidden) clearTimeout(timer)
|
||||
else if (props.active && comparisonPollInterval(job.value.status)) void refresh()
|
||||
}
|
||||
onMounted(() => document.addEventListener('visibilitychange', visibilityChanged))
|
||||
onActivated(() => {
|
||||
suspended = false
|
||||
if (props.active) void refresh()
|
||||
})
|
||||
onDeactivated(() => {
|
||||
suspended = true
|
||||
clearTimeout(timer)
|
||||
generation++
|
||||
abort?.abort()
|
||||
abort = new AbortController()
|
||||
loading.value = false
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
generation++
|
||||
clearTimeout(timer)
|
||||
abort?.abort()
|
||||
document.removeEventListener('visibilitychange', visibilityChanged)
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.comparison-panel { margin: 16px 0 24px; }
|
||||
.comparison-heading { display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap; }
|
||||
.comparison-heading h3 { margin: 0 0 6px; }
|
||||
.comparison-buttons { display:flex;align-items:center;gap:10px;flex-wrap:wrap; }
|
||||
.comparison-options { margin-top:18px; }
|
||||
.plan-select { max-width:620px; }
|
||||
.comparison-fields { display:grid;grid-template-columns:repeat(3,minmax(140px,1fr));gap:16px; }
|
||||
.comparison-fields :deep(.el-select), .comparison-fields :deep(.el-input-number) { width:100%; }
|
||||
.comparison-report { margin:0 0 12px; }
|
||||
.comparison-preprocessing { padding-top:12px; border-top:1px solid var(--el-border-color-lighter); }
|
||||
.comparison-preprocessing h4 { margin:0 0 8px; font-size:14px; font-weight:500; }
|
||||
.comparison-preprocessing .el-checkbox { display:flex; margin-right:0; }
|
||||
.comparison-status { padding:14px 0;border-top:1px solid var(--el-border-color-lighter); }
|
||||
.comparison-status p { margin:10px 0; }
|
||||
.comparison-error { color:var(--el-color-warning);white-space:pre-wrap; }
|
||||
.comparison-blockers { margin: 8px 0 0; padding-left: 18px; }
|
||||
.comparison-blockers li { margin: 7px 0; line-height: 1.6; }
|
||||
.comparison-blockers .el-button { margin-left: 12px; white-space: normal; height: auto; }
|
||||
.comparison-ready { color: var(--el-color-success); font-size: 13px; }
|
||||
.secondary { color:var(--el-text-color-secondary);font-size:12px;overflow-wrap:anywhere; }
|
||||
.gap { margin-top:16px; }
|
||||
@media(max-width:700px) { .comparison-fields { grid-template-columns:1fr; } }
|
||||
.comparison-panel {
|
||||
margin: 16px 0 24px;
|
||||
}
|
||||
|
||||
.comparison-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.comparison-heading h3 {
|
||||
margin: 0 0 6px;
|
||||
}
|
||||
|
||||
.comparison-buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.comparison-options {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.plan-select {
|
||||
max-width: 620px;
|
||||
}
|
||||
|
||||
.comparison-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(140px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.comparison-fields :deep(.el-select),
|
||||
.comparison-fields :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.comparison-report {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.comparison-preprocessing {
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.comparison-preprocessing h4 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.comparison-preprocessing .el-checkbox {
|
||||
display: flex;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.comparison-status {
|
||||
padding: 14px 0;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.comparison-status p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.comparison-error {
|
||||
color: var(--el-color-warning);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.comparison-blockers {
|
||||
padding-left: 18px;
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.comparison-blockers li {
|
||||
margin: 7px 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.comparison-blockers .el-button {
|
||||
height: auto;
|
||||
margin-left: 12px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.comparison-ready {
|
||||
font-size: 13px;
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.secondary {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.gap {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
@media (width <= 700px) {
|
||||
.comparison-fields {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,13 +1,81 @@
|
||||
/** Explain each start requirement with an actionable next step. PDF is optional. */
|
||||
export function comparisonBlockers({ unitId, inputs = {}, dirty, sourceChanged, planId, plans = [], healthAvailable, pending, cloudFileCount = 0 }) {
|
||||
export function comparisonBlockers({
|
||||
unitId,
|
||||
inputs = {},
|
||||
dirty,
|
||||
sourceChanged,
|
||||
planId,
|
||||
plans = /** @type {any[]} */ ([]),
|
||||
healthAvailable,
|
||||
featureAvailable = true,
|
||||
pending,
|
||||
cloudFileCount = 0
|
||||
}) {
|
||||
const issues = []
|
||||
if (!unitId || String(unitId) === '0') issues.push({ key: 'unit', text: '请先选择需要比对的样件。', action: 'materials', label: '选择样件' })
|
||||
if (dirty) issues.push({ key: 'save', text: '比对资料版本尚未保存,当前选择还未生效。', action: 'save', label: '保存比对资料版本' })
|
||||
if (!inputs.modelId) issues.push({ key: 'model', text: '尚未选用三维数模,请上传或选择 X_T / STP 版本。', action: 'materials', label: '选择三维数模' })
|
||||
if (!inputs.cloudId) issues.push({ key: 'cloud', text: cloudFileCount ? '扫描已导出 PLY,但尚未归档并选用于当前样件。' : '尚未关联扫描 PLY,请先完成扫描并导出 PLY。', action: cloudFileCount === 1 ? 'archive' : 'materials', label: cloudFileCount === 1 ? '归档并选用扫描PLY' : '查看扫描导出文件' })
|
||||
if (sourceChanged) issues.push({ key: 'scan', text: '扫描执行已更新或仍在执行,请结束扫描后关联对应的 PLY。', action: 'materials', label: '检查扫描PLY' })
|
||||
if (!planId || !plans.some(plan => plan.id === planId)) issues.push({ key: 'plan', text: '检测计划为必填项,请明确选择一个已维护且启用的计划。', action: 'plan', label: '选择检测计划' })
|
||||
if (!healthAvailable) issues.push({ key: 'health', text: '计算服务尚未就绪,请启动本机检测 EXE 后刷新状态。', action: 'refresh', label: '刷新计算服务状态' })
|
||||
if (pending) issues.push({ key: 'pending', text: '当前输入已有未完成的比对,请查看现有作业,避免重复提交。', action: 'workspace', label: '查看当前比对' })
|
||||
if (!unitId || String(unitId) === '0')
|
||||
issues.push({
|
||||
key: 'unit',
|
||||
text: '请先选择需要比对的样件。',
|
||||
action: 'materials',
|
||||
label: '选择样件'
|
||||
})
|
||||
if (dirty)
|
||||
issues.push({
|
||||
key: 'save',
|
||||
text: '比对资料版本尚未保存,当前选择还未生效。',
|
||||
action: 'save',
|
||||
label: '保存比对资料版本'
|
||||
})
|
||||
if (!inputs.modelId)
|
||||
issues.push({
|
||||
key: 'model',
|
||||
text: '尚未选用三维数模,请上传或选择 X_T / STP 版本。',
|
||||
action: 'materials',
|
||||
label: '选择三维数模'
|
||||
})
|
||||
if (!inputs.cloudId)
|
||||
issues.push({
|
||||
key: 'cloud',
|
||||
text: cloudFileCount
|
||||
? '扫描已导出 PLY,但尚未归档并选用于当前样件。'
|
||||
: '尚未关联扫描 PLY,请先完成扫描并导出 PLY。',
|
||||
action: cloudFileCount === 1 ? 'archive' : 'materials',
|
||||
label: cloudFileCount === 1 ? '归档并选用扫描PLY' : '查看扫描导出文件'
|
||||
})
|
||||
if (sourceChanged)
|
||||
issues.push({
|
||||
key: 'scan',
|
||||
text: '扫描执行已更新或仍在执行,请结束扫描后关联对应的 PLY。',
|
||||
action: 'materials',
|
||||
label: '检查扫描PLY'
|
||||
})
|
||||
if (!planId || !plans.some((plan) => plan.id === planId))
|
||||
issues.push({
|
||||
key: 'plan',
|
||||
text: '检测计划为必填项,请明确选择一个已维护且启用的计划。',
|
||||
action: 'plan',
|
||||
label: '选择检测计划'
|
||||
})
|
||||
if (!healthAvailable)
|
||||
issues.push({
|
||||
key: 'health',
|
||||
text: '计算服务尚未就绪,请启动本机检测 EXE 后刷新状态。',
|
||||
action: 'refresh',
|
||||
label: '刷新计算服务状态'
|
||||
})
|
||||
else if (planId?.startsWith('feature-') && !featureAvailable)
|
||||
issues.push({
|
||||
key: 'feature-capability',
|
||||
text: 'CAD 特征计划需要新版检测 EXE,请安装后刷新状态。',
|
||||
action: 'refresh',
|
||||
label: '刷新计算服务状态'
|
||||
})
|
||||
if (pending)
|
||||
issues.push({
|
||||
key: 'pending',
|
||||
text: '当前输入已有未完成的比对,请查看现有作业,避免重复提交。',
|
||||
action: 'workspace',
|
||||
label: '查看当前比对'
|
||||
})
|
||||
return issues
|
||||
}
|
||||
|
||||
465
am-web/src/views/lab/inspection/CadFeatureViewer.vue
Normal file
465
am-web/src/views/lab/inspection/CadFeatureViewer.vue
Normal file
@ -0,0 +1,465 @@
|
||||
<template>
|
||||
<div class="cad-feature-viewer">
|
||||
<div class="cad-tools">
|
||||
<el-checkbox v-model="showScan" @change="redraw">扫描点云</el-checkbox>
|
||||
<el-checkbox v-model="showCad" @change="redraw">设计数模</el-checkbox>
|
||||
<el-checkbox v-model="heat" @change="redraw">报告热力图</el-checkbox>
|
||||
<el-button size="small" @click="fit">适应</el-button>
|
||||
<el-button size="small" @click="isolate">隔离选面</el-button>
|
||||
<el-button size="small" @click="hide">隐藏选面</el-button>
|
||||
<el-button size="small" @click="restore">全部显示</el-button>
|
||||
<el-button size="small" @click="undo">撤销</el-button>
|
||||
<el-button size="small" @click="clear">取消 Esc</el-button>
|
||||
</div>
|
||||
<div
|
||||
ref="host"
|
||||
class="cad-stage"
|
||||
tabindex="0"
|
||||
@keydown.esc.stop.prevent="clear"
|
||||
@keydown.ctrl.z.stop.prevent="undo"
|
||||
>
|
||||
<div v-if="error" class="cad-error">{{ error }}</div>
|
||||
<div class="cad-hint">点击选面 · Ctrl/Shift 多选 · 拖动旋转 · 右键平移 · 滚轮缩放</div>
|
||||
<div class="cad-selection"
|
||||
>已选 {{ selection.length }} 个曲面 ·
|
||||
{{ hovered ? faceLabel(hovered) : '悬停查看曲面' }}</div
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as THREE from 'three'
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
|
||||
import { userMessage } from './display'
|
||||
const props = defineProps<{
|
||||
mesh?: any
|
||||
points?: number[][]
|
||||
thermal?: any
|
||||
fittedPoints?: number[][]
|
||||
nominal?: any
|
||||
selected?: string[]
|
||||
}>()
|
||||
const emit = defineEmits<{
|
||||
select: [ids: string[]]
|
||||
point: [point: number[], faceId: string]
|
||||
cancel: []
|
||||
}>()
|
||||
const host = ref<HTMLElement>(),
|
||||
error = ref(''),
|
||||
hovered = ref('')
|
||||
const showScan = ref(true),
|
||||
showCad = ref(true),
|
||||
heat = ref(true)
|
||||
const selection = ref<string[]>([]),
|
||||
hidden = new Set<string>(),
|
||||
history: any[] = []
|
||||
const faceNames = computed(
|
||||
() =>
|
||||
new Map(
|
||||
Array.from(new Set<string>(props.mesh?.face_ids || [])).map((id, i) => [id, `曲面 ${i + 1}`])
|
||||
)
|
||||
)
|
||||
const faceLabel = (id: string) => faceNames.value.get(id) || '曲面'
|
||||
let renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.PerspectiveCamera
|
||||
let orbit: OrbitControls,
|
||||
observer: ResizeObserver,
|
||||
cadMesh: THREE.Mesh | undefined,
|
||||
scan: THREE.Points | undefined
|
||||
let selectedCloud: THREE.Points | undefined,
|
||||
nominalOutline: THREE.Line | undefined,
|
||||
geometry: THREE.BufferGeometry | undefined,
|
||||
animation = 0
|
||||
let faceTriangles = new Map<string, number[]>(),
|
||||
painted = new Set<string>(),
|
||||
hoverAt = 0,
|
||||
dragging = false,
|
||||
resizeWidth = 0,
|
||||
resizeHeight = 0
|
||||
function requestRender() {
|
||||
if (animation || !renderer || document.hidden || !host.value?.clientWidth) return
|
||||
animation = requestAnimationFrame(() => {
|
||||
animation = 0
|
||||
if (!renderer || !host.value?.clientWidth || document.hidden) return
|
||||
orbit.update()
|
||||
renderer.render(scene, camera)
|
||||
})
|
||||
}
|
||||
function visibility() {
|
||||
if (document.hidden) {
|
||||
cancelAnimationFrame(animation)
|
||||
animation = 0
|
||||
} else requestRender()
|
||||
}
|
||||
function contextLost(event: Event) {
|
||||
event.preventDefault()
|
||||
cancelAnimationFrame(animation)
|
||||
animation = 0
|
||||
error.value = '三维视图资源已释放,请重新加载三维视图'
|
||||
}
|
||||
const ray = new THREE.Raycaster(),
|
||||
pointer = new THREE.Vector2()
|
||||
let down = [0, 0],
|
||||
lastPoint: number[] = []
|
||||
function remember() {
|
||||
history.push({ selected: [...selection.value], hidden: [...hidden] })
|
||||
if (history.length > 50) history.shift()
|
||||
}
|
||||
function clear() {
|
||||
emit('cancel')
|
||||
remember()
|
||||
selection.value = []
|
||||
hovered.value = ''
|
||||
emit('select', [])
|
||||
paint()
|
||||
}
|
||||
function undo() {
|
||||
const p = history.pop()
|
||||
if (!p) return
|
||||
selection.value = p.selected
|
||||
hidden.clear()
|
||||
p.hidden.forEach((id: string) => hidden.add(id))
|
||||
emit('select', [...selection.value])
|
||||
redraw()
|
||||
}
|
||||
function isolate() {
|
||||
remember()
|
||||
for (const id of props.mesh?.face_ids || []) if (!selection.value.includes(id)) hidden.add(id)
|
||||
redraw()
|
||||
}
|
||||
function hide() {
|
||||
remember()
|
||||
selection.value.forEach((id) => hidden.add(id))
|
||||
redraw()
|
||||
}
|
||||
function restore() {
|
||||
remember()
|
||||
hidden.clear()
|
||||
redraw()
|
||||
}
|
||||
function paint() {
|
||||
if (!geometry) return
|
||||
const colors = geometry.getAttribute('color') as THREE.BufferAttribute
|
||||
const chosen = new Set(selection.value),
|
||||
next = new Set([...chosen, ...(hovered.value ? [hovered.value] : [])])
|
||||
const base = new THREE.Color('#638499'),
|
||||
highlight = new THREE.Color('#fbbf24'),
|
||||
active = new THREE.Color('#1677ff')
|
||||
for (const id of new Set([...painted, ...next])) {
|
||||
const c = chosen.has(id) ? active : id === hovered.value ? highlight : base
|
||||
for (const i of faceTriangles.get(id) || [])
|
||||
for (let j = 0; j < 3; j++) colors.setXYZ(i * 3 + j, c.r, c.g, c.b)
|
||||
}
|
||||
painted = next
|
||||
colors.needsUpdate = true
|
||||
requestRender()
|
||||
}
|
||||
function pick(event: PointerEvent) {
|
||||
if (!cadMesh || !host.value || !showCad.value) return ''
|
||||
const r = host.value.getBoundingClientRect()
|
||||
pointer.set(
|
||||
(2 * (event.clientX - r.left)) / r.width - 1,
|
||||
1 - (2 * (event.clientY - r.top)) / r.height
|
||||
)
|
||||
ray.setFromCamera(pointer, camera)
|
||||
const hit = ray
|
||||
.intersectObject(cadMesh)
|
||||
.find((h) => !hidden.has(props.mesh.face_ids[h.faceIndex!]))
|
||||
lastPoint = hit ? hit.point.toArray() : []
|
||||
return hit ? props.mesh.face_ids[hit.faceIndex!] : ''
|
||||
}
|
||||
function move(event: PointerEvent) {
|
||||
if (dragging || performance.now() - hoverAt < 65) return
|
||||
hoverAt = performance.now()
|
||||
const id = pick(event)
|
||||
if (id !== hovered.value) {
|
||||
hovered.value = id
|
||||
paint()
|
||||
}
|
||||
}
|
||||
function pointerDown(event: PointerEvent) {
|
||||
dragging = true
|
||||
down = [event.clientX, event.clientY]
|
||||
host.value?.focus({ preventScroll: true })
|
||||
}
|
||||
function pointerUp(event: PointerEvent) {
|
||||
dragging = false
|
||||
if (event.button !== 0 || Math.hypot(event.clientX - down[0], event.clientY - down[1]) > 5) return
|
||||
const id = pick(event)
|
||||
if (!id) return
|
||||
emit('point', [...lastPoint], id)
|
||||
remember()
|
||||
selection.value =
|
||||
event.ctrlKey || event.shiftKey
|
||||
? selection.value.includes(id)
|
||||
? selection.value.filter((v) => v !== id)
|
||||
: [...selection.value, id]
|
||||
: [id]
|
||||
emit('select', [...selection.value])
|
||||
paint()
|
||||
}
|
||||
function disposeObject(o?: THREE.Mesh | THREE.Points | THREE.Line) {
|
||||
if (!o) return
|
||||
scene.remove(o)
|
||||
o.geometry.dispose()
|
||||
const m = o.material
|
||||
;(Array.isArray(m) ? m : [m]).forEach((v) => v.dispose())
|
||||
}
|
||||
function drawNominal() {
|
||||
if (!scene) return
|
||||
disposeObject(nominalOutline)
|
||||
nominalOutline = undefined
|
||||
const g = props.nominal
|
||||
if (g?.radius > 0 && g?.center?.length === 3 && g?.axis?.length === 3) {
|
||||
const n = new THREE.Vector3(...(g.axis as [number, number, number])).normalize()
|
||||
const helper = Math.abs(n.z) < 0.9 ? new THREE.Vector3(0, 0, 1) : new THREE.Vector3(1, 0, 0)
|
||||
const x = new THREE.Vector3().crossVectors(n, helper).normalize(),
|
||||
y = new THREE.Vector3().crossVectors(n, x),
|
||||
center = new THREE.Vector3(...(g.center as [number, number, number]))
|
||||
const points = Array.from({ length: 129 }, (_, i) =>
|
||||
center
|
||||
.clone()
|
||||
.addScaledVector(x, g.radius * Math.cos((2 * Math.PI * i) / 128))
|
||||
.addScaledVector(y, g.radius * Math.sin((2 * Math.PI * i) / 128))
|
||||
)
|
||||
nominalOutline = new THREE.Line(
|
||||
new THREE.BufferGeometry().setFromPoints(points),
|
||||
new THREE.LineBasicMaterial({ color: '#ffdb4d', depthTest: false })
|
||||
)
|
||||
nominalOutline.renderOrder = 20
|
||||
scene.add(nominalOutline)
|
||||
}
|
||||
requestRender()
|
||||
}
|
||||
function cloud(points: number[][], color: string, size: number, thermal?: string[]) {
|
||||
const g = new THREE.BufferGeometry()
|
||||
g.setAttribute('position', new THREE.Float32BufferAttribute(points.flat(), 3))
|
||||
if (thermal?.length === points.length) {
|
||||
const c = new THREE.Color()
|
||||
g.setAttribute(
|
||||
'color',
|
||||
new THREE.Float32BufferAttribute(
|
||||
thermal.flatMap((x) => c.set(x).toArray()),
|
||||
3
|
||||
)
|
||||
)
|
||||
}
|
||||
return new THREE.Points(
|
||||
g,
|
||||
new THREE.PointsMaterial({
|
||||
color: thermal ? '#ffffff' : color,
|
||||
size,
|
||||
sizeAttenuation: false,
|
||||
vertexColors: !!thermal
|
||||
})
|
||||
)
|
||||
}
|
||||
function redraw() {
|
||||
if (!scene) return
|
||||
disposeObject(cadMesh)
|
||||
disposeObject(scan)
|
||||
disposeObject(selectedCloud)
|
||||
cadMesh = undefined
|
||||
scan = undefined
|
||||
selectedCloud = undefined
|
||||
geometry = undefined
|
||||
faceTriangles = new Map()
|
||||
painted = new Set()
|
||||
const data = props.mesh
|
||||
if (data && showCad.value) {
|
||||
const positions = new Float32Array(data.triangles.length * 9)
|
||||
const colors = new Float32Array(positions.length),
|
||||
base = new THREE.Color('#638499')
|
||||
data.triangles.forEach((tri: number[], i: number) => {
|
||||
const id = data.face_ids[i]
|
||||
let members = faceTriangles.get(id)
|
||||
if (!members) {
|
||||
members = []
|
||||
faceTriangles.set(id, members)
|
||||
}
|
||||
members.push(i)
|
||||
for (let j = 0; j < 3; j++)
|
||||
for (let k = 0; k < 3; k++) {
|
||||
positions[i * 9 + j * 3 + k] = hidden.has(id) ? 0 : data.vertices[tri[j]][k]
|
||||
colors[i * 9 + j * 3 + k] = [base.r, base.g, base.b][k]
|
||||
}
|
||||
})
|
||||
geometry = new THREE.BufferGeometry()
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3))
|
||||
geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3))
|
||||
geometry.computeVertexNormals()
|
||||
cadMesh = new THREE.Mesh(
|
||||
geometry,
|
||||
new THREE.MeshStandardMaterial({
|
||||
vertexColors: true,
|
||||
side: THREE.DoubleSide,
|
||||
roughness: 0.75,
|
||||
transparent: true,
|
||||
opacity: showScan.value ? 0.52 : 1
|
||||
})
|
||||
)
|
||||
cadMesh.frustumCulled = false
|
||||
scene.add(cadMesh)
|
||||
paint()
|
||||
}
|
||||
if (showScan.value && props.points?.length) {
|
||||
scan = cloud(props.points, '#32c8b8', 2, heat.value ? props.thermal?.colors : undefined)
|
||||
scene.add(scan)
|
||||
}
|
||||
if (props.fittedPoints?.length) {
|
||||
selectedCloud = cloud(props.fittedPoints, '#ffb43b', 4)
|
||||
scene.add(selectedCloud)
|
||||
}
|
||||
drawNominal()
|
||||
requestRender()
|
||||
}
|
||||
function fit() {
|
||||
if (!camera) return
|
||||
const points = props.mesh?.vertices?.length ? props.mesh.vertices : props.points || []
|
||||
if (!points.length) return
|
||||
const box = new THREE.Box3()
|
||||
points.forEach((p: number[]) =>
|
||||
box.expandByPoint(new THREE.Vector3(...(p as [number, number, number])))
|
||||
)
|
||||
const center = box.getCenter(new THREE.Vector3()),
|
||||
size = box.getSize(new THREE.Vector3()).length() || 1
|
||||
orbit.target.copy(center)
|
||||
camera.position
|
||||
.copy(center)
|
||||
.add(new THREE.Vector3(1, -1, 0.7).normalize().multiplyScalar(size * 1.3))
|
||||
camera.near = size / 10000
|
||||
camera.far = size * 100
|
||||
camera.updateProjectionMatrix()
|
||||
orbit.update()
|
||||
}
|
||||
onMounted(() => {
|
||||
try {
|
||||
scene = new THREE.Scene()
|
||||
scene.background = new THREE.Color('#0d1627')
|
||||
camera = new THREE.PerspectiveCamera(45, 1, 0.01, 100000)
|
||||
camera.up.set(0, 0, 1)
|
||||
renderer = new THREE.WebGLRenderer({ antialias: true })
|
||||
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.5))
|
||||
host.value!.appendChild(renderer.domElement)
|
||||
scene.add(new THREE.HemisphereLight('#ffffff', '#4c607b', 2.2))
|
||||
const light = new THREE.DirectionalLight('#ffffff', 2)
|
||||
light.position.set(1, -1, 2)
|
||||
scene.add(light)
|
||||
orbit = new OrbitControls(camera, renderer.domElement)
|
||||
orbit.enableDamping = true
|
||||
orbit.addEventListener('change', requestRender)
|
||||
document.addEventListener('visibilitychange', visibility)
|
||||
renderer.domElement.addEventListener('webglcontextlost', contextLost)
|
||||
renderer.domElement.addEventListener('pointerleave', () => {
|
||||
dragging = false
|
||||
if (hovered.value) {
|
||||
hovered.value = ''
|
||||
paint()
|
||||
}
|
||||
})
|
||||
renderer.domElement.addEventListener('pointerdown', pointerDown)
|
||||
renderer.domElement.addEventListener('pointermove', move)
|
||||
renderer.domElement.addEventListener('pointerup', pointerUp)
|
||||
observer = new ResizeObserver(() => {
|
||||
const w = host.value!.clientWidth,
|
||||
h = host.value!.clientHeight
|
||||
if (!w || !h || (w === resizeWidth && h === resizeHeight)) return
|
||||
resizeWidth = w
|
||||
resizeHeight = h
|
||||
renderer.setSize(w, h, false)
|
||||
camera.aspect = w / h
|
||||
camera.updateProjectionMatrix()
|
||||
requestRender()
|
||||
})
|
||||
observer.observe(host.value!)
|
||||
redraw()
|
||||
fit()
|
||||
requestRender()
|
||||
} catch (e: any) {
|
||||
error.value = userMessage(e, '三维视图加载失败,请刷新页面或检查浏览器设置')
|
||||
}
|
||||
})
|
||||
watch(
|
||||
() => [props.mesh, props.points, props.fittedPoints, props.thermal],
|
||||
(current, previous) => {
|
||||
redraw()
|
||||
if (current[0] && current[0] !== previous?.[0]) fit()
|
||||
}
|
||||
)
|
||||
watch(
|
||||
() => props.selected,
|
||||
(v) => {
|
||||
selection.value = [...(v || [])]
|
||||
paint()
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
watch(
|
||||
() => [props.nominal?.radius, props.nominal?.axis?.join(','), props.nominal?.center?.join(',')],
|
||||
drawNominal
|
||||
)
|
||||
onBeforeUnmount(() => {
|
||||
cancelAnimationFrame(animation)
|
||||
observer?.disconnect()
|
||||
orbit?.dispose()
|
||||
disposeObject(cadMesh)
|
||||
disposeObject(scan)
|
||||
disposeObject(selectedCloud)
|
||||
disposeObject(nominalOutline)
|
||||
document.removeEventListener('visibilitychange', visibility)
|
||||
renderer?.domElement.removeEventListener('webglcontextlost', contextLost)
|
||||
renderer?.dispose()
|
||||
renderer?.forceContextLoss()
|
||||
faceTriangles.clear()
|
||||
history.length = 0
|
||||
})
|
||||
defineExpose({ fit, clear, undo })
|
||||
</script>
|
||||
<style scoped>
|
||||
.cad-tools {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
.cad-stage {
|
||||
position: relative;
|
||||
height: 560px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 0 0 8px 8px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.cad-stage :deep(canvas) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cad-hint,
|
||||
.cad-selection,
|
||||
.cad-error {
|
||||
position: absolute;
|
||||
bottom: 12px;
|
||||
left: 14px;
|
||||
z-index: 1;
|
||||
font-size: 12px;
|
||||
color: #b8c8df;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cad-selection {
|
||||
top: 12px;
|
||||
bottom: auto;
|
||||
color: #ffd27a;
|
||||
}
|
||||
|
||||
.cad-error {
|
||||
top: 45%;
|
||||
color: #ff9393;
|
||||
}
|
||||
</style>
|
||||
197
am-web/src/views/lab/inspection/CadSectionPicker.vue
Normal file
197
am-web/src/views/lab/inspection/CadSectionPicker.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
v-model="opened"
|
||||
title="从 CAD 截面建立测量圆"
|
||||
size="480px"
|
||||
:modal="false"
|
||||
@closed="$emit('preview', null)"
|
||||
>
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
||||
<el-form :disabled="disabled || busy" label-position="top">
|
||||
<el-form-item label="截面法向"
|
||||
><el-button-group
|
||||
><el-button
|
||||
v-for="(label, i) in ['X', 'Y', 'Z']"
|
||||
:key="label"
|
||||
@click="changeAxis([0, 1, 2].map((j) => (j === i ? 1 : 0)))"
|
||||
>{{ label }}</el-button
|
||||
><el-button v-if="initialAxis" @click="changeAxis(initialAxis)"
|
||||
>当前特征轴向</el-button
|
||||
></el-button-group
|
||||
></el-form-item
|
||||
>
|
||||
<el-form-item label="截面位置 / mm(沿法向的设计坐标)"
|
||||
><el-input-number
|
||||
v-model="offset"
|
||||
:min="range[0]"
|
||||
:max="range[1]"
|
||||
:precision="3"
|
||||
:step="1"
|
||||
@change="clearCandidates" /><el-slider
|
||||
v-model="offset"
|
||||
:min="range[0]"
|
||||
:max="range[1]"
|
||||
:step="0.01"
|
||||
@change="clearCandidates"
|
||||
/></el-form-item>
|
||||
<el-button :loading="busy" type="primary" @click="preview">提取截面圆</el-button>
|
||||
</el-form>
|
||||
<p class="inspect-sub"
|
||||
>从完整设计网格提取圆形轮廓;选择候选后可在三维视图中查看位置。实测值仍从扫描点云计算。</p
|
||||
>
|
||||
<el-table
|
||||
:data="candidates"
|
||||
highlight-current-row
|
||||
@current-change="choose"
|
||||
empty-text="请选择截面位置并提取"
|
||||
>
|
||||
<el-table-column label="直径 / mm"
|
||||
><template #default="s">{{
|
||||
(2 * s.row.nominal.radius).toFixed(4)
|
||||
}}</template></el-table-column
|
||||
>
|
||||
<el-table-column label="CAD 拟合残差 / mm"
|
||||
><template #default="s">{{ s.row.cad_fit_rms_mm.toFixed(4) }}</template></el-table-column
|
||||
>
|
||||
</el-table>
|
||||
<template #footer
|
||||
><el-button @click="opened = false">取消</el-button
|
||||
><el-button
|
||||
:loading="busy"
|
||||
type="primary"
|
||||
:disabled="disabled || busy || !chosen"
|
||||
@click="apply"
|
||||
>建立选中测量圆</el-button
|
||||
></template
|
||||
>
|
||||
</el-drawer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as Api from '@/api/lab/inspection'
|
||||
import { userMessage } from './display'
|
||||
const props = defineProps<{
|
||||
disabled?: boolean
|
||||
recordId: string
|
||||
revision: number
|
||||
vertices?: number[][]
|
||||
controlId?: string
|
||||
}>()
|
||||
const emit = defineEmits<{ document: [value: any]; preview: [geometry: any] }>()
|
||||
const opened = ref(false),
|
||||
busy = ref(false),
|
||||
error = ref(''),
|
||||
offset = ref(0),
|
||||
axis = ref([0, 0, 1]),
|
||||
initialAxis = ref<number[]>(),
|
||||
candidates = ref<any[]>([]),
|
||||
chosen = ref<any>()
|
||||
let center = [0, 0, 0]
|
||||
let mounted = true,
|
||||
generation = 0
|
||||
function requestOwner() {
|
||||
const version = ++generation,
|
||||
recordId = props.recordId,
|
||||
revision = props.revision
|
||||
return {
|
||||
recordId,
|
||||
revision,
|
||||
current: () =>
|
||||
mounted &&
|
||||
version === generation &&
|
||||
recordId === props.recordId &&
|
||||
revision === props.revision
|
||||
}
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
mounted = false
|
||||
generation++
|
||||
})
|
||||
const range = computed(() => {
|
||||
let lo = Infinity,
|
||||
hi = -Infinity
|
||||
for (const v of props.vertices || []) {
|
||||
const z = v.reduce((s, x, i) => s + x * axis.value[i], 0)
|
||||
lo = Math.min(lo, z)
|
||||
hi = Math.max(hi, z)
|
||||
}
|
||||
return Number.isFinite(lo) && hi > lo ? [lo, hi] : [-1000, 1000]
|
||||
})
|
||||
function clearCandidates() {
|
||||
generation++
|
||||
candidates.value = []
|
||||
chosen.value = undefined
|
||||
emit('preview', null)
|
||||
}
|
||||
function changeAxis(value: number[]) {
|
||||
const length = Math.hypot(...value)
|
||||
if (!length) return
|
||||
axis.value = value.map((x) => x / length)
|
||||
offset.value = Math.min(
|
||||
range.value[1],
|
||||
Math.max(
|
||||
range.value[0],
|
||||
center.reduce((s, x, i) => s + x * axis.value[i], 0)
|
||||
)
|
||||
)
|
||||
clearCandidates()
|
||||
}
|
||||
function open(geometry?: any) {
|
||||
if (props.disabled) return
|
||||
busy.value = false
|
||||
center = geometry?.center || [0, 0, 0]
|
||||
initialAxis.value = geometry?.axis
|
||||
changeAxis(initialAxis.value || [0, 0, 1])
|
||||
error.value = ''
|
||||
opened.value = true
|
||||
}
|
||||
async function preview() {
|
||||
if (props.disabled || busy.value) return
|
||||
busy.value = true
|
||||
error.value = ''
|
||||
clearCandidates()
|
||||
const owner = requestOwner()
|
||||
try {
|
||||
const r = await Api.post(owner.recordId, 'feature-proposals', {
|
||||
revision: owner.revision,
|
||||
mode: 'preview',
|
||||
section: { axis: axis.value, offset_mm: offset.value }
|
||||
})
|
||||
if (!owner.current() || !opened.value) return
|
||||
candidates.value = r.section_candidates
|
||||
if (!candidates.value.length) error.value = '该截面未找到完整圆形轮廓,请调整截面位置'
|
||||
} catch (e) {
|
||||
if (owner.current()) error.value = userMessage(e)
|
||||
} finally {
|
||||
if (owner.current()) busy.value = false
|
||||
}
|
||||
}
|
||||
function choose(value: any) {
|
||||
chosen.value = value
|
||||
emit('preview', value?.nominal || null)
|
||||
}
|
||||
async function apply() {
|
||||
if (props.disabled || busy.value || !chosen.value) return
|
||||
busy.value = true
|
||||
const owner = requestOwner()
|
||||
try {
|
||||
const r = await Api.post(owner.recordId, 'feature-proposals', {
|
||||
revision: owner.revision,
|
||||
mode: 'apply',
|
||||
section: {
|
||||
axis: axis.value,
|
||||
offset_mm: offset.value,
|
||||
candidate_id: chosen.value.id,
|
||||
...(props.controlId ? { control_id: props.controlId } : { create_control: true })
|
||||
}
|
||||
})
|
||||
if (!owner.current() || !opened.value) return
|
||||
emit('document', r.document)
|
||||
opened.value = false
|
||||
} catch (e) {
|
||||
if (owner.current()) error.value = userMessage(e)
|
||||
} finally {
|
||||
if (owner.current()) busy.value = false
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
123
am-web/src/views/lab/inspection/FeatureDatumEditor.vue
Normal file
123
am-web/src/views/lab/inspection/FeatureDatumEditor.vue
Normal file
@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="datum-heading"
|
||||
><h4>基准体系</h4
|
||||
><el-button :disabled="disabled" size="small" @click="add">添加基准体系</el-button></div
|
||||
>
|
||||
<p class="inspect-sub"
|
||||
>可直接选择圆、圆柱、平面等几何特征,选中后自动设为基准并分配标签。主、次、第三基准按顺序约束;同一级多选表示共同基准。</p
|
||||
>
|
||||
<el-alert v-if="error" :title="error" type="warning" @close="error = ''" />
|
||||
<el-table :data="modelValue" border>
|
||||
<el-table-column label="体系名称" min-width="160"
|
||||
><template #default="{ row }"
|
||||
><el-input
|
||||
:disabled="disabled"
|
||||
v-model="row.name"
|
||||
@update:model-value="emit('update:modelValue', [...modelValue])" /></template
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
v-for="(label, index) in ['主基准', '次基准', '第三基准']"
|
||||
:key="label"
|
||||
:label="label"
|
||||
min-width="190"
|
||||
>
|
||||
<template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="disabled"
|
||||
:model-value="row.precedence[index] || []"
|
||||
multiple
|
||||
clearable
|
||||
filterable
|
||||
placeholder="选择特征并设置基准"
|
||||
:aria-label="`${row.name || '体系'} ${label}`"
|
||||
@update:model-value="update(row, index, $event)"
|
||||
>
|
||||
<el-option
|
||||
v-for="f in candidates"
|
||||
:key="f.id"
|
||||
:label="
|
||||
f.datum_label ? `${f.datum_label} · ${f.name}` : `${f.name}(选择后设为基准)`
|
||||
"
|
||||
:value="f.id"
|
||||
:disabled="row.precedence.some((g, i) => i !== index && g.includes(f.id))"
|
||||
/>
|
||||
<template #empty
|
||||
><div class="datum-empty">{{
|
||||
Object.keys(featureTypes).length
|
||||
? '暂无可作为基准的几何特征,请先添加圆、圆柱或平面等;点和任意曲面区域不能独立作为空间基准。'
|
||||
: '特征列表尚未加载,请刷新后重试。'
|
||||
}}</div></template
|
||||
>
|
||||
</el-select></template
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column width="80"
|
||||
><template #default="{ row }"
|
||||
><el-button :disabled="disabled" link type="danger" @click="emit('remove', row.id)"
|
||||
>移除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { userMessage } from './display'
|
||||
import { datumCandidates, selectDatumFeatures } from './datumSelection'
|
||||
const props = defineProps<{
|
||||
disabled?: boolean
|
||||
modelValue: any[]
|
||||
features: any[]
|
||||
featureTypes: Record<string, any>
|
||||
}>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: any[]]; remove: [id: string] }>()
|
||||
const error = ref(''),
|
||||
candidates = computed(() => datumCandidates(props.features, props.featureTypes))
|
||||
function add() {
|
||||
emit('update:modelValue', [
|
||||
...props.modelValue,
|
||||
{
|
||||
id: crypto.randomUUID().replaceAll('-', ''),
|
||||
name: `基准体系 ${props.modelValue.length + 1}`,
|
||||
precedence: [[]]
|
||||
}
|
||||
])
|
||||
}
|
||||
function update(row: any, index: number, values: string[]) {
|
||||
try {
|
||||
const change = selectDatumFeatures(
|
||||
props.features,
|
||||
props.modelValue,
|
||||
row.id,
|
||||
index,
|
||||
values,
|
||||
props.featureTypes
|
||||
)
|
||||
for (const f of props.features) if (change.labels[f.id]) f.datum_label = change.labels[f.id]
|
||||
emit('update:modelValue', change.frames)
|
||||
error.value = ''
|
||||
} catch (e: any) {
|
||||
error.value = userMessage(e)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.datum-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.datum-empty {
|
||||
max-width: 320px;
|
||||
padding: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
107
am-web/src/views/lab/inspection/FeatureGeometryEditor.vue
Normal file
107
am-web/src/views/lab/inspection/FeatureGeometryEditor.vue
Normal file
@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<div class="geometry-fields">
|
||||
<div v-for="field in vectors" :key="field.key" class="geometry-vector"
|
||||
><span>{{ field.label }}</span
|
||||
><label v-for="(axis, i) in ['X', 'Y', 'Z']" :key="axis"
|
||||
>{{ axis
|
||||
}}<el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue[field.key]?.[i]"
|
||||
:controls="false"
|
||||
:precision="5"
|
||||
:aria-label="`${field.label} ${axis}`"
|
||||
@update:model-value="setVector(field.key, i, $event)" /></label
|
||||
></div>
|
||||
<label v-if="['circle', 'cylinder', 'sphere', 'cone'].includes(type)"
|
||||
>半径 / mm<el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.radius"
|
||||
:controls="false"
|
||||
:min="0.00001"
|
||||
@update:model-value="set('radius', $event)"
|
||||
/></label>
|
||||
<label v-if="type === 'cone'"
|
||||
>半锥角 / °<el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="
|
||||
modelValue.semi_angle == null ? undefined : (modelValue.semi_angle * 180) / Math.PI
|
||||
"
|
||||
:controls="false"
|
||||
:min="0.001"
|
||||
:max="89.999"
|
||||
@update:model-value="
|
||||
set('semi_angle', $event == null ? undefined : ($event * Math.PI) / 180)
|
||||
"
|
||||
/></label>
|
||||
<div v-if="modelValue.axial_range" class="geometry-range"
|
||||
><span>轴向范围 / mm</span
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.axial_range[0]"
|
||||
:controls="false"
|
||||
@update:model-value="setRange(0, $event)" /><span>至</span
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.axial_range[1]"
|
||||
:controls="false"
|
||||
@update:model-value="setRange(1, $event)"
|
||||
/></div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ modelValue: any; type: string; disabled?: boolean }>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: any] }>()
|
||||
const vectors = computed(() => [
|
||||
{ key: 'center', label: '中心位置 / mm' },
|
||||
...(['plane', 'circle', 'cylinder', 'cone', 'line'].includes(props.type)
|
||||
? [{ key: 'axis', label: props.type === 'plane' ? '平面法向' : '轴线方向' }]
|
||||
: [])
|
||||
])
|
||||
function set(key: string, value: any) {
|
||||
const next = { ...props.modelValue }
|
||||
if (value == null) delete next[key]
|
||||
else next[key] = value
|
||||
emit('update:modelValue', next)
|
||||
}
|
||||
function setVector(key: string, index: number, value: any) {
|
||||
const vector = [...(props.modelValue[key] || [null, null, null])]
|
||||
vector[index] = value ?? null
|
||||
set(key, vector)
|
||||
}
|
||||
function setRange(index: number, value: any) {
|
||||
const range = [...props.modelValue.axial_range]
|
||||
range[index] = value ?? null
|
||||
set('axial_range', range)
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.geometry-fields {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.geometry-vector {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.geometry-vector > span {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
|
||||
.geometry-fields .el-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.geometry-range {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.geometry-range > span:first-child {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
</style>
|
||||
885
am-web/src/views/lab/inspection/FeatureTemplateManager.vue
Normal file
885
am-web/src/views/lab/inspection/FeatureTemplateManager.vue
Normal file
@ -0,0 +1,885 @@
|
||||
<template>
|
||||
<section class="inspect-panel">
|
||||
<el-alert v-if="error" type="error" :title="error" @close="error = ''" />
|
||||
<div class="template-toolbar"
|
||||
><el-input
|
||||
v-model="query"
|
||||
placeholder="搜索模板名称"
|
||||
clearable
|
||||
class="template-search"
|
||||
/><el-button @click="load">刷新</el-button
|
||||
><span class="inspect-sub">共 {{ filteredList.length }} 个模板</span></div
|
||||
>
|
||||
<el-table :data="filteredList" v-loading="loading"
|
||||
><el-table-column prop="name" label="模板名称" min-width="240" /><el-table-column
|
||||
label="版本"
|
||||
width="100"
|
||||
><template #default="{ row }">V{{ row.revision }}</template></el-table-column
|
||||
><el-table-column prop="controlCount" label="检测项" width="100" /><el-table-column
|
||||
label="更新时间"
|
||||
width="180"
|
||||
><template #default="{ row }">{{ dateText(row.updateTime) }}</template></el-table-column
|
||||
><el-table-column label="操作" width="260"
|
||||
><template #default="{ row }"
|
||||
><el-button link type="primary" @click="edit(row)">{{
|
||||
writable ? '编辑' : '查看'
|
||||
}}</el-button
|
||||
><el-button link v-if="writable" @click="edit(row, true)">复制</el-button
|
||||
><el-button
|
||||
:disabled="!writable || saving"
|
||||
link
|
||||
type="danger"
|
||||
v-hasPermi="['lab:result:confirm']"
|
||||
@click="remove(row)"
|
||||
>删除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
><template #empty><el-empty description="暂无模板,请新建模板或从检测任务中保存" /></template
|
||||
></el-table>
|
||||
<el-drawer
|
||||
v-model="opened"
|
||||
:title="form.id ? '编辑检测计划模板' : '新建检测计划模板'"
|
||||
size="min(96vw, 1440px)"
|
||||
:before-close="close"
|
||||
destroy-on-close
|
||||
>
|
||||
<el-alert v-if="editError" type="error" :title="editError" :closable="false" class="mb-4" />
|
||||
<el-form :disabled="!writable || saving" label-position="top" class="mt-4"
|
||||
><el-form-item label="模板名称" required
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-model="form.name"
|
||||
maxlength="100"
|
||||
show-word-limit /></el-form-item
|
||||
><el-form-item label="模板说明"
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-model="graph.description"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
/></el-form-item>
|
||||
<el-form-item label="关联零件号"
|
||||
><el-input :disabled="!writable || saving" v-model="graph.part_numbers"
|
||||
/></el-form-item>
|
||||
<el-form-item label="标准版本"
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-model="graph.standard.version"
|
||||
placeholder="填写采用的 GB/T、ISO GPS 标准版本;可稍后维护" /></el-form-item
|
||||
></el-form>
|
||||
<el-collapse
|
||||
><el-collapse-item title="特征、基准与匹配设置"
|
||||
><div class="feature-template-heading"
|
||||
><h4>检测特征</h4
|
||||
><el-button :disabled="!writable || saving" @click="addFeature"
|
||||
>添加特征</el-button
|
||||
></div
|
||||
>
|
||||
<el-table :data="graph.features" border>
|
||||
<el-table-column label="特征名称" min-width="170"
|
||||
><template #default="{ row }"
|
||||
><el-input :disabled="!writable || saving" v-model="row.name" /></template
|
||||
></el-table-column>
|
||||
<el-table-column label="几何类型" width="160"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
:model-value="row.type"
|
||||
@update:model-value="changeType(row, $event)"
|
||||
><el-option
|
||||
v-for="(t, key) in catalog?.types"
|
||||
:key="key"
|
||||
:value="key"
|
||||
:label="t.label" /></el-select></template
|
||||
></el-table-column>
|
||||
<el-table-column label="特征身份" width="160"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
:model-value="!!row.datum_label"
|
||||
@update:model-value="setRole(row, $event)"
|
||||
><el-option :value="false" label="普通特征" /><el-option
|
||||
:value="true"
|
||||
label="基准特征"
|
||||
:disabled="!catalog?.types[row.type]?.datum_allowed" /></el-select></template
|
||||
></el-table-column>
|
||||
<el-table-column label="基准标签" width="120"
|
||||
><template #default="{ row }"
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-if="row.datum_label"
|
||||
v-model="row.datum_label"
|
||||
maxlength="3"
|
||||
placeholder="A、B…"
|
||||
@change="row.datum_label = row.datum_label.toUpperCase().trim()"
|
||||
/><span v-else>—</span></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="匹配方式" min-width="190"
|
||||
><template #default="{ row }"
|
||||
><span>{{
|
||||
row.construction
|
||||
? '构造规则'
|
||||
: row.reference_binding && !row.matching
|
||||
? '同 CAD 恢复 / 跨 CAD 重匹配'
|
||||
: '当前 CAD 按类型和规则匹配'
|
||||
}}</span
|
||||
><el-button
|
||||
:disabled="!writable || saving"
|
||||
link
|
||||
type="primary"
|
||||
@click="editMatching(row)"
|
||||
>设置</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="操作" width="150"
|
||||
><template #default="{ row }"
|
||||
><el-button :disabled="!writable || saving" link @click="addControl(row)"
|
||||
>添加控制</el-button
|
||||
><el-button
|
||||
:disabled="!writable || saving"
|
||||
link
|
||||
type="danger"
|
||||
@click="removeFeature(row)"
|
||||
>移除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
>
|
||||
</el-table>
|
||||
</el-collapse-item></el-collapse
|
||||
><div class="feature-template-heading mt-5"
|
||||
><h4>检测项目</h4
|
||||
><el-button :disabled="!writable || saving" @click="itemDialog = true"
|
||||
>添加检测项</el-button
|
||||
></div
|
||||
>
|
||||
<el-checkbox v-model="advancedControls">显示关联特征、基准与备注</el-checkbox
|
||||
><p class="inspect-sub">尺寸公差填写上、下偏差;形位公差填写上限。同一特征可添加多项检测。</p>
|
||||
<el-table :data="graph.controls" border>
|
||||
<el-table-column label="检测项名称" width="180"
|
||||
><template #default="{ row }"
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-model="row.name"
|
||||
:placeholder="featureName(row.feature_id)" /></template
|
||||
></el-table-column>
|
||||
<el-table-column label="被测特征" width="170"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
:model-value="row.feature_id"
|
||||
@update:model-value="changeControlFeature(row, $event)"
|
||||
><el-option
|
||||
v-for="f in graph.features"
|
||||
:key="f.id"
|
||||
:value="f.id"
|
||||
:label="f.name" /></el-select></template
|
||||
></el-table-column>
|
||||
<el-table-column label="控制项" width="165"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
:model-value="row.kind"
|
||||
@update:model-value="changeKind(row, $event)"
|
||||
><el-option-group
|
||||
v-for="(label, category) in { dimension: '普通尺寸', geometric: '形位公差' }"
|
||||
:key="category"
|
||||
:label="label"
|
||||
><el-option
|
||||
v-for="(c, key) in controlOptions(row.feature_id, category)"
|
||||
:key="key"
|
||||
:value="key"
|
||||
:label="c.label" /></el-option-group></el-select
|
||||
><el-tag v-if="row.migration_review_required" type="warning" size="small"
|
||||
>测量定义待配置</el-tag
|
||||
></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="名义值" width="120"
|
||||
><template #default="{ row }"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
v-if="isSize(row.kind)"
|
||||
v-model="row.nominal"
|
||||
:controls="false"
|
||||
:aria-label="`${featureName(row.feature_id)} ${controlLabel(row.kind)} 名义值`"
|
||||
class="number-input"
|
||||
/><span v-else>—</span></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="公差方式" width="145"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
v-if="isSize(row.kind)"
|
||||
:model-value="row.tolerance?.mode || 'bilateral'"
|
||||
@update:model-value="setToleranceMode(row, $event)"
|
||||
><el-option value="bilateral" label="上 / 下偏差" /><el-option
|
||||
value="limits"
|
||||
label="实际尺寸上下限" /></el-select
|
||||
><span v-else>形位上限</span></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="公差上限 / 上偏差" width="145"
|
||||
><template #default="{ row }"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
:model-value="row.tolerance?.upper"
|
||||
:controls="false"
|
||||
class="number-input"
|
||||
:aria-label="`${featureName(row.feature_id)} ${controlLabel(row.kind)} 公差上限`"
|
||||
@update:model-value="setTolerance(row, 'upper', $event)" /></template
|
||||
></el-table-column>
|
||||
<el-table-column label="下偏差" width="120"
|
||||
><template #default="{ row }"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
v-if="isSize(row.kind)"
|
||||
:model-value="row.tolerance?.lower"
|
||||
:controls="false"
|
||||
class="number-input"
|
||||
@update:model-value="setTolerance(row, 'lower', $event)"
|
||||
/><span v-else>—</span></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column v-if="advancedControls" label="基准体系" min-width="150"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
v-model="row.datum_system_id"
|
||||
clearable
|
||||
placeholder="无基准 / 选择"
|
||||
><el-option
|
||||
v-for="d in graph.datum_systems"
|
||||
:key="d.id"
|
||||
:value="d.id"
|
||||
:label="d.name" /></el-select
|
||||
><span
|
||||
v-if="catalog?.controls[row.kind]?.datum_required && !row.datum_system_id"
|
||||
class="inspect-sub"
|
||||
>该控制需指定基准</span
|
||||
></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column v-if="advancedControls" label="第二特征" min-width="150"
|
||||
><template #default="{ row }"
|
||||
><el-select
|
||||
:disabled="!writable || saving"
|
||||
v-model="row.other_feature_id"
|
||||
clearable
|
||||
placeholder="按控制选择"
|
||||
><el-option
|
||||
v-for="f in graph.features.filter((f) => f.id !== row.feature_id)"
|
||||
:key="f.id"
|
||||
:value="f.id"
|
||||
:label="f.name" /></el-select></template
|
||||
></el-table-column>
|
||||
<el-table-column v-if="advancedControls" label="备注" min-width="190"
|
||||
><template #default="{ row }"
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-model="row.notes"
|
||||
type="textarea"
|
||||
:rows="2" /></template
|
||||
></el-table-column>
|
||||
<el-table-column label="操作" width="110"
|
||||
><template #default="{ row }"
|
||||
><el-button :disabled="!writable || saving" link @click="editParameters(row)"
|
||||
>参数</el-button
|
||||
><el-button
|
||||
:disabled="!writable || saving"
|
||||
link
|
||||
type="danger"
|
||||
@click="graph.controls = graph.controls.filter((c) => c.id !== row.id)"
|
||||
>移除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
>
|
||||
</el-table>
|
||||
<el-collapse
|
||||
><el-collapse-item title="基准体系"
|
||||
><FeatureDatumEditor
|
||||
:disabled="!writable || saving"
|
||||
v-model="graph.datum_systems"
|
||||
:features="graph.features"
|
||||
:feature-types="catalog?.types || {}"
|
||||
@remove="removeFrame" /></el-collapse-item
|
||||
></el-collapse>
|
||||
<el-collapse class="mt-5"
|
||||
><el-collapse-item title="高级设置:未注尺寸公差规则"
|
||||
><GeneralToleranceEditor
|
||||
:disabled="!writable || saving"
|
||||
v-model="form.definition" /></el-collapse-item
|
||||
></el-collapse>
|
||||
<el-collapse class="mt-5"
|
||||
><el-collapse-item title="模板导入与导出" name="advanced"
|
||||
><el-button @click="exportGraph">导出 JSON</el-button
|
||||
><el-button :disabled="!writable || saving" @click="jsonInput?.click()"
|
||||
>导入 JSON</el-button
|
||||
><input
|
||||
ref="jsonInput"
|
||||
type="file"
|
||||
hidden
|
||||
accept=".json"
|
||||
@change="importGraph" /></el-collapse-item
|
||||
></el-collapse>
|
||||
<template #footer
|
||||
><el-button @click="close()">关闭</el-button
|
||||
><el-button
|
||||
:disabled="!writable || saving"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
v-hasPermi="['lab:result:confirm']"
|
||||
@click="save"
|
||||
>保存模板</el-button
|
||||
></template
|
||||
>
|
||||
</el-drawer>
|
||||
<el-dialog v-model="itemDialog" title="添加检测项" width="480px"
|
||||
><el-form :disabled="!writable || saving" label-position="top"
|
||||
><el-form-item label="名称"
|
||||
><el-input
|
||||
:disabled="!writable || saving"
|
||||
v-model="itemName"
|
||||
placeholder="例如:中心孔直径" /></el-form-item
|
||||
><el-form-item label="测量方式"
|
||||
><el-select :disabled="!writable || saving" v-model="itemKind"
|
||||
><el-option
|
||||
v-for="r in itemRecipes"
|
||||
:key="r.value"
|
||||
:value="r.value"
|
||||
:label="r.label" /></el-select></el-form-item
|
||||
><el-form-item v-if="itemKind !== 'flatness'" label="名义值 / mm"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
v-model="itemNominal"
|
||||
:controls="false" /></el-form-item></el-form
|
||||
><template #footer
|
||||
><el-button @click="itemDialog = false">取消</el-button
|
||||
><el-button :disabled="!writable || saving" type="primary" @click="addItem"
|
||||
>添加</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<el-dialog v-model="matchingOpen" title="CAD 匹配与扫描提取规则" width="620px"
|
||||
><template v-if="matchingFeature"
|
||||
><p>设置几何匹配条件;存在多个匹配结果时,可在检测任务中选面定位。</p
|
||||
><el-switch
|
||||
v-model="useReference"
|
||||
active-text="相同 CAD 恢复参考面;不同 CAD 重新匹配"
|
||||
:disabled="!matchingFeature.reference_binding || !writable || saving"
|
||||
/><el-form :disabled="!writable || saving" label-position="top" class="mt-4"
|
||||
><el-form-item
|
||||
v-if="['circle', 'cylinder', 'sphere', 'cone'].includes(matchingFeature.type)"
|
||||
label="CAD 候选半径 / mm(可留空)"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
v-model="matchingRadius"
|
||||
:controls="false"
|
||||
:min="0.0001" /></el-form-item
|
||||
><el-form-item label="扫描搜索距离 / mm"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
v-model="matchingFeature.extraction.search_mm"
|
||||
:min="0.001" /></el-form-item
|
||||
><el-form-item label="最少支持点"
|
||||
><el-input-number
|
||||
:disabled="!writable || saving"
|
||||
v-model="matchingFeature.extraction.min_points"
|
||||
:min="3" /></el-form-item></el-form
|
||||
><p v-if="matchingFeature.type === 'circle'" class="inspect-sub"
|
||||
>截面圆可在 CAD 工作区由圆柱 / 圆锥构造,保存模板时保留父特征和截面规则。</p
|
||||
></template
|
||||
><template #footer
|
||||
><el-button @click="matchingOpen = false">取消</el-button
|
||||
><el-button :disabled="!writable || saving" type="primary" @click="saveMatching"
|
||||
>应用规则</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<el-dialog v-model="parameterOpen" title="测量参数" width="580px"
|
||||
><MeasurementParameters
|
||||
:disabled="!writable || saving"
|
||||
v-if="parameterControl"
|
||||
v-model="parameterDraft"
|
||||
:features="graph.features"
|
||||
:kind="parameterControl.kind"
|
||||
:feature-type="graph.features.find((f) => f.id === parameterControl.feature_id)?.type"
|
||||
:feature-axis="
|
||||
graph.features.find((f) => f.id === parameterControl.feature_id)?.nominal?.axis
|
||||
"
|
||||
/>
|
||||
<el-checkbox
|
||||
:disabled="!writable || saving"
|
||||
v-if="parameterControl?.legacy_row_index != null && parameterControl?.other_feature_id"
|
||||
v-model="measurementConfirmed"
|
||||
>已核对两端几何及测量投影方式,允许计算该尺寸</el-checkbox
|
||||
>
|
||||
<template #footer
|
||||
><el-button @click="parameterOpen = false">取消</el-button
|
||||
><el-button :disabled="!writable || saving" type="primary" @click="saveParameters"
|
||||
>保存参数</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
</section>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { userMessage, dateText } from './display'
|
||||
import * as Api from '@/api/lab/inspection'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import FeatureDatumEditor from './FeatureDatumEditor.vue'
|
||||
import GeneralToleranceEditor from './GeneralToleranceEditor.vue'
|
||||
import MeasurementParameters from './MeasurementParameters.vue'
|
||||
import {
|
||||
measurementParameterError,
|
||||
setToleranceBound,
|
||||
setToleranceMode,
|
||||
toleranceError
|
||||
} from './measurementOptions'
|
||||
import { nextDatumLabel, validateDatumFrames } from './datumSelection'
|
||||
const writable = computed(() => checkPermi(['lab:result:confirm']))
|
||||
const itemDialog = ref(false),
|
||||
itemName = ref(''),
|
||||
itemKind = ref('section_diameter'),
|
||||
itemNominal = ref<number>()
|
||||
const itemRecipes = [
|
||||
{ value: 'section_diameter', label: '截面直径' },
|
||||
{ value: 'cylinder_diameter', label: '圆柱直径' },
|
||||
{ value: 'plane_distance', label: '两个平行端面的距离' },
|
||||
{ value: 'projected_distance', label: '指定方向的中心投影距离' },
|
||||
{ value: 'axis_distance', label: '孔轴间距' },
|
||||
{ value: 'flatness', label: '平面度' }
|
||||
]
|
||||
function addItem() {
|
||||
if (!itemName.value.trim()) {
|
||||
ElMessage.warning('请填写检测项名称')
|
||||
return
|
||||
}
|
||||
if (
|
||||
itemKind.value !== 'flatness' &&
|
||||
!(
|
||||
typeof itemNominal.value === 'number' &&
|
||||
Number.isFinite(itemNominal.value) &&
|
||||
itemNominal.value > 0
|
||||
)
|
||||
) {
|
||||
ElMessage.warning('请填写有效名义值')
|
||||
return
|
||||
}
|
||||
const recipe = itemKind.value,
|
||||
relation = ['plane_distance', 'projected_distance', 'axis_distance'].includes(recipe),
|
||||
kind =
|
||||
recipe === 'flatness'
|
||||
? 'flatness'
|
||||
: recipe === 'axis_distance'
|
||||
? 'hole_distance'
|
||||
: relation
|
||||
? 'length'
|
||||
: 'diameter',
|
||||
geometry =
|
||||
recipe === 'cylinder_diameter'
|
||||
? 'cylinder'
|
||||
: recipe === 'section_diameter' || recipe === 'axis_distance'
|
||||
? 'circle'
|
||||
: 'plane',
|
||||
ids: string[] = []
|
||||
for (let i = 0; i < (relation ? 2 : 1); i++) {
|
||||
const id = uid()
|
||||
ids.push(id)
|
||||
graph.value.features.push({
|
||||
id,
|
||||
name: itemName.value + (relation ? ` · 要素 ${i + 1}` : ''),
|
||||
type: geometry,
|
||||
nominal: {},
|
||||
matching: kind === 'diameter' ? { radius: itemNominal.value! / 2 } : {},
|
||||
binding_status: 'needs_rematch',
|
||||
extraction: {
|
||||
search_mm: 3,
|
||||
min_points: 30,
|
||||
...(geometry === 'plane' ? { normal_angle_deg: 30 } : {})
|
||||
}
|
||||
})
|
||||
}
|
||||
graph.value.controls.push({
|
||||
id: uid(),
|
||||
feature_id: ids[0],
|
||||
...(relation ? { other_feature_id: ids[1] } : {}),
|
||||
kind,
|
||||
nominal: kind === 'flatness' ? null : itemNominal.value,
|
||||
tolerance: null,
|
||||
parameters: {},
|
||||
recipe: { kind: recipe },
|
||||
required: true
|
||||
})
|
||||
itemDialog.value = false
|
||||
itemName.value = ''
|
||||
itemNominal.value = undefined
|
||||
}
|
||||
const advancedControls = ref(false)
|
||||
const list = ref<any[]>([]),
|
||||
catalog = ref<any>(),
|
||||
loading = ref(false),
|
||||
error = ref(''),
|
||||
editError = ref(''),
|
||||
query = ref(''),
|
||||
opened = ref(false),
|
||||
saving = ref(false),
|
||||
form = ref<any>({}),
|
||||
baseline = ref(''),
|
||||
jsonInput = ref<HTMLInputElement>()
|
||||
const graph = computed(() => form.value.definition)
|
||||
const uid = () => crypto.randomUUID().replaceAll('-', '')
|
||||
const controlLabel = (kind: string) => catalog.value?.controls[kind]?.label || kind
|
||||
const featureName = (id: string) => graph.value.features.find((f) => f.id === id)?.name || id
|
||||
const isSize = (kind: string) => catalog.value?.controls[kind]?.category === 'dimension'
|
||||
function controlOptions(id: string, category?: string) {
|
||||
const type = graph.value.features.find((f) => f.id === id)?.type
|
||||
return Object.fromEntries(
|
||||
Object.entries<any>(catalog.value?.controls || {}).filter(
|
||||
([, c]) => c.types.includes(type) && (!category || c.category === category)
|
||||
)
|
||||
)
|
||||
}
|
||||
const filteredList = computed(() =>
|
||||
list.value.filter((t) => !query.value || t.name.includes(query.value))
|
||||
)
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const [templates, capability] = await Promise.allSettled([
|
||||
Api.featureTemplates(),
|
||||
Api.featureCapabilities()
|
||||
])
|
||||
if (templates.status === 'rejected') throw templates.reason
|
||||
list.value = templates.value.list
|
||||
if (capability.status === 'rejected') throw capability.reason
|
||||
const cap = capability.value
|
||||
if (!cap?.types || !cap?.controls) throw Error('检测配置暂不可用,请刷新页面或联系管理员')
|
||||
catalog.value = cap
|
||||
} catch (e: any) {
|
||||
error.value = userMessage(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
function create() {
|
||||
if (!writable.value) return
|
||||
if (!catalog.value) {
|
||||
error.value = '检测配置尚未加载,请刷新后重试'
|
||||
return
|
||||
}
|
||||
form.value = {
|
||||
name: '',
|
||||
definition: {
|
||||
schema_version: 2,
|
||||
unit: 'mm',
|
||||
standard: { family: 'GB/T-ISO-GPS', version: '' },
|
||||
features: [],
|
||||
controls: [],
|
||||
datum_systems: [],
|
||||
coverage: { complete: false }
|
||||
}
|
||||
}
|
||||
editError.value = ''
|
||||
baseline.value = JSON.stringify(form.value)
|
||||
opened.value = true
|
||||
}
|
||||
async function edit(row: any, copy = false) {
|
||||
try {
|
||||
form.value = await Api.featureTemplate(row.id)
|
||||
if (copy) {
|
||||
delete form.value.id
|
||||
delete form.value.revision
|
||||
form.value.name += ' · 副本'
|
||||
}
|
||||
form.value.definition.standard ||= { family: 'GB/T-ISO-GPS', version: '' }
|
||||
editError.value = ''
|
||||
baseline.value = JSON.stringify(form.value)
|
||||
opened.value = true
|
||||
} catch (e: any) {
|
||||
error.value = userMessage(e)
|
||||
}
|
||||
}
|
||||
function addFeature() {
|
||||
graph.value.features.push({
|
||||
id: uid(),
|
||||
name: `特征 ${graph.value.features.length + 1}`,
|
||||
type: 'plane',
|
||||
nominal: {},
|
||||
matching: {},
|
||||
binding_status: 'needs_rematch',
|
||||
extraction: { search_mm: 3, min_points: 30 }
|
||||
})
|
||||
}
|
||||
function changeType(f: any, type: string) {
|
||||
if (
|
||||
graph.value.controls.some(
|
||||
(c) => c.feature_id === f.id && !catalog.value.controls[c.kind]?.types.includes(type)
|
||||
)
|
||||
) {
|
||||
editError.value = '请先移除或更换与新几何类型不兼容的控制'
|
||||
return
|
||||
}
|
||||
if (f.datum_label && !catalog.value.types[type].datum_allowed) {
|
||||
editError.value = '请先移除该特征的基准身份'
|
||||
return
|
||||
}
|
||||
f.type = type
|
||||
f.nominal = {}
|
||||
f.matching = {}
|
||||
delete f.reference_binding
|
||||
delete f.construction
|
||||
editError.value = ''
|
||||
}
|
||||
function setRole(f: any, enabled: boolean) {
|
||||
if (enabled) {
|
||||
const label = nextDatumLabel(graph.value.features)
|
||||
if (!label) {
|
||||
editError.value = '请手工设置唯一基准标签'
|
||||
return
|
||||
}
|
||||
f.datum_label = label
|
||||
} else {
|
||||
if (graph.value.datum_systems.some((d) => d.precedence.flat().includes(f.id))) {
|
||||
editError.value = '该基准已被体系引用,请先调整基准体系'
|
||||
return
|
||||
}
|
||||
delete f.datum_label
|
||||
}
|
||||
editError.value = ''
|
||||
}
|
||||
function addControl(f: any) {
|
||||
const options = controlOptions(f.id)
|
||||
const kind =
|
||||
['diameter', 'flatness', 'straightness', 'taper', 'distance'].find((k) => options[k]) ||
|
||||
Object.keys(options)[0]
|
||||
if (kind)
|
||||
graph.value.controls.push({
|
||||
id: uid(),
|
||||
feature_id: f.id,
|
||||
kind,
|
||||
nominal: null,
|
||||
tolerance: null,
|
||||
parameters: {}
|
||||
})
|
||||
}
|
||||
function changeKind(c: any, kind: string) {
|
||||
c.kind = kind
|
||||
c.nominal = null
|
||||
c.tolerance = null
|
||||
c.parameters = {}
|
||||
delete c.result
|
||||
}
|
||||
function changeControlFeature(c: any, id: string) {
|
||||
c.feature_id = id
|
||||
if (!controlOptions(id)[c.kind]) changeKind(c, Object.keys(controlOptions(id))[0])
|
||||
}
|
||||
function setTolerance(c: any, key: string, value: any) {
|
||||
setToleranceBound(c, key, value, isSize(c.kind))
|
||||
}
|
||||
function removeFrame(id: string) {
|
||||
graph.value.datum_systems = graph.value.datum_systems.filter((d) => d.id !== id)
|
||||
for (const c of graph.value.controls) if (c.datum_system_id === id) delete c.datum_system_id
|
||||
}
|
||||
function removeFeature(f: any) {
|
||||
if (graph.value.features.some((v) => v.construction?.parent_ids?.includes(f.id))) {
|
||||
editError.value = '该特征是构造父特征,请先处理其构造特征'
|
||||
return
|
||||
}
|
||||
for (const d of [...graph.value.datum_systems])
|
||||
if (d.precedence.flat().includes(f.id)) removeFrame(d.id)
|
||||
graph.value.controls = graph.value.controls.filter(
|
||||
(c) => c.feature_id !== f.id && c.other_feature_id !== f.id
|
||||
)
|
||||
graph.value.features = graph.value.features.filter((v) => v.id !== f.id)
|
||||
}
|
||||
const matchingOpen = ref(false),
|
||||
matchingFeature = ref<any>(),
|
||||
matchingRadius = ref<number>(),
|
||||
useReference = ref(false)
|
||||
function editMatching(f: any) {
|
||||
if (f.construction) {
|
||||
editError.value = '构造特征请在任务 CAD 工作区调整父特征和截面规则,再保存模板'
|
||||
return
|
||||
}
|
||||
matchingFeature.value = JSON.parse(JSON.stringify(f))
|
||||
matchingRadius.value = f.matching?.radius ?? f.nominal?.radius
|
||||
useReference.value = !!f.reference_binding && !f.matching
|
||||
matchingOpen.value = true
|
||||
}
|
||||
function saveMatching() {
|
||||
const f = matchingFeature.value
|
||||
if (useReference.value) delete f.matching
|
||||
else f.matching = matchingRadius.value == null ? {} : { radius: matchingRadius.value }
|
||||
const original = graph.value.features.find((v) => v.id === f.id)
|
||||
original.extraction = f.extraction
|
||||
if (f.matching) original.matching = f.matching
|
||||
else delete original.matching
|
||||
matchingOpen.value = false
|
||||
}
|
||||
const parameterOpen = ref(false),
|
||||
parameterControl = ref<any>(),
|
||||
parameterDraft = ref<any>({}),
|
||||
measurementConfirmed = ref(false)
|
||||
function editParameters(c: any) {
|
||||
parameterControl.value = c
|
||||
parameterDraft.value = JSON.parse(JSON.stringify(c.parameters || {}))
|
||||
measurementConfirmed.value = !c.migration_review_required
|
||||
parameterOpen.value = true
|
||||
}
|
||||
function saveParameters() {
|
||||
try {
|
||||
const parameterError = measurementParameterError(
|
||||
parameterControl.value.kind,
|
||||
graph.value.features.find((f) => f.id === parameterControl.value.feature_id)?.type,
|
||||
parameterDraft.value
|
||||
)
|
||||
if (parameterError) {
|
||||
ElMessage.warning(parameterError)
|
||||
return
|
||||
}
|
||||
parameterControl.value.parameters = JSON.parse(JSON.stringify(parameterDraft.value))
|
||||
if (parameterControl.value.legacy_row_index != null && parameterControl.value.other_feature_id)
|
||||
parameterControl.value.migration_review_required = !measurementConfirmed.value
|
||||
parameterOpen.value = false
|
||||
} catch {
|
||||
editError.value = '测量参数无效,请检查后重试'
|
||||
}
|
||||
}
|
||||
function validate() {
|
||||
if (!form.value.name?.trim()) throw Error('请填写模板名称')
|
||||
if (!graph.value.features.length) throw Error('请至少添加一个特征')
|
||||
const labels = new Set()
|
||||
for (const f of graph.value.features) {
|
||||
if (!f.name?.trim() || !catalog.value.types[f.type]) throw Error('请填写特征名称和有效类型')
|
||||
if (f.datum_label) {
|
||||
if (
|
||||
!catalog.value.types[f.type].datum_allowed ||
|
||||
!/^[A-Z]{1,3}$/.test(f.datum_label) ||
|
||||
labels.has(f.datum_label)
|
||||
)
|
||||
throw Error('基准标签需唯一并使用 1–3 位大写字母;点和任意曲面区域不能独立作为空间基准')
|
||||
labels.add(f.datum_label)
|
||||
}
|
||||
}
|
||||
validateDatumFrames(graph.value.features, graph.value.datum_systems, catalog.value.types)
|
||||
for (const c of graph.value.controls) {
|
||||
if (!controlOptions(c.feature_id)[c.kind]) throw Error('控制与几何类型不兼容')
|
||||
const message = toleranceError(c.tolerance, isSize(c.kind), c.nominal)
|
||||
if (message) throw Error(message)
|
||||
}
|
||||
}
|
||||
async function save() {
|
||||
if (!writable.value) return
|
||||
saving.value = true
|
||||
editError.value = ''
|
||||
try {
|
||||
validate()
|
||||
await Api.saveFeatureTemplate(form.value)
|
||||
baseline.value = JSON.stringify(form.value)
|
||||
opened.value = false
|
||||
await load()
|
||||
ElMessage.success('特征模板版本已保存')
|
||||
} catch (e: any) {
|
||||
editError.value = userMessage(e)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
async function close(done?: () => void) {
|
||||
if (JSON.stringify(form.value) !== baseline.value) {
|
||||
try {
|
||||
await ElMessageBox.confirm('关闭将放弃未保存的模板修改,是否继续?', '关闭模板')
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (done) done()
|
||||
else opened.value = false
|
||||
}
|
||||
async function remove(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm('删除此模板?已有任务和报告继续保留。', '删除特征模板')
|
||||
await Api.deleteFeatureTemplate(row.id, row.revision)
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
if (!['cancel', 'close'].includes(e)) error.value = userMessage(e)
|
||||
}
|
||||
}
|
||||
function exportGraph() {
|
||||
Api.saveBlob(
|
||||
new Blob([JSON.stringify(form.value.definition, null, 2)], { type: 'application/json' }),
|
||||
'cad-feature-template.json'
|
||||
)
|
||||
}
|
||||
async function importGraph(event: Event) {
|
||||
try {
|
||||
const file = (event.target as HTMLInputElement).files?.[0]
|
||||
if (!file) return
|
||||
const value = JSON.parse(await file.text())
|
||||
if (
|
||||
value.schema_version !== 2 ||
|
||||
!Array.isArray(value.features) ||
|
||||
!Array.isArray(value.controls) ||
|
||||
!Array.isArray(value.datum_systems)
|
||||
)
|
||||
throw Error('模板文件格式不兼容,请导入从模板管理导出的文件')
|
||||
form.value.definition = value
|
||||
} catch (e: any) {
|
||||
editError.value = userMessage(e)
|
||||
}
|
||||
}
|
||||
defineExpose({ create })
|
||||
onMounted(load)
|
||||
</script>
|
||||
<style scoped>
|
||||
.feature-template-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.feature-template-heading h3,
|
||||
.feature-template-heading h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.feature-template-heading p {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.template-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.template-toolbar .template-search {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.template-toolbar .inspect-sub {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.template-search {
|
||||
max-width: 320px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.number-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
165
am-web/src/views/lab/inspection/GeneralToleranceEditor.vue
Normal file
165
am-web/src/views/lab/inspection/GeneralToleranceEditor.vue
Normal file
@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<div>
|
||||
<p class="inspect-sub">仅使用来源、版本和适用类别明确的公差表;不替换已单独设置的公差。</p>
|
||||
<el-form :disabled="disabled" label-position="top"
|
||||
><el-form-item label="未标注项目的默认加工类别"
|
||||
><el-select
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.default_manufacturing_category"
|
||||
clearable
|
||||
placeholder="未确定,逐项保留待设置"
|
||||
@update:model-value="updateCategory"
|
||||
><el-option value="machined" label="机加工" /><el-option
|
||||
value="cast"
|
||||
label="铸造" /><el-option value="sheet" label="钣金" /></el-select></el-form-item
|
||||
></el-form>
|
||||
<article v-for="(rule, index) in rules" :key="index" class="tolerance-rule">
|
||||
<el-form :disabled="disabled" label-position="top" inline>
|
||||
<el-form-item label="标准与版本"
|
||||
><el-input
|
||||
:disabled="disabled"
|
||||
v-model="rule.standard_version"
|
||||
@change="changed"
|
||||
placeholder="按图纸要求填写"
|
||||
/></el-form-item>
|
||||
<el-form-item label="等级"
|
||||
><el-input :disabled="disabled" v-model="rule.grade" @change="changed"
|
||||
/></el-form-item>
|
||||
<el-form-item label="适用类别"
|
||||
><el-select
|
||||
:disabled="disabled"
|
||||
v-model="rule.category"
|
||||
style="width: 130px"
|
||||
@change="changed"
|
||||
><el-option value="machined" label="机加工" /><el-option
|
||||
value="cast"
|
||||
label="铸造" /><el-option value="sheet" label="钣金" /></el-select
|
||||
></el-form-item>
|
||||
<el-form-item label="依据"
|
||||
><el-input
|
||||
:disabled="disabled"
|
||||
v-model="rule.source"
|
||||
@change="changed"
|
||||
placeholder="图纸页码、技术要求条目"
|
||||
/></el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="rule.ranges" size="small"
|
||||
><el-table-column label="大于 / mm"
|
||||
><template #default="s"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
v-model="s.row.min_mm"
|
||||
:controls="false"
|
||||
@change="changed" /></template></el-table-column
|
||||
><el-table-column label="至 / mm"
|
||||
><template #default="s"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
v-model="s.row.max_mm"
|
||||
:controls="false"
|
||||
@change="changed" /></template></el-table-column
|
||||
><el-table-column label="下偏差 / mm"
|
||||
><template #default="s"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
v-model="s.row.lower"
|
||||
:controls="false"
|
||||
@change="changed" /></template></el-table-column
|
||||
><el-table-column label="上偏差 / mm"
|
||||
><template #default="s"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
v-model="s.row.upper"
|
||||
:controls="false"
|
||||
@change="changed" /></template></el-table-column
|
||||
><el-table-column width="70"
|
||||
><template #default="s"
|
||||
><el-button :disabled="disabled" link @click="removeBand(rule, s.$index)"
|
||||
>移除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
></el-table
|
||||
>
|
||||
<el-button :disabled="disabled" link @click="addBand(rule)">添加尺寸段</el-button
|
||||
><el-checkbox v-model="rule.approved" :disabled="!valid(rule) || disabled" @change="changed"
|
||||
>已核对依据与数值,允许用于未注尺寸</el-checkbox
|
||||
><el-button :disabled="disabled" link type="danger" @click="removeRule(Number(index))"
|
||||
>删除规则</el-button
|
||||
>
|
||||
</article>
|
||||
<el-button :disabled="disabled" @click="add">添加未注尺寸公差规则</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ modelValue: any; disabled?: boolean }>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: any] }>()
|
||||
const rules = computed(() => props.modelValue.general_tolerances || [])
|
||||
function removeBand(rule: any, index: number) {
|
||||
rule.ranges.splice(index, 1)
|
||||
changed()
|
||||
}
|
||||
function addBand(rule: any) {
|
||||
rule.ranges.push({})
|
||||
changed()
|
||||
}
|
||||
function removeRule(index: number) {
|
||||
rules.value.splice(index, 1)
|
||||
changed()
|
||||
}
|
||||
function valid(r: any) {
|
||||
return (
|
||||
!!r.standard_version &&
|
||||
!!r.grade &&
|
||||
!!r.category &&
|
||||
!!r.source &&
|
||||
r.ranges?.length > 0 &&
|
||||
r.ranges.every(
|
||||
(b: any) =>
|
||||
['min_mm', 'max_mm', 'lower', 'upper'].every(
|
||||
(k) => typeof b[k] === 'number' && Number.isFinite(b[k])
|
||||
) &&
|
||||
b.min_mm < b.max_mm &&
|
||||
b.lower <= b.upper
|
||||
)
|
||||
)
|
||||
}
|
||||
function changed() {
|
||||
for (const r of rules.value) if (!valid(r)) r.approved = false
|
||||
emit('update:modelValue', { ...props.modelValue, general_tolerances: [...rules.value] })
|
||||
}
|
||||
function updateCategory(value: any) {
|
||||
emit('update:modelValue', {
|
||||
...props.modelValue,
|
||||
default_manufacturing_category: value || undefined
|
||||
})
|
||||
}
|
||||
function add() {
|
||||
emit('update:modelValue', {
|
||||
...props.modelValue,
|
||||
general_tolerances: [
|
||||
...rules.value,
|
||||
{
|
||||
standard_version: '',
|
||||
grade: '',
|
||||
source: '',
|
||||
category: '',
|
||||
approved: false,
|
||||
controls: ['diameter', 'radius', 'length', 'distance', 'thickness', 'hole_distance'],
|
||||
ranges: [{}]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.tolerance-rule {
|
||||
padding: 14px;
|
||||
margin: 12px 0;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.el-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@ -4,7 +4,13 @@
|
||||
><div
|
||||
><h3>点云处理工作区</h3
|
||||
><p>在扫描原始坐标系中调整规则。先预览保留 / 排除点,再确认并重新对齐。</p></div
|
||||
><el-button :loading="loading" :disabled="busy" @click="load">重新读取</el-button></div
|
||||
><div
|
||||
><ProcessedStlDownload
|
||||
:record-id="recordId"
|
||||
:disabled="!exportEnabled || busy || loading || blocked || recipeDirty"
|
||||
/>
|
||||
<el-button :loading="loading" :disabled="busy" @click="load">重新读取</el-button></div
|
||||
></div
|
||||
>
|
||||
<el-alert v-if="error" :title="error" type="error" show-icon @close="error = ''" />
|
||||
<el-alert
|
||||
@ -144,17 +150,36 @@
|
||||
><el-radio-group v-model="r.mode"
|
||||
><el-radio value="keep">保留内部</el-radio
|
||||
><el-radio value="remove">删除内部</el-radio></el-radio-group
|
||||
><el-form-item label="顶点坐标 / mm(JSON 数组)"
|
||||
><el-input
|
||||
v-model="r.verticesText"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="[[0,0],[10,0],[10,10],[0,10]]" /></el-form-item
|
||||
></template>
|
||||
><el-form-item label="多边形顶点 / mm"
|
||||
><div
|
||||
><div v-for="(vertex, vi) in r.vertices" :key="vi" class="clean-axis"
|
||||
><span>{{ Number(vi) + 1 }}</span
|
||||
><el-input-number
|
||||
v-model="vertex[0]"
|
||||
:controls="false"
|
||||
:aria-label="`顶点 ${Number(vi) + 1} 第一坐标`"
|
||||
/><el-input-number
|
||||
v-model="vertex[1]"
|
||||
:controls="false"
|
||||
:aria-label="`顶点 ${Number(vi) + 1} 第二坐标`"
|
||||
/><el-button
|
||||
link
|
||||
:disabled="r.vertices.length <= 3"
|
||||
@click="r.vertices.splice(vi, 1)"
|
||||
>移除</el-button
|
||||
></div
|
||||
><el-button
|
||||
link
|
||||
:disabled="r.vertices.length >= 100"
|
||||
@click="r.vertices.push([null, null])"
|
||||
>添加顶点</el-button
|
||||
></div
|
||||
></el-form-item
|
||||
></template
|
||||
>
|
||||
<div v-else class="inspect-sub"
|
||||
>CAD 主体编号:{{
|
||||
r.component_ids?.join(', ')
|
||||
}}。修改前置规则后,请重新生成自动方案。</div
|
||||
>已匹配 {{ r.component_ids?.length || 0 }} 个 CAD
|
||||
主体。修改前置规则后,请重新生成方案。</div
|
||||
>
|
||||
</el-form> </article
|
||||
><el-empty
|
||||
@ -218,10 +243,7 @@
|
||||
prop="removed"
|
||||
label="本步排除" /><el-table-column prop="retained" label="保留"
|
||||
/></el-table>
|
||||
<div class="inspect-sub mt-12px"
|
||||
>预览按照完整原始点云计算保留结果,窗口最多显示 24,000
|
||||
个采样点。规则只排除原始点,正式对齐使用确认后保留的点云。</div
|
||||
>
|
||||
<div class="inspect-sub mt-12px">预览显示部分点;清理和对齐使用确认后保留的完整点云。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clean-footer"
|
||||
@ -241,11 +263,16 @@
|
||||
</section>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { userMessage } from './display'
|
||||
import * as Api from '@/api/lab/inspection'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import InspectionViewer from './InspectionViewer.vue'
|
||||
import ProcessedStlDownload from './ProcessedStlDownload.vue'
|
||||
import type { Vec3 } from './geometry'
|
||||
const props = defineProps<{ recordId: string; blocked?: boolean }>(),
|
||||
const props = withDefaults(
|
||||
defineProps<{ recordId: string; blocked?: boolean; exportEnabled?: boolean }>(),
|
||||
{ exportEnabled: true }
|
||||
),
|
||||
emit = defineEmits<{ applied: [state: any]; dirty: [dirty: boolean] }>()
|
||||
const data = shallowRef<any>({}),
|
||||
rules = ref<any[]>([]),
|
||||
@ -294,7 +321,7 @@ function editable(actions: any[]) {
|
||||
return actions.map((r) => ({
|
||||
...r,
|
||||
...(r.type === 'isolated' ? { neighbors: r.neighbors || 20 } : {}),
|
||||
...(r.type === 'polygon' ? { verticesText: JSON.stringify(r.vertices) } : {})
|
||||
...(r.type === 'polygon' ? { vertices: clone(r.vertices || []) } : {})
|
||||
}))
|
||||
}
|
||||
async function load() {
|
||||
@ -313,7 +340,7 @@ async function load() {
|
||||
signature.value = JSON.stringify(rules.value)
|
||||
saved.value = signature.value
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '读取原始点云失败'
|
||||
error.value = userMessage(e, '读取原始点云失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@ -325,7 +352,7 @@ async function run(fn: () => Promise<void>) {
|
||||
try {
|
||||
await fn()
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || String(e)
|
||||
error.value = userMessage(e)
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
@ -334,12 +361,17 @@ function actions() {
|
||||
return rules.value.map((rule) => {
|
||||
const r = clone(rule)
|
||||
if (r.type === 'polygon') {
|
||||
try {
|
||||
r.vertices = JSON.parse(r.verticesText)
|
||||
} catch {
|
||||
throw new Error('投影多边形顶点需为有效 JSON 数组')
|
||||
}
|
||||
delete r.verticesText
|
||||
if (
|
||||
!Array.isArray(r.vertices) ||
|
||||
r.vertices.length < 3 ||
|
||||
r.vertices.some(
|
||||
(v) =>
|
||||
!Array.isArray(v) ||
|
||||
v.length !== 2 ||
|
||||
v.some((n) => typeof n !== 'number' || !Number.isFinite(n))
|
||||
)
|
||||
)
|
||||
throw new Error('请填写至少三个完整的多边形顶点')
|
||||
}
|
||||
return r
|
||||
})
|
||||
@ -363,12 +395,12 @@ function addRule() {
|
||||
type,
|
||||
plane: 'xy',
|
||||
mode: 'keep',
|
||||
verticesText: JSON.stringify([
|
||||
vertices: [
|
||||
[b[0][0], b[0][1]],
|
||||
[b[1][0], b[0][1]],
|
||||
[b[1][0], b[1][1]],
|
||||
[b[0][0], b[1][1]]
|
||||
])
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -426,34 +458,41 @@ onMounted(load)
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.clean-heading h3 {
|
||||
font-size: 17px;
|
||||
margin: 0 0 8px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.clean-heading p {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.clean-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 310px minmax(0, 1fr);
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.clean-controls {
|
||||
min-width: 0;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.clean-controls .el-input-number,
|
||||
.clean-controls .el-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.clean-controls :deep(.el-form-item) {
|
||||
margin-bottom: 13px;
|
||||
}
|
||||
|
||||
.clean-rule-heading,
|
||||
.clean-rule-title,
|
||||
.clean-add {
|
||||
@ -461,38 +500,47 @@ onMounted(load)
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.clean-rule-heading {
|
||||
justify-content: space-between;
|
||||
margin: 20px 0 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.clean-add {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.clean-add .el-select {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.clean-rule-list {
|
||||
max-height: 620px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.clean-rule {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
margin-bottom: 12px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.clean-rule-title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 13px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.clean-rule-title strong {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.clean-rule-title .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.clean-axis {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -500,33 +548,40 @@ onMounted(load)
|
||||
margin: 10px 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.clean-axis .el-input-number {
|
||||
min-width: 0;
|
||||
width: 100px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.clean-preview {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.clean-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.clean-metrics > div {
|
||||
padding: 15px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.clean-metrics small {
|
||||
font-size: 11px;
|
||||
color: var(--el-text-color-secondary);
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-size: 11px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.clean-metrics strong {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.clean-preview-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -535,32 +590,39 @@ onMounted(load)
|
||||
margin: 14px 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.clean-footer {
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
display: flex;
|
||||
padding-top: 18px;
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.clean-footer > span {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.clean-panel .el-alert {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
@media (max-width: 1050px) {
|
||||
|
||||
@media (width <= 1050px) {
|
||||
.clean-layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.clean-controls {
|
||||
max-height: 550px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.clean-rule-list {
|
||||
max-height: 360px;
|
||||
}
|
||||
|
||||
.clean-metrics {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
2055
am-web/src/views/lab/inspection/InspectionFeatures.vue
Normal file
2055
am-web/src/views/lab/inspection/InspectionFeatures.vue
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
540
am-web/src/views/lab/inspection/LegacyInspectionTemplates.vue
Normal file
540
am-web/src/views/lab/inspection/LegacyInspectionTemplates.vue
Normal file
@ -0,0 +1,540 @@
|
||||
<template>
|
||||
<main class="inspect-page">
|
||||
<header class="inspect-header"
|
||||
><div class="inspect-kicker">检测计划模板</div
|
||||
><div class="inspect-title-line"
|
||||
><div
|
||||
><h1>检测计划模板</h1
|
||||
><p>维护模板名称、检测项与公差,统一新建检测和计划调整的检测依据。</p></div
|
||||
><el-button @click="$router.back()">返回任务</el-button
|
||||
><el-button type="primary" v-hasPermi="['lab:result:confirm']" @click="edit()"
|
||||
><Icon icon="ep:plus" class="mr-6px" />新建模板</el-button
|
||||
></div
|
||||
></header
|
||||
>
|
||||
<el-alert v-if="error" :title="error" type="error" show-icon @close="error = ''" />
|
||||
<section class="inspect-panel inspect-search"
|
||||
><el-input
|
||||
v-model="query.name"
|
||||
placeholder="搜索模板名称"
|
||||
clearable
|
||||
style="width: 280px"
|
||||
@keyup.enter="search"
|
||||
><template #prefix><Icon icon="ep:search" /></template></el-input
|
||||
><el-select v-model="query.enabled" clearable placeholder="全部状态" style="width: 150px"
|
||||
><el-option label="已启用" value="true" /><el-option
|
||||
label="已停用"
|
||||
value="false" /></el-select
|
||||
><el-button type="primary" plain @click="search">查询</el-button
|
||||
><el-button @click="reset">重置</el-button
|
||||
><span class="inspect-sub ml-auto">共 {{ total }} 个模板</span></section
|
||||
>
|
||||
<section class="inspect-panel"
|
||||
><el-table :data="list" v-loading="loading"
|
||||
><el-table-column label="模板名称" min-width="270"
|
||||
><template #default="s"
|
||||
><div class="inspect-table-title"
|
||||
><span class="inspect-table-icon"><Icon icon="ep:document-copy" :size="20" /></span
|
||||
><div
|
||||
><strong>{{ s.row.name }}</strong
|
||||
><div class="inspect-sub">{{ s.row.description || '—' }}</div></div
|
||||
></div
|
||||
></template
|
||||
></el-table-column
|
||||
><el-table-column
|
||||
prop="partNumbers"
|
||||
label="自动匹配零件号"
|
||||
min-width="200"
|
||||
show-overflow-tooltip
|
||||
/><el-table-column prop="rowCount" label="检测项" width="90" /><el-table-column
|
||||
label="版本"
|
||||
width="85"
|
||||
><template #default="s">V{{ s.row.revision }}</template></el-table-column
|
||||
><el-table-column label="状态" width="100"
|
||||
><template #default="s"
|
||||
><el-tag :type="s.row.enabled ? 'success' : 'info'">{{
|
||||
s.row.enabled ? '已启用' : '已停用'
|
||||
}}</el-tag></template
|
||||
></el-table-column
|
||||
><el-table-column label="更新时间" width="175"
|
||||
><template #default="s">{{ dateText(s.row.updateTime) }}</template></el-table-column
|
||||
><el-table-column label="操作" fixed="right" width="240"
|
||||
><template #default="s"
|
||||
><el-button link type="primary" @click="edit(s.row)">{{
|
||||
writable ? '编辑字段' : '查看'
|
||||
}}</el-button
|
||||
><el-button link v-hasPermi="['lab:result:confirm']" @click="edit(s.row, true)"
|
||||
>复制</el-button
|
||||
><el-button link @click="exportTemplate(s.row)">导出</el-button
|
||||
><el-button
|
||||
link
|
||||
type="danger"
|
||||
v-hasPermi="['lab:result:confirm']"
|
||||
@click="remove(s.row)"
|
||||
>删除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
><template #empty
|
||||
><el-empty description="暂无检测计划模板"
|
||||
><el-button type="primary" v-hasPermi="['lab:result:confirm']" @click="edit()"
|
||||
>新建模板</el-button
|
||||
></el-empty
|
||||
></template
|
||||
></el-table
|
||||
><Pagination
|
||||
:total="total"
|
||||
v-model:page="query.pageNo"
|
||||
v-model:limit="query.pageSize"
|
||||
@pagination="load"
|
||||
/></section>
|
||||
<el-drawer
|
||||
v-model="drawer"
|
||||
:title="model.id ? '维护检测计划模板' : '新建检测计划模板'"
|
||||
size="min(96vw, 1320px)"
|
||||
:before-close="close"
|
||||
destroy-on-close
|
||||
>
|
||||
<div v-loading="editing"
|
||||
><el-alert
|
||||
v-if="editError"
|
||||
:title="editError"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/><el-alert
|
||||
title="保存后会更新模板版本。已经建立的检测任务继续使用当时的计划;需要更新时可在任务中重新载入模板。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="model"
|
||||
label-position="top"
|
||||
:disabled="saving || !writable"
|
||||
class="template-form"
|
||||
><el-row :gutter="20"
|
||||
><el-col :span="14"
|
||||
><el-form-item
|
||||
label="模板名称"
|
||||
prop="name"
|
||||
:rules="[{ required: true, message: '请输入模板名称', trigger: 'blur' }]"
|
||||
><el-input
|
||||
v-model="model.name"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
placeholder="如:管类零件尺寸检测" /></el-form-item></el-col
|
||||
><el-col :span="6"
|
||||
><el-form-item label="状态"
|
||||
><el-switch
|
||||
v-model="model.enabled"
|
||||
active-text="启用"
|
||||
inactive-text="停用" /></el-form-item></el-col
|
||||
><el-col :span="4"
|
||||
><el-form-item label="当前版本"
|
||||
><el-tag>{{
|
||||
model.id ? 'V' + model.revision : '首次保存 V1'
|
||||
}}</el-tag></el-form-item
|
||||
></el-col
|
||||
></el-row
|
||||
><el-form-item label="自动匹配零件号"
|
||||
><el-input
|
||||
v-model="model.partNumbers"
|
||||
maxlength="500"
|
||||
placeholder="可填写多个完整零件号,以逗号分隔;留空时由操作员手动选择模板" /></el-form-item
|
||||
><el-form-item label="模板说明"
|
||||
><el-input
|
||||
v-model="model.description"
|
||||
maxlength="1000"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="适用零件、图纸版本或检测要求" /></el-form-item
|
||||
></el-form>
|
||||
<div class="template-items-heading"
|
||||
><div
|
||||
><h3
|
||||
>检测项与字段内容 <el-tag size="small">{{ model.rows.length }} 项</el-tag></h3
|
||||
><p>按行维护名称、几何类型、控制项、名义值、公差与备注。尺寸单位为 mm。</p></div
|
||||
><div class="template-tools" v-if="writable"
|
||||
><el-button @click="jsonInput?.click()" :disabled="saving">导入 JSON</el-button
|
||||
><el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="addRow"
|
||||
:disabled="saving || model.rows.length >= 500"
|
||||
><Icon icon="ep:plus" class="mr-4px" />添加检测项</el-button
|
||||
><input ref="jsonInput" type="file" accept=".json" hidden @change="importJson" /></div
|
||||
></div>
|
||||
<el-table :data="model.rows" border max-height="500" class="template-fields"
|
||||
><el-table-column type="index" label="序号" width="60" /><el-table-column
|
||||
label="检测项名称"
|
||||
min-width="180"
|
||||
><template #default="s"
|
||||
><el-input
|
||||
v-model="s.row.name"
|
||||
maxlength="120"
|
||||
:disabled="!writable || saving"
|
||||
placeholder="如:中心孔直径" /></template></el-table-column
|
||||
><el-table-column label="几何类型" width="150"
|
||||
><template #default="s"
|
||||
><el-select
|
||||
v-model="s.row.type"
|
||||
:disabled="!writable || saving"
|
||||
@change="changeType(s.row)"
|
||||
><el-option
|
||||
v-for="o in types"
|
||||
:key="o.value"
|
||||
:value="o.value"
|
||||
:label="o.label" /></el-select></template></el-table-column
|
||||
><el-table-column label="控制项" width="125"
|
||||
><template #default="s"
|
||||
><el-select
|
||||
v-model="s.row.control"
|
||||
filterable
|
||||
allow-create
|
||||
default-first-option
|
||||
:disabled="!writable || saving"
|
||||
><el-option
|
||||
v-for="v in ['直径', '长度', '孔距', '面距', '点间距', '平面度', '圆柱度']"
|
||||
:key="v"
|
||||
:value="v"
|
||||
:label="v" /></el-select></template></el-table-column
|
||||
><el-table-column label="名义 / mm" width="155"
|
||||
><template #default="s"
|
||||
><el-input-number
|
||||
v-model="s.row.nominal_mm"
|
||||
:min="0"
|
||||
:max="10000000"
|
||||
:precision="4"
|
||||
:controls="false"
|
||||
:disabled="!writable || saving"
|
||||
style="width: 100%" /></template></el-table-column
|
||||
><el-table-column label="公差" width="135"
|
||||
><template #default="s"
|
||||
><el-input
|
||||
v-model="s.row.tol_text"
|
||||
:disabled="!writable || saving"
|
||||
placeholder="±0.1 / +0.1/0" /></template></el-table-column
|
||||
><el-table-column label="备注" min-width="180"
|
||||
><template #default="s"
|
||||
><el-input
|
||||
v-model="s.row.notes"
|
||||
:disabled="!writable || saving"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 1, maxRows: 3 }"
|
||||
maxlength="1000"
|
||||
placeholder="测量位置、图纸标注等" /></template></el-table-column
|
||||
><el-table-column v-if="writable" label="操作" width="160" fixed="right"
|
||||
><template #default="s"
|
||||
><el-button link :disabled="saving || s.$index === 0" @click="moveRow(s.$index, -1)"
|
||||
>上移</el-button
|
||||
><el-button
|
||||
link
|
||||
:disabled="saving || s.$index === model.rows.length - 1"
|
||||
@click="moveRow(s.$index, 1)"
|
||||
>下移</el-button
|
||||
><el-button
|
||||
link
|
||||
type="danger"
|
||||
:disabled="saving"
|
||||
@click="model.rows.splice(s.$index, 1)"
|
||||
>移除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
><template #empty><el-empty description="点击添加检测项,开始定义模板字段" /></template
|
||||
></el-table>
|
||||
<p class="inspect-sub mt-12px"
|
||||
>公差可留空;支持
|
||||
±0.1、+0.025/0、+1/-0.5。未设置公差的检测项保留测量值,显示“未设公差”。</p
|
||||
></div
|
||||
>
|
||||
<template #footer
|
||||
><div class="template-footer"
|
||||
><span class="inspect-sub">{{ dirty ? '有修改待保存' : '模板内容已同步' }}</span
|
||||
><el-button :disabled="saving" @click="close(() => (drawer = false))">关闭</el-button
|
||||
><el-button
|
||||
v-if="writable"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="editing"
|
||||
@click="save"
|
||||
>保存模板</el-button
|
||||
></div
|
||||
></template
|
||||
>
|
||||
</el-drawer>
|
||||
</main>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as Api from '@/api/lab/inspection'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { dateText } from './display'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
import './inspection.scss'
|
||||
defineOptions({ name: 'LabLegacyInspectionTemplates' })
|
||||
const writable = computed(() => checkPermi(['lab:result:confirm'])),
|
||||
list = ref<any[]>([]),
|
||||
total = ref(0),
|
||||
loading = ref(false),
|
||||
error = ref(''),
|
||||
drawer = ref(false),
|
||||
editing = ref(false),
|
||||
saving = ref(false),
|
||||
editError = ref(''),
|
||||
form = ref(),
|
||||
jsonInput = ref<HTMLInputElement>(),
|
||||
baseline = ref('')
|
||||
const model = ref<any>({ name: '', description: '', partNumbers: '', enabled: true, rows: [] }),
|
||||
dirty = computed(() => JSON.stringify(model.value) !== baseline.value),
|
||||
query = reactive({ name: '', enabled: '', pageNo: 1, pageSize: 20 })
|
||||
const types = [
|
||||
{ value: 'circle', label: '圆 / 孔 / 管径' },
|
||||
{ value: 'distance', label: '长度 / 距离' },
|
||||
{ value: 'hole_distance', label: '孔心距' },
|
||||
{ value: 'plane_distance', label: '平行面距' },
|
||||
{ value: 'point_distance', label: '扫描点间距' },
|
||||
{ value: 'plane', label: '平面' },
|
||||
{ value: 'cylinder', label: '圆柱' }
|
||||
]
|
||||
let sequence = 0
|
||||
async function load() {
|
||||
const owner = ++sequence
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await Api.templatePage({ ...query })
|
||||
if (owner === sequence) {
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
error.value = ''
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (owner === sequence) error.value = e?.message || '模板查询失败'
|
||||
} finally {
|
||||
if (owner === sequence) loading.value = false
|
||||
}
|
||||
}
|
||||
function search() {
|
||||
query.pageNo = 1
|
||||
void load()
|
||||
}
|
||||
function reset() {
|
||||
query.name = ''
|
||||
query.enabled = ''
|
||||
search()
|
||||
}
|
||||
async function edit(row?: any, copy = false) {
|
||||
editing.value = true
|
||||
editError.value = ''
|
||||
try {
|
||||
const data = row
|
||||
? await Api.templateDetail(row.id)
|
||||
: { name: '', description: '', partNumbers: '', enabled: true, rows: [] }
|
||||
if (copy) {
|
||||
delete data.id
|
||||
delete data.revision
|
||||
delete data.builtinKey
|
||||
data.name = (data.name + ' · 副本').slice(0, 100)
|
||||
data.partNumbers = ''
|
||||
data.enabled = false
|
||||
}
|
||||
model.value = JSON.parse(JSON.stringify(data))
|
||||
baseline.value = JSON.stringify(model.value)
|
||||
drawer.value = true
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '读取模板失败'
|
||||
} finally {
|
||||
editing.value = false
|
||||
}
|
||||
}
|
||||
function addRow() {
|
||||
model.value.rows.push({
|
||||
table: 'feature',
|
||||
type: 'circle',
|
||||
name: '检测项 ' + (model.value.rows.length + 1),
|
||||
control: '直径',
|
||||
nominal_mm: null,
|
||||
tol_text: '',
|
||||
notes: ''
|
||||
})
|
||||
}
|
||||
function changeType(row: any) {
|
||||
const feature = ['circle', 'plane', 'cylinder'].includes(row.type)
|
||||
row.table = feature ? 'feature' : 'gauge'
|
||||
row.control = {
|
||||
circle: '直径',
|
||||
plane: '平面度',
|
||||
cylinder: '圆柱度',
|
||||
distance: '长度',
|
||||
hole_distance: '孔距',
|
||||
plane_distance: '面距',
|
||||
point_distance: '点间距'
|
||||
}[row.type]
|
||||
}
|
||||
function moveRow(index: number, offset: number) {
|
||||
const rows = model.value.rows
|
||||
;[rows[index], rows[index + offset]] = [rows[index + offset], rows[index]]
|
||||
}
|
||||
async function close(done: () => void) {
|
||||
if (saving.value) return
|
||||
if (dirty.value) {
|
||||
try {
|
||||
await ElMessageBox.confirm('当前模板有未保存修改,是否放弃修改并关闭?', '关闭模板', {
|
||||
confirmButtonText: '放弃修改',
|
||||
cancelButtonText: '继续编辑'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
done()
|
||||
}
|
||||
async function save() {
|
||||
if (saving.value) return
|
||||
editError.value = ''
|
||||
try {
|
||||
await form.value.validate()
|
||||
if (!model.value.rows.length) throw new Error('请至少添加一个检测项')
|
||||
for (const [i, row] of model.value.rows.entries()) {
|
||||
if (!row.name?.trim() || row.nominal_mm == null || !Number.isFinite(Number(row.nominal_mm)))
|
||||
throw new Error(`第 ${i + 1} 项:请填写名称和有效名义值`)
|
||||
}
|
||||
saving.value = true
|
||||
model.value = await Api.saveTemplate(model.value)
|
||||
baseline.value = JSON.stringify(model.value)
|
||||
ElMessage.success('模板已保存,版本 V' + model.value.revision)
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
editError.value = e?.message || '请检查模板名称与检测项字段'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
async function remove(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`删除模板「${row.name}」?已有检测任务和报告继续保留。`,
|
||||
'删除模板',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
await Api.removeTemplate(row.id, row.revision)
|
||||
ElMessage.success('模板已删除')
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel' && e !== 'close') error.value = e?.message || '删除失败'
|
||||
}
|
||||
}
|
||||
async function exportTemplate(row: any) {
|
||||
try {
|
||||
const data = await Api.templateDetail(row.id)
|
||||
Api.saveBlob(
|
||||
new Blob(
|
||||
[
|
||||
JSON.stringify(
|
||||
{
|
||||
schema_version: 1,
|
||||
unit: 'mm',
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
partNumbers: data.partNumbers,
|
||||
rows: data.rows
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
],
|
||||
{ type: 'application/json;charset=utf-8' }
|
||||
),
|
||||
data.name + '-V' + data.revision + '.json'
|
||||
)
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '导出失败'
|
||||
}
|
||||
}
|
||||
async function importJson(e: Event) {
|
||||
const input = e.target as HTMLInputElement,
|
||||
file = input.files?.[0]
|
||||
if (!file) return
|
||||
try {
|
||||
if (file.size > 2 * 1024 * 1024) throw new Error('模板 JSON 不得超过 2 MB')
|
||||
const data = JSON.parse(await file.text())
|
||||
const rows = Array.isArray(data) ? data : data.rows
|
||||
if (!Array.isArray(rows) || !rows.length || rows.length > 500)
|
||||
throw new Error('JSON 需包含 1–500 个检测项 rows')
|
||||
if (dirty.value) await ElMessageBox.confirm('导入会替换当前字段内容,是否继续?', '导入模板')
|
||||
model.value.rows = rows
|
||||
if (!model.value.name && data.name) model.value.name = data.name
|
||||
editError.value = ''
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel' && e !== 'close') editError.value = e?.message || 'JSON 模板无效'
|
||||
} finally {
|
||||
input.value = ''
|
||||
}
|
||||
}
|
||||
onMounted(load)
|
||||
</script>
|
||||
<style scoped>
|
||||
.template-form {
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
.template-items-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin: 12px 0 18px;
|
||||
}
|
||||
|
||||
.template-items-heading h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.template-items-heading p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.template-tools {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.template-tools .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.template-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.template-footer > span {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.template-footer .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.template-fields :deep(.el-table__cell) {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.template-fields :deep(.el-button + .el-button) {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.inspect-table-title strong {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@media (width <= 800px) {
|
||||
.template-items-heading {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
272
am-web/src/views/lab/inspection/MeasurementParameters.vue
Normal file
272
am-web/src/views/lab/inspection/MeasurementParameters.vue
Normal file
@ -0,0 +1,272 @@
|
||||
<template>
|
||||
<el-form :disabled="disabled" label-position="top">
|
||||
<el-form-item v-if="kind === 'angle'" label="角度定义">
|
||||
<el-select
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.angle_mode || 'acute'"
|
||||
@update:model-value="set('angle_mode', $event)"
|
||||
>
|
||||
<el-option value="acute" label="两方向较小夹角(0–90°)" /><el-option
|
||||
value="directed"
|
||||
label="按特征方向测量(0–180°)"
|
||||
/><el-option value="supplementary" label="较小夹角的补角" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<template v-if="['circular_runout', 'total_runout'].includes(kind)">
|
||||
<el-form-item label="跳动方向"
|
||||
><el-select
|
||||
:disabled="disabled"
|
||||
:model-value="
|
||||
modelValue.runout_direction || (featureType === 'plane' ? 'axial' : 'radial')
|
||||
"
|
||||
@update:model-value="set('runout_direction', $event)"
|
||||
><el-option value="radial" label="径向跳动" /><el-option
|
||||
value="axial"
|
||||
label="端面轴向跳动" /></el-select
|
||||
></el-form-item>
|
||||
<el-form-item label="最小圆周覆盖 / °"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.min_coverage_deg ?? 270"
|
||||
:min="1"
|
||||
:max="360"
|
||||
@update:model-value="set('min_coverage_deg', $event)"
|
||||
/></el-form-item>
|
||||
<el-form-item
|
||||
v-if="kind === 'circular_runout' && modelValue.runout_direction === 'axial'"
|
||||
label="实际圆环最大带宽 / mm"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.max_ring_width_mm"
|
||||
:min="0.001"
|
||||
@update:model-value="set('max_ring_width_mm', $event)"
|
||||
/></el-form-item>
|
||||
</template>
|
||||
<el-form-item v-if="kind === 'fitting_diameter'" label="配合类型"
|
||||
><el-radio-group
|
||||
:model-value="modelValue.material_side"
|
||||
@update:model-value="set('material_side', $event)"
|
||||
><el-radio value="internal">内孔</el-radio
|
||||
><el-radio value="external">外圆</el-radio></el-radio-group
|
||||
></el-form-item
|
||||
>
|
||||
<template
|
||||
v-if="
|
||||
['parallelism', 'perpendicularity', 'angularity'].includes(kind) && featureType !== 'plane'
|
||||
"
|
||||
>
|
||||
<el-form-item label="轴线评价长度 / mm"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.evaluation_length_mm"
|
||||
:min="0.001"
|
||||
:controls="false"
|
||||
@update:model-value="set('evaluation_length_mm', $event)"
|
||||
/></el-form-item>
|
||||
<el-form-item label="公差带形状"
|
||||
><el-select
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.zone"
|
||||
@update:model-value="set('zone', $event)"
|
||||
><el-option value="cylindrical" label="圆柱公差带" /><el-option
|
||||
value="parallel_planes"
|
||||
label="两平行平面" /></el-select
|
||||
></el-form-item>
|
||||
</template>
|
||||
<el-form-item v-if="kind === 'angularity'" label="理论角度 / °"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.angle_deg"
|
||||
:min="0"
|
||||
:max="180"
|
||||
:controls="false"
|
||||
@update:model-value="set('angle_deg', $event)"
|
||||
/></el-form-item>
|
||||
<el-form-item v-if="kind === 'arc_length'" label="弧段角度 / °"
|
||||
><el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.sweep_deg"
|
||||
:min="0.001"
|
||||
:max="360"
|
||||
:controls="false"
|
||||
@update:model-value="set('sweep_deg', $event)"
|
||||
/></el-form-item>
|
||||
<template v-if="['distance', 'length', 'hole_distance', 'chamfer', 'thickness'].includes(kind)">
|
||||
<el-form-item label="测量方式"
|
||||
><el-select
|
||||
:disabled="disabled"
|
||||
:model-value="projectionMode"
|
||||
@update:model-value="changeProjection"
|
||||
><el-option value="axis_distance" label="轴线间距" /><el-option
|
||||
value="plane_distance"
|
||||
label="两个平行面的间距" /><el-option
|
||||
value="point_plane"
|
||||
label="点 / 圆心到平面的距离" /><el-option
|
||||
value="center"
|
||||
label="空间中心距" /><el-option
|
||||
value="surface_minimum"
|
||||
label="两扫描区域的最小点距" /><el-option
|
||||
value="projected"
|
||||
label="指定方向投影" /></el-select
|
||||
></el-form-item>
|
||||
</template>
|
||||
<el-form-item v-if="projectionMode === 'projected' || kind === 'extent'" label="方向参考">
|
||||
<el-select
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.direction_feature_id || ''"
|
||||
@update:model-value="set('direction_feature_id', $event)"
|
||||
><el-option value="" label="指定方向向量" /><el-option
|
||||
v-for="f in (features || []).filter((f) =>
|
||||
['circle', 'cylinder', 'cone', 'plane', 'line'].includes(f.type)
|
||||
)"
|
||||
:key="f.id"
|
||||
:value="f.id"
|
||||
:label="f.name + ' · 轴线 / 法向'"
|
||||
/></el-select>
|
||||
<el-select
|
||||
:disabled="disabled"
|
||||
v-if="modelValue.direction_feature_id"
|
||||
:model-value="modelValue.direction_source || 'nominal'"
|
||||
@update:model-value="set('direction_source', $event)"
|
||||
><el-option value="nominal" label="沿设计特征方向" /><el-option
|
||||
value="measured"
|
||||
label="沿实测特征方向"
|
||||
/></el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="
|
||||
(projectionMode === 'projected' || kind === 'extent') && !modelValue.direction_feature_id
|
||||
"
|
||||
label="测量方向"
|
||||
><el-button-group class="mb-2"
|
||||
><el-button
|
||||
:disabled="disabled"
|
||||
v-for="(axis, i) in ['X', 'Y', 'Z']"
|
||||
:key="axis"
|
||||
size="small"
|
||||
@click="
|
||||
set(
|
||||
'direction',
|
||||
[0, 1, 2].map((j) => (j === i ? 1 : 0))
|
||||
)
|
||||
"
|
||||
>{{ axis }} 方向</el-button
|
||||
><el-button
|
||||
:disabled="disabled"
|
||||
v-if="featureAxis"
|
||||
size="small"
|
||||
@click="set('direction', [...featureAxis])"
|
||||
>特征轴向</el-button
|
||||
></el-button-group
|
||||
><div class="parameter-vector"
|
||||
><label v-for="(axis, i) in ['X', 'Y', 'Z']" :key="axis"
|
||||
>{{ axis
|
||||
}}<el-input-number
|
||||
:disabled="disabled"
|
||||
:model-value="modelValue.direction?.[i]"
|
||||
:controls="false"
|
||||
:aria-label="`测量方向 ${axis}`"
|
||||
@update:model-value="setDirection(i, $event)" /></label></div
|
||||
></el-form-item>
|
||||
<p v-if="kind === 'extent'" class="inspect-sub"
|
||||
>计算所选扫描区域沿指定方向的实际跨度;请确保两端均已扫描。</p
|
||||
>
|
||||
<p v-else-if="kind === 'thickness'" class="inspect-sub">沿两个平行面的法向测量厚度。</p>
|
||||
<p v-else-if="!configurable" class="inspect-sub">此检测项无需附加测量参数。</p>
|
||||
</el-form>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
disabled?: boolean
|
||||
modelValue: any
|
||||
kind: string
|
||||
featureType?: string
|
||||
featureAxis?: number[]
|
||||
features?: any[]
|
||||
}>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: any] }>()
|
||||
const configurable = computed(
|
||||
() =>
|
||||
[
|
||||
'fitting_diameter',
|
||||
'parallelism',
|
||||
'perpendicularity',
|
||||
'angularity',
|
||||
'arc_length',
|
||||
'distance',
|
||||
'length',
|
||||
'hole_distance',
|
||||
'chamfer',
|
||||
'extent',
|
||||
'angle',
|
||||
'circular_runout',
|
||||
'total_runout',
|
||||
'thickness'
|
||||
].includes(props.kind) &&
|
||||
!(props.featureType === 'plane' && ['parallelism', 'perpendicularity'].includes(props.kind))
|
||||
)
|
||||
const projectionMode = computed(() =>
|
||||
props.modelValue.mode === '3d_center'
|
||||
? 'center'
|
||||
: props.modelValue.mode ||
|
||||
(props.modelValue.direction || props.modelValue.direction_feature_id
|
||||
? 'projected'
|
||||
: props.kind === 'chamfer'
|
||||
? 'projected'
|
||||
: props.kind === 'hole_distance'
|
||||
? 'axis_distance'
|
||||
: props.kind === 'thickness'
|
||||
? 'plane_distance'
|
||||
: 'center')
|
||||
)
|
||||
function set(key: string, value: any) {
|
||||
const next = { ...props.modelValue }
|
||||
if (key === 'direction') delete next.direction_feature_id
|
||||
if (key === 'direction_feature_id') {
|
||||
delete next.direction
|
||||
if (!value) {
|
||||
delete next.direction_feature_id
|
||||
value = undefined
|
||||
}
|
||||
}
|
||||
if (value == null) delete next[key]
|
||||
else next[key] = value
|
||||
emit('update:modelValue', next)
|
||||
}
|
||||
function changeProjection(mode: string) {
|
||||
const next = { ...props.modelValue }
|
||||
delete next.direction
|
||||
delete next.direction_feature_id
|
||||
delete next.mode
|
||||
next.mode = mode
|
||||
if (mode === 'projected')
|
||||
next.direction = props.featureAxis ? [...props.featureAxis] : [null, null, null]
|
||||
emit('update:modelValue', next)
|
||||
}
|
||||
function setDirection(index: number, value: any) {
|
||||
const vector = [...(props.modelValue.direction || [null, null, null])]
|
||||
vector[index] = value ?? null
|
||||
set('direction', vector)
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.parameter-vector {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.parameter-vector label {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.parameter-vector .el-input-number {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
59
am-web/src/views/lab/inspection/ProcessedStlDownload.vue
Normal file
59
am-web/src/views/lab/inspection/ProcessedStlDownload.vue
Normal file
@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="stl-download">
|
||||
<el-button :loading="loading" :disabled="disabled" @click="download">下载处理后 STL</el-button>
|
||||
<div v-if="loading" class="stl-progress">
|
||||
<el-progress :percentage="Math.min(100, progress.progress || 0)" :stroke-width="5" />
|
||||
<span>{{ progress.message || '正在准备 STL' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as Api from '@/api/lab/inspection'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { userMessage } from './display'
|
||||
import { downloadProcessedStl } from './stlDownload'
|
||||
const props = defineProps<{ recordId: string; disabled?: boolean }>()
|
||||
const loading = ref(false),
|
||||
progress = ref<any>({})
|
||||
let active = true
|
||||
onBeforeUnmount(() => {
|
||||
active = false
|
||||
})
|
||||
async function download() {
|
||||
if (loading.value || props.disabled) return
|
||||
const recordId = props.recordId
|
||||
loading.value = true
|
||||
try {
|
||||
await downloadProcessedStl(
|
||||
{
|
||||
state: () => Api.state(recordId),
|
||||
start: (revision) => Api.post(recordId, 'cleanup', { operation: 'export_stl', revision }),
|
||||
file: () => Api.processedStl(recordId),
|
||||
save: (blob) => Api.saveBlob(blob, '处理后点云.stl')
|
||||
},
|
||||
(value) => {
|
||||
progress.value = value
|
||||
},
|
||||
() => active && props.recordId === recordId
|
||||
)
|
||||
} catch (error) {
|
||||
if (active && props.recordId === recordId)
|
||||
ElMessage.error(userMessage(error, 'STL 下载失败,请重试'))
|
||||
} finally {
|
||||
if (active) loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.stl-download {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stl-progress {
|
||||
min-width: 220px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
86
am-web/src/views/lab/inspection/datumSelection.ts
Normal file
86
am-web/src/views/lab/inspection/datumSelection.ts
Normal file
@ -0,0 +1,86 @@
|
||||
// Shared by template editing and task editing; eligibility comes from the engine.
|
||||
export function datumCandidates(features: any[], types: Record<string, any>) {
|
||||
return features.filter((f) => types[f.type]?.datum_allowed === true)
|
||||
}
|
||||
|
||||
export function nextDatumLabel(features: any[]) {
|
||||
const used = new Set(features.map((f) => f.datum_label).filter(Boolean))
|
||||
for (let index = 1; index <= 18278; index++) {
|
||||
let value = index,
|
||||
label = ''
|
||||
while (value > 0) {
|
||||
value--
|
||||
label = String.fromCharCode(65 + (value % 26)) + label
|
||||
value = Math.floor(value / 26)
|
||||
}
|
||||
if (!used.has(label)) return label
|
||||
}
|
||||
throw Error('基准标签已用完,请检查特征定义')
|
||||
}
|
||||
|
||||
export function validateDatumFrames(features: any[], frames: any[], types: Record<string, any>) {
|
||||
const labels = new Set<string>()
|
||||
for (const f of features)
|
||||
if (f.datum_label) {
|
||||
if (
|
||||
!types[f.type]?.datum_allowed ||
|
||||
!/^[A-Z]{1,3}$/.test(f.datum_label) ||
|
||||
labels.has(f.datum_label)
|
||||
)
|
||||
throw Error('基准标签需唯一且对应有效几何特征')
|
||||
labels.add(f.datum_label)
|
||||
}
|
||||
for (const frame of frames) {
|
||||
if (
|
||||
!frame.name?.trim() ||
|
||||
!Array.isArray(frame.precedence) ||
|
||||
frame.precedence.length < 1 ||
|
||||
frame.precedence.length > 3 ||
|
||||
frame.precedence.some((g: any) => !Array.isArray(g) || !g.length)
|
||||
)
|
||||
throw Error('基准体系名称和主基准不能为空,并按优先级连续配置')
|
||||
const ids = frame.precedence.flat()
|
||||
if (
|
||||
new Set(ids).size !== ids.length ||
|
||||
ids.some((id: string) => !features.find((f) => f.id === id)?.datum_label)
|
||||
)
|
||||
throw Error('基准体系包含重复或失效引用')
|
||||
}
|
||||
}
|
||||
|
||||
export function selectDatumFeatures(
|
||||
features: any[],
|
||||
frames: any[],
|
||||
frameId: string,
|
||||
index: number,
|
||||
ids: string[],
|
||||
types: Record<string, any>
|
||||
) {
|
||||
if (!Number.isInteger(index) || index < 0 || index > 2) throw Error('基准优先级无效')
|
||||
const frame = frames.find((f) => f.id === frameId)
|
||||
if (!frame) throw Error('基准体系已变化,请重新加载')
|
||||
const allowed = new Set(datumCandidates(features, types).map((f) => f.id))
|
||||
if (new Set(ids).size !== ids.length || ids.some((id) => !allowed.has(id)))
|
||||
throw Error('请选择可作为基准的有效几何特征')
|
||||
const groups = frame.precedence.map((g: string[]) => [...g])
|
||||
while (groups.length <= index) groups.push([])
|
||||
groups[index] = [...ids]
|
||||
while (groups.length > 1 && !groups.at(-1).length) groups.pop()
|
||||
if (groups.slice(0, -1).some((g) => g.length === 0))
|
||||
throw Error('请按主、次、第三基准顺序配置;清空前一级前先清空后续基准')
|
||||
const all = groups.flat()
|
||||
if (new Set(all).size !== all.length) throw Error('同一特征不能重复用于不同基准优先级')
|
||||
const labels: Record<string, string> = {},
|
||||
pool = features.map((f) => ({ ...f }))
|
||||
for (const id of ids) {
|
||||
const feature = pool.find((f) => f.id === id)
|
||||
if (!feature.datum_label) {
|
||||
feature.datum_label = nextDatumLabel(pool)
|
||||
labels[id] = feature.datum_label
|
||||
}
|
||||
}
|
||||
return {
|
||||
labels,
|
||||
frames: frames.map((f) => (f.id === frameId ? { ...f, precedence: groups } : f))
|
||||
}
|
||||
}
|
||||
@ -20,3 +20,5 @@ export const inputName = (row: any, role: string) => {
|
||||
}
|
||||
}
|
||||
export const fileSize = (n: number) => (n ? `${(n / 1024 / 1024).toFixed(2)} MB` : '—')
|
||||
|
||||
export { userMessage, methodLabel, drawingIssue } from '@/utils/inspectionPresentation'
|
||||
|
||||
206
am-web/src/views/lab/inspection/featurePresentation.ts
Normal file
206
am-web/src/views/lab/inspection/featurePresentation.ts
Normal file
@ -0,0 +1,206 @@
|
||||
const derivedFields = new Set([
|
||||
'measurement_state',
|
||||
'assessment_state',
|
||||
'reason_code',
|
||||
'next_action',
|
||||
'workflow_note',
|
||||
'workflow_warnings',
|
||||
'extraction_audit',
|
||||
'measured',
|
||||
'evaluation',
|
||||
'evaluation_state',
|
||||
'result',
|
||||
'result_snapshot',
|
||||
'diagnostic',
|
||||
'status',
|
||||
'patch_mesh',
|
||||
'support_points',
|
||||
'preview_points',
|
||||
'scan_region',
|
||||
'scan_region_diagnostic'
|
||||
])
|
||||
export function toleranceLabel(t: any): string {
|
||||
if (!t) return '—'
|
||||
if (t.mode === 'limits')
|
||||
return t.lower != null && t.upper != null
|
||||
? `${t.lower}~${t.upper}`
|
||||
: t.lower != null
|
||||
? `≥${t.lower}`
|
||||
: `≤${t.upper}`
|
||||
if (t.mode === 'upper') return `≤${t.upper}`
|
||||
const signed = (x: number) => (x === 0 ? '0' : x > 0 ? `+${x}` : `${x}`)
|
||||
return `${signed(t.upper)}/${signed(t.lower)}`
|
||||
}
|
||||
// Editable metadata defines dirtiness; multi-megabyte immutable geometry is not a form field.
|
||||
export function definitionSignature(doc: any): string {
|
||||
return JSON.stringify(doc, (key, value) => (derivedFields.has(key) ? undefined : value))
|
||||
}
|
||||
export function definitionForExport(doc: any): any {
|
||||
const outputs = new Set([
|
||||
'extraction_audit',
|
||||
'measured',
|
||||
'result',
|
||||
'evaluation',
|
||||
'evaluation_state',
|
||||
'result_snapshot',
|
||||
'scan_region',
|
||||
'scan_region_diagnostic'
|
||||
])
|
||||
const copy = JSON.parse(
|
||||
JSON.stringify(doc, (key, value) => (outputs.has(key) ? undefined : value))
|
||||
)
|
||||
invalidateFeatureResults(copy)
|
||||
return copy
|
||||
}
|
||||
export function invalidateFeatureResults(doc: any): void {
|
||||
for (const feature of doc.features) {
|
||||
delete feature.extraction_audit
|
||||
delete feature.measured
|
||||
delete feature.status
|
||||
delete feature.diagnostic
|
||||
delete feature.scan_region
|
||||
delete feature.scan_region_diagnostic
|
||||
}
|
||||
for (const control of doc.controls) {
|
||||
delete control.result
|
||||
for (const key of [
|
||||
'measurement_state',
|
||||
'assessment_state',
|
||||
'reason_code',
|
||||
'next_action',
|
||||
'workflow_note',
|
||||
'workflow_warnings'
|
||||
])
|
||||
delete control[key]
|
||||
}
|
||||
delete doc.result_snapshot
|
||||
delete doc.evaluation_state
|
||||
delete doc.evaluation
|
||||
}
|
||||
export function useFeatureResults(graph: any): boolean {
|
||||
if (graph.evaluation_state === 'stale')
|
||||
return (
|
||||
graph.controls.length > 0 &&
|
||||
(graph.report_scope === 'feature_plan' ||
|
||||
!!graph.template_selection ||
|
||||
graph.controls.some((c: any) => c.required))
|
||||
)
|
||||
if (!graph.evaluation) return false
|
||||
if (graph.report_scope === 'feature_plan' && graph.controls.length) return true
|
||||
if (graph.controls.some((c: any) => c.result?.value != null)) return true
|
||||
if (graph.legacy_migration) return false
|
||||
return (
|
||||
!!graph.template_selection ||
|
||||
graph.controls.some(
|
||||
(c: any) => c.required || !['cad_geometry', 'drawing_recommendation'].includes(c.origin)
|
||||
)
|
||||
)
|
||||
}
|
||||
export function combinedResultRows(plan: any[], features: any[]): any[] {
|
||||
return [
|
||||
...plan.map((row, plan_index) => ({
|
||||
...row,
|
||||
plan_index,
|
||||
...(row.measured_mm == null && row.trial_measured_mm != null
|
||||
? {
|
||||
measured_mm: row.trial_measured_mm,
|
||||
error_mm: row.nominal_mm == null ? null : row.trial_measured_mm - row.nominal_mm,
|
||||
inspection_result: '待判定'
|
||||
}
|
||||
: {}),
|
||||
result_source: '检测计划'
|
||||
})),
|
||||
...features.map((row) => ({ ...row, result_source: 'CAD 特征' }))
|
||||
]
|
||||
}
|
||||
export type ResultLoadState = 'idle' | 'loading' | 'ready' | 'error'
|
||||
export function snapshotResultRows(
|
||||
plan: any[],
|
||||
features: any[],
|
||||
primary: boolean,
|
||||
state: ResultLoadState
|
||||
): any[] {
|
||||
return state === 'ready' ? combinedResultRows(primary ? [] : plan, features) : []
|
||||
}
|
||||
export function featureDisplayControls(graph: any, hasPlan: boolean): any[] {
|
||||
if (!useFeatureResults(graph)) return []
|
||||
const controls =
|
||||
!hasPlan || graph.template_selection
|
||||
? graph.controls
|
||||
: graph.controls.filter(
|
||||
(c: any) =>
|
||||
c.required ||
|
||||
!['cad_geometry', 'drawing_recommendation'].includes(c.origin) ||
|
||||
c.result?.value != null
|
||||
)
|
||||
return graph.evaluation_state === 'stale'
|
||||
? controls.map((c: any) => ({
|
||||
...c,
|
||||
result: { status: 'stale' },
|
||||
measurement_state: 'pending',
|
||||
assessment_state: 'pending',
|
||||
reason_code: 'result_stale',
|
||||
next_action: 'recalculate',
|
||||
workflow_note: '检测条件已更新,请重新计算;历史报告仍可查看。'
|
||||
}))
|
||||
: controls
|
||||
}
|
||||
|
||||
export function resultNote(
|
||||
row: any,
|
||||
sanitize: (value: any, fallback?: string) => string = (
|
||||
_value,
|
||||
fallback = '请核对测量位置与提取参数'
|
||||
) => fallback
|
||||
): string {
|
||||
const diagnostic = row.workflow_note || row.diagnostic || row.measurement_reason || ''
|
||||
if (
|
||||
row.reason_code === 'nominal_mismatch' ||
|
||||
/与计划名义.*不一致|CAD 尺寸.*不一致/.test(diagnostic)
|
||||
)
|
||||
return 'CAD 尺寸与计划不一致,请核对位置或模型版本'
|
||||
if (
|
||||
row.measurement_state === 'computed_unverified' ||
|
||||
(row.trial_measured_mm != null &&
|
||||
row.measurement_status !== '自动测量' &&
|
||||
/门槛|候选试测/.test(diagnostic))
|
||||
)
|
||||
return '拟合质量未通过,请核对扫描覆盖与提取范围'
|
||||
const labels: any = {
|
||||
result_stale: '检测条件已更新,请重新计算;历史报告仍可查看。',
|
||||
binding_required: '请选择测量位置',
|
||||
ambiguous_binding: '存在多个匹配位置,请选择对应要素',
|
||||
no_points_in_region: '当前选区未提取到扫描点,请先核对位置与对齐',
|
||||
insufficient_support: '当前选区支持点不足,请核对提取范围与局部扫描',
|
||||
insufficient_coverage: '当前特征覆盖不足,请核对选区与扫描覆盖',
|
||||
reference_extraction_failed: row.workflow_note || '参考要素提取失败,请核对对应测量位置',
|
||||
insufficient_scan: '当前特征支持不足,请核对选区与局部扫描',
|
||||
datum_required: '请设置基准或检查基准扫描数据',
|
||||
unsupported: '当前测量方式不支持此项配置',
|
||||
cad_unavailable: '设计模型读取失败,请检查模型文件',
|
||||
alignment_check: '请核对单位与对齐结果',
|
||||
tolerance_unset: '未配置公差,保留测量值',
|
||||
capability_unverified: '已有测量值,判定依据待完善'
|
||||
}
|
||||
if (labels[row.reason_code]) return labels[row.reason_code]
|
||||
if (row.measured_mm == null) {
|
||||
if (diagnostic) return sanitize(diagnostic, '请核对测量位置与提取参数')
|
||||
return '请选择测量位置并计算'
|
||||
}
|
||||
if (!row.tol_text && !row.tolerance) return labels.tolerance_unset
|
||||
if (row.status === 'capability_unverified') return labels.capability_unverified
|
||||
return ''
|
||||
}
|
||||
export function resultAction(row: any): string {
|
||||
const labels: Record<string, string> = {
|
||||
recalculate: '重新计算',
|
||||
tolerance: '设置公差',
|
||||
datum: '设置基准',
|
||||
capability: '完善判定依据',
|
||||
scan: '检查扫描',
|
||||
parameters: '调整参数',
|
||||
model: '检查模型',
|
||||
alignment: '检查对齐'
|
||||
}
|
||||
return labels[row.next_action] || (row.measured_mm == null ? '选择测量位置' : '定位复核')
|
||||
}
|
||||
@ -63,3 +63,34 @@ export function nearestPoint(hits: ScreenPoint[], x: number, y: number, radius =
|
||||
}
|
||||
return nearest
|
||||
}
|
||||
|
||||
export function selectedCadFaces(features: any[], selected: string[]): any[] {
|
||||
const ids = new Set(selected)
|
||||
return features.filter(
|
||||
(f) =>
|
||||
ids.has(f.id) || (!f.nominal_feature_group && f.source?.face_ids?.some((id) => ids.has(id)))
|
||||
)
|
||||
}
|
||||
|
||||
export function mergedAxialRange(
|
||||
features: any[],
|
||||
center: number[],
|
||||
axis: number[]
|
||||
): [number, number] {
|
||||
const length = Math.hypot(...axis)
|
||||
if (!length || !xyz(center)) throw new Error('请核对合并特征的轴线')
|
||||
const n = axis.map((v) => v / length)
|
||||
const values = features.flatMap((f) => {
|
||||
const g = f.nominal,
|
||||
length = Math.hypot(...(g.axis || []))
|
||||
if (!xyz(g.center) || !length || g.axial_range?.length !== 2)
|
||||
throw new Error('所选曲面缺少有效轴向范围')
|
||||
return g.axial_range.map((z: number) =>
|
||||
n.reduce(
|
||||
(total, value, i) => total + (g.center[i] + (z * g.axis[i]) / length - center[i]) * value,
|
||||
0
|
||||
)
|
||||
)
|
||||
})
|
||||
return [Math.min(...values), Math.max(...values)]
|
||||
}
|
||||
|
||||
223
am-web/src/views/lab/inspection/measurementOptions.ts
Normal file
223
am-web/src/views/lab/inspection/measurementOptions.ts
Normal file
@ -0,0 +1,223 @@
|
||||
/** Validate user-supplied measurement definitions without inventing physical defaults. */
|
||||
export function measurementParameterError(
|
||||
kind: string,
|
||||
featureType: string | undefined,
|
||||
p: any
|
||||
): string {
|
||||
const finite = (v: any) => typeof v === 'number' && Number.isFinite(v)
|
||||
if (
|
||||
['distance', 'length', 'thickness', 'hole_distance', 'chamfer'].includes(kind) &&
|
||||
p.mode &&
|
||||
![
|
||||
'center',
|
||||
'3d_center',
|
||||
'projected',
|
||||
'plane_distance',
|
||||
'point_plane',
|
||||
'axis_distance',
|
||||
'surface_minimum'
|
||||
].includes(p.mode)
|
||||
)
|
||||
return '请选择有效的测量方式'
|
||||
if (
|
||||
kind === 'angle' &&
|
||||
p.angle_mode &&
|
||||
!['acute', 'directed', 'supplementary'].includes(p.angle_mode)
|
||||
)
|
||||
return '请选择角度定义'
|
||||
if (['circular_runout', 'total_runout'].includes(kind)) {
|
||||
if (p.runout_direction && !['axial', 'radial'].includes(p.runout_direction))
|
||||
return '请选择跳动方向'
|
||||
if (
|
||||
p.min_coverage_deg != null &&
|
||||
(!finite(p.min_coverage_deg) || p.min_coverage_deg <= 0 || p.min_coverage_deg > 360)
|
||||
)
|
||||
return '圆周覆盖应大于 0° 且不超过 360°'
|
||||
if (
|
||||
kind === 'circular_runout' &&
|
||||
p.runout_direction === 'axial' &&
|
||||
(!finite(p.max_ring_width_mm) || p.max_ring_width_mm <= 0)
|
||||
)
|
||||
return '请设置实际圆环带宽'
|
||||
}
|
||||
if (kind === 'fitting_diameter' && !['internal', 'external'].includes(p.material_side))
|
||||
return '请选择内孔或外圆'
|
||||
if (['parallelism', 'perpendicularity', 'angularity'].includes(kind) && featureType !== 'plane') {
|
||||
if (!finite(p.evaluation_length_mm) || p.evaluation_length_mm <= 0)
|
||||
return '请填写大于零的轴线评价长度'
|
||||
if (!['cylindrical', 'parallel_planes'].includes(p.zone)) return '请选择公差带形状'
|
||||
}
|
||||
if (kind === 'angularity' && (!finite(p.angle_deg) || p.angle_deg < 0 || p.angle_deg > 180))
|
||||
return '请填写 0–180° 的理论角度'
|
||||
if (kind === 'arc_length' && (!finite(p.sweep_deg) || p.sweep_deg <= 0 || p.sweep_deg > 360))
|
||||
return '请填写大于 0° 且不超过 360° 的弧段角度'
|
||||
if (p.direction_feature_id) {
|
||||
if (p.direction != null) return '请选择参考特征或指定向量之一'
|
||||
if (p.direction_source && !['nominal', 'measured'].includes(p.direction_source))
|
||||
return '请选择设计或实测参考方向'
|
||||
} else if (
|
||||
p.direction != null ||
|
||||
['chamfer', 'extent'].includes(kind) ||
|
||||
p.mode === 'projected'
|
||||
) {
|
||||
if (
|
||||
!Array.isArray(p.direction) ||
|
||||
p.direction.length !== 3 ||
|
||||
!p.direction.every(finite) ||
|
||||
Math.hypot(...p.direction) === 0
|
||||
)
|
||||
return '请填写完整且非零的测量方向'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
/** CAD values are for nominal definitions only; never called to fill scan results. */
|
||||
export function nominalFromGeometry(
|
||||
c: any,
|
||||
f: any,
|
||||
other?: any,
|
||||
features: any[] = []
|
||||
): number | null {
|
||||
const a = f?.nominal,
|
||||
b = other?.nominal
|
||||
let p = c.parameters || {}
|
||||
const dot = (x: number[], y: number[]) => x.reduce((s, n, i) => s + n * y[i], 0)
|
||||
const unit = (x: number[]) => {
|
||||
const length = Math.hypot(...x)
|
||||
if (!length) throw Error('zero direction')
|
||||
return x.map((v) => v / length)
|
||||
}
|
||||
try {
|
||||
if (p.direction_feature_id) {
|
||||
const ref =
|
||||
features.find((v) => v.id === p.direction_feature_id) ||
|
||||
(f?.id === p.direction_feature_id ? f : undefined)
|
||||
if (!ref?.nominal?.axis) return null
|
||||
p = { ...p, direction: ref.nominal.axis }
|
||||
}
|
||||
if (['diameter', 'fitting_diameter'].includes(c.kind)) return 2 * a.radius
|
||||
if (['radius', 'fillet_radius'].includes(c.kind)) return a.radius
|
||||
if (c.kind === 'taper') return (2 * a.semi_angle * 180) / Math.PI
|
||||
if (c.kind === 'arc_length' && p.sweep_deg) return (a.radius * p.sweep_deg * Math.PI) / 180
|
||||
if (c.kind === 'extent' && p.direction) {
|
||||
const direction = unit(p.direction),
|
||||
points = a.patch_mesh?.vertices || a.support_points
|
||||
if (points?.length) {
|
||||
const values = points.map((v: number[]) => dot(v, direction))
|
||||
let lo = Infinity,
|
||||
hi = -Infinity
|
||||
for (const v of values) {
|
||||
lo = Math.min(lo, v)
|
||||
hi = Math.max(hi, v)
|
||||
}
|
||||
return hi - lo
|
||||
}
|
||||
if (a.bounds && direction.filter((v: number) => Math.abs(v) > 1e-8).length === 1)
|
||||
return Math.abs(
|
||||
dot(
|
||||
a.bounds[1].map((v: number, i: number) => v - a.bounds[0][i]),
|
||||
direction
|
||||
)
|
||||
)
|
||||
return null
|
||||
}
|
||||
if (!b) return null
|
||||
const d = a.center.map((n: number, i: number) => n - b.center[i])
|
||||
if (c.kind === 'angle') {
|
||||
const cosine = dot(unit(a.axis), unit(b.axis)),
|
||||
angle =
|
||||
(Math.acos(
|
||||
Math.max(-1, Math.min(1, p.angle_mode === 'directed' ? cosine : Math.abs(cosine)))
|
||||
) *
|
||||
180) /
|
||||
Math.PI
|
||||
return p.angle_mode === 'supplementary' ? 180 - angle : angle
|
||||
}
|
||||
const mode =
|
||||
p.mode ||
|
||||
(c.kind === 'thickness'
|
||||
? 'plane_distance'
|
||||
: p.direction
|
||||
? 'projected'
|
||||
: c.kind === 'hole_distance'
|
||||
? 'axis_distance'
|
||||
: 'center')
|
||||
if (mode === 'surface_minimum') return null
|
||||
if (mode === 'projected') {
|
||||
const v = dot(d, unit(p.direction))
|
||||
return p.signed ? v : Math.abs(v)
|
||||
}
|
||||
if (mode === 'plane_distance') {
|
||||
if (f.type !== 'plane' || other.type !== 'plane') return null
|
||||
const axis = unit(p.direction || a.axis),
|
||||
na = unit(a.axis),
|
||||
nb = unit(b.axis)
|
||||
if (Math.abs(dot(na, nb)) < 0.99 || Math.abs(dot(nb, axis)) < 1e-6) return null
|
||||
return Math.abs(dot(d, nb) / dot(nb, axis))
|
||||
}
|
||||
if (mode === 'point_plane') {
|
||||
const plane = f.type === 'plane' ? a : b,
|
||||
point = f.type === 'plane' ? b : a
|
||||
return Math.abs(
|
||||
dot(
|
||||
point.center.map((v: number, i: number) => v - plane.center[i]),
|
||||
unit(plane.axis)
|
||||
)
|
||||
)
|
||||
}
|
||||
if (mode === 'axis_distance') {
|
||||
const n = unit(a.axis),
|
||||
m = unit(b.axis),
|
||||
cross = [n[1] * m[2] - n[2] * m[1], n[2] * m[0] - n[0] * m[2], n[0] * m[1] - n[1] * m[0]]
|
||||
if (Math.hypot(...cross) > 1e-6)
|
||||
return c.kind === 'hole_distance' ? null : Math.abs(dot(d, unit(cross)))
|
||||
const z = dot(d, n)
|
||||
return Math.sqrt(Math.max(0, dot(d, d) - z * z))
|
||||
}
|
||||
return Math.hypot(...d)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function toleranceError(t: any, size: boolean, nominal: any): string {
|
||||
if (!t) return ''
|
||||
if (t.mode === 'limits') {
|
||||
const values = [t.lower, t.upper].filter((v) => v != null)
|
||||
return !size ||
|
||||
!values.length ||
|
||||
values.some((v) => !Number.isFinite(v)) ||
|
||||
(t.lower != null && t.upper != null && t.lower > t.upper)
|
||||
? '请填写有效的尺寸上限或下限'
|
||||
: ''
|
||||
}
|
||||
if (
|
||||
!Number.isFinite(t.upper) ||
|
||||
!Number.isFinite(t.lower) ||
|
||||
t.upper < t.lower ||
|
||||
(!size && (t.upper < 0 || t.lower !== 0))
|
||||
)
|
||||
return '公差上下限无效'
|
||||
return size && !Number.isFinite(nominal) ? '有尺寸偏差时需填写名义值' : ''
|
||||
}
|
||||
export function setToleranceBound(c: any, key: string, value: any, size: boolean): void {
|
||||
if (value == null) {
|
||||
if (c.tolerance?.mode === 'limits') {
|
||||
delete c.tolerance[key]
|
||||
if (c.tolerance.lower == null && c.tolerance.upper == null) c.tolerance = null
|
||||
} else c.tolerance = null
|
||||
return
|
||||
}
|
||||
c.tolerance ||= { mode: size ? 'bilateral' : 'upper', upper: 0, lower: 0 }
|
||||
c.tolerance[key] = value
|
||||
}
|
||||
export function setToleranceMode(c: any, mode: string): void {
|
||||
const old = c.tolerance
|
||||
if (old?.mode === mode) return
|
||||
const offset = Number.isFinite(c.nominal) ? (mode === 'limits' ? c.nominal : -c.nominal) : null
|
||||
c.tolerance = {
|
||||
mode,
|
||||
lower: old?.lower != null && offset != null ? old.lower + offset : null,
|
||||
upper: old?.upper != null && offset != null ? old.upper + offset : null
|
||||
}
|
||||
}
|
||||
43
am-web/src/views/lab/inspection/stlDownload.ts
Normal file
43
am-web/src/views/lab/inspection/stlDownload.ts
Normal file
@ -0,0 +1,43 @@
|
||||
export async function downloadProcessedStl(
|
||||
api: {
|
||||
state: () => Promise<any>
|
||||
start: (revision: number) => Promise<any>
|
||||
file: () => Promise<Blob>
|
||||
save: (file: Blob) => void
|
||||
},
|
||||
onProgress: (value: any) => void,
|
||||
active: () => boolean = () => true,
|
||||
wait: () => Promise<void> = () => new Promise((resolve) => setTimeout(resolve, 1500)),
|
||||
now: () => number = Date.now
|
||||
): Promise<boolean> {
|
||||
const started = now()
|
||||
let state = await api.state()
|
||||
if (!active()) return false
|
||||
let progress = state.stl_export || {}
|
||||
if (!['processing', 'done'].includes(progress.status))
|
||||
progress = (await api.start(state.revision)).stl_export || {}
|
||||
while (active()) {
|
||||
onProgress(progress)
|
||||
if (progress.status === 'done') {
|
||||
const file = await api.file()
|
||||
const header = await file.slice(0, 84).arrayBuffer()
|
||||
if (
|
||||
header.byteLength !== 84 ||
|
||||
new DataView(header).getUint32(80, true) < 1 ||
|
||||
file.size !== 84 + 50 * new DataView(header).getUint32(80, true)
|
||||
)
|
||||
throw Error('STL 文件无效,请重新生成')
|
||||
if (!active()) return false
|
||||
api.save(file)
|
||||
return true
|
||||
}
|
||||
if (progress.status === 'error' || progress.status === 'stale')
|
||||
throw Error(progress.message || 'STL 生成失败,请重新生成')
|
||||
if (now() - started > 660000) throw Error('STL 生成时间较长,请稍后重新下载')
|
||||
await wait()
|
||||
if (!active()) return false
|
||||
state = await api.state()
|
||||
progress = state.stl_export || {}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -1,527 +1,33 @@
|
||||
<template>
|
||||
<main class="inspect-page">
|
||||
<header class="inspect-header"
|
||||
><div class="inspect-kicker">检测计划模板</div
|
||||
><div class="inspect-title-line"
|
||||
><div
|
||||
><h1>检测计划模板</h1
|
||||
><p>维护模板名称、检测项与公差,统一新建检测和计划调整的检测依据。</p></div
|
||||
><el-button @click="$router.back()">返回任务</el-button><el-button type="primary" v-hasPermi="['lab:result:confirm']" @click="edit()"
|
||||
><Icon icon="ep:plus" class="mr-6px" />新建模板</el-button
|
||||
></div
|
||||
></header
|
||||
>
|
||||
<el-alert v-if="error" :title="error" type="error" show-icon @close="error = ''" />
|
||||
<section class="inspect-panel inspect-search"
|
||||
><el-input
|
||||
v-model="query.name"
|
||||
placeholder="搜索模板名称"
|
||||
clearable
|
||||
style="width: 280px"
|
||||
@keyup.enter="search"
|
||||
><template #prefix><Icon icon="ep:search" /></template></el-input
|
||||
><el-select v-model="query.enabled" clearable placeholder="全部状态" style="width: 150px"
|
||||
><el-option label="已启用" value="true" /><el-option
|
||||
label="已停用"
|
||||
value="false" /></el-select
|
||||
><el-button type="primary" plain @click="search">查询</el-button
|
||||
><el-button @click="reset">重置</el-button
|
||||
><span class="inspect-sub ml-auto">共 {{ total }} 个模板</span></section
|
||||
>
|
||||
<section class="inspect-panel"
|
||||
><el-table :data="list" v-loading="loading"
|
||||
><el-table-column label="模板名称" min-width="270"
|
||||
><template #default="s"
|
||||
><div class="inspect-table-title"
|
||||
><span class="inspect-table-icon"><Icon icon="ep:document-copy" :size="20" /></span
|
||||
><div
|
||||
><strong>{{ s.row.name }}</strong
|
||||
><div class="inspect-sub">{{ s.row.description || '—' }}</div></div
|
||||
></div
|
||||
></template
|
||||
></el-table-column
|
||||
><el-table-column
|
||||
prop="partNumbers"
|
||||
label="自动匹配零件号"
|
||||
min-width="200"
|
||||
show-overflow-tooltip
|
||||
/><el-table-column prop="rowCount" label="检测项" width="90" /><el-table-column
|
||||
label="版本"
|
||||
width="85"
|
||||
><template #default="s">V{{ s.row.revision }}</template></el-table-column
|
||||
><el-table-column label="状态" width="100"
|
||||
><template #default="s"
|
||||
><el-tag :type="s.row.enabled ? 'success' : 'info'">{{
|
||||
s.row.enabled ? '已启用' : '已停用'
|
||||
}}</el-tag></template
|
||||
></el-table-column
|
||||
><el-table-column label="更新时间" width="175"
|
||||
><template #default="s">{{ dateText(s.row.updateTime) }}</template></el-table-column
|
||||
><el-table-column label="操作" fixed="right" width="240"
|
||||
><template #default="s"
|
||||
><el-button link type="primary" @click="edit(s.row)">{{
|
||||
writable ? '编辑字段' : '查看'
|
||||
}}</el-button
|
||||
><el-button link v-hasPermi="['lab:result:confirm']" @click="edit(s.row, true)"
|
||||
>复制</el-button
|
||||
><el-button link @click="exportTemplate(s.row)">导出</el-button
|
||||
><el-button
|
||||
link
|
||||
type="danger"
|
||||
<el-tabs v-model="active" class="inspection-template-tabs">
|
||||
<el-tab-pane label="CAD 特征计划(基准 / 形位公差)" name="features" lazy>
|
||||
<main class="inspect-page">
|
||||
<header class="inspect-header"
|
||||
><div class="inspect-title-line">
|
||||
<div
|
||||
><h1>CAD 特征计划</h1
|
||||
><p>维护特征、公差与基准体系;选用到新任务后按实际数模重新匹配。</p></div
|
||||
>
|
||||
<el-button @click="$router.back()">返回任务</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['lab:result:confirm']"
|
||||
@click="remove(s.row)"
|
||||
>删除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
><template #empty
|
||||
><el-empty description="暂无检测计划模板"
|
||||
><el-button type="primary" v-hasPermi="['lab:result:confirm']" @click="edit()"
|
||||
>新建模板</el-button
|
||||
></el-empty
|
||||
></template
|
||||
></el-table
|
||||
><Pagination
|
||||
:total="total"
|
||||
v-model:page="query.pageNo"
|
||||
v-model:limit="query.pageSize"
|
||||
@pagination="load"
|
||||
/></section>
|
||||
<el-drawer
|
||||
v-model="drawer"
|
||||
:title="model.id ? '维护检测计划模板' : '新建检测计划模板'"
|
||||
size="min(96vw, 1320px)"
|
||||
:before-close="close"
|
||||
destroy-on-close
|
||||
>
|
||||
<div v-loading="editing"
|
||||
><el-alert
|
||||
v-if="editError"
|
||||
:title="editError"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/><el-alert
|
||||
title="保存后会更新模板版本。已经建立的检测任务继续使用当时的计划;需要更新时可在任务中重新载入模板。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="model"
|
||||
label-position="top"
|
||||
:disabled="saving || !writable"
|
||||
class="template-form"
|
||||
><el-row :gutter="20"
|
||||
><el-col :span="14"
|
||||
><el-form-item
|
||||
label="模板名称"
|
||||
prop="name"
|
||||
:rules="[{ required: true, message: '请输入模板名称', trigger: 'blur' }]"
|
||||
><el-input
|
||||
v-model="model.name"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
placeholder="如:管类零件尺寸检测" /></el-form-item></el-col
|
||||
><el-col :span="6"
|
||||
><el-form-item label="状态"
|
||||
><el-switch
|
||||
v-model="model.enabled"
|
||||
active-text="启用"
|
||||
inactive-text="停用" /></el-form-item></el-col
|
||||
><el-col :span="4"
|
||||
><el-form-item label="当前版本"
|
||||
><el-tag>{{
|
||||
model.id ? 'V' + model.revision : '首次保存 V1'
|
||||
}}</el-tag></el-form-item
|
||||
></el-col
|
||||
></el-row
|
||||
><el-form-item label="自动匹配零件号"
|
||||
><el-input
|
||||
v-model="model.partNumbers"
|
||||
maxlength="500"
|
||||
placeholder="可填写多个完整零件号,以逗号分隔;留空时由操作员手动选择模板" /></el-form-item
|
||||
><el-form-item label="模板说明"
|
||||
><el-input
|
||||
v-model="model.description"
|
||||
maxlength="1000"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="适用零件、图纸版本或检测要求" /></el-form-item
|
||||
></el-form>
|
||||
<div class="template-items-heading"
|
||||
><div
|
||||
><h3
|
||||
>检测项与字段内容 <el-tag size="small">{{ model.rows.length }} 项</el-tag></h3
|
||||
><p>按行维护名称、几何类型、控制项、名义值、公差与备注。尺寸单位为 mm。</p></div
|
||||
><div class="template-tools" v-if="writable"
|
||||
><el-button @click="jsonInput?.click()" :disabled="saving">导入 JSON</el-button
|
||||
><el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="addRow"
|
||||
:disabled="saving || model.rows.length >= 500"
|
||||
><Icon icon="ep:plus" class="mr-4px" />添加检测项</el-button
|
||||
><input ref="jsonInput" type="file" accept=".json" hidden @change="importJson" /></div
|
||||
></div>
|
||||
<el-table :data="model.rows" border max-height="500" class="template-fields"
|
||||
><el-table-column type="index" label="序号" width="60" /><el-table-column
|
||||
label="检测项名称"
|
||||
min-width="180"
|
||||
><template #default="s"
|
||||
><el-input
|
||||
v-model="s.row.name"
|
||||
maxlength="120"
|
||||
:disabled="!writable || saving"
|
||||
placeholder="如:中心孔直径" /></template></el-table-column
|
||||
><el-table-column label="几何类型" width="150"
|
||||
><template #default="s"
|
||||
><el-select
|
||||
v-model="s.row.type"
|
||||
:disabled="!writable || saving"
|
||||
@change="changeType(s.row)"
|
||||
><el-option
|
||||
v-for="o in types"
|
||||
:key="o.value"
|
||||
:value="o.value"
|
||||
:label="o.label" /></el-select></template></el-table-column
|
||||
><el-table-column label="控制项" width="125"
|
||||
><template #default="s"
|
||||
><el-select
|
||||
v-model="s.row.control"
|
||||
filterable
|
||||
allow-create
|
||||
default-first-option
|
||||
:disabled="!writable || saving"
|
||||
><el-option
|
||||
v-for="v in ['直径', '长度', '孔距', '面距', '点间距', '平面度', '圆柱度']"
|
||||
:key="v"
|
||||
:value="v"
|
||||
:label="v" /></el-select></template></el-table-column
|
||||
><el-table-column label="名义 / mm" width="155"
|
||||
><template #default="s"
|
||||
><el-input-number
|
||||
v-model="s.row.nominal_mm"
|
||||
:min="0"
|
||||
:max="10000000"
|
||||
:precision="4"
|
||||
:controls="false"
|
||||
:disabled="!writable || saving"
|
||||
style="width: 100%" /></template></el-table-column
|
||||
><el-table-column label="公差" width="135"
|
||||
><template #default="s"
|
||||
><el-input
|
||||
v-model="s.row.tol_text"
|
||||
:disabled="!writable || saving"
|
||||
placeholder="±0.1 / +0.1/0" /></template></el-table-column
|
||||
><el-table-column label="备注" min-width="180"
|
||||
><template #default="s"
|
||||
><el-input
|
||||
v-model="s.row.notes"
|
||||
:disabled="!writable || saving"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 1, maxRows: 3 }"
|
||||
maxlength="1000"
|
||||
placeholder="测量位置、图纸标注等" /></template></el-table-column
|
||||
><el-table-column v-if="writable" label="操作" width="160" fixed="right"
|
||||
><template #default="s"
|
||||
><el-button link :disabled="saving || s.$index === 0" @click="moveRow(s.$index, -1)"
|
||||
>上移</el-button
|
||||
><el-button
|
||||
link
|
||||
:disabled="saving || s.$index === model.rows.length - 1"
|
||||
@click="moveRow(s.$index, 1)"
|
||||
>下移</el-button
|
||||
><el-button
|
||||
link
|
||||
type="danger"
|
||||
:disabled="saving"
|
||||
@click="model.rows.splice(s.$index, 1)"
|
||||
>移除</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
><template #empty><el-empty description="点击添加检测项,开始定义模板字段" /></template
|
||||
></el-table>
|
||||
<p class="inspect-sub mt-12px"
|
||||
>公差可留空;支持
|
||||
±0.1、+0.025/0、+1/-0.5。未设置公差的检测项保留测量值,显示“未设公差”。</p
|
||||
></div
|
||||
>
|
||||
<template #footer
|
||||
><div class="template-footer"
|
||||
><span class="inspect-sub">{{ dirty ? '有修改待保存' : '模板内容已同步' }}</span
|
||||
><el-button :disabled="saving" @click="close(() => (drawer = false))">关闭</el-button
|
||||
><el-button
|
||||
v-if="writable"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="editing"
|
||||
@click="save"
|
||||
>保存模板</el-button
|
||||
></div
|
||||
></template
|
||||
>
|
||||
</el-drawer>
|
||||
</main>
|
||||
@click="featureManager?.create()"
|
||||
>新建特征计划</el-button
|
||||
>
|
||||
</div></header
|
||||
>
|
||||
<FeatureTemplateManager ref="featureManager" />
|
||||
</main>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="原有检测计划" name="legacy" lazy><LegacyInspectionTemplates /></el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as Api from '@/api/lab/inspection'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { dateText } from './display'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
import FeatureTemplateManager from './FeatureTemplateManager.vue'
|
||||
import LegacyInspectionTemplates from './LegacyInspectionTemplates.vue'
|
||||
import './inspection.scss'
|
||||
defineOptions({ name: 'LabInspectionTemplates' })
|
||||
const writable = computed(() => checkPermi(['lab:result:confirm'])),
|
||||
list = ref<any[]>([]),
|
||||
total = ref(0),
|
||||
loading = ref(false),
|
||||
error = ref(''),
|
||||
drawer = ref(false),
|
||||
editing = ref(false),
|
||||
saving = ref(false),
|
||||
editError = ref(''),
|
||||
form = ref(),
|
||||
jsonInput = ref<HTMLInputElement>(),
|
||||
baseline = ref('')
|
||||
const model = ref<any>({ name: '', description: '', partNumbers: '', enabled: true, rows: [] }),
|
||||
dirty = computed(() => JSON.stringify(model.value) !== baseline.value),
|
||||
query = reactive({ name: '', enabled: '', pageNo: 1, pageSize: 20 })
|
||||
const types = [
|
||||
{ value: 'circle', label: '圆 / 孔 / 管径' },
|
||||
{ value: 'distance', label: '长度 / 距离' },
|
||||
{ value: 'hole_distance', label: '孔心距' },
|
||||
{ value: 'plane_distance', label: '平行面距' },
|
||||
{ value: 'point_distance', label: '扫描点间距' },
|
||||
{ value: 'plane', label: '平面' },
|
||||
{ value: 'cylinder', label: '圆柱' }
|
||||
]
|
||||
let sequence = 0
|
||||
async function load() {
|
||||
const owner = ++sequence
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await Api.templatePage({ ...query })
|
||||
if (owner === sequence) {
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
error.value = ''
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (owner === sequence) error.value = e?.message || '模板查询失败'
|
||||
} finally {
|
||||
if (owner === sequence) loading.value = false
|
||||
}
|
||||
}
|
||||
function search() {
|
||||
query.pageNo = 1
|
||||
void load()
|
||||
}
|
||||
function reset() {
|
||||
query.name = ''
|
||||
query.enabled = ''
|
||||
search()
|
||||
}
|
||||
async function edit(row?: any, copy = false) {
|
||||
editing.value = true
|
||||
editError.value = ''
|
||||
try {
|
||||
const data = row
|
||||
? await Api.templateDetail(row.id)
|
||||
: { name: '', description: '', partNumbers: '', enabled: true, rows: [] }
|
||||
if (copy) {
|
||||
delete data.id
|
||||
delete data.revision
|
||||
delete data.builtinKey
|
||||
data.name = (data.name + ' · 副本').slice(0, 100)
|
||||
data.partNumbers = ''
|
||||
data.enabled = false
|
||||
}
|
||||
model.value = JSON.parse(JSON.stringify(data))
|
||||
baseline.value = JSON.stringify(model.value)
|
||||
drawer.value = true
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '读取模板失败'
|
||||
} finally {
|
||||
editing.value = false
|
||||
}
|
||||
}
|
||||
function addRow() {
|
||||
model.value.rows.push({
|
||||
table: 'feature',
|
||||
type: 'circle',
|
||||
name: '检测项 ' + (model.value.rows.length + 1),
|
||||
control: '直径',
|
||||
nominal_mm: null,
|
||||
tol_text: '',
|
||||
notes: ''
|
||||
})
|
||||
}
|
||||
function changeType(row: any) {
|
||||
const feature = ['circle', 'plane', 'cylinder'].includes(row.type)
|
||||
row.table = feature ? 'feature' : 'gauge'
|
||||
row.control = {
|
||||
circle: '直径',
|
||||
plane: '平面度',
|
||||
cylinder: '圆柱度',
|
||||
distance: '长度',
|
||||
hole_distance: '孔距',
|
||||
plane_distance: '面距',
|
||||
point_distance: '点间距'
|
||||
}[row.type]
|
||||
}
|
||||
function moveRow(index: number, offset: number) {
|
||||
const rows = model.value.rows
|
||||
;[rows[index], rows[index + offset]] = [rows[index + offset], rows[index]]
|
||||
}
|
||||
async function close(done: () => void) {
|
||||
if (saving.value) return
|
||||
if (dirty.value) {
|
||||
try {
|
||||
await ElMessageBox.confirm('当前模板有未保存修改,是否放弃修改并关闭?', '关闭模板', {
|
||||
confirmButtonText: '放弃修改',
|
||||
cancelButtonText: '继续编辑'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
done()
|
||||
}
|
||||
async function save() {
|
||||
if (saving.value) return
|
||||
editError.value = ''
|
||||
try {
|
||||
await form.value.validate()
|
||||
if (!model.value.rows.length) throw new Error('请至少添加一个检测项')
|
||||
for (const [i, row] of model.value.rows.entries()) {
|
||||
if (!row.name?.trim() || row.nominal_mm == null || !Number.isFinite(Number(row.nominal_mm)))
|
||||
throw new Error(`第 ${i + 1} 项:请填写名称和有效名义值`)
|
||||
}
|
||||
saving.value = true
|
||||
model.value = await Api.saveTemplate(model.value)
|
||||
baseline.value = JSON.stringify(model.value)
|
||||
ElMessage.success('模板已保存,版本 V' + model.value.revision)
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
editError.value = e?.message || '请检查模板名称与检测项字段'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
async function remove(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`删除模板「${row.name}」?已有检测任务和报告继续保留。`,
|
||||
'删除模板',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
await Api.removeTemplate(row.id, row.revision)
|
||||
ElMessage.success('模板已删除')
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel' && e !== 'close') error.value = e?.message || '删除失败'
|
||||
}
|
||||
}
|
||||
async function exportTemplate(row: any) {
|
||||
try {
|
||||
const data = await Api.templateDetail(row.id)
|
||||
Api.saveBlob(
|
||||
new Blob(
|
||||
[
|
||||
JSON.stringify(
|
||||
{
|
||||
schema_version: 1,
|
||||
unit: 'mm',
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
partNumbers: data.partNumbers,
|
||||
rows: data.rows
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
],
|
||||
{ type: 'application/json;charset=utf-8' }
|
||||
),
|
||||
data.name + '-V' + data.revision + '.json'
|
||||
)
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '导出失败'
|
||||
}
|
||||
}
|
||||
async function importJson(e: Event) {
|
||||
const input = e.target as HTMLInputElement,
|
||||
file = input.files?.[0]
|
||||
if (!file) return
|
||||
try {
|
||||
if (file.size > 2 * 1024 * 1024) throw new Error('模板 JSON 不得超过 2 MB')
|
||||
const data = JSON.parse(await file.text())
|
||||
const rows = Array.isArray(data) ? data : data.rows
|
||||
if (!Array.isArray(rows) || !rows.length || rows.length > 500)
|
||||
throw new Error('JSON 需包含 1–500 个检测项 rows')
|
||||
if (dirty.value) await ElMessageBox.confirm('导入会替换当前字段内容,是否继续?', '导入模板')
|
||||
model.value.rows = rows
|
||||
if (!model.value.name && data.name) model.value.name = data.name
|
||||
editError.value = ''
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel' && e !== 'close') editError.value = e?.message || 'JSON 模板无效'
|
||||
} finally {
|
||||
input.value = ''
|
||||
}
|
||||
}
|
||||
onMounted(load)
|
||||
const active = ref('features')
|
||||
const featureManager = ref<InstanceType<typeof FeatureTemplateManager>>()
|
||||
</script>
|
||||
<style scoped>
|
||||
.template-form {
|
||||
margin-top: 22px;
|
||||
}
|
||||
.template-items-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin: 12px 0 18px;
|
||||
}
|
||||
.template-items-heading h3 {
|
||||
font-size: 15px;
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.template-items-heading p {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.template-tools {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.template-tools .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
.template-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.template-footer > span {
|
||||
margin-right: auto;
|
||||
}
|
||||
.template-footer .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
.template-fields :deep(.el-table__cell) {
|
||||
padding: 10px 0;
|
||||
}
|
||||
.template-fields :deep(.el-button + .el-button) {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.inspect-table-title strong {
|
||||
font-weight: 500;
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
.template-items-heading {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
66
deploy/windows11/RELEASE-20261118-cad-inspection.md
Normal file
66
deploy/windows11/RELEASE-20261118-cad-inspection.md
Normal file
@ -0,0 +1,66 @@
|
||||
# CAD 特征、基准与处理后 STL
|
||||
|
||||
本次在原有任务尺寸比对工作区中接入同级 ai-scanner 的 CAD 特征检测组件。计算由独立的检测 EXE 完成,平台不自行用前端拟合结果代替检测服务判定。
|
||||
|
||||
## 使用入口
|
||||
|
||||
- 任务的尺寸比对工作区新增“CAD 特征”:在数模选面、预览并应用匹配、调整提取范围、提取点云特征和计算控制项。
|
||||
- 检测项根据 EXE 的能力清单显示尺寸与形位公差类型;不支持、拟合不足、待复核及未验证能力的结果保留原始状态。
|
||||
- 支持设置基准标签、主/次/第三基准优先级及共同基准,控制项可关联基准体系。
|
||||
- “维护检测计划”提供 CAD 特征计划及原有检测计划两个入口。新特征模板保存描述、名义几何、公差与基准关系,应用到其他 CAD 时重新匹配,不复制上次测量结果或有效绑定。
|
||||
- 点云处理及结果页面提供“下载处理后 STL”,显示生成进度,校验文件后下载。它不直接确认交付;交付仍使用现有 STL/PDF 成套归档和确认流程。报告已生成而 STL 尚未就绪时,生成 STL 后可在任务中“重试成果归档”。
|
||||
|
||||
## 检测 EXE 契约
|
||||
|
||||
沿用 `lab.inspection.base-url`,模板默认通过 `INSPECTION_PYTHON_BASE_URL` 指向 `http://127.0.0.1:8769`。实际环境配置和现场私有配置不由此次移植改写。
|
||||
|
||||
新版 EXE 需要提供以下契约;用户另行安装和维护 EXE,`update.ps1` 不负责升级 EXE:
|
||||
|
||||
| 方法与任务路径 | 用途 |
|
||||
| --- | --- |
|
||||
| `GET /api/health` | 返回 `feature_capabilities.types` 和 `feature_capabilities.controls`,用于可用特征、公差及基准资格 |
|
||||
| `GET /api/tasks/{id}/cad-features` | CAD 名义特征、稳定面标识及三角网格 |
|
||||
| `GET/POST /api/tasks/{id}/feature-plan` | 读取或保存 v2 特征定义,包含 revision、mm 单位、features、controls、datum_systems |
|
||||
| `POST .../feature-proposals` | `mode:preview` 仅预览,`mode:apply` 应用匹配 |
|
||||
| `POST .../feature-construct`、`POST .../feature-template` | 构造特征及应用模板 |
|
||||
| `POST .../feature-evaluate` | 提取并评价,返回明确结果或诊断状态 |
|
||||
| `POST .../feature-report` | 发布报告及新的成果版本 |
|
||||
| `POST .../cleanup` | `operation:export_stl`,携带当前 revision |
|
||||
| `GET /api/tasks/{id}` | 原有状态之外,提供 `stl_export.status/progress/message`,导出失效时返回 stale/error |
|
||||
| `GET .../files/cleaned_source.stl` | 当前处理后点云生成的有效二进制 STL |
|
||||
| `GET .../files/feature_results.json` | 与发布报告对应的完整特征结果快照;有 result_snapshot_id 时必须与文档的 result_snapshot.id 一致 |
|
||||
|
||||
创建检测任务时,特征模板通过服务端读取的 `feature_template_id`、`feature_template_snapshot` 传给 EXE;原有计划继续使用 `plan_template_snapshot`。原始文件仍由平台校验归属、版本及校验和后提交。
|
||||
|
||||
未返回能力清单的旧 EXE 仍可使用原有计划;CAD 入口会停用,安装新版后点击工作区“刷新状态”或重新打开。匹配预览和 STL 导出不改变等待新报告的业务状态。编辑后的计算结果与历史发布报告分开,归档时从 EXE 获取发布快照,并在传输后再次核对成果版本。
|
||||
|
||||
生成特征报告后切换到成果页并刷新归档状态,不立即下载旧 PDF。当前成果尚未归档、归档失败或正在等待新版本时,PDF 下载保持停用,后端同样拒绝把上一版交付文件当作本版返回。只读及计算服务离线时禁用编辑控件,仍可查看定义;切换样件或关闭工作区后,延迟响应不会覆盖下一样件或继续发起后续计算。
|
||||
|
||||
## 数据库及获准发布后的升级
|
||||
|
||||
新增幂等、只建表的 `am-backend/sql/freescan/018_inspection_cad_features.sql`:
|
||||
|
||||
- `lab_inspection_feature_plan`:按租户与检测记录保存版本化定义、当前评价结果。
|
||||
- `lab_inspection_feature_template`:按租户保存可复用模板,使用乐观版本校验。
|
||||
|
||||
该迁移已登记到 `scripts/bootstrap_standalone.py` 的批准增量清单,现有 `deploy/windows11/update.ps1` 的 `--upgrade` 阶段自动执行。既有模板、任务、用户、菜单及历史报告不做全量覆盖,不引入 ai-scanner 的业务数据或恢复数据 SQL。前端新增开发依赖 `@types/three@0.181.0`,锁文件已同步,发布仍使用 `pnpm install --frozen-lockfile` 构建。
|
||||
|
||||
本次仅准备代码和升级路径,没有发布授权。之后每次发布仍按 `PRODUCTION-RELEASE.md`:用户当次明确要求发布、现场空闲,正式 AI 通过 `update.ps1` 更新并核对 `deployment.json`;不手工换 JAR,不执行全量迁移或空库初始化。
|
||||
|
||||
## 验证范围
|
||||
|
||||
开发验证使用本机 HTTP 模拟服务与 H2 内存数据库;核验权限与任务归属、模板脱敏和重新匹配、版本冲突、预览/导出状态、报告快照一致性、下载校验、超时及页面卸载处理,并执行现有相关回归及前后端构建。
|
||||
|
||||
后端实验室模块 239 项测试及完整 JAR 打包通过;前端 17 项相关行为测试通过,并执行改动范围的类型检查、ESLint / Stylelint / Prettier 检查和完整 standalone 构建。测试不包含真实 EXE 算法及界面交互验收。
|
||||
|
||||
初次移植验证没有连接现场设备、正式服务或正式数据库。Windows 界面自动化通道返回访问拒绝,浏览器交互验证受限;安装包的后续接口联调结果见下节,真实零件匹配精度及计量能力仍需现场验收。任务新增测试源码、模拟页面、构建输出和临时日志在验证结束后清理。
|
||||
|
||||
## 2026-11-18 安装包接口联调补充
|
||||
|
||||
用户安装 EXE 后,已在开发库 `192.168.28.10/am-freescan` 执行 018 增量,仅创建两张特征表;重复执行新增结构为零。修正基础资产清单将 018 误作种子数据的问题,完整离线升级清单可通过检查,没有运行初始化或全量迁移。
|
||||
|
||||
使用同一安装包的本机独立实例与新 Java 检测网关、业务服务及开发 MySQL 完成 17 项联调。独立实例仅绑定回环地址,输出集中于本轮验证目录。合成样例包含 6 个平面、1 个圆柱面、A/B/C 基准及 9 项尺寸/形位控制;孔径设计值 10 mm,实测约 9.991989 mm;处理后 STL 共 95,191 个三角面,PDF/STL 成套归档、PDF 下载及发布特征快照冻结均通过。EXE 返回的 `capability_unverified` 保留为待核验状态,平台未转换为合格。
|
||||
|
||||
修正 STL 归档对新版内容指纹的误判:`stl_export.input_revision` 可以为哈希值,不能与数字清理修订号比较;归档时核对下载前后的导出状态、输入指纹、清理及报告版本。旧数字版本兼容,显式返回文件名时同样检查版本与就绪状态,发生变化或 stale 时仍拒绝归档。验证数据清理脚本已补齐新特征表,并保护仍被非验证作业引用的模板。
|
||||
|
||||
本次后端 232 项测试及完整打包、29 项既有 Python 检查及 3 项新增清理边界检查通过。此次接口联调没有启动完整业务后端,也未重启现有旧版 IDEA 实例;新页面接口的启用仍须按项目约定,以隔离开发配置重新启动新版后端。浏览器交互验收及真实零件计量验收不包含在本次接口联调结果中。此次测试任务、模板、执行数据及临时文件均按验证批次清理,未修改正式库、设备配置或正式服务,也未提交或推送。
|
||||
@ -136,7 +136,7 @@ def load_assets():
|
||||
seeds = {}
|
||||
for path in sorted(SQL_ROOT.glob("*.sql")):
|
||||
if path.name.endswith("_schema.sql") or path.name in {"005_scan_only.sql", "006_resource_scheduling.sql",
|
||||
"007_scanner_integration.sql", "008_scanner_execution_view.sql", "009_rotary_base_integration.sql", "010_scanner_framework_reference.sql", "011_fixture_framework.sql", "012_robot_service_endpoint.sql", "013_execution_plan.sql", "014_dimension_delivery.sql", "015_fixture_trajectory.sql", "017_dimension_comparison.sql"}:
|
||||
"007_scanner_integration.sql", "008_scanner_execution_view.sql", "009_rotary_base_integration.sql", "010_scanner_framework_reference.sql", "011_fixture_framework.sql", "012_robot_service_endpoint.sql", "013_execution_plan.sql", "014_dimension_delivery.sql", "015_fixture_trajectory.sql", "017_dimension_comparison.sql", "018_inspection_cad_features.sql"}:
|
||||
# Dedicated additive migration runs after bootstrap_cmvr. It is not
|
||||
# a reference seed and must never pass through the seed executor.
|
||||
continue
|
||||
|
||||
@ -35,7 +35,7 @@ MIGRATIONS = (
|
||||
"008_scanner_execution_view.sql", "009_rotary_base_integration.sql",
|
||||
"010_scanner_framework_reference.sql", "011_fixture_framework.sql",
|
||||
"012_robot_service_endpoint.sql", "013_execution_plan.sql", "014_dimension_delivery.sql",
|
||||
"015_fixture_trajectory.sql", "017_dimension_comparison.sql",
|
||||
"015_fixture_trajectory.sql", "017_dimension_comparison.sql", "018_inspection_cad_features.sql",
|
||||
)
|
||||
|
||||
def plan():
|
||||
|
||||
@ -28,7 +28,8 @@ lab_sample lab_fixture lab_fixture_applicable lab_fixture_framework lab_fixture_
|
||||
NATIVE_TABLES = '''aima_test_case aima_task aima_task_test_case aima_task_instance aima_test_log
|
||||
te_detection_item te_detection_item_version te_task_config_info te_task_orchestration
|
||||
te_task_inst te_task_inst_flow_version te_node_inst te_ai_evaluation'''.split()
|
||||
TABLES = LAB_TABLES + NATIVE_TABLES + ['infra_file','lab_device','lab_scanner_command','lab_scanner_framework_transfer','lab_inspection_scan']
|
||||
TABLES = LAB_TABLES + NATIVE_TABLES + ['infra_file','lab_device','lab_scanner_command','lab_scanner_framework_transfer',
|
||||
'lab_inspection_feature_plan','lab_inspection_feature_template','lab_inspection_scan']
|
||||
|
||||
|
||||
def plan_rows(data, prefixes=None):
|
||||
@ -69,9 +70,25 @@ def plan_rows(data, prefixes=None):
|
||||
choose(table, lambda r: has(r, 'task_id', task_ids))
|
||||
comparison_keys={(str(r.get('tenant_id')),str(r.get('engine_id'))) for r in rows('lab_dimension_comparison') if r.get('engine_id')}
|
||||
choose('lab_inspection_scan',lambda r:(str(r.get('tenant_id')),str(r.get('id'))) in comparison_keys)
|
||||
choose('lab_inspection_feature_plan',lambda r:(str(r.get('tenant_id')),str(r.get('scan_id'))) in comparison_keys)
|
||||
choose('lab_inspection_feature_template',lambda r:marked(r.get('name')))
|
||||
template_keys={(str(r.get('tenant_id')),str(r.get('id'))) for r in rows('lab_inspection_feature_template')}
|
||||
for index,row in enumerate(data.get('lab_dimension_comparison',[])):
|
||||
if index not in selected.get('lab_dimension_comparison',set()) and (str(row.get('tenant_id')),str(row.get('engine_id'))) in comparison_keys:
|
||||
raise ValueError('非测试比对作业仍引用待清理的计算记录')
|
||||
if template_keys and index not in selected.get('lab_dimension_comparison',set()):
|
||||
options=json.loads(row.get('options_json') or '{}')
|
||||
selection=str(options.get('selected_template_id',''))
|
||||
references={str(options.get('feature_template_id',''))}
|
||||
if selection.startswith('feature-'):
|
||||
references.add(selection[8:])
|
||||
snapshot=options.get('feature_template_snapshot')
|
||||
if isinstance(snapshot,str):
|
||||
snapshot=json.loads(snapshot)
|
||||
if isinstance(snapshot,dict):
|
||||
references.add(str(snapshot.get('id','')))
|
||||
if any((str(row.get('tenant_id')),identifier) in template_keys for identifier in references):
|
||||
raise ValueError('非测试比对作业仍引用待清理的特征模板')
|
||||
if any(r.get('status') in ('SUBMITTING','UNKNOWN','PROCESSING','ARCHIVE_PENDING') for r in rows('lab_dimension_comparison')):
|
||||
raise ValueError('比对作业尚未确认终态,拒绝清理')
|
||||
execution_ids = ids('lab_execution')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user