feat(cleaner): track skipped materials and skip DB writes on dry run

Record materials not in the deletion list as "skipped" with reason
instead of just logging them. Skip inserting material details to
database during dry runs to avoid phantom records.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-04-13 15:58:00 +08:00
parent 116539ff42
commit 151485caed
4 changed files with 258 additions and 3 deletions

View File

@@ -417,6 +417,11 @@ export class CleanerApplicationService {
result: CleanerResult
): Promise<void> {
try {
// Query execution record to determine if this is a dry run
const batchDetails = await historyDao.getBatchDetails(batchId)
const execution = batchDetails.executions.find((e) => e.attemptNumber === attemptNumber)
const isDryRun = execution?.isDryRun ?? false
// Update order statuses and insert material details
for (const detail of result.details) {
await historyDao.updateOrderStatus(
@@ -479,7 +484,7 @@ export class CleanerApplicationService {
})
}
if (materialDetails.length > 0) {
if (materialDetails.length > 0 && !isDryRun) {
await historyDao.insertMaterialDetails(batchId, attemptNumber, materialDetails)
}
}