ff
This commit is contained in:
parent
89e9a320d9
commit
75e9ca107e
@ -145,11 +145,22 @@ namespace YD_AllHeartRates.Api.Services.Impl
|
|||||||
|
|
||||||
int warmUp = 0, low = 0, medium = 0, high = 0, warning = 0;
|
int warmUp = 0, low = 0, medium = 0, high = 0, warning = 0;
|
||||||
|
|
||||||
|
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
|
||||||
|
// 获取所有学号
|
||||||
|
var studentNos = studentList.Select(s => s.StudentNo).ToList();
|
||||||
|
|
||||||
|
// 一次性获取 JumpRopeData(当天数据)
|
||||||
|
var jumpRopeDict = await _userContext.JumpRopeData
|
||||||
|
.Where(x => studentNos.Contains(x.StudentNo) && x.ScoreTime.Date == today)
|
||||||
|
.ToDictionaryAsync(x => x.StudentNo, x => x);
|
||||||
|
|
||||||
|
|
||||||
foreach (var student in studentList)
|
foreach (var student in studentList)
|
||||||
{
|
{
|
||||||
var heartRateKey = $"heartRate:{student.StudentNo}";
|
var heartRateKey = $"heartRate:{student.StudentNo}";
|
||||||
//var jumpRopeKey = $"jumpRope:{student.StudentNo}";
|
//var jumpRopeKey = $"jumpRope:{student.StudentNo}";
|
||||||
|
|
||||||
//string jumpRopeKey = $"{student.StudentNo}_{DateTime.Now:yyyyMMdd}";
|
//string jumpRopeKey = $"{student.StudentNo}_{DateTime.Now:yyyyMMdd}";
|
||||||
|
|
||||||
var jumpRopeKey = $"jumpRope:active:{student.StudentNo}:{DateTime.Now:yyyyMMdd}";
|
var jumpRopeKey = $"jumpRope:active:{student.StudentNo}:{DateTime.Now:yyyyMMdd}";
|
||||||
@ -159,10 +170,8 @@ namespace YD_AllHeartRates.Api.Services.Impl
|
|||||||
|
|
||||||
var jumpRope = _caching.Get<JumpRopeData>(jumpRopeKey);
|
var jumpRope = _caching.Get<JumpRopeData>(jumpRopeKey);
|
||||||
|
|
||||||
if (jumpRope == null)
|
if (jumpRope == null && jumpRopeDict.TryGetValue(student.StudentNo, out var jr))
|
||||||
{
|
jumpRope = jr;
|
||||||
jumpRope = await _userContext.JumpRopeData.Where(x => x.StudentNo == student.StudentNo).FirstOrDefaultAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ❗心率缓存未命中 → 单独查数据库
|
// ❗心率缓存未命中 → 单独查数据库
|
||||||
//if (heartRate == null)
|
//if (heartRate == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user