|
|
|
@ -1261,13 +1261,31 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
{ |
|
|
|
|
var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id && x.Source == Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED); |
|
|
|
|
var inserts = new List<Ghre_StudyRecord>(); |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == entity.CourseId); |
|
|
|
|
DateTime courseTime = Db.GetDate(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 自动给学习记录匹配考试ID |
|
|
|
|
var studyRecords = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
.WhereIF(!entity.CourseId.IsNull(), x => x.CourseId == entity.CourseId) |
|
|
|
|
.WhereIF(!entity.CourseSceneId.IsNull(), x => x.CourseSceneId == entity.CourseSceneId) |
|
|
|
|
.Where(x => x.ExamId == null).ToListAsync(); |
|
|
|
|
studyRecords.ForEach(x => x.ExamId = entity.Id); |
|
|
|
|
await Db.Updateable(studyRecords).UpdateColumns(it => new { it.ExamId }).ExecuteCommandAsync(); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < staffs.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var staff = staffs[i]; |
|
|
|
|
|
|
|
|
|
var exist = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
.WhereIF(!entity.CourseId.IsNull(), x => x.CourseId == entity.CourseId) |
|
|
|
|
.WhereIF(!entity.CourseSceneId.IsNull(), x => x.CourseSceneId == entity.CourseSceneId) |
|
|
|
|
.Where(x => x.ExamId == id && x.StaffId == staff.StaffId ).AnyAsync(); |
|
|
|
|
|
|
|
|
|
if (!exist) |
|
|
|
|
inserts.Add(new Ghre_StudyRecord() |
|
|
|
|
{ |
|
|
|
|
StaffId = staff.StaffId, |
|
|
|
@ -1285,15 +1303,6 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
} |
|
|
|
|
if (inserts.Any()) |
|
|
|
|
await Db.Insertable(inserts).ExecuteReturnSnowflakeIdListAsync(); |
|
|
|
|
|
|
|
|
|
#region 自动给学习记录匹配考试ID |
|
|
|
|
var studyRecords = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
.WhereIF(!entity.CourseId.IsNull(), x => x.CourseId == entity.CourseId) |
|
|
|
|
.WhereIF(!entity.CourseSceneId.IsNull(), x => x.CourseSceneId == entity.CourseSceneId) |
|
|
|
|
.Where(x => x.ExamId == null).ToListAsync(); |
|
|
|
|
studyRecords.ForEach(x => x.ExamId = entity.Id); |
|
|
|
|
await Db.Updateable(studyRecords).UpdateColumns(it => new { it.ExamId }).ExecuteCommandAsync(); |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|