|
|
@@ -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 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <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> |
|
|
|