This commit is contained in:
tanglong 2026-07-29 16:22:41 +08:00
parent 62f4a05ce3
commit 17039797ea
20 changed files with 40 additions and 18 deletions

View File

@ -0,0 +1,6 @@
C:\Users\tangl\Desktop\Git\YD_AllHeartRates.Api\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.Dto.ResponseMsg 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
C:\Users\tangl\Desktop\Git\YD_AllHeartRates.Api\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.MemoryCaches.MemoryCacheSetup 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
C:\Users\tangl\Desktop\Git\YD_AllHeartRates.Api\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.Middlewares.SystemExceptionApplicationBuilderExtensions 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
C:\Users\tangl\Desktop\Git\YD_AllHeartRates.Api\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 无法为 YD_AllHeartRates.Commons.Utils.Util 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。
C:\Users\tangl\Desktop\Git\YD_AllHeartRates.Api\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 正在跳过 method System.Int32 YD_AllHeartRates.Commons.Utils.Util.GetRank(!!0 score),method System.Int32 YD_AllHeartRates.Commons.Utils.Util.GetRank(!!0 score) unstubbable: 无法同时指定类约束和 "class" 或 "struct" 约束
C:\Users\tangl\Desktop\Git\YD_AllHeartRates.Api\YD_AllHeartRates.Api\Fakes\YD_AllHeartRates.Commons.fakes : warning : 正在跳过 method System.String YD_AllHeartRates.Commons.Utils.Util.GetRankStr(!!0 score),method System.String YD_AllHeartRates.Commons.Utils.Util.GetRankStr(!!0 score) unstubbable: 无法同时指定类约束和 "class" 或 "struct" 约束

View File

@ -105,6 +105,15 @@ namespace YD_AllHeartRates.Api.Middlewares
private static readonly List<string> SchoolCodeList = new List<string> { "202504080013", "202603220088" };
private static readonly StudentCacheInfo TestStudent = new StudentCacheInfo
{
EduId = "test-edu-00204915",
Name = "测试学生204915",
School = "上海市实验学校东滩高级中学",
Grade = "高三",
ClassName = "高三2班"
};
public SportsRoutineReportJob(IDataPushService dataPushService, UserContext userContext, SmartSportsContext sportsContext, ICaching caching)
{
_dataPushService = dataPushService;
@ -119,6 +128,7 @@ namespace YD_AllHeartRates.Api.Middlewares
var cachedList = _caching.Get<List<StudentCacheInfo>>(redisKey);
if (cachedList != null && cachedList.Count > 0)
{
AddTestStudent(cachedList);
_students = cachedList;
Console.WriteLine("从 Redis 加载学生信息完成。");
return;
@ -184,6 +194,8 @@ namespace YD_AllHeartRates.Api.Middlewares
}
}
AddTestStudent(result);
// 写入 Redis(直接存对象,不再存 json 字符串)
_caching.AddObject(redisKey, result);
_students = result;
@ -191,6 +203,14 @@ namespace YD_AllHeartRates.Api.Middlewares
Console.WriteLine("学生信息已缓存到 Redis。");
}
private static void AddTestStudent(List<StudentCacheInfo> students)
{
if (students.Any(x => x.EduId == TestStudent.EduId))
return;
students.Add(TestStudent);
}
public Task StartAsync(CancellationToken cancellationToken)
{
// 每分钟检查一次时间,看是否在8-18点并35分执行
@ -203,7 +223,7 @@ namespace YD_AllHeartRates.Api.Middlewares
var now = DateTime.Now;
// 每天 8:30 ~ 18:30 每小时35分执行
if (now.Hour < 8 || now.Hour > 18 || now.Minute != 15)
if (now.Hour < 8 || now.Hour > 18 || now.Minute != 30)
return;
var startTime = now.AddHours(-1);

View File

@ -1,10 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// This code was generated by a tool.
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@ -14,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_AllHeartRates.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9a604b4f150745ad91a9b343a7759979767c9791")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+62f4a05ce34f3bc35f2fad628026cd4d78c2fbb1")]
[assembly: System.Reflection.AssemblyProductAttribute("YD_AllHeartRates.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("YD_AllHeartRates.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
e3c7751633165ec338a31b3731933fa824c45918a5a547644156bab8c2c9649c
5af16d6e6609085a88a8b3c38d2cf2d7fe8b774b69544c02bea0a5ecc654aff5

View File

@ -1,10 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// This code was generated by a tool.
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@ -14,7 +13,6 @@ using System.Reflection;
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("Microsoft.AspNetCore.Mvc.Versioning")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("Swashbuckle.AspNetCore.SwaggerGen")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("YD_AllHeartRates.Commons")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("YD_AllHeartRates.Commons.1.0.0.0.Fakes")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1,10 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// This code was generated by a tool.
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@ -14,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("YD_AllHeartRates.Commons")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9a604b4f150745ad91a9b343a7759979767c9791")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+62f4a05ce34f3bc35f2fad628026cd4d78c2fbb1")]
[assembly: System.Reflection.AssemblyProductAttribute("YD_AllHeartRates.Commons")]
[assembly: System.Reflection.AssemblyTitleAttribute("YD_AllHeartRates.Commons")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
883a5887de4afba2d4b6161ca46d51365b0294665d147c610e4c5a288afdb427
21e4e28f923f1db74934b62b386bc124886d28c4608e70deb1443898726850b0