|
|
|
@ -16,6 +16,7 @@ using Tiobon.Core.Common.UserManager; |
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
|
using Tiobon.Core.Common.DB.Dapper; |
|
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
|
using System.Data; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -716,19 +717,19 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
{ |
|
|
|
|
x.ExamName = x.ExamName + "(" + x.ExamNo + ")"; |
|
|
|
|
|
|
|
|
|
if (x.Status == Consts.DIC_EXAM_STATUS_RELEASED || x.Status == Consts.DIC_EXAM_STATUS_DISABLED) |
|
|
|
|
if (x.Status == Consts.DicExamStatus.RELEASED || x.Status == Consts.DicExamStatus.DISABLED) |
|
|
|
|
{ |
|
|
|
|
x.canEdit = 0; |
|
|
|
|
x.canDelete = 0; |
|
|
|
|
} |
|
|
|
|
if (x.Status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
|
if (x.Status == Consts.DicExamStatus.DRAFT) |
|
|
|
|
{ |
|
|
|
|
x.showLink = 0; |
|
|
|
|
x.showResult = 0; |
|
|
|
|
x.canClose = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (x.Status == Consts.DIC_EXAM_STATUS_DISABLED) |
|
|
|
|
if (x.Status == Consts.DicExamStatus.DISABLED) |
|
|
|
|
{ |
|
|
|
|
x.canClose = 0; |
|
|
|
|
x.canPreview = 0; |
|
|
|
@ -1070,15 +1071,17 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
if (id == 0) |
|
|
|
|
{ |
|
|
|
|
if (string.IsNullOrEmpty(pageData.Status)) |
|
|
|
|
pageData.Status = Consts.DIC_EXAM_STATUS_DRAFT; |
|
|
|
|
pageData.Status = Consts.DicExamStatus.DRAFT; |
|
|
|
|
var insert = Mapper.Map(pageData).ToANew<InsertGhre_ExamInput>(); |
|
|
|
|
id = await base.Add(insert); |
|
|
|
|
|
|
|
|
|
var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput() |
|
|
|
|
var insertStaffs = pageData.staffTableData |
|
|
|
|
.Where(x => x.DataSource == "Manual") |
|
|
|
|
.Select(x => new InsertGhre_ExamStaffInput() |
|
|
|
|
{ |
|
|
|
|
ExamId = id, |
|
|
|
|
StaffId = x.StaffID, |
|
|
|
|
Source = x.DataSource |
|
|
|
|
Source = "Manual" |
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
await _ghre_ExamStaffServices.Add(insertStaffs); |
|
|
|
@ -1097,12 +1100,12 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
} |
|
|
|
|
var insert = Mapper.Map(pageData).ToANew<EditGhre_ExamInput>(); |
|
|
|
|
await base.Update(id, insert); |
|
|
|
|
await _ghre_ExamStaffServices.Delete(x => x.ExamId == id); |
|
|
|
|
var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput() |
|
|
|
|
await _ghre_ExamStaffServices.Delete(x => x.ExamId == id && x.Source == "Manual"); |
|
|
|
|
var insertStaffs = pageData.staffTableData.Where(x => x.DataSource == "Manual").Select(x => new InsertGhre_ExamStaffInput() |
|
|
|
|
{ |
|
|
|
|
ExamId = id, |
|
|
|
|
StaffId = x.StaffID, |
|
|
|
|
Source = x.DataSource |
|
|
|
|
Source = "Manual" |
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
await _ghre_ExamStaffServices.Add(insertStaffs); |
|
|
|
@ -1114,7 +1117,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
public async Task<ServiceResult> UpdateStatus(long[] ids, string status) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
|
if (status == Consts.DicExamStatus.DRAFT) |
|
|
|
|
{ |
|
|
|
|
string sql = $@"SELECT A.RoleId, B.RoleNo, B.RoleName
|
|
|
|
|
FROM Ghrs_UserRole A LEFT JOIN Ghrs_Role B ON A.RoleId = B.RoleId |
|
|
|
@ -1127,7 +1130,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
return ServiceResult.OprateFailed("暂无取消发布权限!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (status != Consts.DIC_EXAM_STATUS_RELEASED && status != Consts.DIC_EXAM_STATUS_DISABLED && status != Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
|
if (status != Consts.DicExamStatus.RELEASED && status != Consts.DicExamStatus.DISABLED && status != Consts.DicExamStatus.DRAFT) |
|
|
|
|
throw new Exception("无效的状态"); |
|
|
|
|
|
|
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
|
@ -1146,10 +1149,10 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
ent.UpdateIP = ip; |
|
|
|
|
ent.UpdateProg = api; |
|
|
|
|
|
|
|
|
|
if (entity.Status == Consts.DIC_EXAM_STATUS_RELEASED && status == Consts.DIC_EXAM_STATUS_DRAFT && await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == "UnderWay")) |
|
|
|
|
if (entity.Status == Consts.DicExamStatus.RELEASED && status == Consts.DicExamStatus.DRAFT && await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == "UnderWay")) |
|
|
|
|
return ServiceResult.OprateFailed("已有学员参与考试,不可取消发布!"); |
|
|
|
|
|
|
|
|
|
if (entity.Status == Consts.DIC_EXAM_STATUS_DISABLED && status == Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
|
if (entity.Status == Consts.DicExamStatus.DISABLED && status == Consts.DicExamStatus.RELEASED) |
|
|
|
|
{ |
|
|
|
|
if (entity.LinkType == "CourseId") |
|
|
|
|
{ |
|
|
|
@ -1157,21 +1160,21 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
if (course is null) |
|
|
|
|
return ServiceResult.OprateFailed("该考试关联的课程已被删除,暂不可取消归档!"); |
|
|
|
|
|
|
|
|
|
if (course.Status != Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
|
return ServiceResult.OprateFailed($"该考试关联的课程【{course.CourseName}({course.CourseNo})】状态为【{(course.Status == Consts.DIC_EXAM_STATUS_DISABLED ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
|
if (course.Status != Consts.DicExamStatus.RELEASED) |
|
|
|
|
return ServiceResult.OprateFailed($"该考试关联的课程【{course.CourseName}({course.CourseNo})】状态为【{(course.Status == Consts.DicExamStatus.DISABLED ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var examPaper = await _ghre_ExamPaperServices.QueryById(entity.ExamPaperId); |
|
|
|
|
if (examPaper is null) |
|
|
|
|
return ServiceResult.OprateFailed("该考试关联的试卷已被删除,暂不可取消归档!"); |
|
|
|
|
if (examPaper.Status != Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
|
return ServiceResult.OprateFailed($"该考试关联的试卷【{examPaper.PaperName}({examPaper.PaperNo})】状态为【{(examPaper.Status == Consts.DIC_EXAM_STATUS_DISABLED ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
|
if (examPaper.Status != Consts.DicExamStatus.RELEASED) |
|
|
|
|
return ServiceResult.OprateFailed($"该考试关联的试卷【{examPaper.PaperName}({examPaper.PaperNo})】状态为【{(examPaper.Status == Consts.DicExamStatus.DISABLED ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (entity.LinkType == Consts.DIC_EXAM_LINK_TYPE_COURSE) |
|
|
|
|
{ |
|
|
|
|
#region 校验同一个课程下 考试时间不允许重叠 |
|
|
|
|
var exams = await base.Query(x => x.Status == Consts.DIC_EXAM_STATUS_RELEASED && x.CourseId == entity.CourseId && x.Id != id); |
|
|
|
|
var exams = await base.Query(x => x.Status == Consts.DicExamStatus.RELEASED && x.CourseId == entity.CourseId && x.Id != id); |
|
|
|
|
if (exams.Any()) |
|
|
|
|
for (int i = 0; i < exams.Count; i++) |
|
|
|
|
{ |
|
|
|
@ -1195,7 +1198,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#region 校验同一个课程场景下 考试时间不允许重叠 |
|
|
|
|
var exams = await base.Query(x => x.Status == Consts.DIC_EXAM_STATUS_RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id); |
|
|
|
|
var exams = await base.Query(x => x.Status == Consts.DicExamStatus.RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id); |
|
|
|
|
if (exams.Any()) |
|
|
|
|
for (int i = 0; i < exams.Count; i++) |
|
|
|
|
{ |
|
|
|
@ -1214,8 +1217,39 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region 生成学习记录 |
|
|
|
|
if (status == Consts.DicExamStatus.RELEASED && entity.Status == Consts.DicExamStatus.DRAFT) |
|
|
|
|
{ |
|
|
|
|
var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id && x.Source == "Manual"); |
|
|
|
|
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, |
|
|
|
|
CourseEndTime = courseTime.AddMonths(3), |
|
|
|
|
CourseType = "ManualRequired", |
|
|
|
|
CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN, |
|
|
|
|
StudyStatus = Consts.DIC_STUDY_RECORD_STUDY_STATUS_NO_JOIN |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (inserts.Any()) |
|
|
|
|
await Db.Insertable(inserts).ExecuteReturnSnowflakeIdListAsync(); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (status == Consts.DIC_EXAM_STATUS_RELEASED || status == Consts.DIC_EXAM_STATUS_DISABLED || status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
|
if (status == Consts.DicExamStatus.RELEASED || status == Consts.DicExamStatus.DISABLED || status == Consts.DicExamStatus.DRAFT) |
|
|
|
|
{ |
|
|
|
|
entity.Status = status; |
|
|
|
|
entities.Add(entity); |
|
|
|
@ -1223,9 +1257,9 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = await BaseDal.Update(entities); |
|
|
|
|
if (status == Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
|
if (status == Consts.DicExamStatus.RELEASED) |
|
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
|
else if (status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
|
else if (status == Consts.DicExamStatus.DRAFT) |
|
|
|
|
return ServiceResult.OprateSuccess("取消发布成功!"); |
|
|
|
|
else |
|
|
|
|
return ServiceResult.OprateSuccess("停用成功!"); |
|
|
|
@ -1351,7 +1385,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
{ |
|
|
|
|
var exam = await base.QueryById(id); |
|
|
|
|
var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id); |
|
|
|
|
exam.Status = Consts.DIC_EXAM_STATUS_DRAFT; |
|
|
|
|
exam.Status = Consts.DicExamStatus.DRAFT; |
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(exam).ToANew<InsertGhre_ExamInput>(); |
|
|
|
|
|
|
|
|
|