From 2127068df7e1769cb6ad7357bf3397ed303ff0ef Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Thu, 9 Jun 2022 10:57:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E8=AE=B0=E5=BD=95=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E5=AE=89=E6=8E=92=E7=8F=AD=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Exam_ExamPlanController.cs | 33 ++++++++ .../Views/Exam_ExamPlan/Index.cshtml | 15 +++- .../Views/Exam_ExamPlan/Index.js | 29 +++++++ .../Exam_ExamPlanClassBLL.cs | 23 +++++- .../Exam_ExamPlanClassIBLL.cs | 3 + .../Exam_ExamPlanClassService.cs | 75 +++++++++++++++++++ .../Exam_ExamPlanLessonBLL.cs | 31 ++++++-- .../Exam_ExamPlanLessonIBLL.cs | 1 + .../Exam_ExamPlanLessonService.cs | 63 +++++++++++----- .../LessonInfo/LessonInfoEntity.cs | 3 + 10 files changed, 248 insertions(+), 28 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs index 416f44569..6e7b8efa4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/Exam_ExamPlanController.cs @@ -5,6 +5,7 @@ using System.Web.Mvc; using System.Collections.Generic; using System; using System.Linq; +using Newtonsoft.Json; namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { @@ -18,6 +19,8 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers public class Exam_ExamPlanController : MvcControllerBase { private Exam_ExamPlanIBLL exam_ExamPlanIBLL = new Exam_ExamPlanBLL(); + private Exam_ExamPlanLessonIBLL exam_ExamPlanLessonIBLL = new Exam_ExamPlanLessonBLL(); + private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL(); #region 视图功能 @@ -253,6 +256,36 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers int res = exam_ExamPlanIBLL.GenerateForm(AcademicYearNo, Semester, PlanType); return Success("清空(" + res + ")条数据成功!"); } + /// + /// 一键安排课程 + /// + /// + /// + [HttpPost] + [AjaxOnly] + public ActionResult PlanLessonByEPId(string keyValue) + { + exam_ExamPlanLessonIBLL.InitExamPlanLesson(keyValue); + return Success("操作成功!"); + } + /// + /// 一键安排班级 + /// + /// + /// + [HttpPost] + [AjaxOnly] + public ActionResult PlanClassByEPId(string keyValue) + { + var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count(); + if (count <= 0) + { + return Fail("请先安排课程!"); + } + + exam_ExamPlanClassIBLL.PlanClassByEPId(keyValue); + return Success("操作成功!"); + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.cshtml index 0e3cc0335..31f8989d1 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.cshtml @@ -57,8 +57,21 @@   生成排考名单   清除排考名单   清除排考记录 -   安排考试 +
+ + +
+
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.js index 6d00344ee..8f43e80d8 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ExamPlan/Index.js @@ -161,6 +161,35 @@ var bootstrap = function ($, learun) { F_UrlAddress: '/EducationalAdministration/Exam_ExamPlanLesson/Index?EPId=' + keyValue }); }); + //一键安排课程 + $('#lr_examlesson').on('click', + function () { + var keyValue = $('#gridtable').jfGridValue('EPId'); + if (learun.checkrow(keyValue)) { + learun.layerConfirm('是否确认安排课程!', function (res) { + if (res) { + learun.postForm(top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlan/PlanLessonByEPId', { keyValue: keyValue }, function () { + refreshGirdData(); + }); + } + }); + } + }); + + //一键安排班级 + $('#lr_examclass').on('click', + function () { + var keyValue = $('#gridtable').jfGridValue('EPId'); + if (learun.checkrow(keyValue)) { + learun.layerConfirm('是否确认安排班级!', function (res) { + if (res) { + learun.postForm(top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlan/PlanClassByEPId', { keyValue: keyValue }, function () { + refreshGirdData(); + }); + } + }); + } + }); }, // 初始化列表 initGird: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassBLL.cs index 5599292d0..eff4495f6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassBLL.cs @@ -67,7 +67,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + /// /// 获取实体数据 /// @@ -181,7 +181,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + + + public void PlanClassByEPId(string keyValue) + { + try + { + exam_ExamPlanClassService.PlanClassByEPId(keyValue); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassIBLL.cs index a8231b9ec..2adbf50f8 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassIBLL.cs @@ -47,6 +47,9 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration void SaveList(List list); (bool flag, string msg) IsExamConflict(List list); + + void PlanClassByEPId(string keyValue); + #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassService.cs index 40de43186..93660d231 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanClass/Exam_ExamPlanClassService.cs @@ -314,6 +314,81 @@ where l.EPLId='{EPLId}' } } } + + /// + /// 一键安排班级 + /// + public void PlanClassByEPId(string EPId) + { + var db = this.BaseRepository("CollegeMIS"); + try + { + db.BeginTrans(); + //排考记录表 + var examPlan = db.FindEntity(EPId); + //查询当前考试记录所有考试课程 + var lessonList = db.FindList(x => x.EPId == EPId); + foreach (var lesson in lessonList) + { + var lessonno = lesson.LessonNo; + if (lesson.LessonNo.Contains("(")) + { + lessonno = lesson.LessonNo.Split('(')[0]; + } + + //查询课程信息 + var lessoninfo = db.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("专业")) + { + //专业课添加此专业的所有班级 + var addSql = $@"insert into Exam_ExamPlanClass + SELECT NEWID(),'{lesson.EPLId}',c.ClassName,t.ClassNo,count(1) as StuNum FROM Exam_ExamStudent t + left join classinfo c on t.ClassNo=c.ClassNo WHERE t.ESEnabled=1 and t.AcademicYearNo='{examPlan.AcademicYearNo}' and t.Semester='{examPlan.Semester}' and t.ESType='{examPlan.PlanType}' and c.majorno='{lessoninfo.TeachMajorNo}' + and t.ClassNo not in (select ClassNo from [dbo].[Exam_ExamPlanClass] where EPLId='{lesson.EPLId}') + group by t.ClassNo,t.AcademicYearNo,t.Semester,t.ESType,c.ClassName "; + db.ExecuteBySql(addSql); + } + else if (lessoninfo.LessonTypeName.Contains("公共") || lessoninfo.LessonTypeName.Contains("公开")) + { + //公共课添加所有班级 + var addSql = $@"insert into Exam_ExamPlanClass + SELECT NEWID(),'{lesson.EPLId}',c.ClassName,t.ClassNo,count(1) as StuNum FROM Exam_ExamStudent t + left join classinfo c on t.ClassNo=c.ClassNo WHERE t.ESEnabled=1 and t.AcademicYearNo='{examPlan.AcademicYearNo}' and t.Semester='{examPlan.Semester}' and t.ESType='{examPlan.PlanType}' + and t.ClassNo not in (select ClassNo from [dbo].[Exam_ExamPlanClass] where EPLId='{lesson.EPLId}') + group by t.ClassNo,t.AcademicYearNo,t.Semester,t.ESType,c.ClassName "; + db.ExecuteBySql(addSql); + } + + } + + //更新排考安排课程表实排班级数、实排人数 + string sql = $@"update l +set l.RealStuCount=t.RealStuCount,l.RealClassNum=t.RealClassNum +from Exam_ExamPlanLesson l +join (select '{lesson.EPLId}' as EPLId,count(1) as RealClassNum,sum(ClassStuNum) as RealStuCount from Exam_ExamPlanClass where EPLId='{lesson.EPLId}' +)t on l.EPLId=t.EPLId +where l.EPLId='{lesson.EPLId}' +"; + db.ExecuteBySql(sql); + } + db.Commit(); + + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion } 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 834b2e282..76c291449 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 @@ -42,7 +42,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + public IEnumerable GetPageListForLesson(Pagination pagination, string queryJson) { try @@ -61,6 +61,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + + public IEnumerable GetListByEPId(string EPId) + { + try + { + return exam_ExamPlanLessonService.GetListByEPId(EPId); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } /// /// 获取Exam_ExamPlanLesson表实体数据 /// @@ -89,7 +108,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 获取左侧树形数据 /// /// - public List GetTree(string EPId) + public List GetTree(string EPId) { try { @@ -107,7 +126,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration isexpand = true, parentId = "" }; - treeList.Add(node); } + treeList.Add(node); + } return treeList.ToTree(); } catch (Exception ex) @@ -150,12 +170,12 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } - + /// /// 审核 /// /// 主键 - public void Check(string keyValue,int ELCheckMark) + public void Check(string keyValue, int ELCheckMark) { try { @@ -196,7 +216,6 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - /// /// 保存实体数据(新增、修改) /// 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 3c6c32929..9557074df 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 @@ -22,6 +22,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// IEnumerable GetPageList(Pagination pagination, string queryJson); IEnumerable GetPageListForLesson(Pagination pagination, string queryJson); + IEnumerable GetListByEPId(string EPId); /// /// 获取Exam_ExamPlanLesson表实体数据 /// 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 2af24f242..5c3f6a862 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 @@ -122,6 +122,32 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + public IEnumerable GetListByEPId(string EPId) + { + try + { + var strSql = new StringBuilder(); + strSql.Append("SELECT "); + strSql.Append(@"p.AcademicYearNo,p.Semester,t.* "); + strSql.Append(" FROM Exam_ExamPlanLesson t "); + strSql.Append(" join [dbo].[Exam_ExamPlan] p on t.epid=p.epid "); + strSql.Append($" WHERE 1=1 and t.EPId='{EPId}'"); + + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString()); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + /// /// 获取Exam_ExamPlanLesson表实体数据 /// @@ -154,10 +180,20 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration { try { - return this.BaseRepository("CollegeMIS").FindTable($@" select distinct t.EPLId,t.LessonName,a.ltorder,t.LessonNo from Exam_ExamPlanLesson t + var sql = $@"select distinct t.EPLId,t.LessonName,a.ltorder,t.LessonNo from Exam_ExamPlanLesson t + join (select l.lessonno,l.LessonTypeId,lt.ltorder from [dbo].[LessonInfo] l left join CdLessonType lt on l.LessonTypeId=lt.ltid where l.checkmark=1) a + on t.LessonNo=a.lessonno + where EPId='{EPId}' order by a.ltorder, t.LessonNo"; + var examplan = this.BaseRepository("CollegeMIS").FindEntity(EPId); + if (examplan.PlanType == "1") + { + sql = $@"select distinct t.EPLId,t.LessonName,a.ltorder,t.LessonNo from Exam_ExamPlanLesson t join (select l.lessonno,l.LessonTypeId,lt.ltorder from [dbo].[LessonInfo] l left join CdLessonType lt on l.LessonTypeId=lt.ltid where l.checkmark=1) a on SUBSTRING(t.LessonNo,0,CHARINDEX('(',t.LessonNo))=a.lessonno - where EPId='{EPId}' order by a.ltorder, t.LessonNo"); + where EPId='{EPId}' order by a.ltorder, t.LessonNo"; + } + + return this.BaseRepository("CollegeMIS").FindTable(sql); } catch (Exception ex) { @@ -236,7 +272,6 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 排考记录主表Id public void InitExamPlanLesson(string EPId) { - var db = this.BaseRepository("CollegeMIS"); try { //排考记录主表 @@ -277,27 +312,17 @@ and AcademicYearNo='{exam_ExamPlan.AcademicYearNo}' and Semester='{exam_ExamPlan this.BaseRepository("CollegeMIS").ExecuteBySql(sql); } - db.BeginTrans(); //排考课程表 - var list = db.FindList(x => x.EPId == EPId); + var EPLIdlist = this.BaseRepository("CollegeMIS").FindList(x => x.EPId == EPId).Select(x => x.EPLId); + var EPLIds = string.Join("','", EPLIdlist); //班级 - var classInfo = db.FindList($"select ClassNo,count(1) as StuNum FROM Exam_ExamStudent where ESEnabled=1 and ESType='{exam_ExamPlan.PlanType}' and AcademicYearNo='{exam_ExamPlan.AcademicYearNo}' and Semester='{exam_ExamPlan.Semester}' group by ClassNo"); - foreach (var lesson in list) - { - //考试课程信息 - var examLesson = db.FindEntity(x => x.ELId == lesson.ELId); - - //应排班级数 - lesson.ClassNum = classInfo.Count(); - //应考人数 - lesson.StuCount = classInfo.Sum(x => x.StuNum); - db.Update(lesson); - } - db.Commit(); + var classInfo = this.BaseRepository("CollegeMIS").FindList($"select ClassNo,count(1) as StuNum FROM Exam_ExamStudent where ESEnabled=1 and ESType='{exam_ExamPlan.PlanType}' and AcademicYearNo='{exam_ExamPlan.AcademicYearNo}' and Semester='{exam_ExamPlan.Semester}' group by ClassNo"); + //修改应排班级数和应考人数 + var UpdSql = $"update Exam_ExamPlanLesson set ClassNum='{classInfo.Count()}',StuCount='{classInfo.Sum(x => x.StuNum)}' where EPLId in ('{EPLIds}')"; + this.BaseRepository("CollegeMIS").ExecuteBySql(UpdSql); } catch (Exception ex) { - db.Rollback(); if (ex is ExceptionEx) { throw; diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/LessonInfo/LessonInfoEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/LessonInfo/LessonInfoEntity.cs index 4646aca70..9c57f9bd0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/LessonInfo/LessonInfoEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/LessonInfo/LessonInfoEntity.cs @@ -184,6 +184,9 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } #endregion #region 扩展字段 + [NotMapped] + public string LessonTypeName { get; set; } + #endregion } }