From 63641b4885be78c5fa35fc421c6383394424261d Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Mon, 20 Jun 2022 18:08:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E6=8E=92=E8=80=83=E8=AF=95-=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=80=83=E8=AF=95=E6=97=B6=E9=97=B4=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=B8=8B=E6=8B=89=E6=A1=86=EF=BC=8C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=80=83=E8=AF=95=E8=AE=B0=E5=BD=95=E7=9A=84=E5=AE=89=E6=8E=92?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exam_ExamPlanLessonController.cs | 28 ++++-- .../Views/Exam_ExamPlanLesson/Form.cshtml | 14 ++- .../Views/Exam_ExamPlanLesson/Form.js | 21 ++++- .../Exam_ExamPlanLessonBLL.cs | 39 +++++++- .../Exam_ExamPlanLessonIBLL.cs | 3 +- .../Exam_ExamPlanLessonService.cs | 93 +++++++++++++++++++ .../Exam_ExamPlanTimeEntity.cs | 3 + 7 files changed, 185 insertions(+), 16 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanLessonController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanLessonController.cs index 1b29bacd0..86baa8d27 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanLessonController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanLessonController.cs @@ -21,7 +21,6 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL(); private Exam_ExamStudentIBLL exam_ExamStudentIBLL = new Exam_ExamStudentBLL(); private Exam_ExamPlanRoomIBLL exam_ExamPlanRoomIBLL = new Exam_ExamPlanRoomBLL(); - private StuInfoBasicIBLL StuInfoBasicIBLL = new StuInfoBasicBLL(); #region 视图功能 @@ -152,7 +151,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers /// /// /// - [HttpGet] + [HttpGet] [AjaxOnly] public ActionResult GetPageListForLesson(string pagination, string queryJson) { @@ -227,6 +226,18 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers return Success(data); } + + /// + /// 获取考试记录安排时间数据 + /// + /// + [HttpGet] + [AjaxOnly] + public ActionResult GetExamDateSel(string EPLId) + { + var data = exam_ExamPlanLessonIBLL.GetExamDateSel(EPLId); + return Success(data); + } #endregion #region 提交数据 @@ -334,12 +345,13 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers } entity.EPLId = keyValue; - //判断考试时间是否冲突 - //var res = exam_ExamPlanLessonIBLL.IsExamTimeClash(entity); - //if (res.flag && !string.IsNullOrEmpty(res.lessonname)) - //{ - // return Fail("考试时间与课程(" + res.lessonname + ")冲突!"); - //} + + //判断考试时间是否冲突,同一专业同一时间段只能安排一门考试课程 + var res = exam_ExamPlanLessonIBLL.IsAllowSave(entity); + if (!res.flag && !string.IsNullOrEmpty(res.str)) + { + return Fail(res.str); + } //保存 exam_ExamPlanLessonIBLL.SaveEntity(keyValue, entity); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.cshtml index 5d3a838e4..6aebedec0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.cshtml @@ -4,16 +4,20 @@ }
+
考试时间*
+
+
+ -
+ -
+
@Html.AppendJsFile("/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.js index 60264e6da..2e45b0989 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlanLesson/Form.js @@ -15,17 +15,36 @@ var bootstrap = function ($, learun) { page.initData(); }, bind: function () { + $('#ExamDateSel').lrselect({ + placeholder: "请选择考试时间", + allowSearch: false, + url: top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlanLesson/GetExamDateSel?EPLId='+keyValue, + value: 'edate', + text: 'edate', + select: function(item) { + if (item) { + $('#ExamDate').val(item.ExamDate); + $('#ExamTimeStart').val(item.ExamTimeStart); + $('#ExamTimeEnd').val(item.ExamTimeEnd); + } + } + }); }, initData: function () { if (!!keyValue) { $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlanLesson/GetFormData?keyValue=' + keyValue, function (data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { - $('#' + id ).jfGridSet('refreshdata', data[id]); + $('#' + id).jfGridSet('refreshdata', data[id]); } else { $('[data-table="' + id + '"]').lrSetFormData(data[id]); } + if (!!data[id] && !!data[id].ExamDate) { + var edate=learun.formatDate(data[id].ExamDate,'yyyy-MM-dd')+" "+data[id].ExamTimeStart+'-'+data[id].ExamTimeEnd; + + $('#ExamDateSel').lrselectSet(edate); + } } }); } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonBLL.cs index 88d9b16d4..5961c20fc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonBLL.cs @@ -80,6 +80,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + + public IEnumerable GetExamDateSel(string EPLId) + { + try + { + return exam_ExamPlanLessonService.GetExamDateSel(EPLId); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + /// /// 获取Exam_ExamPlanLesson表实体数据 /// @@ -260,7 +280,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + public (bool flag, string str) IsAllowSave(Exam_ExamPlanLessonEntity entity) + { + try + { + return exam_ExamPlanLessonService.IsAllowSave(entity); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } /// /// 判断考试时间是否冲突 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonIBLL.cs index 1d0b71c78..f1c23aab6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonIBLL.cs @@ -23,6 +23,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration IEnumerable GetPageList(Pagination pagination, string queryJson); IEnumerable GetPageListForLesson(Pagination pagination, string queryJson); IEnumerable GetListByEPId(string EPId); + IEnumerable GetExamDateSel(string EPLId); /// /// 获取Exam_ExamPlanLesson表实体数据 /// @@ -54,7 +55,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration void SaveEntity(string keyValue, Exam_ExamPlanLessonEntity entity); (bool flag, string msg) PlanLessonTimeByEPId(string keyValue); - + (bool flag, string str) IsAllowSave(Exam_ExamPlanLessonEntity entity); (bool flag, string lessonname) IsExamTimeClash(Exam_ExamPlanLessonEntity entity); #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs index 6a849546a..8737dad17 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanLesson/Exam_ExamPlanLessonService.cs @@ -148,6 +148,55 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + /// + /// 获取考试记录安排时间数据 + /// + /// + /// + public IEnumerable GetExamDateSel(string EPLId) + { + try + { + var epLesson = this.BaseRepository("CollegeMIS").FindEntity(EPLId); + string sql = $"Select Id,ExamDate,ExamTimeStart,ExamTimeEnd,CONVERT(nvarchar(10),ExamDate,120)+' '+ExamTimeStart+'-'+ ExamTimeEnd as edate from [dbo].[Exam_ExamPlanTime] where epid='{epLesson.EPId}' "; + + var lessonno = epLesson.LessonNo; + if (epLesson.LessonNo.Contains("(")) + { + lessonno = epLesson.LessonNo.Split('(')[0]; + } + + //查询课程信息 + var lessoninfo = this.BaseRepository("CollegeMIS").FindList($@"select top 1 t.LessonTypeName,l.* from lessoninfo l + join [dbo].[CdLessonType] t on l.LessonTypeId = t.LTId where l.LessonNo='{lessonno}' ").FirstOrDefault(); + if (lessoninfo != null) + { + if (lessoninfo.LessonTypeName.Contains("公开") || lessoninfo.LessonTypeName.Contains("公共")) + { + sql += " and examtype='2'"; + } + else + { + sql += " and examtype='1'"; + } + } + + sql += " order by cast((CONVERT(nvarchar(10),ExamDate,120)+' '+ExamTimeStart) as datetime)"; + return this.BaseRepository("CollegeMIS").FindList(sql); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + /// /// 获取Exam_ExamPlanLesson表实体数据 /// @@ -468,6 +517,50 @@ SELECT t.ClassNo,count(1) as StuNum FROM Exam_ExamStudent t } } + /// + /// 判断考试时间是否冲突 + /// + /// + public (bool flag, string str) IsAllowSave(Exam_ExamPlanLessonEntity entity) + { + try + { + var ExamPlanLesson = this.BaseRepository("CollegeMIS") + .FindEntity(entity.EPLId); + //考试课程数据 + var EPLessonList = this.BaseRepository("CollegeMIS").FindList($@" select distinct elesson.ExamTime as ExamLength,ltype.LessonTypeName,info.TeachMajorNo,t.* from Exam_ExamPlanLesson t +join Exam_ExamLesson elesson on t.LessonNo=elesson.LessonNo +left join LessonInfo info on t.LessonNo=info.LessonNo +left join CdLessonType ltype on info.LessonTypeId=ltype.LTId + where t.EPId='{ExamPlanLesson.EPId}' and info.CheckMark=1 "); + if (ExamPlanLesson.LessonNo.Contains("(")) + { + EPLessonList = this.BaseRepository("CollegeMIS").FindList($@" select distinct elesson.ExamTime as ExamLength,ltype.LessonTypeName,info.TeachMajorNo,t.* from Exam_ExamPlanLesson t +join Exam_ExamLesson elesson on left(t.LessonNo,charindex('(',t.LessonNo)-1)=elesson.LessonNo +left join LessonInfo info on left(t.LessonNo,charindex('(',t.LessonNo)-1)=info.LessonNo +left join CdLessonType ltype on info.LessonTypeId=ltype.LTId + where t.EPId='{ExamPlanLesson.EPId}' and info.CheckMark=1 "); + } + var EPLesson = EPLessonList.Where(x => x.EPLId == ExamPlanLesson.EPLId).FirstOrDefault(); + if (EPLessonList.ToList().Exists(x => x.EPLId != entity.EPLId && x.TeachMajorNo == EPLesson.TeachMajorNo && x.ExamLength == EPLesson.ExamLength && x.ExamDate != null && x.ExamDate == entity.ExamDate && x.ExamTime == entity.ExamTime)) + { + return (false, "同专业同时段只能安排一门课程!"); + } + + return (true, ""); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } /// /// 自动生成考试课程排考时间 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanTime/Exam_ExamPlanTimeEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanTime/Exam_ExamPlanTimeEntity.cs index 157874cb1..a57c80988 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanTime/Exam_ExamPlanTimeEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanTime/Exam_ExamPlanTimeEntity.cs @@ -69,6 +69,9 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } #endregion #region 扩展字段 + [NotMapped] + public string edate { get; set; } + #endregion } }