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

@ -1261,30 +1261,11 @@ 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();
for (int i = 0; i < staffs.Count; i++)
{
var staff = staffs[i];
inserts.Add(new Ghre_StudyRecord()
{
StaffId = staff.StaffId,
ExamId = id,
CourseSnapId = snap?.Id,
CourseId = entity.CourseId,
CourseSceneId = entity.CourseSceneId,
JoinTime = courseTime,
CourseBeginTime = courseTime.Date,
CourseEndTime = courseTime.Date.AddMonths(snap?.ValidityPeriod ?? 1),
CourseType = Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED,
CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN,
StudyStatus = Consts.DicStudyRecordStudyStatus.NO_JOIN
});
}
if (inserts.Any())
await Db.Insertable(inserts).ExecuteReturnSnowflakeIdListAsync();
#region 自动给学习记录匹配考试ID
var studyRecords = await Db.Queryable<Ghre_StudyRecord>()
@ -1294,6 +1275,34 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
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,
ExamId = id,
CourseSnapId = snap?.Id,
CourseId = entity.CourseId,
CourseSceneId = entity.CourseSceneId,
JoinTime = courseTime,
CourseBeginTime = courseTime.Date,
CourseEndTime = courseTime.Date.AddMonths(snap?.ValidityPeriod ?? 1),
CourseType = Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED,
CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN,
StudyStatus = Consts.DicStudyRecordStudyStatus.NO_JOIN
});
}
if (inserts.Any())
await Db.Insertable(inserts).ExecuteReturnSnowflakeIdListAsync();
}
#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