ss
This commit is contained in:
parent
3c399871d7
commit
43f076f872
@ -172,12 +172,12 @@ namespace YD_AllHeartRates.Api.Mqtt
|
|||||||
if (string.IsNullOrWhiteSpace(ble.RawData)) continue;
|
if (string.IsNullOrWhiteSpace(ble.RawData)) continue;
|
||||||
|
|
||||||
var student = _studentList.FirstOrDefault(x => x.JumpRopeId == ble.BleName);
|
var student = _studentList.FirstOrDefault(x => x.JumpRopeId == ble.BleName);
|
||||||
if (student?.GradeId == 0 || student?.ClassId == 0) continue;
|
if (student == null || student.GradeId == 0 || student.ClassId == 0) continue;
|
||||||
|
|
||||||
var data = ParseHexData(ble.RawData);
|
var data = ParseHexData(ble.RawData);
|
||||||
if (data == null) continue;
|
if (data == null) continue;
|
||||||
|
|
||||||
int mfIndex = IndexOfSequence(data, new byte[] { 0xFF, 0x04, 0xFF, 0xCF });
|
int mfIndex = Array.IndexOf(data, new byte[] { 0xFF, 0x04, 0xFF, 0xCF });
|
||||||
if (mfIndex < 0 || data.Length < mfIndex + 10) continue;
|
if (mfIndex < 0 || data.Length < mfIndex + 10) continue;
|
||||||
|
|
||||||
int jumpCount = data[mfIndex + 5] + (data[mfIndex + 6] << 8);
|
int jumpCount = data[mfIndex + 5] + (data[mfIndex + 6] << 8);
|
||||||
@ -297,27 +297,5 @@ namespace YD_AllHeartRates.Api.Mqtt
|
|||||||
}
|
}
|
||||||
if (buffer.Count > 0) yield return buffer;
|
if (buffer.Count > 0) yield return buffer;
|
||||||
}
|
}
|
||||||
public static int IndexOfSequence(byte[] buffer, byte[] pattern)
|
|
||||||
{
|
|
||||||
if (pattern.Length == 0 || buffer.Length < pattern.Length)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (int i = 0; i <= buffer.Length - pattern.Length; i++)
|
|
||||||
{
|
|
||||||
bool matched = true;
|
|
||||||
for (int j = 0; j < pattern.Length; j++)
|
|
||||||
{
|
|
||||||
if (buffer[i + j] != pattern[j])
|
|
||||||
{
|
|
||||||
matched = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (matched)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Reflection.PortableExecutable;
|
using System.Reflection.PortableExecutable;
|
||||||
@ -24,6 +25,7 @@ namespace YD_AllHeartRates.Api.Services.Impl
|
|||||||
private readonly LoginContext _loginContext;
|
private readonly LoginContext _loginContext;
|
||||||
private string schoolCode;
|
private string schoolCode;
|
||||||
private readonly ICaching _caching;
|
private readonly ICaching _caching;
|
||||||
|
private readonly Dictionary<string, JumpRopeData> _jumpDailyMap = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造
|
/// 构造
|
||||||
@ -147,11 +149,17 @@ namespace YD_AllHeartRates.Api.Services.Impl
|
|||||||
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}";
|
||||||
|
|
||||||
// 先从缓存拿
|
// 先从缓存拿
|
||||||
var heartRate = _caching.Get<HeartRateData>(heartRateKey);
|
var heartRate = _caching.Get<HeartRateData>(heartRateKey);
|
||||||
var jumpRope = _caching.Get<JumpRopeData>(jumpRopeKey);
|
|
||||||
|
//var jumpRope = _caching.Get<JumpRopeData>(jumpRopeKey);
|
||||||
|
|
||||||
|
_jumpDailyMap.TryGetValue(jumpRopeKey, out var jumpRope);
|
||||||
|
|
||||||
|
|
||||||
// ❗心率缓存未命中 → 单独查数据库
|
// ❗心率缓存未命中 → 单独查数据库
|
||||||
//if (heartRate == null)
|
//if (heartRate == null)
|
||||||
@ -173,8 +181,8 @@ namespace YD_AllHeartRates.Api.Services.Impl
|
|||||||
// .OrderByDescending(x => x.ScoreTime)
|
// .OrderByDescending(x => x.ScoreTime)
|
||||||
// .FirstOrDefaultAsync();
|
// .FirstOrDefaultAsync();
|
||||||
|
|
||||||
// //if (jumpRope != null)
|
// if (jumpRope != null)
|
||||||
// // _caching.AddObject(jumpRopeKey, jumpRope, 60);
|
// _caching.AddObject(jumpRopeKey, jumpRope, 60);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// 心率强度判断
|
// 心率强度判断
|
||||||
|
@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_AllHeartRates.Api")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_AllHeartRates.Api")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e813d22174a36ed6a56d32c6680c8cbe3560475c")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3c399871d7a4fff8b5d368263e3942991a974fdd")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("YD_AllHeartRates.Api")]
|
[assembly: System.Reflection.AssemblyProductAttribute("YD_AllHeartRates.Api")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("YD_AllHeartRates.Api")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("YD_AllHeartRates.Api")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
297fd43299ec4dd1d6e6586c0f993bcc28ee868403ee350c618e71c5827769a6
|
937ead42c43efa52de467b7e6b0b10b17938c2bb3b9c6b465840319e0efb56a9
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user