@@ -113,6 +113,31 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
return Success("删除成功!"); | return Success("删除成功!"); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 生成排考名单 | |||||
/// </summary> | |||||
/// <param name="keyValue"></param> | |||||
/// <returns></returns> | |||||
[HttpPost] | |||||
[AjaxOnly] | |||||
public ActionResult Generate(string keyValue) | |||||
{ | |||||
exam_ExamPlanIBLL.Generate(keyValue); | |||||
return Success("生成成功!"); | |||||
} | |||||
/// <summary> | |||||
/// 清除排考名单/清除所有排考记录 | |||||
/// </summary> | |||||
/// <param name="keyValue">排考记录主表Id</param> | |||||
/// <param name="type">1:清除排考名单;2:清除所有排考记录</param> | |||||
/// <returns></returns> | |||||
[HttpPost] | |||||
[AjaxOnly] | |||||
public ActionResult ClearGenerate(string keyValue, int type) | |||||
{ | |||||
exam_ExamPlanIBLL.ClearGenerate(keyValue, type); | |||||
return Success("操作成功!"); | |||||
} | |||||
/// <summary> | |||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
/// </summary> | /// </summary> | ||||
/// <param name="keyValue">主键</param> | /// <param name="keyValue">主键</param> | ||||
@@ -230,6 +230,12 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
if (ELCheckMark == 1) | if (ELCheckMark == 1) | ||||
{ | { | ||||
var entity = exam_ExamPlanLessonIBLL.GetExam_ExamPlanLessonEntity(keyValue); | 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) | if (entity.SeatCount < entity.RealStuCount) | ||||
{ | { | ||||
return Fail("考场座位数不足!"); | return Fail("考场座位数不足!"); | ||||
@@ -55,6 +55,7 @@ | |||||
<div class=" btn-group btn-group-sm" learun-authorize="yes"> | <div class=" btn-group btn-group-sm" learun-authorize="yes"> | ||||
<a id="lr_generate" class="btn btn-default"><i class="fa fa-plus"></i> 生成排考名单</a> | <a id="lr_generate" class="btn btn-default"><i class="fa fa-plus"></i> 生成排考名单</a> | ||||
<a id="lr_cleargenerate" class="btn btn-default"><i class="fa fa-plus"></i> 清除排考名单</a> | <a id="lr_cleargenerate" class="btn btn-default"><i class="fa fa-plus"></i> 清除排考名单</a> | ||||
<a id="lr_cleardata" class="btn btn-default"><i class="fa fa-plus"></i> 清除排考记录</a> | |||||
<a id="lr_planks" class="btn btn-default"><i class="fa fa-plus"></i> 安排考试</a> | <a id="lr_planks" class="btn btn-default"><i class="fa fa-plus"></i> 安排考试</a> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -86,31 +86,42 @@ var bootstrap = function ($, learun) { | |||||
}); | }); | ||||
// 生成排考名单 | // 生成排考名单 | ||||
$('#lr_generate').on('click', function () { | $('#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 () { | $('#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', | $('#lr_planks').on('click', | ||||
@@ -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); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
@@ -36,6 +36,9 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
/// </summary> | /// </summary> | ||||
/// <param name="keyValue">主键</param> | /// <param name="keyValue">主键</param> | ||||
void DeleteEntity(string keyValue); | void DeleteEntity(string keyValue); | ||||
void ClearGenerate(string keyValue, int type); | |||||
void Generate(string keyValue); | |||||
/// <summary> | /// <summary> | ||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
/// </summary> | /// </summary> | ||||
@@ -4,6 +4,7 @@ using Learun.Util; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Data; | using System.Data; | ||||
using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
namespace Learun.Application.TwoDevelopment.EducationalAdministration | namespace Learun.Application.TwoDevelopment.EducationalAdministration | ||||
@@ -149,6 +150,205 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 清除排考名单/清除所有排考记录 | |||||
/// </summary> | |||||
/// <param name="keyValue">排考记录主表Id</param> | |||||
/// <param name="type">1:清除排考名单;2:清除所有排考记录</param> | |||||
/// <returns></returns> | |||||
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<Exam_ExamPlanLessonEntity>(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); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 生成排考名单 | |||||
/// </summary> | |||||
/// <param name="keyValue">排考记录主表Id</param> | |||||
public void Generate(string keyValue) | |||||
{ | |||||
var db = this.BaseRepository("CollegeMIS"); | |||||
try | |||||
{ | |||||
db.BeginTrans(); | |||||
//排考安排课程已审核的数据 | |||||
var planLessonData = db.FindList<Exam_ExamPlanLessonEntity>(x => x.EPId == keyValue && x.ELCheckMark == true); | |||||
//排考安排明细数据 | |||||
List<Exam_ArrangeExamTermItemNewEntity> itemList = new List<Exam_ArrangeExamTermItemNewEntity>(); | |||||
foreach (var planLesson in planLessonData) | |||||
{ | |||||
//排考安排考场 | |||||
var planRoomData = db.FindList<Exam_ExamPlanRoomEntity>(x => x.EPLId == planLesson.EPLId).ToList(); | |||||
//考场数 | |||||
int planRoomCount = planRoomData.Count(); | |||||
//添加排考安排数据 | |||||
foreach (var planRoom in planRoomData) | |||||
{ | |||||
var ExamTermEntity = db.FindEntity<Exam_ArrangeExamTermNewEntity>(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<Exam_ExamPlanClassEntity>(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<StuInfoBasicEntity>(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); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 生成随机数组 | |||||
/// </summary> | |||||
/// <param name="maxValue"></param> | |||||
/// <returns></returns> | |||||
private List<int> getRanNum(int maxValue) | |||||
{ | |||||
Random ra = new Random(unchecked((int)DateTime.Now.Ticks)); | |||||
int[] arrNum = { }; | |||||
var list = new List<int>(); | |||||
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<int> 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; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 保存实体数据(新增、修改) | /// 保存实体数据(新增、修改) | ||||
/// </summary> | /// </summary> | ||||
@@ -205,6 +205,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
entity.Create(); | entity.Create(); | ||||
this.BaseRepository("CollegeMIS").Insert(entity); | this.BaseRepository("CollegeMIS").Insert(entity); | ||||
} | } | ||||
UpdateExamPlanLesson(entity.EPLId); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||