|
|
|
@ -13,6 +13,7 @@ using Tiobon.Core.Common.Helper; |
|
|
|
|
using AgileObjects.AgileMapper.Extensions; |
|
|
|
|
using SqlSugar; |
|
|
|
|
using Tiobon.Core.DataAccess; |
|
|
|
|
using System.Data; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -380,42 +381,44 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
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.Ado.SqlQuerySingleAsync<Ghre_Exam>(sql); |
|
|
|
|
//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("该门课程勿需考试!"); |
|
|
|
|
return ServiceResult<QueryExam>.OprateFailed("该门课程无需考试!"); |
|
|
|
|
|
|
|
|
|
var insrt = new InsertGhre_ExamRecordInput() |
|
|
|
|
{ |
|
|
|
@ -427,7 +430,9 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
ExamDate = DateTime.Now.Date, |
|
|
|
|
RetakeTimes = 0, |
|
|
|
|
Status = "Wait", |
|
|
|
|
ScoreStatus = "NoScore" |
|
|
|
|
ScoreStatus = "NoScore", |
|
|
|
|
BeginTime = exam.BeginTime, |
|
|
|
|
EndTime = exam.EndTime |
|
|
|
|
}; |
|
|
|
|
examRecordId = await base.Add(insrt); |
|
|
|
|
} |
|
|
|
@ -560,13 +565,16 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
if (extend.ExamStatus == "ExamEnd") |
|
|
|
|
extend.ScoreOut = false; |
|
|
|
|
|
|
|
|
|
TimeSpan timeDifference = record.EndTime.Value - DateTime.Now; |
|
|
|
|
extend.RemainingSecond = Convert.ToInt32(timeDifference.TotalSeconds); |
|
|
|
|
if (extend.RemainingSecond < 0) extend.RemainingSecond = 0; |
|
|
|
|
//TimeSpan timeDifference = record.EndTime.Value - DateTime.Now; |
|
|
|
|
//extend.RemainingSecond = Convert.ToInt32(timeDifference.TotalSeconds); |
|
|
|
|
//if (extend.RemainingSecond < 0) extend.RemainingSecond = 0; |
|
|
|
|
extend.RemainingSecond = 3600; |
|
|
|
|
if (exampaper.AnswerTime != null) |
|
|
|
|
extend.RemainingSecond = exampaper.AnswerTime.Value * 60; |
|
|
|
|
|
|
|
|
|
if (record.ActualEndTime != null) |
|
|
|
|
{ |
|
|
|
|
timeDifference = record.ActualEndTime.Value - record.ActualBeginTime.Value; |
|
|
|
|
TimeSpan timeDifference = record.ActualEndTime.Value - record.ActualBeginTime.Value; |
|
|
|
|
|
|
|
|
|
extend.UsageTime = $"{timeDifference.Minutes}分{timeDifference.Seconds}秒"; |
|
|
|
|
} |
|
|
|
|