zuoye tongbu
This commit is contained in:
parent
490075f9d4
commit
39ce239956
@ -124,23 +124,42 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
||||
|
||||
foreach (var homeWork in homeWorkEntities)
|
||||
{
|
||||
var dto = new SportsDataPushDto
|
||||
if (homeWork.HomeWorkStudents == null || homeWork.HomeWorkStudents.Count == 0)
|
||||
{
|
||||
StudentNo = UserLoginContext.Current.UserNo,
|
||||
SportsItem = AppSettings.JingShiTiJiao.SportsItem,
|
||||
SportsDate = homeWork.StartTime.ToString("yyyy-MM-dd"),
|
||||
SportsService = AppSettings.JingShiTiJiao.Channel,
|
||||
SportsScene = "addhomework",
|
||||
SportsDetail = JsonConvert.SerializeObject(
|
||||
homeWork,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}
|
||||
)
|
||||
};
|
||||
_logger.LogWarning($"作业[{homeWork.Id}] 未关联学生");
|
||||
continue;
|
||||
}
|
||||
|
||||
pushList.Add(dto);
|
||||
foreach (var student in homeWork.HomeWorkStudents)
|
||||
{
|
||||
var dto = new SportsDataPushDto
|
||||
{
|
||||
// 👉 每个学生一条
|
||||
StudentNo = student.StudentNo,
|
||||
|
||||
SportsItem = AppSettings.JingShiTiJiao.SportsItem,
|
||||
SportsDate = homeWork.StartTime.ToString("yyyy-MM-dd"),
|
||||
SportsService = AppSettings.JingShiTiJiao.Channel,
|
||||
SportsScene = "addhomework",
|
||||
|
||||
// 👉 只序列化当前作业 + 当前学生
|
||||
SportsDetail = JsonConvert.SerializeObject(
|
||||
student,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
pushList.Add(dto);
|
||||
}
|
||||
}
|
||||
|
||||
if (pushList.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("作业同步任务中,没有可推送的数据");
|
||||
return;
|
||||
}
|
||||
|
||||
var res = await _jingShiTiJiaoService.PushSportsData(pushList);
|
||||
@ -160,6 +179,7 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
||||
_logger.LogError(ex, "作业数据上传失败");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -78,6 +78,7 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 根据班级编号获取学生列表
|
||||
/// </summary>
|
||||
/// <param name="classNo"></param>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -12,7 +13,7 @@ namespace YD_WeChatApplet.Api.SmartSportsEntitys
|
||||
/// 作业学生表
|
||||
/// </summary>
|
||||
[Table("S_HomeWorkStudents")]
|
||||
public class S_HomeWorkStudents
|
||||
public class S_HomeWorkStudents
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
@ -100,6 +101,7 @@ namespace YD_WeChatApplet.Api.SmartSportsEntitys
|
||||
/// <summary>
|
||||
/// 导航属性
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public S_HomeWork HomeWork { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user