From 02b7b0ba9abcfcce3b55f6dda3fccfbeb40f82bc Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Fri, 17 Jul 2026 11:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YD_YiLu/Services/Impl/DeviceSyncService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/YD_YiLu/Services/Impl/DeviceSyncService.cs b/YD_YiLu/Services/Impl/DeviceSyncService.cs index 980c28f..1264c40 100644 --- a/YD_YiLu/Services/Impl/DeviceSyncService.cs +++ b/YD_YiLu/Services/Impl/DeviceSyncService.cs @@ -1144,10 +1144,11 @@ namespace YD_YiLu.Api.Services.Impl .Select(day => { var dayTrains = trains.Where(x => x.StartTime.Date == day).ToList(); + var daySeconds = dayTrains.Sum(x => x.Duration); return new YtpGradeListItem { Time = day.ToString("yyyy-MM-dd"), - Duration = dayTrains.Sum(x => x.Duration).ToString(), + Duration = SecondsToHours(daySeconds), Count = dayTrains.Count.ToString() }; }) @@ -1159,10 +1160,10 @@ namespace YD_YiLu.Api.Services.Impl { CourseId = g.Key, CourseName = Util.GetEnumDescription(g.Key), - Time = g.Sum(x => x.Duration).ToString(), + Time = SecondsToHours(g.Sum(x => x.Duration)), Count = g.Count() }) - .OrderByDescending(x => int.TryParse(x.Time, out var seconds) ? seconds : 0) + .OrderByDescending(x => double.TryParse(x.Time, out var hours) ? hours : 0) .ToList(); return result; @@ -1406,6 +1407,11 @@ namespace YD_YiLu.Api.Services.Impl return "AUTO-" + MD5Helper.MD5Encrypt32(value); } + private static string SecondsToHours(int seconds) + { + return (seconds / 3600.0).ToString("0.00"); + } + private static (DateTime? start, DateTime? end) GetDateRange(int dateType, string queryStart, string queryEnd) { var today = DateTime.Now.Date;