feat: add model file library links
This commit is contained in:
@@ -43,6 +43,26 @@ function ensureDir(dir: string) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
function formatRegistrationTimestamp(date: Date): string {
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return [
|
||||
date.getFullYear(),
|
||||
pad(date.getMonth() + 1),
|
||||
pad(date.getDate()),
|
||||
'-',
|
||||
pad(date.getHours()),
|
||||
pad(date.getMinutes()),
|
||||
pad(date.getSeconds()),
|
||||
].join('');
|
||||
}
|
||||
|
||||
function registeredPointcloudDisplayName(sourceName: string | undefined, derivedFile: string, resultId: number): string {
|
||||
const sourceParsed = path.parse(sourceName || 'pointcloud');
|
||||
const stem = sourceParsed.name || 'pointcloud';
|
||||
const ext = path.extname(derivedFile) || sourceParsed.ext || '.ply';
|
||||
return `${stem}_已配准_${formatRegistrationTimestamp(new Date())}_R${resultId}${ext}`;
|
||||
}
|
||||
|
||||
/** 把 process / mock cmd 模板里的占位符替换成实际路径。 */
|
||||
function resolvePlaceholders(value: string, ctx: Record<string, string>): string {
|
||||
return value.replace(/\{(\w+)\}/g, (_, key) => ctx[key] ?? `{${key}}`);
|
||||
@@ -91,7 +111,7 @@ async function gatherInputs(
|
||||
}
|
||||
}
|
||||
|
||||
return { task, pointCloudPaths, cadPath };
|
||||
return { task, pointCloudRecords, pointCloudPaths, cadPath };
|
||||
}
|
||||
|
||||
async function writeInputJson(
|
||||
@@ -282,7 +302,12 @@ export async function runAlgorithmJob(
|
||||
|
||||
try {
|
||||
await patchProgress(resultId, pluginId, 0.02, '准备输入');
|
||||
const { pointCloudPaths, cadPath } = await gatherInputs(taskId, manifest, pointCloudFileIds, cadFileIds);
|
||||
const { pointCloudRecords, pointCloudPaths, cadPath } = await gatherInputs(
|
||||
taskId,
|
||||
manifest,
|
||||
pointCloudFileIds,
|
||||
cadFileIds,
|
||||
);
|
||||
const inputJsonPath = await writeInputJson(
|
||||
workDir,
|
||||
taskId,
|
||||
@@ -350,13 +375,16 @@ export async function runAlgorithmJob(
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const sourcePointcloud = pointCloudRecords[0];
|
||||
const displayName = registeredPointcloudDisplayName(sourcePointcloud?.name, d.file, resultId);
|
||||
await db.createRegisteredPointcloudFile(
|
||||
taskId,
|
||||
d.name ?? d.file,
|
||||
displayName,
|
||||
absPath,
|
||||
resultId,
|
||||
sourcePointcloud?.id ?? null,
|
||||
);
|
||||
console.log(`[AlgorithmJobRunner] registered derived pointcloud: ${d.name ?? d.file}`);
|
||||
console.log(`[AlgorithmJobRunner] registered derived pointcloud: ${displayName}`);
|
||||
} catch (err) {
|
||||
console.error('[AlgorithmJobRunner] failed to register derived pointcloud:', err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user