From 024e2bd51f1fe90e966298353447e95ee9e8cc9b Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Thu, 1 Aug 2024 14:07:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=80=83=E8=AF=95=E4=B8=8E?= =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E8=AE=B0=E5=BD=95=E7=BB=91=E5=AE=9A=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 13 ++-- .../Helper/{UtilConvert.cs => UtilHelper.cs} | 36 ++++++++--- Tiobon.Core.Model/Consts.cs | 19 ++++-- .../Ghre/Ghre_ExamRecordServices.cs | 62 +++++++------------ .../Ghre/Ghre_ExamServices.cs | 8 +-- 5 files changed, 77 insertions(+), 61 deletions(-) rename Tiobon.Core.Common/Helper/{UtilConvert.cs => UtilHelper.cs} (91%) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 8953e5b7..3ba97531 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -12612,14 +12612,19 @@ 已归档 - + - 考试管理-日期类型-考试区间 + 考试管理-日期类型 - + - 考试管理-日期类型-学完多久 + 时间区间 + + + + + 学完多久 diff --git a/Tiobon.Core.Common/Helper/UtilConvert.cs b/Tiobon.Core.Common/Helper/UtilHelper.cs similarity index 91% rename from Tiobon.Core.Common/Helper/UtilConvert.cs rename to Tiobon.Core.Common/Helper/UtilHelper.cs index a242d2f3..9cde33e2 100644 --- a/Tiobon.Core.Common/Helper/UtilConvert.cs +++ b/Tiobon.Core.Common/Helper/UtilHelper.cs @@ -1,14 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Tiobon.Core { /// /// /// - public static class UtilConvert + public static class UtilHelper { /// /// @@ -247,7 +244,7 @@ namespace Tiobon.Core { Type innerType = type.GetGenericArguments()[0]; object innerValue = ChangeType(value, innerType); - return Activator.CreateInstance(type, new object[] {innerValue}); + return Activator.CreateInstance(type, new object[] { innerValue }); } if (value is string && type == typeof(Guid)) return new Guid(value as string); @@ -290,7 +287,7 @@ namespace Tiobon.Core .Remove(split.Length - 2, 1); } - addMethod.Invoke(lis, new object[] {ChangeType(str, type)}); + addMethod.Invoke(lis, new object[] { ChangeType(str, type) }); } } @@ -308,5 +305,30 @@ namespace Tiobon.Core return source.Any() && source.All(s => s != null); } + + public static bool IsNull(this long? thisValue) + { + return thisValue is null; + } + public static bool IsNull(this int? thisValue) + { + return thisValue is null; + } + public static bool IsNull(this decimal? thisValue) + { + return thisValue is null; + } + public static bool IsNull(this string thisValue) + { + return string.IsNullOrWhiteSpace(thisValue); + } + public static bool IsNull(this DateTime? thisValue) + { + return thisValue is null; + } + public static bool IsNull(this T entity) where T : class + { + return entity == null; + } } } \ No newline at end of file diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs index 97111315..c6ff9829 100644 --- a/Tiobon.Core.Model/Consts.cs +++ b/Tiobon.Core.Model/Consts.cs @@ -30,13 +30,19 @@ public class Consts #region 考试管理-日期类型 /// - /// 考试管理-日期类型-考试区间 + /// 考试管理-日期类型 /// - public const string DIC_EXAM_DATE_TYPE_EXAM_DATE = "ExamDate"; - /// - /// 考试管理-日期类型-学完多久 - /// - public const string DIC_EXAM_DATE_TYPE_AFTERHOWLONG = "AfterHowLong"; + public static class DicExamDateType + { + /// + /// 时间区间 + /// + public const string EXAM_DATE = "ExamDate"; + /// + /// 学完多久 + /// + public const string AFTER_HOW_LONG = "AfterHowLong"; + } #endregion #region 考试管理-关联类型 @@ -82,4 +88,5 @@ public class Consts public const string DIC_STUDY_RECORD_STUDY_STATUS_HAS_FINISH = "HasFinish"; #endregion + } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs index 8d20260d..3cfa00e9 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs @@ -375,50 +375,27 @@ public class Ghre_ExamRecordServices : BaseServices().FirstAsync(x => x.StudyRecordId == id); - if (examRecord != null) + if (!examRecord.IsNull()) examRecordId = examRecord.Id; else { var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == id); - //string sql = @$"SELECT A.StaffId, - // A.Source, - // A.ExamId, - // B.Id, - // B.LinkType, - // B.CourseId, - // B.CourseSceneId, - // B.ExamPaperId, - // B.CoverUrl, - // B.ExamNo, - // B.ExamName, - // B.DateType, - // B.BeginTime, - // B.EndTime, - // B.AfterHowLong, - // B.ExamMode, - // B.ExamPlace, - // B.IsLinkOpenClass, - // B.OpenClassId, - // B.Status - // FROM Ghre_ExamStaff A - // JOIN Ghre_Exam B - // ON A.ExamId = B.Id - // AND B.Status = 'Released' - // AND A.IsEnable = B.IsEnable - // AND B.CourseId = '{studyRecord.CourseId}' - // WHERE A.IsEnable = 1 - // AND ( B.DateType = 'AfterHowLong' - // OR ( B.DateType = 'ExamDate' - // AND B.BeginTime >= GETDATE () - // AND B.EndTime <= GETDATE ())) - // AND A.StaffId = {studyRecord.StaffId}"; var exam = await Db.Queryable() - .Where(x => x.Id == studyRecord.ExamId) - .FirstAsync(x => x.Status == Consts.DicExamStatus.RELEASED); - if (exam is null) - return ServiceResult.OprateFailed("该门课程无需考试!"); + .Where(x => x.Id == studyRecord.ExamId) + .FirstAsync(x => x.Status == Consts.DicExamStatus.RELEASED); + if (exam.IsNull()) + exam = await Db.Queryable() + .Where(x => x.Status == Consts.DicExamStatus.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) + .WhereIF(!studyRecord.CourseSceneId.IsNull(), x => x.CourseSceneId == studyRecord.CourseSceneId) + .FirstAsync(); + + if (exam.IsNull()) + return ServiceResult.OprateFailed("该门课程尚未开启考试,清联系HR !"); var insrt = new InsertGhre_ExamRecordInput() { @@ -435,12 +412,17 @@ public class Ghre_ExamRecordServices : BaseServices= exam.BeginTime && entity.BeginTime <= exam.EndTime) || (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime) @@ -1237,11 +1237,11 @@ public class Ghre_ExamServices : BaseServices= exam.BeginTime && entity.BeginTime <= exam.EndTime) || (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime)) return ServiceResult.OprateFailed($"课程场景【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】时间重叠!");