feat(cleaner): record all material operations in database, including successful deletions

Previously only skipped and failed materials were persisted. Now every
material (deleted, uncertain, skipped, failed) is recorded in
CleanerMaterialDetail for full audit traceability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-04-13 14:24:18 +08:00
parent 0286df94dd
commit 116539ff42
3 changed files with 30 additions and 1 deletions

View File

@@ -433,9 +433,22 @@ export class CleanerApplicationService {
detail.errors.length > 0 ? detail.errors.join('\n') : undefined
)
// Insert material details for skipped and failed materials
// Insert material details for all materials
const materialDetails: InsertMaterialDetailInput[] = []
for (const deleted of detail.deletedMaterials) {
materialDetails.push({
orderNumber: detail.orderNumber,
materialCode: deleted.materialCode,
materialName: deleted.materialName,
rowNumber: deleted.rowNumber,
result: deleted.outcome,
reason: null,
attemptCount: 1,
finalErrorCategory: null
})
}
for (const skipped of detail.skippedMaterials) {
materialDetails.push({
orderNumber: detail.orderNumber,