master
xiaochanghai 11 months ago
parent 6345ff82d3
commit e67a52fd21
  1. 29
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs
  2. 11
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

@ -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

@ -241,6 +241,15 @@ namespace Tiobon.Core.Services
continue;
}
if (name == "CourseType")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
var value1 = jsonParam.columnValue;
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
continue;
}
if (!string.IsNullOrWhiteSpace(value))
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
@ -372,6 +381,8 @@ namespace Tiobon.Core.Services
LEFT JOIN Ghre_CourseScene G ON A.CourseSceneId = G.Id
WHERE A.Id = '{id}'";
course = await Db.Ado.SqlQuerySingleAsync<Ghre_StudyRecordCourse>(sql);
if (course.IsNull())
return ServiceResult<Ghre_StudyRecordCourse>.OprateFailed("无效的学习记录ID!");
if (course.CourseSceneId.IsNull())
{

Loading…
Cancel
Save