|
|
|
@ -375,50 +375,27 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
{ |
|
|
|
|
var examRecord = await Db.Queryable<Ghre_ExamRecord>().FirstAsync(x => x.StudyRecordId == id); |
|
|
|
|
|
|
|
|
|
if (examRecord != null) |
|
|
|
|
if (!examRecord.IsNull()) |
|
|
|
|
examRecordId = examRecord.Id; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
var studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == id); |
|
|
|
|
//string sql = @$"SELECT A.StaffId, |
|
|
|
|
// A.Source, |
|
|
|
|
// A.ExamId, |
|
|
|
|
// B.Id, |
|
|
|
|
// B.LinkType, |
|
|
|
|
// B.CourseId, |
|
|
|
|
// B.CourseSceneId, |
|
|
|
|
// B.ExamPaperId, |
|
|
|
|
// B.CoverUrl, |
|
|
|
|
// B.ExamNo, |
|
|
|
|
// B.ExamName, |
|
|
|
|
// B.DateType, |
|
|
|
|
// B.BeginTime, |
|
|
|
|
// B.EndTime, |
|
|
|
|
// B.AfterHowLong, |
|
|
|
|
// B.ExamMode, |
|
|
|
|
// B.ExamPlace, |
|
|
|
|
// B.IsLinkOpenClass, |
|
|
|
|
// B.OpenClassId, |
|
|
|
|
// B.Status |
|
|
|
|
// FROM Ghre_ExamStaff A |
|
|
|
|
// JOIN Ghre_Exam B |
|
|
|
|
// ON A.ExamId = B.Id |
|
|
|
|
// AND B.Status = 'Released' |
|
|
|
|
// AND A.IsEnable = B.IsEnable |
|
|
|
|
// AND B.CourseId = '{studyRecord.CourseId}' |
|
|
|
|
// WHERE A.IsEnable = 1 |
|
|
|
|
// AND ( B.DateType = 'AfterHowLong' |
|
|
|
|
// OR ( B.DateType = 'ExamDate' |
|
|
|
|
// AND B.BeginTime >= GETDATE () |
|
|
|
|
// AND B.EndTime <= GETDATE ())) |
|
|
|
|
// AND A.StaffId = {studyRecord.StaffId}"; |
|
|
|
|
|
|
|
|
|
var exam = await Db.Queryable<Ghre_Exam>() |
|
|
|
|
.Where(x => x.Id == studyRecord.ExamId) |
|
|
|
|
.FirstAsync(x => x.Status == Consts.DicExamStatus.RELEASED); |
|
|
|
|
if (exam is null) |
|
|
|
|
return ServiceResult<QueryExam>.OprateFailed("该门课程无需考试!"); |
|
|
|
|
if (exam.IsNull()) |
|
|
|
|
exam = await Db.Queryable<Ghre_Exam>() |
|
|
|
|
.Where(x => x.Status == Consts.DicExamStatus.RELEASED |
|
|
|
|
&& ((x.DateType == Consts.DicExamDateType.EXAM_DATE |
|
|
|
|
&& x.BeginTime.Value.Date <= DateTime.Now.Date && x.EndTime.Value.Date >= DateTime.Now.Date) || x.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)) |
|
|
|
|
.WhereIF(!studyRecord.CourseId.IsNull(), x => x.CourseId == studyRecord.CourseId) |
|
|
|
|
.WhereIF(!studyRecord.CourseSceneId.IsNull(), x => x.CourseSceneId == studyRecord.CourseSceneId) |
|
|
|
|
.FirstAsync(); |
|
|
|
|
|
|
|
|
|
if (exam.IsNull()) |
|
|
|
|
return ServiceResult<QueryExam>.OprateFailed("该门课程尚未开启考试,清联系HR !"); |
|
|
|
|
|
|
|
|
|
var insrt = new InsertGhre_ExamRecordInput() |
|
|
|
|
{ |
|
|
|
@ -435,12 +412,17 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
EndTime = exam.EndTime |
|
|
|
|
}; |
|
|
|
|
examRecordId = await base.Add(insrt); |
|
|
|
|
|
|
|
|
|
if (studyRecord.ExamId.IsNull()) |
|
|
|
|
{ |
|
|
|
|
string sql = $@"UPDATE Ghre_StudyRecord SET ExamId={exam.Id} WHERE Id='{studyRecord.Id}'; "; |
|
|
|
|
await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (examRecordId == 0) examRecordId = id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var records = await QueryFilterPage(body, $"Id='{examRecordId}'"); |
|
|
|
|
|
|
|
|
|
if (!records.result.DT_TableDataT1.Any()) |
|
|
|
@ -569,10 +551,10 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
//extend.RemainingSecond = Convert.ToInt32(timeDifference.TotalSeconds); |
|
|
|
|
//if (extend.RemainingSecond < 0) extend.RemainingSecond = 0; |
|
|
|
|
extend.RemainingSecond = 3600; |
|
|
|
|
if (exampaper.AnswerTime != null) |
|
|
|
|
if (!exampaper.AnswerTime.IsNull()) |
|
|
|
|
extend.RemainingSecond = exampaper.AnswerTime.Value * 60; |
|
|
|
|
|
|
|
|
|
if (record.ActualEndTime != null) |
|
|
|
|
if (!record.ActualEndTime.IsNull()) |
|
|
|
|
{ |
|
|
|
|
TimeSpan timeDifference = record.ActualEndTime.Value - record.ActualBeginTime.Value; |
|
|
|
|
|
|
|
|
|