feat: integrate CampusScope.filter() into all business services (12 services + 12 modules)

This commit is contained in:
2026-07-05 23:58:51 +08:00
parent eeae06fe30
commit cd6364268d
40 changed files with 949 additions and 172 deletions

View File

@@ -223,4 +223,36 @@ export class ClassroomsController {
});
return result;
}
}
@Get('report')
@RequirePermission('classroom:view')
async exportReport(
@Query('dateFrom') dateFrom: string,
@Query('dateTo') dateTo: string,
@Res() res: Response,
) {
const data = await this.service.getUsageReport(dateFrom, dateTo);
const workbook = new ExcelJS.Workbook();
const ws = workbook.addWorksheet('教室使用统计');
ws.columns = [
{ header: '教室名称', key: 'name', width: 20 },
{ header: '楼栋', key: 'building', width: 12 },
{ header: '类型', key: 'roomType', width: 12 },
{ header: '容量', key: 'capacity', width: 8 },
{ header: '统计天数', key: 'totalDays', width: 10 },
{ header: '租赁占用天数', key: 'rentalDays', width: 14 },
{ header: '排课占用天数', key: 'scheduleDays', width: 14 },
{ header: '空闲天数', key: 'idleDays', width: 10 },
{ header: '占用率', key: 'occupancyRate', width: 10 },
];
ws.getRow(1).font = { bold: true };
ws.getRow(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE0E0E0' } };
for (const row of data) {
ws.addRow({ ...row, occupancyRate: `${row.occupancyRate}%` });
}
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.setHeader('Content-Disposition', 'attachment; filename=classroom-report.xlsx');
await workbook.xlsx.write(res);
res.end();
}
}