feat: add channel report batch briefs

This commit is contained in:
hectorzhao
2026-09-02 18:29:05 +08:00
parent 2dff1be750
commit 7cb5dd376e
27 changed files with 1083 additions and 153 deletions
@@ -73,6 +73,7 @@ export class ReportChannelExportService {
const reportTypes = [...new Set(items.map((item) => item.reportType))];
const workbook = new ExcelJS.Workbook();
const fileRows: Array<{ item: (typeof items)[number]; taskId: string; rowNumber: number }> = [];
const briefItems: Array<{ batchItemId: string; smsContent: string }> = [];
const incompleteBatchItemIds: string[] = [];
let totalRows = 0;
for (const reportType of reportTypes) {
@@ -94,6 +95,9 @@ export class ReportChannelExportService {
const values = fields.map(
(field) => resolveExportValue(item.snapshot, field.code, field.name) ?? field.defaultValue ?? '',
);
const smsContentIndex = fields.findIndex((field) => field.name.trim() === '短信内容');
const smsContentValue = smsContentIndex >= 0 ? values[smsContentIndex] : '';
const smsContent = isFileRef(smsContentValue) ? '' : String(smsContentValue ?? '');
const missing = fields.filter((field, index) => field.required && !hasValue(values[index]));
const missingReason =
fields.length === 0
@@ -186,6 +190,7 @@ export class ReportChannelExportService {
}
row.height = targetHeight;
fileRows.push({ item, taskId: task.id, rowNumber: row.number });
briefItems.push({ batchItemId: item.batchItem.id, smsContent });
for (const entry of tasks)
await this.recordTask(entry.task.id, channelId, entry.existingTask?.status, 'exporting');
}
@@ -219,7 +224,7 @@ export class ReportChannelExportService {
rowNumber: entry.rowNumber,
})),
});
return { file: { ...file, fileObject: uploaded }, incompleteBatchItemIds };
return { file: { ...file, fileObject: uploaded }, incompleteBatchItemIds, briefItems };
}
async getSingleMaterialDetail(data: SingleReportMaterialDto) {