diff --git a/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs b/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs index cc86499..03fd8e4 100644 --- a/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs +++ b/YD_YiLu.Commons/Dto/DeviceSync/DeviceSyncMyRecordDto.cs @@ -105,6 +105,6 @@ namespace YD_YiLu.Commons.Dto.DeviceSync public int CourseId { get; set; } public string CourseName { get; set; } public string Time { get; set; } - public int Count { get; set; } + public string Count { get; set; } } } diff --git a/YD_YiLu/Services/Impl/DeviceSyncService.cs b/YD_YiLu/Services/Impl/DeviceSyncService.cs index e1f3b7b..033b665 100644 --- a/YD_YiLu/Services/Impl/DeviceSyncService.cs +++ b/YD_YiLu/Services/Impl/DeviceSyncService.cs @@ -1189,8 +1189,8 @@ namespace YD_YiLu.Api.Services.Impl { CourseId = g.Key, CourseName = Util.GetEnumDescription(g.Key), - Time = SecondsToHours(g.Sum(x => x.Duration)), - Count = g.Count() + Time = SecondsToWholeHours(g.Sum(x => x.Duration)), + Count = g.Count().ToString() }) .OrderByDescending(x => double.TryParse(x.Time, out var hours) ? hours : 0) .ToList(); @@ -1441,31 +1441,35 @@ namespace YD_YiLu.Api.Services.Impl return (seconds / 3600.0).ToString("0.####"); } + private static string SecondsToWholeHours(int seconds) + { + if (seconds <= 0) + return "0"; + + return Math.Ceiling(seconds / 3600.0).ToString("0"); + } + private static bool IsYtpSummaryDateType(int dateType) { - return dateType == 1 || dateType == 2 || dateType == 3 || dateType == 4 || dateType == 9; + return dateType >= 0 && dateType <= 9; } private static string GetYtpSummaryTime(int dateType) { - var today = DateTime.Now.Date; - var weekStart = GetWeekStart(today); - var monthStart = new DateTime(today.Year, today.Month, 1); - - switch (dateType) + return dateType switch { - case 1: - return today.ToString("yyyy-MM-dd"); - case 2: - return $"{weekStart:MM-dd}~{weekStart.AddDays(6):MM-dd}"; - case 3: - return monthStart.AddMonths(1).AddDays(-1).ToString("MM-dd"); - case 9: - return today.Year.ToString(); - } - - var (start, end) = GetCurrentSemesterRange(today); - return $"{start:MM-dd}~{end:MM-dd}"; + 0 => "\u5168\u90e8", + 1 => "\u4eca\u65e5", + 2 => "\u672c\u5468", + 3 => "\u672c\u6708", + 4 => "\u672c\u5b66\u671f", + 5 => "\u6307\u5b9a\u65f6\u95f4", + 6 => "\u4e0a\u5468", + 7 => "\u4e0a\u6708", + 8 => "\u6700\u8fd1\u4e09\u4e2a\u6708", + 9 => "\u672c\u5e74\u5ea6", + _ => "" + }; } private static DateTime GetWeekStart(DateTime today)