From e4a6fd0474539d4f396d470b4923b894bb8a4892 Mon Sep 17 00:00:00 2001
From: zhangli <1109134334@qq.com>
Date: Mon, 25 Apr 2022 10:51:31 +0800
Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=8E=92=E8=80=83=E5=90=8D?=
=?UTF-8?q?=E5=8D=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/Exam_ExamPlanController.cs | 25 +++
.../Exam_ExamPlanLessonController.cs | 6 +
.../Views/Exam_ExamPlan/Index.cshtml | 1 +
.../Views/Exam_ExamPlan/Index.js | 55 +++--
.../Exam_ExamPlan/Exam_ExamPlanBLL.cs | 37 ++++
.../Exam_ExamPlan/Exam_ExamPlanIBLL.cs | 3 +
.../Exam_ExamPlan/Exam_ExamPlanService.cs | 200 ++++++++++++++++++
.../Exam_ExamPlanRoomService.cs | 2 +
8 files changed, 307 insertions(+), 22 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 560342202..f4dce10ad 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
@@ -113,6 +113,31 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
return Success("删除成功!");
}
///
+ /// 生成排考名单
+ ///
+ ///
+ ///
+ [HttpPost]
+ [AjaxOnly]
+ public ActionResult Generate(string keyValue)
+ {
+ exam_ExamPlanIBLL.Generate(keyValue);
+ return Success("生成成功!");
+ }
+ ///
+ /// 清除排考名单/清除所有排考记录
+ ///
+ /// 排考记录主表Id
+ /// 1:清除排考名单;2:清除所有排考记录
+ ///
+ [HttpPost]
+ [AjaxOnly]
+ public ActionResult ClearGenerate(string keyValue, int type)
+ {
+ exam_ExamPlanIBLL.ClearGenerate(keyValue, type);
+ return Success("操作成功!");
+ }
+ ///
/// 保存实体数据(新增、修改)
///
/// 主键
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 b24ad9ee5..84a640d37 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
@@ -230,6 +230,12 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
if (ELCheckMark == 1)
{
var entity = exam_ExamPlanLessonIBLL.GetExam_ExamPlanLessonEntity(keyValue);
+ if ((entity.RealClassNum == null || entity.RealClassNum == 0) ||
+ (entity.SeatCount == null || entity.SeatCount == 0))
+ {
+ return Fail("请先安排班级和考场!");
+ }
+
if (entity.SeatCount < entity.RealStuCount)
{
return Fail("考场座位数不足!");
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 15b62df28..5c4065e36 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
@@ -55,6 +55,7 @@
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 f4d904e3c..9d045a9ec 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
@@ -86,31 +86,42 @@ var bootstrap = function ($, learun) {
});
// 生成排考名单
$('#lr_generate').on('click', function () {
- learun.layerForm({
- id: 'form_clear',
- title: '生成排考名单',
- url: top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlan/GenerateForm',
- width: 500,
- height: 300,
- btn: ['确定', '关闭'],
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
+ var keyValue = $('#gridtable').jfGridValue('EPId');
+ if (learun.checkrow(keyValue)) {
+ learun.layerConfirm('是否确认生成排考名单!', function (res) {
+ if (res) {
+ learun.postForm(top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlan/Generate', { keyValue: keyValue }, function () {
+ refreshGirdData();
+ });
+ }
+ });
+ }
});
// 清除排考名单
$('#lr_cleargenerate').on('click', function () {
- learun.layerForm({
- id: 'form_generate',
- title: '清除排考名单',
- url: top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlan/GenerateForm',
- width: 500,
- height: 300,
- btn: ['确定', '关闭'],
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
+ var keyValue = $('#gridtable').jfGridValue('EPId');
+ if (learun.checkrow(keyValue)) {
+ learun.layerConfirm('是否确认清除排考名单!', function (res) {
+ if (res) {
+ learun.postForm(top.$.rootUrl + '/EducationalAdministration/Exam_ExamPlan/ClearGenerate', { keyValue: keyValue, type: 1 }, function () {
+ refreshGirdData();
+ });
+ }
+ });
+ }
+ });
+ //清除排考记录
+ $('#lr_cleardata').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/ClearGenerate', { keyValue: keyValue, type: 2 }, function () {
+ refreshGirdData();
+ });
+ }
+ });
+ }
});
// 安排考试
$('#lr_planks').on('click',
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanBLL.cs
index 187483bff..cf4c8e992 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanBLL.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanBLL.cs
@@ -93,6 +93,43 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}
+ public void ClearGenerate(string keyValue, int type)
+ {
+ try
+ {
+ exam_ExamPlanService.ClearGenerate(keyValue, type);
+ }
+ catch (Exception ex)
+ {
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowBusinessException(ex);
+ }
+ }
+ }
+
+ public void Generate(string keyValue)
+ {
+ try
+ {
+ exam_ExamPlanService.Generate(keyValue);
+ }
+ 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_ExamPlan/Exam_ExamPlanIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanIBLL.cs
index 207862e8f..fad617a88 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanIBLL.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanIBLL.cs
@@ -36,6 +36,9 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
///
/// 主键
void DeleteEntity(string keyValue);
+
+ void ClearGenerate(string keyValue, int type);
+ void Generate(string keyValue);
///
/// 保存实体数据(新增、修改)
///
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanService.cs
index dbb19a35b..ba209c059 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanService.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlan/Exam_ExamPlanService.cs
@@ -4,6 +4,7 @@ using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
+using System.Linq;
using System.Text;
namespace Learun.Application.TwoDevelopment.EducationalAdministration
@@ -149,6 +150,205 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
+ ///
+ /// 清除排考名单/清除所有排考记录
+ ///
+ /// 排考记录主表Id
+ /// 1:清除排考名单;2:清除所有排考记录
+ ///
+ public void ClearGenerate(string keyValue, int type)
+ {
+ var db = this.BaseRepository("CollegeMIS");
+ try
+ {
+ db.BeginTrans();
+ //清除排考名单
+ db.ExecuteBySql($@"delete from Exam_ArrangeExamTermNew where EPId='{keyValue}';
+delete from Exam_ArrangeExamTermItemNew where EPId='{keyValue}';");
+ if (type == 2)
+ {
+ //清除所有排考记录
+
+ //考试安排课程表
+ var planLessonList = db.FindList(x => x.EPId == keyValue);
+ var planLessonIds = "";
+ if (planLessonList.Count() > 1)
+ {
+ planLessonIds = string.Join("','", planLessonList.Select(x => x.EPLId).ToList());
+ }
+ else if (planLessonList.Count() == 1)
+ {
+ planLessonIds = planLessonList.Select(x => x.EPLId).FirstOrDefault();
+ }
+
+ if (!string.IsNullOrEmpty(planLessonIds))
+ {
+ db.ExecuteBySql($@"delete from Exam_ExamPlanClass where EPLId in ('{planLessonIds}');
+delete from Exam_ExamPlanRoom where EPLId in ('{planLessonIds}');");
+ db.ExecuteBySql($@"delete from Exam_ExamPlanLesson where EPId='{keyValue}'");
+ }
+ }
+
+ db.Commit();
+ }
+ catch (Exception ex)
+ {
+ db.Rollback();
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowServiceException(ex);
+ }
+ }
+ }
+
+ ///
+ /// 生成排考名单
+ ///
+ /// 排考记录主表Id
+ public void Generate(string keyValue)
+ {
+ var db = this.BaseRepository("CollegeMIS");
+ try
+ {
+ db.BeginTrans();
+ //排考安排课程已审核的数据
+ var planLessonData = db.FindList(x => x.EPId == keyValue && x.ELCheckMark == true);
+
+ //排考安排明细数据
+ List itemList = new List();
+ foreach (var planLesson in planLessonData)
+ {
+ //排考安排考场
+ var planRoomData = db.FindList(x => x.EPLId == planLesson.EPLId).ToList();
+ //考场数
+ int planRoomCount = planRoomData.Count();
+ //添加排考安排数据
+ foreach (var planRoom in planRoomData)
+ {
+ var ExamTermEntity = db.FindEntity(x => x.ClassroomNo == planRoom.ClassroomNo);
+ //排考安排表
+ if (ExamTermEntity == null)
+ {
+ Exam_ArrangeExamTermNewEntity ExamTermNewEntity = new Exam_ArrangeExamTermNewEntity();
+ ExamTermNewEntity.Create();
+ ExamTermNewEntity.EPId = keyValue;
+ ExamTermNewEntity.LessonName = planLesson.LessonName;
+ ExamTermNewEntity.LessonNo = planLesson.LessonNo;
+ ExamTermNewEntity.ExamDate = planLesson.ExamDate;
+ ExamTermNewEntity.ExamTime = planLesson.ExamTime;
+ ExamTermNewEntity.EmpName = planRoom.EmpName;
+ ExamTermNewEntity.EmpNo = planRoom.EmpNo;
+ ExamTermNewEntity.ClassroomName = planRoom.ClassroomName;
+ ExamTermNewEntity.ClassroomNo = planRoom.ClassroomNo;
+ ExamTermNewEntity.F_SchoolId = LoginUserInfo.Get().companyId;
+ db.Insert(ExamTermNewEntity);
+ }
+ else
+ {
+ //修改
+ ExamTermEntity.LessonName = planLesson.LessonName;
+ ExamTermEntity.LessonNo = planLesson.LessonNo;
+ ExamTermEntity.ExamDate = planLesson.ExamDate;
+ ExamTermEntity.ExamTime = planLesson.ExamTime;
+ ExamTermEntity.EmpName = planRoom.EmpName;
+ ExamTermEntity.EmpNo = planRoom.EmpNo;
+ ExamTermEntity.ClassroomName = planRoom.ClassroomName;
+ ExamTermEntity.ClassroomNo = planRoom.ClassroomNo;
+ db.Update(ExamTermEntity);
+ }
+
+ //生成考场随机数
+ var sealNumArr = getRanNum(planRoom.SeatCount.Value);
+ for (int n = 0; n < sealNumArr.Count; n++)
+ {
+ //考场安排明细
+ Exam_ArrangeExamTermItemNewEntity item = new Exam_ArrangeExamTermItemNewEntity();
+ item.Create();
+ item.EPId = keyValue;
+ item.LessonNo = planLesson.LessonNo;
+ item.LessonName = planLesson.LessonName;
+ item.ExamDate = planLesson.ExamDate;
+ item.ExamTime = planLesson.ExamTime;
+ item.EmpName = planRoom.EmpName;
+ item.EmpNo = planRoom.EmpNo;
+ item.ClassroomName = planRoom.ClassroomName;
+ item.ClassroomNo = planRoom.ClassroomNo;
+ item.F_SchoolId = LoginUserInfo.Get().userId;
+ item.SitNumber = sealNumArr[n].ToString().PadLeft(3, '0');
+ itemList.Add(item);
+ }
+ }
+
+ //排考安排班级
+ var planClassData = db.FindList(x => x.EPLId == planLesson.EPLId);
+ var classnos = string.Join("','", planClassData.Select(x => x.ClassNo).ToList());
+ string stuSql = $"select * from StuInfoBasic where classno in ('{classnos}') and stuno not in (select StuNo from Exam_ArrangeExamTermItemNew where EPId='{keyValue}')";
+ //所有考生
+ var stuInfoList = db.FindList(stuSql).ToList();
+
+ if (itemList.Count >= stuInfoList.Count())
+ {
+ //为考生安排座位
+ for (int i = 0; i < stuInfoList.Count; i++)
+ {
+ itemList[i].StuNo = stuInfoList[i].StuNo;
+ itemList[i].StuName = stuInfoList[i].StuName;
+ }
+
+ db.Insert(itemList);
+ }
+ }
+
+ db.Commit();
+ }
+ catch (Exception ex)
+ {
+ db.Rollback();
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowServiceException(ex);
+ }
+ }
+ }
+ ///
+ /// 生成随机数组
+ ///
+ ///
+ ///
+ private List getRanNum(int maxValue)
+ {
+ Random ra = new Random(unchecked((int)DateTime.Now.Ticks));
+ int[] arrNum = { };
+ var list = new List();
+ int tmp = 0;
+ int minValue = 1;
+ for (int i = 0; i < maxValue; i++)
+ {
+ tmp = ra.Next(minValue, maxValue + 1); //随机取数
+ list.Add(getNum(list, tmp, minValue, maxValue + 1, ra)); //取出值赋到数组中
+ }
+
+ return list;
+ }
+
+ private int getNum(List list, int tmp, int minValue, int maxValue, Random ra)
+ {
+ if (list.Exists(x => x == tmp))
+ {
+ tmp = ra.Next(minValue, maxValue); //重新随机获取。
+ tmp = getNum(list, tmp, minValue, maxValue, ra);//递归:如果取出来的数字和已取得的数字有重复就重新随机获取。
+
+ }
+ return tmp;
+ }
///
/// 保存实体数据(新增、修改)
///
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanRoom/Exam_ExamPlanRoomService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanRoom/Exam_ExamPlanRoomService.cs
index c68fc3fc4..7a9c0aa77 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanRoom/Exam_ExamPlanRoomService.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/Exam_ExamPlanRoom/Exam_ExamPlanRoomService.cs
@@ -205,6 +205,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
entity.Create();
this.BaseRepository("CollegeMIS").Insert(entity);
}
+
+ UpdateExamPlanLesson(entity.EPLId);
}
catch (Exception ex)
{