|
|
@ -716,19 +716,19 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
{ |
|
|
|
{ |
|
|
|
x.ExamName = x.ExamName + "(" + x.ExamNo + ")"; |
|
|
|
x.ExamName = x.ExamName + "(" + x.ExamNo + ")"; |
|
|
|
|
|
|
|
|
|
|
|
if (x.Status == "Released" || x.Status == "Disabled") |
|
|
|
if (x.Status == Consts.DIC_EXAM_STATUS_RELEASED || x.Status == Consts.DIC_EXAM_STATUS_DISABLED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
x.canEdit = 0; |
|
|
|
x.canEdit = 0; |
|
|
|
x.canDelete = 0; |
|
|
|
x.canDelete = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
if (x.Status == "Draft") |
|
|
|
if (x.Status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
x.showLink = 0; |
|
|
|
x.showLink = 0; |
|
|
|
x.showResult = 0; |
|
|
|
x.showResult = 0; |
|
|
|
x.canClose = 0; |
|
|
|
x.canClose = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (x.Status == "Disabled") |
|
|
|
if (x.Status == Consts.DIC_EXAM_STATUS_DISABLED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
x.canClose = 0; |
|
|
|
x.canClose = 0; |
|
|
|
x.canPreview = 0; |
|
|
|
x.canPreview = 0; |
|
|
@ -763,7 +763,6 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
return new ServicePageResult<Ghre_ExamDto>(filter.pageNum, totalCount, filter.pageSize, data); |
|
|
|
return new ServicePageResult<Ghre_ExamDto>(filter.pageNum, totalCount, filter.pageSize, data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<string>> ExportExcel(QueryExport body, string status) |
|
|
|
public async Task<ServiceResult<string>> ExportExcel(QueryExport body, string status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QueryBody filter = new QueryBody(); |
|
|
|
QueryBody filter = new QueryBody(); |
|
|
@ -811,7 +810,6 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
return ServiceResult<string>.OprateSuccess("导出成功", path); |
|
|
|
return ServiceResult<string>.OprateSuccess("导出成功", path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<DefaultGhre_ExamInput>> QueryDefault(long Id) |
|
|
|
public async Task<ServiceResult<DefaultGhre_ExamInput>> QueryDefault(long Id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var input = new DefaultGhre_ExamInput(); |
|
|
|
var input = new DefaultGhre_ExamInput(); |
|
|
@ -1023,7 +1021,6 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
return ServiceResult<DefaultGhre_ExamInput>.OprateSuccess("查询成功!", input); |
|
|
|
return ServiceResult<DefaultGhre_ExamInput>.OprateSuccess("查询成功!", input); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<List<StaffTableData>>> QueryStaff(List<int> Ids, string type) |
|
|
|
public async Task<ServiceResult<List<StaffTableData>>> QueryStaff(List<int> Ids, string type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string sql = @"SELECT A.StaffID,
|
|
|
|
string sql = @"SELECT A.StaffID,
|
|
|
@ -1073,7 +1070,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
if (id == 0) |
|
|
|
if (id == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(pageData.Status)) |
|
|
|
if (string.IsNullOrEmpty(pageData.Status)) |
|
|
|
pageData.Status = "Draft"; |
|
|
|
pageData.Status = Consts.DIC_EXAM_STATUS_DRAFT; |
|
|
|
var insert = Mapper.Map(pageData).ToANew<InsertGhre_ExamInput>(); |
|
|
|
var insert = Mapper.Map(pageData).ToANew<InsertGhre_ExamInput>(); |
|
|
|
id = await base.Add(insert); |
|
|
|
id = await base.Add(insert); |
|
|
|
|
|
|
|
|
|
|
@ -1117,7 +1114,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
public async Task<ServiceResult> UpdateStatus(long[] ids, string status) |
|
|
|
public async Task<ServiceResult> UpdateStatus(long[] ids, string status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (status == "Draft") |
|
|
|
if (status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string sql = $@"SELECT A.RoleId, B.RoleNo, B.RoleName
|
|
|
|
string sql = $@"SELECT A.RoleId, B.RoleNo, B.RoleName
|
|
|
|
FROM Ghrs_UserRole A LEFT JOIN Ghrs_Role B ON A.RoleId = B.RoleId |
|
|
|
FROM Ghrs_UserRole A LEFT JOIN Ghrs_Role B ON A.RoleId = B.RoleId |
|
|
@ -1130,7 +1127,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
return ServiceResult.OprateFailed("暂无取消发布权限!"); |
|
|
|
return ServiceResult.OprateFailed("暂无取消发布权限!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (status != "Released" && status != "Disabled" && status != "Draft") |
|
|
|
if (status != Consts.DIC_EXAM_STATUS_RELEASED && status != Consts.DIC_EXAM_STATUS_DISABLED && status != Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
throw new Exception("无效的状态"); |
|
|
|
throw new Exception("无效的状态"); |
|
|
|
|
|
|
|
|
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
@ -1149,10 +1146,10 @@ 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 == "Released" && status == "Draft" && await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == "UnderWay")) |
|
|
|
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")) |
|
|
|
return ServiceResult.OprateFailed("已有学员参与考试,不可取消发布!"); |
|
|
|
return ServiceResult.OprateFailed("已有学员参与考试,不可取消发布!"); |
|
|
|
|
|
|
|
|
|
|
|
if (entity.Status == "Disabled" && status == "Released") |
|
|
|
if (entity.Status == Consts.DIC_EXAM_STATUS_DISABLED && status == Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (entity.LinkType == "CourseId") |
|
|
|
if (entity.LinkType == "CourseId") |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1160,19 +1157,65 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
if (course is null) |
|
|
|
if (course is null) |
|
|
|
return ServiceResult.OprateFailed("该考试关联的课程已被删除,暂不可取消归档!"); |
|
|
|
return ServiceResult.OprateFailed("该考试关联的课程已被删除,暂不可取消归档!"); |
|
|
|
|
|
|
|
|
|
|
|
if (course.Status != "Released") |
|
|
|
if (course.Status != Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
return ServiceResult.OprateFailed($"该考试关联的课程【{course.CourseName}({course.CourseNo})】状态为【{(course.Status == "Disabled" ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
return ServiceResult.OprateFailed($"该考试关联的课程【{course.CourseName}({course.CourseNo})】状态为【{(course.Status == Consts.DIC_EXAM_STATUS_DISABLED ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var examPaper = await _ghre_ExamPaperServices.QueryById(entity.ExamPaperId); |
|
|
|
var examPaper = await _ghre_ExamPaperServices.QueryById(entity.ExamPaperId); |
|
|
|
if (examPaper is null) |
|
|
|
if (examPaper is null) |
|
|
|
return ServiceResult.OprateFailed("该考试关联的试卷已被删除,暂不可取消归档!"); |
|
|
|
return ServiceResult.OprateFailed("该考试关联的试卷已被删除,暂不可取消归档!"); |
|
|
|
if (examPaper.Status != "Released") |
|
|
|
if (examPaper.Status != Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
return ServiceResult.OprateFailed($"该考试关联的试卷【{examPaper.PaperName}({examPaper.PaperNo})】状态为【{(examPaper.Status == "Disabled" ? "已停用" : "草稿箱")}】,暂不可取消归档!"); |
|
|
|
return ServiceResult.OprateFailed($"该考试关联的试卷【{examPaper.PaperName}({examPaper.PaperNo})】状态为【{(examPaper.Status == Consts.DIC_EXAM_STATUS_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); |
|
|
|
|
|
|
|
if (exams.Any()) |
|
|
|
|
|
|
|
for (int i = 0; i < exams.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var exam = exams[i]; |
|
|
|
|
|
|
|
var course = await _ghre_CourseServices.QuerySingle(entity.CourseId); |
|
|
|
|
|
|
|
if (exam.DateType != entity.DateType || exam.DateType == Consts.DIC_EXAM_DATE_TYPE_AFTERHOWLONG) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (exam.DateType == Consts.DIC_EXAM_DATE_TYPE_EXAM_DATE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ((entity.BeginTime >= exam.BeginTime && entity.BeginTime <= exam.EndTime) |
|
|
|
|
|
|
|
|| (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime) |
|
|
|
|
|
|
|
|| (exam.EndTime >= entity.BeginTime && exam.EndTime <= entity.EndTime) |
|
|
|
|
|
|
|
|| (exam.EndTime >= entity.BeginTime && exam.EndTime <= entity.EndTime)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】时间重叠!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#region 校验同一个课程场景下 考试时间不允许重叠 |
|
|
|
|
|
|
|
var exams = await base.Query(x => x.Status == Consts.DIC_EXAM_STATUS_RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id); |
|
|
|
|
|
|
|
if (exams.Any()) |
|
|
|
|
|
|
|
for (int i = 0; i < exams.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var exam = exams[i]; |
|
|
|
|
|
|
|
var course = await _ghre_CourseSceneServices.QuerySingle(entity.CourseSceneId); |
|
|
|
|
|
|
|
if (exam.DateType != entity.DateType || exam.DateType == Consts.DIC_EXAM_DATE_TYPE_AFTERHOWLONG) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程场景【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (exam.DateType == Consts.DIC_EXAM_DATE_TYPE_EXAM_DATE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ((entity.BeginTime >= exam.BeginTime && entity.BeginTime <= exam.EndTime) || (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程场景【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】时间重叠!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (status == "Released" || status == "Disabled" || status == "Draft") |
|
|
|
if (status == Consts.DIC_EXAM_STATUS_RELEASED || status == Consts.DIC_EXAM_STATUS_DISABLED || status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
entity.Status = status; |
|
|
|
entity.Status = status; |
|
|
|
entities.Add(entity); |
|
|
|
entities.Add(entity); |
|
|
@ -1180,9 +1223,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 == "Released") |
|
|
|
if (status == Consts.DIC_EXAM_STATUS_RELEASED) |
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
else if (status == "Draft") |
|
|
|
else if (status == Consts.DIC_EXAM_STATUS_DRAFT) |
|
|
|
return ServiceResult.OprateSuccess("取消发布成功!"); |
|
|
|
return ServiceResult.OprateSuccess("取消发布成功!"); |
|
|
|
else |
|
|
|
else |
|
|
|
return ServiceResult.OprateSuccess("停用成功!"); |
|
|
|
return ServiceResult.OprateSuccess("停用成功!"); |
|
|
@ -1308,7 +1351,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
{ |
|
|
|
{ |
|
|
|
var exam = await base.QueryById(id); |
|
|
|
var exam = await base.QueryById(id); |
|
|
|
var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id); |
|
|
|
var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id); |
|
|
|
exam.Status = "Draft"; |
|
|
|
exam.Status = Consts.DIC_EXAM_STATUS_DRAFT; |
|
|
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(exam).ToANew<InsertGhre_ExamInput>(); |
|
|
|
var insert = Mapper.Map(exam).ToANew<InsertGhre_ExamInput>(); |
|
|
|
|
|
|
|
|
|
|
|