time
This commit is contained in:
parent
a980826100
commit
f30386d596
@ -105,6 +105,6 @@ namespace YD_YiLu.Commons.Dto.DeviceSync
|
|||||||
public int CourseId { get; set; }
|
public int CourseId { get; set; }
|
||||||
public string CourseName { get; set; }
|
public string CourseName { get; set; }
|
||||||
public string Time { get; set; }
|
public string Time { get; set; }
|
||||||
public int Count { get; set; }
|
public string Count { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1189,8 +1189,8 @@ namespace YD_YiLu.Api.Services.Impl
|
|||||||
{
|
{
|
||||||
CourseId = g.Key,
|
CourseId = g.Key,
|
||||||
CourseName = Util.GetEnumDescription<CourseType>(g.Key),
|
CourseName = Util.GetEnumDescription<CourseType>(g.Key),
|
||||||
Time = SecondsToHours(g.Sum(x => x.Duration)),
|
Time = SecondsToWholeHours(g.Sum(x => x.Duration)),
|
||||||
Count = g.Count()
|
Count = g.Count().ToString()
|
||||||
})
|
})
|
||||||
.OrderByDescending(x => double.TryParse(x.Time, out var hours) ? hours : 0)
|
.OrderByDescending(x => double.TryParse(x.Time, out var hours) ? hours : 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -1441,31 +1441,35 @@ namespace YD_YiLu.Api.Services.Impl
|
|||||||
return (seconds / 3600.0).ToString("0.####");
|
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)
|
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)
|
private static string GetYtpSummaryTime(int dateType)
|
||||||
{
|
{
|
||||||
var today = DateTime.Now.Date;
|
return dateType switch
|
||||||
var weekStart = GetWeekStart(today);
|
|
||||||
var monthStart = new DateTime(today.Year, today.Month, 1);
|
|
||||||
|
|
||||||
switch (dateType)
|
|
||||||
{
|
{
|
||||||
case 1:
|
0 => "\u5168\u90e8",
|
||||||
return today.ToString("yyyy-MM-dd");
|
1 => "\u4eca\u65e5",
|
||||||
case 2:
|
2 => "\u672c\u5468",
|
||||||
return $"{weekStart:MM-dd}~{weekStart.AddDays(6):MM-dd}";
|
3 => "\u672c\u6708",
|
||||||
case 3:
|
4 => "\u672c\u5b66\u671f",
|
||||||
return monthStart.AddMonths(1).AddDays(-1).ToString("MM-dd");
|
5 => "\u6307\u5b9a\u65f6\u95f4",
|
||||||
case 9:
|
6 => "\u4e0a\u5468",
|
||||||
return today.Year.ToString();
|
7 => "\u4e0a\u6708",
|
||||||
}
|
8 => "\u6700\u8fd1\u4e09\u4e2a\u6708",
|
||||||
|
9 => "\u672c\u5e74\u5ea6",
|
||||||
var (start, end) = GetCurrentSemesterRange(today);
|
_ => ""
|
||||||
return $"{start:MM-dd}~{end:MM-dd}";
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DateTime GetWeekStart(DateTime today)
|
private static DateTime GetWeekStart(DateTime today)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user