实验课表

This commit is contained in:
2026-07-28 21:25:21 +08:00 Unverified
parent ec979f640d
commit 51c3b81e27
7 changed files with 687 additions and 28 deletions
@@ -25,14 +25,21 @@ public static class TimetableExcelExporter
sheet.Row(1).Height = 34;
sheet.Range("A2:H2").Merge();
var examSummary = timetable.ExamEntries.Count > 0
? $" · 已融入 {timetable.ExamEntries.Count} 场考试"
: "";
var activitySummary = string.Concat(
timetable.ExamEntries.Count > 0
? $" · 已融入 {timetable.ExamEntries.Count} 场考试"
: "",
timetable.ExperimentEntries.Count > 0
? $" · 已融入 {timetable.ExperimentEntries.Count} 场实验"
: "");
var hasOneOffActivities =
timetable.ExamEntries.Count > 0 ||
timetable.ExperimentEntries.Count > 0;
sheet.Cell("A2").Value = timetable.Plan is null
? timetable.ExamEntries.Count > 0
? $"固定课表尚未发布{examSummary} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}"
? hasOneOffActivities
? $"固定课表尚未发布{activitySummary} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}"
: "本学期暂无可用课表版本"
: $"版本:{timetable.Plan.Version} · 状态:{PlanStatus(timetable.Plan.Status)}{examSummary} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}";
: $"版本:{timetable.Plan.Version} · 状态:{PlanStatus(timetable.Plan.Status)}{activitySummary} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}";
sheet.Cell("A2").Style
.Font.SetFontColor(XLColor.FromHtml("#52677A"))
.Fill.SetBackgroundColor(XLColor.FromHtml("#EFF3F6"));
@@ -55,6 +62,7 @@ public static class TimetableExcelExporter
var timedEntries = timetable.Entries
.Concat(timetable.ExamEntries)
.Concat(timetable.ExperimentEntries)
.ToArray();
var periods = timetable.Slots.Select(x => x.PeriodNumber)
.Concat(timedEntries.SelectMany(x =>
@@ -95,7 +103,11 @@ public static class TimetableExcelExporter
{
cell.Style
.Fill.SetBackgroundColor(XLColor.FromHtml(
entries.Any(x => x.IsExam) ? "#FFF1E8" : "#E8F3F2"))
entries.Any(x => x.IsExam)
? "#FFF1E8"
: entries.Any(x => x.IsExperiment)
? "#E7F5F1"
: "#E8F3F2"))
.Font.SetFontColor(XLColor.FromHtml("#173F4C"));
}
}
@@ -147,7 +159,14 @@ public static class TimetableExcelExporter
}
private static string EntryText(TimetableEntryDto entry) =>
entry.IsExam
entry.IsExperiment
? $"【实验】{entry.ExperimentProjectName}\n" +
$"{entry.CourseName} · {ArrangementMode(entry)}\n" +
$"{string.Join('、', entry.TeacherNames)}\n" +
$"{Location(entry)}\n" +
$"{entry.ExperimentDate:yyyy-MM-dd} · 第 {entry.StartPeriod}-" +
$"{entry.StartPeriod + entry.PeriodCount - 1} 节"
: entry.IsExam
? $"【考试】{entry.CourseName}\n" +
$"{entry.ExamPlanName}\n" +
$"{string.Join('、', entry.TeacherNames)}\n" +
@@ -159,6 +178,14 @@ public static class TimetableExcelExporter
$"{Location(entry)}\n" +
$"{entry.StartWeek}-{entry.EndWeek} 周";
private static string ArrangementMode(TimetableEntryDto entry) =>
entry.ExperimentArrangementMode switch
{
Domain.Academic.ExperimentArrangementMode.Centralized => "集中安排",
Domain.Academic.ExperimentArrangementMode.SelfScheduled => "自主预约",
_ => "实验安排"
};
private static string Location(TimetableEntryDto entry) =>
string.Join(" · ", new[]
{