|
|
@ -1196,8 +1196,23 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
ent.UpdateIP = ip; |
|
|
|
ent.UpdateIP = ip; |
|
|
|
ent.UpdateProg = api; |
|
|
|
ent.UpdateProg = api; |
|
|
|
|
|
|
|
|
|
|
|
if (entity.Status == DIC_EXAM_STATUS.RELEASED && status == DIC_EXAM_STATUS.DRAFT && await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == DIC_EXAM_RECORD_STATUS.EXAMING)) |
|
|
|
if (entity.Status == DIC_EXAM_STATUS.RELEASED && status == DIC_EXAM_STATUS.DRAFT) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.ExamId == id && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.NO_JOIN)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed("已有学员正在学习,不可取消发布!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == DIC_EXAM_RECORD_STATUS.EXAMING)) |
|
|
|
return ServiceResult.OprateFailed("已有学员参与考试,不可取消发布!"); |
|
|
|
return ServiceResult.OprateFailed("已有学员参与考试,不可取消发布!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.Status == DIC_EXAM_STATUS.RELEASED && status == DIC_EXAM_STATUS.DISABLED) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.ExamId == id && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.NO_JOIN)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed("已有学员正在学习,不可归档!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == DIC_EXAM_RECORD_STATUS.EXAMING)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed("已有学员参与考试,不可归档!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (entity.Status == DIC_EXAM_STATUS.DISABLED && status == DIC_EXAM_STATUS.RELEASED) |
|
|
|
if (entity.Status == DIC_EXAM_STATUS.DISABLED && status == DIC_EXAM_STATUS.RELEASED) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1315,9 +1330,9 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
JoinTime = courseTime, |
|
|
|
JoinTime = courseTime, |
|
|
|
CourseBeginTime = courseTime.Date, |
|
|
|
CourseBeginTime = courseTime.Date, |
|
|
|
CourseEndTime = courseEndTime, |
|
|
|
CourseEndTime = courseEndTime, |
|
|
|
CourseType = Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED, |
|
|
|
CourseType = DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED, |
|
|
|
CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN, |
|
|
|
CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN, |
|
|
|
StudyStatus = Consts.DicStudyRecordStudyStatus.NO_JOIN |
|
|
|
StudyStatus = DIC_STUDY_RECORD_STUDY_STATUS.NO_JOIN |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (inserts.Any()) |
|
|
|
if (inserts.Any()) |
|
|
@ -1325,7 +1340,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
if (status == Consts.DIC_EXAM_STATUS.RELEASED || status == Consts.DIC_EXAM_STATUS.DISABLED || status == Consts.DIC_EXAM_STATUS.DRAFT) |
|
|
|
if (status == DIC_EXAM_STATUS.RELEASED || status == DIC_EXAM_STATUS.DISABLED || status == DIC_EXAM_STATUS.DRAFT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
entity.Status = status; |
|
|
|
entity.Status = status; |
|
|
|
entities.Add(entity); |
|
|
|
entities.Add(entity); |
|
|
@ -1333,9 +1348,9 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var result = await BaseDal.Update(entities); |
|
|
|
var result = await BaseDal.Update(entities); |
|
|
|
if (status == Consts.DIC_EXAM_STATUS.RELEASED) |
|
|
|
if (status == DIC_EXAM_STATUS.RELEASED) |
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
else if (status == Consts.DIC_EXAM_STATUS.DRAFT) |
|
|
|
else if (status == DIC_EXAM_STATUS.DRAFT) |
|
|
|
return ServiceResult.OprateSuccess("取消发布成功!"); |
|
|
|
return ServiceResult.OprateSuccess("取消发布成功!"); |
|
|
|
else |
|
|
|
else |
|
|
|
return ServiceResult.OprateSuccess("归档成功!"); |
|
|
|
return ServiceResult.OprateSuccess("归档成功!"); |
|
|
@ -1587,13 +1602,91 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
public async Task<ServiceResult> ExecuteExamOver() |
|
|
|
public async Task<ServiceResult> ExecuteExamOver() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var now = Db.GetDate(); |
|
|
|
var now = Db.GetDate(); |
|
|
|
var exams = await Db.Queryable<Ghre_Exam>().Where(x => |
|
|
|
|
|
|
|
x.DateType == DicExamDateType.EXAM_DATE && |
|
|
|
var exams = await Db.Queryable<Ghre_Exam>().Where(x => x.Status == DIC_EXAM_STATUS.RELEASED && |
|
|
|
x.Status == DIC_EXAM_STATUS.RELEASED && |
|
|
|
((x.DateType == DicExamDateType.EXAM_DATE && x.EndTime != null && x.EndTime.Value.Date == now.Date.AddDays(-1)) || x.DateType == DicExamDateType.AFTER_HOW_LONG) |
|
|
|
x.EndTime !=null&& |
|
|
|
|
|
|
|
x.EndTime.Value.Date== now |
|
|
|
|
|
|
|
).ToListAsync(); |
|
|
|
).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("提交成功!"); |
|
|
|
for (int i = 0; i < exams.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var exam = exams[i]; |
|
|
|
|
|
|
|
//if (await Db.Queryable<Ghre_ExamPaper>().Where(x => x.ScoreMethod == DIC_EXAM_PAPER_SCORE_METHOD.MANUAL && x.Id == exam.ExamPaperId).AnyAsync()) |
|
|
|
|
|
|
|
// continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var studyRecords = new List<Ghre_StudyRecord>(); |
|
|
|
|
|
|
|
if (exam.DateType == DicExamDateType.EXAM_DATE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#region 固定日期 |
|
|
|
|
|
|
|
studyRecords = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => x.ExamId == exam.Id && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH) |
|
|
|
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#region 考完周期 |
|
|
|
|
|
|
|
exam.AfterHowLong = (exam.AfterHowLong ?? 7) + 1; |
|
|
|
|
|
|
|
var examEndDt = now.AddDays(-exam.AfterHowLong.Value); |
|
|
|
|
|
|
|
studyRecords = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => |
|
|
|
|
|
|
|
x.ExamId == exam.Id && |
|
|
|
|
|
|
|
x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && |
|
|
|
|
|
|
|
x.CourseEndTime != null && |
|
|
|
|
|
|
|
x.CourseEndTime.Value.Date == examEndDt.Date) |
|
|
|
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var inserts = new List<Ghre_ExamRecord>(); |
|
|
|
|
|
|
|
var updates = new List<Ghre_ExamRecord>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (studyRecords.Any()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < studyRecords.Count; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
studyRecords[j].StudyStatus = DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH; |
|
|
|
|
|
|
|
studyRecords[j].RemarkSz = "考试结束自动关闭!"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var examRecord = await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == studyRecords[j].Id && x.ExamId == exam.Id).FirstAsync(); |
|
|
|
|
|
|
|
if (examRecord.IsNull()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
inserts.Add(new Ghre_ExamRecord() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Id = SnowFlakeSingle.Instance.NextId(), |
|
|
|
|
|
|
|
ExamId = exam.Id, |
|
|
|
|
|
|
|
StudyRecordId = studyRecords[j].Id, |
|
|
|
|
|
|
|
StaffId = studyRecords[j].StaffId, |
|
|
|
|
|
|
|
CourseSnapId = studyRecords[j].CourseSnapId, |
|
|
|
|
|
|
|
ExamPaperId = exam.ExamPaperId, |
|
|
|
|
|
|
|
ExamDate = DateTime.Now.Date.AddDays(-1), |
|
|
|
|
|
|
|
RetakeTimes = 0, |
|
|
|
|
|
|
|
Score = 0, |
|
|
|
|
|
|
|
AdjustScore = 0, |
|
|
|
|
|
|
|
IsPass = false, |
|
|
|
|
|
|
|
Comment = "考试结束自动出分!", |
|
|
|
|
|
|
|
Status = DIC_EXAM_RECORD_STATUS.SYSTEM_END, |
|
|
|
|
|
|
|
ScoreStatus = DIC_EXAM_RECORD_SCORE_STATUS.HAS_SCORE, |
|
|
|
|
|
|
|
BeginTime = exam.DateType == DicExamDateType.EXAM_DATE ? exam.BeginTime : DateTime.Now.Date.AddDays(-exam.AfterHowLong.Value), |
|
|
|
|
|
|
|
EndTime = exam.DateType == DicExamDateType.EXAM_DATE ? exam.EndTime : DateTime.Now.Date.AddDays(-1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
examRecord.Score = 0; |
|
|
|
|
|
|
|
examRecord.AdjustScore = 0; |
|
|
|
|
|
|
|
examRecord.Status = DIC_EXAM_RECORD_STATUS.SYSTEM_END; |
|
|
|
|
|
|
|
examRecord.ScoreStatus = DIC_EXAM_RECORD_SCORE_STATUS.HAS_SCORE; |
|
|
|
|
|
|
|
examRecord.IsPass = false; |
|
|
|
|
|
|
|
examRecord.Comment = "考试结束自动出分!"; |
|
|
|
|
|
|
|
updates.Add(examRecord); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Db.Insertable(inserts).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
await Db.Updateable(updates).UpdateColumns(it => new { it.Score, it.AdjustScore, it.Status, it.ScoreStatus, it.IsPass, it.Comment }).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
await Db.Updateable(studyRecords).UpdateColumns(it => new { it.StudyStatus, it.RemarkSz }).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("执行成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |