From deb064b789ee320e916b17a491500dc0b32ac796 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 29 Jul 2024 17:15:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=96=B0=E5=A2=9E=E6=A0=A1=E9=AA=8C=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=AF=BE=E7=A8=8B/=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=20=E8=80=83=E8=AF=95=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=B8=8D=E5=85=81=E8=AE=B8=E9=87=8D=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 40 +++++++++ Tiobon.Core.Model/Consts.cs | 45 +++++++++++ .../Ghre/Ghre_ExamServices.cs | 81 ++++++++++++++----- 3 files changed, 147 insertions(+), 19 deletions(-) create mode 100644 Tiobon.Core.Model/Consts.cs diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index ab8d79aa..872b7bcc 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -12312,6 +12312,46 @@ 系统用户(Dto.View) + + + 全局常量 + + + + + 考试管理-状态-草稿箱 + + + + + 考试管理-状态-已发布 + + + + + 考试管理-状态-已归档 + + + + + 考试管理-日期类型-考试区间 + + + + + 考试管理-日期类型-学完多久 + + + + + 考试管理-关联类型-課程 + + + + + 考试管理-关联类型-場景 + + 无任何权限 diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs new file mode 100644 index 00000000..87fdf628 --- /dev/null +++ b/Tiobon.Core.Model/Consts.cs @@ -0,0 +1,45 @@ +namespace Tiobon.Core.Model; + +/// +/// 全局常量 +/// +public class Consts +{ + #region 考试管理-状态 + /// + /// 考试管理-状态-草稿箱 + /// + public const string DIC_EXAM_STATUS_DRAFT = "Draft"; + /// + /// 考试管理-状态-已发布 + /// + public const string DIC_EXAM_STATUS_RELEASED = "Released"; + + /// + /// 考试管理-状态-已归档 + /// + public const string DIC_EXAM_STATUS_DISABLED = "Disabled"; + #endregion + + #region 考试管理-日期类型 + /// + /// 考试管理-日期类型-考试区间 + /// + public const string DIC_EXAM_DATE_TYPE_EXAM_DATE = "ExamDate"; + /// + /// 考试管理-日期类型-学完多久 + /// + public const string DIC_EXAM_DATE_TYPE_AFTERHOWLONG = "AfterHowLong"; + #endregion + + #region 考试管理-关联类型 + /// + /// 考试管理-关联类型-課程 + /// + public const string DIC_EXAM_LINK_TYPE_COURSE = "CourseId"; + /// + /// 考试管理-关联类型-場景 + /// + public const string DIC_EXAM_DATE_TYPE_COURSE_SCENE = "CourseSceneId"; + #endregion +} \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 6137d645..2d833d3d 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -716,19 +716,19 @@ public class Ghre_ExamServices : BaseServices(filter.pageNum, totalCount, filter.pageSize, data); } - public async Task> ExportExcel(QueryExport body, string status) { QueryBody filter = new QueryBody(); @@ -811,7 +810,6 @@ public class Ghre_ExamServices : BaseServices.OprateSuccess("导出成功", path); } - public async Task> QueryDefault(long Id) { var input = new DefaultGhre_ExamInput(); @@ -1023,7 +1021,6 @@ public class Ghre_ExamServices : BaseServices.OprateSuccess("查询成功!", input); } - public async Task>> QueryStaff(List Ids, string type) { string sql = @"SELECT A.StaffID, @@ -1073,7 +1070,7 @@ public class Ghre_ExamServices : BaseServices(); id = await base.Add(insert); @@ -1117,7 +1114,7 @@ public class Ghre_ExamServices : BaseServices UpdateStatus(long[] ids, string status) { - if (status == "Draft") + if (status == Consts.DIC_EXAM_STATUS_DRAFT) { string sql = $@"SELECT A.RoleId, B.RoleNo, B.RoleName FROM Ghrs_UserRole A LEFT JOIN Ghrs_Role B ON A.RoleId = B.RoleId @@ -1130,7 +1127,7 @@ public class Ghre_ExamServices : BaseServices 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("已有学员参与考试,不可取消发布!"); - if (entity.Status == "Disabled" && status == "Released") + if (entity.Status == Consts.DIC_EXAM_STATUS_DISABLED && status == Consts.DIC_EXAM_STATUS_RELEASED) { if (entity.LinkType == "CourseId") { @@ -1160,19 +1157,65 @@ public class Ghre_ExamServices : BaseServices 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; entities.Add(entity); @@ -1180,9 +1223,9 @@ public class Ghre_ExamServices : BaseServices x.ExamId == id); - exam.Status = "Draft"; + exam.Status = Consts.DIC_EXAM_STATUS_DRAFT; var insert = Mapper.Map(exam).ToANew();