From e0789936a330ae00e239998d9b9a6c8983c031b8 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Thu, 1 Aug 2024 16:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 23 +++- Tiobon.Core.Model/Consts.cs | 26 ++++- .../Ghre/Ghre_ExamRecordServices.cs | 4 +- .../Ghre/Ghre_ExamServices.cs | 104 ++++++++++-------- .../Ghre/Ghre_StudyRecordServices.cs | 3 +- .../Ghre/Ghre_StudyRuleServices.cs | 8 +- Tiobon.Core/Tiobon.Core.Model.xml | 23 +++- 7 files changed, 129 insertions(+), 62 deletions(-) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 45be744a..486ca850 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -12592,22 +12592,22 @@ 全局常量 - + 考试管理-状态 - + 草稿箱 - + 已发布 - + 已归档 @@ -12637,6 +12637,21 @@ 考试管理-关联类型-場景 + + + 考试管理-人员来源 + + + + + 手动必修 + + + + + 必修规则 + + 培训记录-课程状态-进行中 diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs index aaf25804..33601aa0 100644 --- a/Tiobon.Core.Model/Consts.cs +++ b/Tiobon.Core.Model/Consts.cs @@ -5,12 +5,13 @@ /// public class Consts { + #region 考试管理-日期类型 #region 考试管理-状态 /// /// 考试管理-状态 /// - public static class DicExamStatus + public static class DIC_EXAM_STATUS { /// /// 草稿箱 @@ -56,6 +57,28 @@ public class Consts public const string DIC_EXAM_DATE_TYPE_COURSE_SCENE = "CourseSceneId"; #endregion + + #region 考试管理-人员来源 + /// + /// 考试管理-人员来源 + /// + public static class DIC_EXAM_STAFF_SOURCE + { + /// + /// 手动必修 + /// + public const string MANUAL_REQUIRED = "ManualRequired"; + /// + /// 必修规则 + /// + public const string STUDY_RULE_REQUIRED = "StudyRuleRequired"; + + } + #endregion + + #endregion + + #region 培训记录-课程状态 /// @@ -89,7 +112,6 @@ public class Consts #endregion - #region 考试记录 #region 考试记录-状态 diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs index 95fc3335..35eeafa1 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs @@ -384,10 +384,10 @@ public class Ghre_ExamRecordServices : BaseServices() .Where(x => x.Id == studyRecord.ExamId) - .FirstAsync(x => x.Status == Consts.DicExamStatus.RELEASED); + .FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED); if (exam.IsNull()) exam = await Db.Queryable() - .Where(x => x.Status == Consts.DicExamStatus.RELEASED + .Where(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED && ((x.DateType == Consts.DicExamDateType.EXAM_DATE && x.BeginTime.Value.Date <= DateTime.Now.Date && x.EndTime.Value.Date >= DateTime.Now.Date) || x.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)) .WhereIF(!studyRecord.CourseId.IsNull(), x => x.CourseId == studyRecord.CourseId) diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 755b09f2..4e94215c 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -17,6 +17,7 @@ using MongoDB.Driver.Linq; using Tiobon.Core.Common.DB.Dapper; using Tiobon.Core.Common.Helper; using System.Data; +using Snappier; namespace Tiobon.Core.Services; @@ -717,19 +718,19 @@ public class Ghre_ExamServices : BaseServices Ids.Contains(x.StaffID)); var data = await Db.Ado.SqlQueryAsync(sql); - //var data = list.Select(x => new StaffTableData() - //{ - // StaffID = x.StaffID, - // StaffNo = x.StaffNo, - // StaffName = x.StaffName, - // Mail = x.Email - //}).ToList(); + data.ForEach(x => + { + if (x.DataSource.IsNull()) + { + x.DataSource = Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED; + x.DataSourceLabel = "手动必修"; + } + }); + return ServiceResult>.OprateSuccess("查询成功!", data); } - - public async Task>> QueryStaff1(long examId) { string sql = @$"SELECT D.Id, @@ -1076,9 +1077,12 @@ public class Ghre_ExamServices : BaseServices(sql); data.ForEach(x => { - if (x.DataSource == "ManualRequired") + if (x.DataSource.IsNull()) + x.DataSource = Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED; + + if (x.DataSource == Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED) x.DataSourceLabel = "手动必修"; - else if (x.DataSource == "StudyRuleRequired") + else if (x.DataSource == Consts.DIC_EXAM_STAFF_SOURCE.STUDY_RULE_REQUIRED) x.DataSourceLabel = "必修规则"; }); @@ -1104,17 +1108,17 @@ public class Ghre_ExamServices : BaseServices(); id = await base.Add(insert); var insertStaffs = pageData.staffTableData - .Where(x => x.DataSource == "Manual") + .Where(x => x.DataSource == Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED) .Select(x => new InsertGhre_ExamStaffInput() { ExamId = id, StaffId = x.StaffID, - Source = "Manual" + Source = x.DataSource ?? Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED }).ToList(); await _ghre_ExamStaffServices.Add(insertStaffs); @@ -1133,12 +1137,12 @@ public class Ghre_ExamServices : BaseServices(); await base.Update(id, insert); - 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() + await _ghre_ExamStaffServices.Delete(x => x.ExamId == id && (x.Source == Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED || x.Source == null)); + var insertStaffs = pageData.staffTableData.Where(x => x.DataSource == Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED).Select(x => new InsertGhre_ExamStaffInput() { ExamId = id, StaffId = x.StaffID, - Source = "Manual" + Source = x.DataSource ?? Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED }).ToList(); await _ghre_ExamStaffServices.Add(insertStaffs); @@ -1150,7 +1154,7 @@ public class Ghre_ExamServices : BaseServices UpdateStatus(long[] ids, string status) { - if (status == Consts.DicExamStatus.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 @@ -1163,7 +1167,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 == Consts.DicExamStatus.DISABLED && status == Consts.DicExamStatus.RELEASED) + if (entity.Status == Consts.DIC_EXAM_STATUS.DISABLED && status == Consts.DIC_EXAM_STATUS.RELEASED) { if (entity.LinkType == "CourseId") { @@ -1193,30 +1197,29 @@ public class Ghre_ExamServices : BaseServices x.Status == Consts.DicExamStatus.RELEASED && x.CourseId == entity.CourseId && x.Id != id); + 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.DicExamDateType.AFTER_HOW_LONG) - { return ServiceResult.OprateFailed($"课程【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】!"); - } + else if (exam.DateType == Consts.DicExamDateType.EXAM_DATE) { if ((entity.BeginTime >= exam.BeginTime && entity.BeginTime <= exam.EndTime) @@ -1231,19 +1234,21 @@ public class Ghre_ExamServices : BaseServices x.Status == Consts.DicExamStatus.RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id); + 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.DicExamDateType.AFTER_HOW_LONG) - { return ServiceResult.OprateFailed($"课程场景【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】!"); - } + else if (exam.DateType == Consts.DicExamDateType.EXAM_DATE) { - if ((entity.BeginTime >= exam.BeginTime && entity.BeginTime <= exam.EndTime) || (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime)) + 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})】时间重叠!"); } } @@ -1251,10 +1256,11 @@ public class Ghre_ExamServices : BaseServices x.ExamId == id && x.Source == "Manual"); + var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id && x.Source == Consts.DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED); var inserts = new List(); + ; var snap = await Db.Queryable().FirstAsync(x => x.CourseId == entity.CourseId); DateTime courseTime = Db.GetDate(); for (int i = 0; i < staffs.Count; i++) @@ -1269,20 +1275,28 @@ public class Ghre_ExamServices : BaseServices() + .WhereIF(!entity.CourseId.IsNull(), x => x.CourseId == entity.CourseId) + .WhereIF(!entity.CourseSceneId.IsNull(), x => x.CourseSceneId == entity.CourseSceneId) + .Where(x => x.ExamId == null).ToListAsync(); + studyRecords.ForEach(x => x.ExamId = entity.Id); + await Db.Updateable(studyRecords).UpdateColumns(it => new { it.ExamId }).ExecuteCommandAsync(); + #endregion } #endregion - - if (status == Consts.DicExamStatus.RELEASED || status == Consts.DicExamStatus.DISABLED || status == Consts.DicExamStatus.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); @@ -1290,9 +1304,9 @@ public class Ghre_ExamServices : BaseServices x.ExamId == id); - exam.Status = Consts.DicExamStatus.DRAFT; + exam.Status = Consts.DIC_EXAM_STATUS.DRAFT; var insert = Mapper.Map(exam).ToANew(); diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index 5857e64b..924057bd 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -189,7 +189,7 @@ namespace Tiobon.Core.Services A.CourseName, A.StandardHour, A.CreditPoints, - A.CourseEndTime CourseBeginDate, + A.CourseBeginTime CourseBeginDate, A.CourseEndTime CourseEndDate, A.ExamDate, A.ExamBeginDate, @@ -292,6 +292,7 @@ namespace Tiobon.Core.Services x.CourseDateString = DateTimeHelper.ConvertToDayString(x.CourseBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.CourseEndDate); if (x.ExamBeginDate != null && x.ExamEndDate != null) x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.ExamEndDate); + else x.ExamDateString = $"学完{x.AfterHowLong}天"; }); return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index 8016be21..4d3839f3 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -200,7 +200,7 @@ public class Ghre_StudyRuleServices : BaseServices().FirstAsync(x => x.Id == ruleId); - + var ruleStaffs = await Db.Queryable().Where(x => x.StudyRuleId == ruleId).ToListAsync(); await Db.Updateable().Where(x => x.StudyRuleId == ruleId && x.IsEnable == 1) @@ -238,7 +238,7 @@ public class Ghre_StudyRuleServices : BaseServices x.Status == Consts.DicExamStatus.RELEASED); var exam = await Db.Queryable() - .Where(x => x.Status == Consts.DicExamStatus.RELEASED + .Where(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED && ((x.DateType == Consts.DicExamDateType.EXAM_DATE && x.BeginTime.Value.Date <= DateTime.Now.Date && x.EndTime.Value.Date >= DateTime.Now.Date) || x.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)) .WhereIF(!rule.CourseId.IsNull(), x => x.CourseId == rule.CourseId) @@ -266,8 +266,8 @@ public class Ghre_StudyRuleServices : BaseServices - + 考试管理-状态 - + 草稿箱 - + 已发布 - + 已归档 @@ -12637,6 +12637,21 @@ 考试管理-关联类型-場景 + + + 考试管理-人员来源 + + + + + 手动必修 + + + + + 必修规则 + + 培训记录-课程状态-进行中