yundongguan
This commit is contained in:
parent
d3e9523a58
commit
c28da1d332
@ -286,18 +286,33 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
|||||||
var prevResult = studentResults.Skip(1).FirstOrDefault();
|
var prevResult = studentResults.Skip(1).FirstOrDefault();
|
||||||
|
|
||||||
var maxScore = studentResults.Any()
|
var maxScore = studentResults.Any()
|
||||||
? studentResults.Max(x => x.Score)
|
? studentResults.Max(x => x.Value)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
var classAvgScore = studentResults.Any()
|
//var classAvgScore = studentResults.Any()
|
||||||
? studentResults.Average(x => x.Score)
|
// ? studentResults.Average(x => x.Value)
|
||||||
: 0;
|
// : 0;
|
||||||
|
|
||||||
var schoolAvgScore = sportsTestResults
|
// 1. 获取每个学生最新的 ScoreTime
|
||||||
.Where(x => x.CategoryValue == item.Id)
|
var latestRecords = sportsTestResults
|
||||||
.Select(x => x.Score)
|
.Where(x => x.CategoryValue == item.Id) // 先按指标过滤,提升效率
|
||||||
.DefaultIfEmpty(0)
|
.GroupBy(x => x.StudentNo)
|
||||||
.Average();
|
.Select(g => new
|
||||||
|
{
|
||||||
|
StudentNo = g.Key,
|
||||||
|
MaxScoreTime = g.Max(x => x.ScoreTime)
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. 关联原表,取得最新测试的那条记录(该指标的值)
|
||||||
|
var latestValues = from record in sportsTestResults
|
||||||
|
join latest in latestRecords
|
||||||
|
on new { record.StudentNo, record.ScoreTime }
|
||||||
|
equals new { latest.StudentNo, ScoreTime = latest.MaxScoreTime }
|
||||||
|
where record.CategoryValue == item.Id
|
||||||
|
select record.Value;
|
||||||
|
|
||||||
|
// 3. 计算平均值(如果没有数据则返回0)
|
||||||
|
var schoolAvgScore = latestValues.DefaultIfEmpty(0).Average();
|
||||||
|
|
||||||
// 🚀 趋势图(关键:反转集合)
|
// 🚀 趋势图(关键:反转集合)
|
||||||
var trendList = studentResults
|
var trendList = studentResults
|
||||||
@ -316,12 +331,13 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
|||||||
Name = item.CategoryName,
|
Name = item.CategoryName,
|
||||||
|
|
||||||
Rank = lastResult?.Rank,
|
Rank = lastResult?.Rank,
|
||||||
|
GradeId = lastResult.GradeId,
|
||||||
|
|
||||||
PrevScore = prevResult?.Score ?? 0,
|
PrevScore = prevResult?.Score ?? 0,
|
||||||
LastScore = lastResult?.Score ?? 0,
|
LastScore = lastResult?.Score ?? 0,
|
||||||
|
|
||||||
MaxScore = (float)maxScore,
|
MaxScore = (float)maxScore,
|
||||||
ClassAvgScore = (float)classAvgScore,
|
//ClassAvgScore = (float)classAvgScore,
|
||||||
SchoolAvgScore = (float)schoolAvgScore,
|
SchoolAvgScore = (float)schoolAvgScore,
|
||||||
|
|
||||||
ScoreTrendChart = trendChart,
|
ScoreTrendChart = trendChart,
|
||||||
|
|||||||
@ -426,10 +426,17 @@ namespace YD_WeChatApplet.Services
|
|||||||
res.MinHR = (int)heartRateDataList.Min(x => x.Value);
|
res.MinHR = (int)heartRateDataList.Min(x => x.Value);
|
||||||
res.AvgHR = (int)heartRateDataList.Average(x => x.Value);
|
res.AvgHR = (int)heartRateDataList.Average(x => x.Value);
|
||||||
|
|
||||||
res.HighIntensity = heartRateDataList.Where(x => x.Strength > 50).Sum(x => x.MotionDuration);
|
var highIntensityCount = heartRateDataList.Count(x => x.Strength > 50);
|
||||||
|
|
||||||
double totalDuration = heartRateDataList.Sum(x => x.MotionDuration);
|
res.HighIntensity = (int)Math.Round((double)highIntensityCount / classRoomStudent.Count(), MidpointRounding.AwayFromZero);
|
||||||
res.HighIntensityDurationRatio = totalDuration > 0 ? res.HighIntensity / totalDuration : 0;
|
|
||||||
|
// 计算时间跨度(分钟)
|
||||||
|
//var minScoreTime = heartRateDataList.Min(x => x.ScoreTime);
|
||||||
|
//var maxScoreTime = heartRateDataList.Max(x => x.ScoreTime);
|
||||||
|
//double totalMinutes = (maxScoreTime - minScoreTime).TotalMinutes;
|
||||||
|
|
||||||
|
double totalMinutes = heartRateDataList.Count();
|
||||||
|
res.HighIntensityDurationRatio = totalMinutes > 0 ? Math.Round(highIntensityCount / totalMinutes * 100, MidpointRounding.AwayFromZero) : 0;
|
||||||
|
|
||||||
var studentTrainingRecordList = classRoom.ClassroomStudentRecord.ToList();
|
var studentTrainingRecordList = classRoom.ClassroomStudentRecord.ToList();
|
||||||
List<StudentTrainingRecordDto> studentList = new List<StudentTrainingRecordDto>();
|
List<StudentTrainingRecordDto> studentList = new List<StudentTrainingRecordDto>();
|
||||||
@ -517,9 +524,17 @@ namespace YD_WeChatApplet.Services
|
|||||||
res.MinHR = (int)heartRateDataList.Min(x => x.Value);
|
res.MinHR = (int)heartRateDataList.Min(x => x.Value);
|
||||||
res.AvgHR = (int)heartRateDataList.Average(x => x.Value);
|
res.AvgHR = (int)heartRateDataList.Average(x => x.Value);
|
||||||
|
|
||||||
res.HighIntensity = heartRateDataList.Where(x => x.Strength > 50).Sum(x => x.MotionDuration);
|
//res.HighIntensity = heartRateDataList.Where(x => x.Strength > 50).Sum(x => x.MotionDuration);
|
||||||
double totalDuration = heartRateDataList.Sum(x => x.MotionDuration);
|
|
||||||
res.HighIntensityDurationRatio = totalDuration > 0 ? res.HighIntensity / totalDuration : 0;
|
res.HighIntensity = heartRateDataList.Count(x => x.Strength > 50);
|
||||||
|
|
||||||
|
// 计算时间跨度(分钟)
|
||||||
|
//var minScoreTime = heartRateDataList.Min(x => x.ScoreTime);
|
||||||
|
//var maxScoreTime = heartRateDataList.Max(x => x.ScoreTime);
|
||||||
|
//double totalMinutes = (maxScoreTime - minScoreTime).TotalMinutes;
|
||||||
|
|
||||||
|
double totalMinutes = heartRateDataList.Count();
|
||||||
|
res.HighIntensityDurationRatio = totalMinutes > 0 ? Math.Round((double)res.HighIntensity / totalMinutes * 100, MidpointRounding.AwayFromZero) : 0;
|
||||||
|
|
||||||
// 计算时间轴(每分钟平均心率)
|
// 计算时间轴(每分钟平均心率)
|
||||||
DateTime baseTime;
|
DateTime baseTime;
|
||||||
|
|||||||
@ -73,7 +73,6 @@ namespace YD_WeChatApplet.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<StudentClassRoomReportDto> StudentClassRoomReport(StudentClassRoomReportRequestDto dto);
|
Task<StudentClassRoomReportDto> StudentClassRoomReport(StudentClassRoomReportRequestDto dto);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 班级体测报告
|
/// 班级体测报告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -15,6 +15,7 @@ namespace YD_WeChatApplet.Commons.Dto.ClassRoomRecord
|
|||||||
/// 查询类型[1:课堂/2:时间]
|
/// 查询类型[1:课堂/2:时间]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Type { get; set; }
|
public int Type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 课堂Id
|
/// 课堂Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -67,6 +67,11 @@ namespace YD_WeChatApplet.Commons.Dto.Patriarch
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Rank { get; set; }
|
public string Rank { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///年级Id
|
||||||
|
/// </summary>
|
||||||
|
public int? GradeId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 成绩趋势图
|
/// 成绩趋势图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user