123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.RetakeManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.RetakeManage;
- using EMIS.Utility;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.EducationManage;
- using EMIS.DataLogic.EducationManage;
- using EMIS.CommonLogic.EducationSchedule;
- using EMIS.DataLogic.SystemSetting;
- using EMIS.CommonLogic.RetakeManage.General;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.RetakeManage.General
- {
- public class RetakePlanResultServices : BaseServices, IRetakePlanResultServices
- {
- public RetakePlanResultDAL RetakePlanResultDAL { get; set; }
- public EducationMissionClassDAL educationMissionClassDAL { get; set; }
- public RetakePlanTaskDAL RetakePlanTaskDAL { get; set; }
- public IInSchoolSettingServices InSchoolSettingServices { get; set; }
- public IRetakePlanStudentApplyServices IRetakePlanStudentApplyServices { get; set; }
- /// <summary>
- /// 查询重修班级信息View(统计已报人数)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="retakeTypeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakePlanTaskView> GetRetakePlanResultTaskView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- Guid? departmentID, Guid? coursematerialID, int? retakeTypeID, int? statusID, int pageIndex, int pageSize)
- {
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //排除重修任务状态为未开放状态的信息
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus != (int)ER_RetakePlanStatus.NotOpened);
- if (schoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (retakeTypeID.HasValue)
- {
- //重修类型
- expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID);
- }
- if (statusID.HasValue)
- {
- //重修任务状态
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus == statusID);
- }
- //查询对应的重修班级信息View
- var query = RetakePlanResultDAL.GetRetakePlanResultTaskView(expRetakePlan);
- if (collegeID.HasValue)
- {
- //开课院系所
- query = query.Where(x => x.CourseCollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- //开课教研室
- query = query.Where(x => x.DepartmentID == departmentID);
- }
- //查询条件()
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode.Length)
- .ThenBy(x => x.SchoolyearCode).ThenBy(x => x.DepartmentCode.Length)
- .ThenBy(x => x.DepartmentCode).ThenBy(x => x.RetakeTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CourseTypeID).ThenBy(x => x.ClassName)
- .ToGridResultSet<RetakePlanTaskView>(pageIndex, pageSize);
- //查询对应的重修计划IDList
- var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
- //查询对应的课程表信息
- var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
- //查询合并显示的课程表信息
- var weekdayTimesList = IRetakePlanStudentApplyServices.GetWeekdayTimesSegmentName(schedulingList);
- result.rows.ForEach(x =>
- {
- var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
- x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
- x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
- });
- //查询合并显示的任课老师信息
- var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
- result.rows.ForEach(x =>
- x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
- return result;
- }
- /// <summary>
- /// 查询重修班级信息List(统计已报人数)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="retakeTypeID"></param>
- /// <returns></returns>
- public List<RetakePlanTaskView> GetRetakePlanResultTaskViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- Guid? departmentID, Guid? coursematerialID, int? retakeTypeID, int? statusID)
- {
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //排除重修任务状态为未开放状态的信息
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus != (int)ER_RetakePlanStatus.NotOpened);
- if (schoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (retakeTypeID.HasValue)
- {
- //重修类型
- expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID);
- }
- if (statusID.HasValue)
- {
- //重修任务状态
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus == statusID);
- }
- //查询对应的重修班级信息View
- var query = RetakePlanResultDAL.GetRetakePlanResultTaskView(expRetakePlan);
- if (collegeID.HasValue)
- {
- //开课院系所
- query = query.Where(x => x.CourseCollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- //开课教研室
- query = query.Where(x => x.DepartmentID == departmentID);
- }
- //查询条件()
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode.Length)
- .ThenBy(x => x.SchoolyearCode).ThenBy(x => x.DepartmentCode.Length)
- .ThenBy(x => x.DepartmentCode).ThenBy(x => x.RetakeTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CourseTypeID).ThenBy(x => x.ClassName)
- .ToList();
- //查询对应的重修计划IDList
- var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
- //查询对应的课程表信息
- var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
- //查询合并显示的课程表信息
- var weekdayTimesList = IRetakePlanStudentApplyServices.GetWeekdayTimesSegmentName(schedulingList);
- result.ForEach(x =>
- {
- var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
- x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
- x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
- });
- //查询合并显示的任课老师信息
- var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
- result.ForEach(x =>
- x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
- return result;
- }
- /// <summary>
- /// 查询对应的重修班级报名名单信息
- /// </summary>
- /// <param name="retakePlanID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeStudentListView> GetRetakePlanResultTaskStudentView(Guid? retakePlanID, int pageIndex, int pageSize)
- {
- var query = RetakePlanResultDAL.GetRetakePlanResultView(x => x.RetakePlanID == retakePlanID)
- .OrderBy(x => x.LoginID);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的重修班级报名名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="retakePlanID"></param>
- /// <returns></returns>
- public List<RetakeStudentListView> GetRetakePlanResultTaskStudentViewList(ConfiguretView configuretView, Guid? retakePlanID)
- {
- var query = RetakePlanResultDAL.GetRetakePlanResultView(x => x.RetakePlanID == retakePlanID)
- .OrderBy(x => x.LoginID);
- return query.ToList();
- }
- /// <summary>
- /// 查询对应的重修班级未报名名单列表(未报名名单)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="retakePlanID"></param>
- /// <param name="gradeYearID"></param>
- /// <param name="standardID"></param>
- /// <param name="classmajorID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeStudentListView> GetStudentView(ConfiguretView configuretView, Guid? retakePlanID,
- int? gradeYearID, int? standardID, Guid? classmajorID, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- //查询对应的重修计划信息
- var retakePlanView = RetakePlanResultDAL.RetakePlanRepository.Entities
- .Where(x => x.RetakePlanID == retakePlanID).SingleOrDefault();
- if (retakePlanView == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- //查询对应的重修班级未报名名单
- var query = RetakePlanResultDAL.GetRetakePlanResultTaskStudentView(x => x.RetakePlanID == retakePlanID);
- if (gradeYearID.HasValue)
- {
- query = query.Where(x => x.Gradeyear == gradeYearID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- query = query.Where(x => x.ClassmajorID == classmajorID);
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- //在校状态
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- query = query.Where(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- query = query.Where(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
-
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length)
- .ThenBy(x => x.LoginID)
- .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 重修班级报名名单报名(从计划人数中选择)
- /// 由于存在多个相对应的重修计划,需要判断报名情况
- /// </summary>
- /// <param name="retakePlanID"></param>
- /// <param name="UserIDs"></param>
- /// <returns></returns>
- public string AddStudent(Guid? retakePlanID, string UserIDs)
- {
- try
- {
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<Guid?> userIDslist = UserIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- //查询对应的学生信息View
- var studentViewList = RetakePlanResultDAL.StudentRepository
- .GetList(x => userIDslist.Contains(x.UserID)).ToList();
- //查询对应的重修计划信息View
- var retakePlanView = RetakePlanResultDAL.RetakePlanRepository
- .GetList(x => x.RetakePlanID == retakePlanID, (x => x.ER_RetakePlanSetting), (x => x.CF_Student)).FirstOrDefault();
- if (retakePlanView == null)
- {
- throw new Exception("数据有误,请核查");
- }
- if (retakePlanView.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated)
- {
- throw new Exception("不能对已开班状态的信息进行报名。");
- }
- //对人数上限进行判断
- if (retakePlanView.PeopleNumlimit != null && retakePlanView.PeopleNumlimit != 0
- && (retakePlanView.CF_Student.Count() + userIDslist.Count()) > retakePlanView.PeopleNumlimit.Value)
- {
- throw new Exception("报名人数已达上限。");
- }
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakePlanView.CoursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == retakePlanView.CoursematerialID);
- }
- if (retakePlanView.RetakeTypeID.HasValue)
- {
- //重修类型
- expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakePlanView.RetakeTypeID);
- }
- if (retakePlanView.SchoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakePlanView.SchoolyearID);
- }
- if (retakePlanView.CourseTypeID.HasValue)
- {
- //课程类型
- expRetakePlan = expRetakePlan.And(x => x.CourseTypeID == retakePlanView.CourseTypeID);
- }
- if (retakePlanView.Credit.HasValue)
- {
- //课程学分
- expRetakePlan = expRetakePlan.And(x => x.Credit == retakePlanView.Credit);
- }
- //查询对应的重修计划信息View
- var newRetakePlanViewList = RetakePlanResultDAL.GetRetakePlanResultTaskView(expRetakePlan);
- var newRetakePlanIDList = newRetakePlanViewList.Where(x => x.DepartmentID == retakePlanView.ER_RetakePlanSetting.DepartmentID).Select(x => x.RetakePlanID).ToList();
- //查询对应的重修报名信息List
- var retakePlanStudentApplyList = RetakePlanResultDAL.RetakePlanStudentRepository
- .GetList(x => newRetakePlanIDList.Contains(x.RetakePlanID),
- (x => x.ER_RetakePlan),
- (x => x.ER_RetakePlan.CF_Student))
- .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
- .ToList();
- //if (retakePlanStudentApplyList.Count() > 0)
- //{
- // throw new Exception("存在对应的已报名重修计划名单。");
- //}
- //判断重修计划的报名情况
- foreach (var studentView in studentViewList)
- {
- //查询对应的学生重修报名信息
- var retakePlanStudentApply = retakePlanStudentApplyList
- .Where(x => x.UserID == studentView.UserID).ToList();
- if (retakePlanStudentApply.Count() <= 0)
- {
- //表示可报名
- //目前缺少排课冲突的判断(暂时不考虑)
- //重修报名
- retakePlanView.CF_Student.Add(studentView);
- success++;
- }
- else
- {
- //表示已存在报名名单
- fail++;
- }
- }
- UnitOfWork.Commit();
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "个";
- }
- else
- {
- tipMessage = success + "个," + fail + "个失败,原因:已存在相应的报名信息,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除(重修报名名单删除,取消报名)
- /// </summary>
- /// <param name="retakePlanID"></param>
- /// <param name="UserIDs"></param>
- public void DeleteStudent(Guid? retakePlanID, string UserIDs)
- {
- try
- {
- List<Guid?> userIDslist = UserIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- //查询对应的重修计划信息
- var retakePlanView = RetakePlanResultDAL.RetakePlanRepository
- .GetList(x => x.RetakePlanID == retakePlanID, x => x.CF_Student).FirstOrDefault();
- if (retakePlanView == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- if (retakePlanView.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated)
- {
- throw new Exception("不能对已开班状态的信息取消报名。");
- }
- //重修报名表
- retakePlanView.CF_Student.RemoveWhere(x => userIDslist.Contains(x.UserID));
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 开班(重修计划)
- /// </summary>
- /// <param name="RetakePlanIDs"></param>
- /// <returns></returns>
- public string RetakePlanResultGenerate(string RetakePlanIDs)
- {
- try
- {
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<Guid?> RetakePlanIDslist = RetakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- //查询对应的重修计划信息
- var retakePlanList = RetakePlanResultDAL.RetakePlanRepository
- .GetList(x => RetakePlanIDslist.Contains(x.RetakePlanID),
- x => x.CF_Student,
- x => x.EM_Coursematerial,
- x => x.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings,
- x => x.ER_RetakePlanSetting,
- x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType,
- x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace,
- x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting,
- x => x.ER_RetakePlanStudent,
- x => x.ER_RetakePlanTeacher,
- x => x.ER_RetakePlanSettingScheduling
- ).ToList();
- var noSchedulingList = retakePlanList.Where(x => x.ER_RetakePlanSettingScheduling.Count() == 0).FirstOrDefault();
- if (noSchedulingList != null)
- {
- throw new Exception(noSchedulingList.ClassName + ",缺少排课信息,不能开班");
- }
- var noClassRoomList = retakePlanList.Where(x => x.ER_RetakePlanSettingScheduling.Any(w => w.ClassroomID == null)).FirstOrDefault();
- if (noClassRoomList != null)
- {
- throw new Exception(noClassRoomList.ClassName + ",未设置上课教室,不能开班");
- }
- var DepartmentIDsList = retakePlanList.Select(x => x.ER_RetakePlanSetting.DepartmentID).Distinct().ToList();
-
- var CollegeDepartmentList = RetakePlanResultDAL.DepartmentRepository.GetList(x => DepartmentIDsList.Contains(x.DepartmentID));
-
- var RetakeGenerateList = retakePlanList.Where(x => x.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated).ToList();
- if (RetakeGenerateList.Count > 0)
- {
- throw new Exception("已开班状态的重修计划不能进行开班,请核查。");
- }
- string coursematerialName = "";
- var courseNames = retakePlanList.Where(x => x.EM_Coursematerial != null && x.EM_Coursematerial.EM_ClassGrouping == null).Select(x => x.EM_Coursematerial.CourseName).Distinct().ToArray();
- coursematerialName = string.Join(",", courseNames);
- if (courseNames.Length > 0)
- {
- throw new Exception("以下重修所对应的课程并未设置上课类型,无法确定任务班的分班方式,请到课程资料菜单完成设置后再次进行提交:\r\n" + coursematerialName);
- }
- List<string> message = new List<string>();
- //var PassRetakeList = RetakeList;
- List<ER_RetakePlan> RemoveList = new List<ER_RetakePlan>();
- //验证必填项
- #region
- for (int i = 0; i < retakePlanList.Count; i++)
- //foreach (var Retake in PassRetakeList)
- {
- var Retake = retakePlanList[i];
- if (Retake.ER_RetakePlanSetting.DepartmentID == null)
- {
- message.Add("教研室、");
- //message += ;
- //RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- RemoveList.Add(Retake);
- }
- if (Retake.ER_RetakePlanSetting.CourseCategoryID == null)
- {
- message.Add("课程属性、");
- //message += ;
- //RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- RemoveList.Add(Retake);
- }
- if (Retake.ER_RetakePlanSetting.CourseQualityID == null)
- {
- message.Add("课程性质、");
- //message += ;
- RemoveList.Add(Retake);//RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.CourseTypeID == null)
- {
- message.Add("课程类型、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ExaminationModeID == null)
- {
- message.Add("考试方式、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting != null)
- {
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse == null)
- {
- message.Add("理论学时、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours == null)
- {
- message.Add("实验学时、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum == null)
- {
- message.Add("每周次数、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum == null)
- {
- message.Add("理论周数、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum == null)
- {
- message.Add("实验周数、");
- //message += "实验周数、";
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum == null)
- {
- message.Add("开始周次、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum == null)
- {
- message.Add("结束周次、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours == null)
- {
- message.Add("周学时、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- }
- else
- {
- message.Add("教学设置、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.Count == 0 || !Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.Any(w => w.TeachingModeID != null))
- {
- message.Add("授课方式、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- //if (Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace.Count == 0 || !Retake.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace.Any(w => w.TeachingPlace != null))
- //{
- // message += "授课地点、";
- // RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- //}
- if (Retake.CF_Student.Count == 0)
- {
- message.Add("报名学生、");
- //message += ;
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- if (Retake.EM_Coursematerial != null && Retake.EM_Coursematerial.EM_ClassGrouping == null)
- {
- RemoveList.Add(Retake);//PassRetakeList.Remove(Retake);
- }
- }
- RemoveList = RemoveList.Distinct().ToList();
- retakePlanList.RemoveAll(x => RemoveList.Contains(x));
- //message = message.Length > 0 ? message.Remove(message.Length - 1) : message;
- string result = "";
- message.Distinct().ToList().ForEach(x => result += x);
- result = result.Length > 0 ? result.Remove(result.Length - 1) : result;
- #endregion
- ////判断是否有设置授课方式
- //var noTeachingModeTypeList = RetakeList.Where(x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.Count == 0)
- // .Concat(RetakeList.Where(x => !x.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.Any(w => w.TeachingModeID != null))).ToList();
- //if (noTeachingModeTypeList.Count > 0)
- //{
- // throw new Exception("没有设置授课方式的计划不能提交,请核查。");
- //}
- var resultMissionList = new List<EM_EducationMission>(); //教学任务
- var resultMissionClassList = new List<EM_EducationMissionClass>(); //教学任务班
- var resultMissionClassTeachingSettingList = new List<EM_EducationMissionClassTeachingSetting>();
- var resultEducationSchedulingClassList = new List<EM_EducationSchedulingClass>(); //排课班表
- var resultTeacherList = new List<EM_MissionClassTeacher>(); //教学任务班任课老师表
- var resultEducationSchedulingList = new List<ES_EducationScheduling>(); //排课课表
- var resultEducationSchedulingTeacherList = new List<ES_EducationSchedulingTeacher>(); //排课老师表
- var resultEducationSchedulingWeekNumList = new List<ES_EducationSchedulingWeekNum>(); //排课周次表
- var resultCourseProcessList = new List<EM_CourseProcess>(); //课程进度
- var resultCourseProcessTeacherList = new List<EM_CourseProcessTeacher>(); //课程进度任课老师表
- var resultEducationMissionClassSettingsList = new List<EM_EducationMissionClassSettings>(); //任务班设置表
- var query = (
- from efsc in
- (
- //先找出上课类型没有设置的授课方式,然后单独成一个班
- (from efsc in retakePlanList
- where efsc.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType
- .Any(x => !efsc.EM_Coursematerial
- .EM_ClassGrouping
- .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID))
- select new
- {
- RetakePlan = efsc,
- TeachingMode = efsc.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType
- .FirstOrDefault(x => !efsc.EM_Coursematerial
- .EM_ClassGrouping
- .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID))
- .TeachingModeID
- })
- //接下来对除理论班之外的其他分班设置进行匹配,如果该专业课程有这个授课方式的话,就单独再分一个班
- .Concat(
- from efsc in retakePlanList
- from tmt in efsc.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType
- from cgs in efsc.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings
- where tmt.TeachingModeID == cgs.TeachingModeID
- select new
- {
- RetakePlan = efsc,
- TeachingMode = cgs.TeachingModeID
- }))
- join co in RetakePlanResultDAL.DepartmentRepository.Entities on efsc.RetakePlan.ER_RetakePlanSetting.DepartmentID equals co.DepartmentID
- join dtm in DictionaryHelper.GetDictionaryValue(ViewModel.DictionaryItem.CF_TeachingMode) on efsc.TeachingMode equals dtm.Value
- group dtm by new
- {
- RetakePlan = efsc.RetakePlan,
- CollegeID = co.CollegeID
- } into g
- select new
- {
- collegeID = g.Key.CollegeID,
- RetakePlan = g.Key.RetakePlan,
- TeachingSetting = g.Key.RetakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting,
- TeachingMode = g.Select(x => x).ToList(),
- Teacher = g.Key.RetakePlan.ER_RetakePlanTeacher,
- Scheduling = g.Key.RetakePlan.ER_RetakePlanSettingScheduling,
- Student = g.Key.RetakePlan.CF_Student, //选此课的学生
- RetakePlanStudent = g.Key.RetakePlan.ER_RetakePlanStudent
- }
- );
- var missionDataList = query.ToList();
- for (int i = 0; i < missionDataList.Count; i++)
- {
- var mission = missionDataList[i];
- EM_EducationMission educationMission = new EM_EducationMission();
- educationMission.EducationMissionID = Guid.NewGuid();
- educationMission.ClassName = mission.RetakePlan.ClassName;
- educationMission.DepartmentID = mission.RetakePlan.ER_RetakePlanSetting.DepartmentID;
- educationMission.SchoolyearID = mission.RetakePlan.SchoolyearID;
- educationMission.CollegeID = mission.collegeID;//CollegeDepartmentList.FirstOrDefault(x => x.DepartmentID == mission.RetakePlan.ER_RetakePlanSetting.DepartmentID.Value).CollegeID;
- SetNewStatus(educationMission);
- //educationMission.CF_Classmajor.Add(mission.Classmajor);
- resultMissionList.Add(educationMission);
- foreach (var tm in mission.TeachingMode)
- {
- var Scheduling = mission.RetakePlan.ER_RetakePlanSettingScheduling.FirstOrDefault();
- EM_EducationMissionClass educationMissionClass = new EM_EducationMissionClass();
- educationMissionClass.EducationMissionClassID = Guid.NewGuid();
- educationMissionClass.OrderNo = 0;
- educationMissionClass.EducationMissionID = educationMission.EducationMissionID;
- educationMissionClass.Name = mission.RetakePlan.ClassName;
- //educationMissionClass.Name = mission.Classmajor.Name + "-" + mission.ExecutablePlan.EM_FreeSelectionCouse.EM_Coursematerial.CourseName;
- educationMissionClass.TeachingModeID = tm.Value;
- if (mission.TeachingMode.Count > 0)
- {
- educationMissionClass.Name += "【" + tm.Name + "】";
- }
- //重修默认为必修
- educationMissionClass.OptionalCourseTypeID = (int)CF_CourseSelectType.Required;
- educationMissionClass.CoursematerialID = mission.RetakePlan.CoursematerialID;
- educationMissionClass.CourseStructureID = mission.RetakePlan.ER_RetakePlanSetting.CourseStructureID;
- educationMissionClass.CourseCategoryID = mission.RetakePlan.ER_RetakePlanSetting.CourseCategoryID;
- educationMissionClass.CourseTypeID = mission.RetakePlan.CourseTypeID;
- educationMissionClass.CourseQualityID = mission.RetakePlan.ER_RetakePlanSetting.CourseQualityID;
- educationMissionClass.ExaminationModeID = mission.RetakePlan.ER_RetakePlanSetting.ExaminationModeID;
- educationMissionClass.TeachinglanguageID = mission.RetakePlan.ER_RetakePlanSetting.TeachinglanguageID;
- //重修默认为必修
- educationMissionClass.HandleModeID = (int)EMIS.ViewModel.CF_HandleMode.RequiredCourse;
- educationMissionClass.IsNeedMaterial = mission.RetakePlan.ER_RetakePlanSetting.IsNeedMaterial;
- //成绩类型,默认为百分制
- educationMissionClass.ResultTypeID = (int)EMIS.ViewModel.CF_ResultType.Percentage;
- SetNewStatus(educationMissionClass);
- educationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Scheduled;
- //插入教学设置
- EM_EducationMissionClassTeachingSetting educationMissionClassTeachingSetting = new EM_EducationMissionClassTeachingSetting();
- educationMissionClassTeachingSetting.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- educationMissionClassTeachingSetting.Credit = mission.RetakePlan.Credit;
- educationMissionClassTeachingSetting.TheoryCourse = mission.TeachingSetting.TheoryCourse;
- educationMissionClassTeachingSetting.Practicehours = mission.TeachingSetting.Practicehours;
- educationMissionClassTeachingSetting.Trialhours = mission.TeachingSetting.Trialhours;
- educationMissionClassTeachingSetting.WeeklyNum = mission.TeachingSetting.WeeklyNum;
- educationMissionClassTeachingSetting.TheoryWeeklyNum = mission.TeachingSetting.TheoryWeeklyNum;
- educationMissionClassTeachingSetting.PracticeWeeklyNum = mission.TeachingSetting.PracticeWeeklyNum;
- educationMissionClassTeachingSetting.TrialWeeklyNum = mission.TeachingSetting.TrialWeeklyNum;
- educationMissionClassTeachingSetting.StartWeeklyNum = mission.TeachingSetting.StartWeeklyNum;
- educationMissionClassTeachingSetting.EndWeeklyNum = mission.TeachingSetting.EndWeeklyNum;
- educationMissionClassTeachingSetting.WeeklyHours = mission.TeachingSetting.WeeklyHours;
- foreach (var list in mission.Teacher.Select(x => new { x.UserID, x.TeachType }))
- {
- EM_MissionClassTeacher teacher = new EM_MissionClassTeacher();
- teacher.MissionClassTeacherID = Guid.NewGuid();
- teacher.MissionClassID = educationMissionClass.EducationMissionClassID;
- teacher.TeachType = list.TeachType;
- teacher.UserID = list.UserID;
- SetNewStatus(teacher);
- educationMissionClass.EM_MissionClassTeacher.Add(teacher);
- resultTeacherList.Add(teacher);
- }
- int? ClassroomType = null; //教室类型,教学任务班表和课程进度需要
- if (Scheduling != null && Scheduling.ClassroomID != null)
- {
- var classRoom = educationMissionClassDAL.ClassroomRepository.GetList(x => x.ClassroomID == Scheduling.ClassroomID, x => x.CF_ClassroomType).FirstOrDefault();
- if (classRoom != null && classRoom.CF_ClassroomType.FirstOrDefault() != null)
- {
- ClassroomType = classRoom.CF_ClassroomType.FirstOrDefault().ClassroomType;
- educationMissionClass.ClassroomTypeID = ClassroomType;
- }
- educationMissionClass.ClassroomID = Scheduling.ClassroomID;
- }
- if (Scheduling.CoursesTimeID != null)
- {
- var coursesTime = educationMissionClassDAL.CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == Scheduling.CoursesTimeID).FirstOrDefault();
- educationMissionClass.EM_CoursesTime = new HashSet<EM_CoursesTime>();
- educationMissionClass.EM_CoursesTime.Add(coursesTime);
- }
- //插入排课班
- EM_EducationSchedulingClass educationSchedulingClass = new EM_EducationSchedulingClass();
- educationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid();
- educationSchedulingClass.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- educationSchedulingClass.TaskGroupName = "1班";
- SetNewStatus(educationSchedulingClass);
- //添加排课任务班学生
- educationSchedulingClass.CF_Student = mission.Student; //选此课的学生
- resultMissionClassList.Add(educationMissionClass);
- resultMissionClassTeachingSettingList.Add(educationMissionClassTeachingSetting);
- resultEducationSchedulingClassList.Add(educationSchedulingClass);
- #region//插入排课相关信息
- //添加排课任务班学生
- educationSchedulingClass.CF_Student = mission.Student; //选此课的学生
- //根据开始和结束周,得到所有周的列表
- List<int?> schedulingWeekList = new List<int?>();
- schedulingWeekList.Add(mission.TeachingSetting.StartWeeklyNum);
- schedulingWeekList.Add(mission.TeachingSetting.EndWeeklyNum);
- for (int j = 1; j + schedulingWeekList.Min() < schedulingWeekList.Max(); j++)
- {
- schedulingWeekList.Add(j + schedulingWeekList.Min());
- }
- //排课课表
- foreach (var list in mission.Scheduling.Select(x => new { x.CoursesTimeID, x.ClassroomID, x.Weekday }))
- {
- ES_EducationScheduling educationScheduling = new ES_EducationScheduling();
- educationScheduling.EducationSchedulingID = Guid.NewGuid();
- educationScheduling.EducationSchedulingClassID = educationSchedulingClass.EducationSchedulingClassID;
- educationScheduling.SchoolyearID = educationMission.SchoolyearID;
- educationScheduling.Weekday = list.Weekday;
- educationScheduling.ClassroomID = list.ClassroomID;
- educationScheduling.CoursesTimeID = list.CoursesTimeID;
- SetNewStatus(educationScheduling);
- //educationScheduling.ES_EducationSchedulingTeacher.Add(educationScheduling);
- resultEducationSchedulingList.Add(educationScheduling);
- //排课教师表
- foreach (var teacherlist in mission.Teacher.Select(x => new { x.UserID, x.TeachType }))
- {
- ES_EducationSchedulingTeacher teacher = new ES_EducationSchedulingTeacher();
- teacher.EducationSchedulingTeacherID = Guid.NewGuid();
- teacher.EducationSchedulingID = educationScheduling.EducationSchedulingID;
- teacher.TeachingMethod = teacherlist.TeachType;
- teacher.UserID = teacherlist.UserID;
- SetNewStatus(teacher);
- educationScheduling.ES_EducationSchedulingTeacher.Add(teacher);
- resultEducationSchedulingTeacherList.Add(teacher);
- }
- foreach (var weekList in schedulingWeekList)
- {
- ES_EducationSchedulingWeekNum week = new ES_EducationSchedulingWeekNum();
- week.EducationSchedulingWeekNumID = Guid.NewGuid();
- week.EducationSchedulingID = educationScheduling.EducationSchedulingID;
- week.WeekNum = weekList;
- SetNewStatus(week);
- educationScheduling.ES_EducationSchedulingWeekNum.Add(week);
- resultEducationSchedulingWeekNumList.Add(week);
- }
- }
- //课程进度和教室以及任务班设置表
- foreach (var weekList in schedulingWeekList)
- {
- EM_CourseProcess process = new EM_CourseProcess();
- process.CourseProcessID = Guid.NewGuid();
- process.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- process.Week = weekList;
- process.Times = mission.TeachingSetting.WeeklyHours;
- process.ClassroomTypeID = ClassroomType;
- process.ClassroomID = educationMissionClass.ClassroomID;
- SetNewStatus(process);
- resultCourseProcessList.Add(process);
- //任务班设置表
- EM_EducationMissionClassSettings educationMissionClassSettings = new EM_EducationMissionClassSettings();
- educationMissionClassSettings.EducationMissionClassSettingsID = Guid.NewGuid();
- educationMissionClassSettings.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- educationMissionClassSettings.WeeklyNum = weekList;
- SetNewStatus(educationMissionClassSettings);
- resultEducationMissionClassSettingsList.Add(educationMissionClassSettings);
- //排课教师表
- foreach (var teacherlist in mission.Teacher.Select(x => new { x.UserID, x.TeachType }))
- {
- EM_CourseProcessTeacher teacher = new EM_CourseProcessTeacher();
- teacher.CourseProcessTeacherID = Guid.NewGuid();
- teacher.CourseProcessID = process.CourseProcessID;
- teacher.UserID = teacherlist.UserID;
- teacher.TeachType = teacherlist.TeachType;
- SetNewStatus(teacher);
- resultCourseProcessTeacherList.Add(teacher);
- }
- }
- #endregion
- mission.RetakePlanStudent.ToList().ForEach(x => x.EducationMissionID = educationMission.EducationMissionID);
- }
- //UnitOfWork.Add(educationMission);
- }
- UnitOfWork.BulkInsert(resultMissionList); //教学任务
- UnitOfWork.BulkInsert(resultMissionClassList); //教学任务班
- UnitOfWork.BulkInsert(resultMissionClassTeachingSettingList);
- UnitOfWork.BulkInsert(resultTeacherList); //
- UnitOfWork.BulkInsert(resultMissionClassList, x => x.EM_CoursesTime); //
- UnitOfWork.BulkInsert(resultEducationMissionClassSettingsList); //任务班设置表
- UnitOfWork.BulkInsert(resultEducationSchedulingList); //排课课表
- UnitOfWork.BulkInsert(resultEducationSchedulingTeacherList); //排课老师表
- UnitOfWork.BulkInsert(resultEducationSchedulingWeekNumList); //
- UnitOfWork.BulkInsert(resultEducationSchedulingClassList); //排课班表
- UnitOfWork.BulkInsert(resultEducationSchedulingClassList, (x => x.CF_Student)); //排课班与学生关联表
- UnitOfWork.BulkInsert(resultCourseProcessList); //课程进度
- UnitOfWork.BulkInsert(resultCourseProcessTeacherList); //课程进度任课老师表
- retakePlanList.ForEach(x => x.RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated);
- UnitOfWork.Commit();
- if (RemoveList.Count == 0)
- {
- return "开班成功。";
- }
- else
- {
- return string.Format("成功开班{0}条,失败{1}条,原因:缺少{2}", retakePlanList.Count, RemoveList.Count, result + "。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 检测重修报名人数是否超过人数下限和人数上限范围
- /// </summary>
- /// <param name="retakePlanIDs"></param>
- /// <returns></returns>
- public bool IsOverRange(string retakePlanIDs)
- {
- List<Guid?> list = retakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- var IsExistsList = this.RetakePlanTaskDAL.RetakePlanRepository
- .GetList(x => list.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList();
- if (IsExistsList != null && IsExistsList.Count() > 0)
- {
- foreach (var IsExists in IsExistsList)
- {
- if (IsExists.PeopleNumlower != null && IsExists.PeopleNumlower != 0)
- {
- //人数下限
- if (IsExists.CF_Student.Count() < IsExists.PeopleNumlower.Value)
- {
- return true;
- }
- }
- else if (IsExists.PeopleNumlimit != null && IsExists.PeopleNumlimit != 0)
- {
- //人数上限
- if (IsExists.CF_Student.Count() > IsExists.PeopleNumlimit.Value)
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- /// <summary>
- /// 查询重修计划报名名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="retakePlanStatusID"></param>
- /// <param name="generalPurposeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeStudentListView> GetRetakePlanResultStudentView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? coursematerialID,
- int? inSchoolStatus, int? retakePlanStatusID, int? generalPurposeID, int pageIndex, int pageSize)
- {
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- ////排除重修任务状态为未开放状态的信息
- //expRetakePlan = expRetakePlan.And(x => x.RecordStatus != (int)ER_RetakePlanStatus.NotOpened);
- if (coursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (schoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
- }
- if (retakePlanStatusID.HasValue)
- {
- //重修任务状态
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus == retakePlanStatusID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- //在校状态
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = RetakePlanResultDAL.GetRetakePlanResultStudentView(expRetakePlan, expStudent);
- if (collegeID.HasValue)
- {
- //院系所
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- //年级
- query = query.Where(x => x.Gradeyear == yearID);
- }
- if (standardID.HasValue)
- {
- //专业名称
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- //培养层次
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- //学习形式
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (generalPurposeID.HasValue)
- {
- //报名状态
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.ApplyStatus == true);
- }
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.ApplyStatus == false);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCredit)
- .ThenBy(x => x.DepartmentCode.Length).ThenBy(x => x.DepartmentCode)
- .ThenBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询重修计划报名名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="retakePlanStatusID"></param>
- /// <param name="generalPurposeID"></param>
- /// <returns></returns>
- public List<RetakeStudentListView> GetRetakePlanResultStudentViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? coursematerialID,
- int? inSchoolStatus, int? retakePlanStatusID, int? generalPurposeID)
- {
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- ////排除重修任务状态为未开放状态的信息
- //expRetakePlan = expRetakePlan.And(x => x.RecordStatus != (int)ER_RetakePlanStatus.NotOpened);
- if (coursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (schoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
- }
- if (retakePlanStatusID.HasValue)
- {
- //重修任务状态
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus == retakePlanStatusID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- //在校状态
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = RetakePlanResultDAL.GetRetakePlanResultStudentView(expRetakePlan, expStudent);
- if (collegeID.HasValue)
- {
- //院系所
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- //年级
- query = query.Where(x => x.Gradeyear == yearID);
- }
- if (standardID.HasValue)
- {
- //专业名称
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- //培养层次
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- //学习形式
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (generalPurposeID.HasValue)
- {
- //报名状态
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.ApplyStatus == true);
- }
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.ApplyStatus == false);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCredit)
- .ThenBy(x => x.DepartmentCode.Length).ThenBy(x => x.DepartmentCode)
- .ThenBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .ToList();
- }
- /// <summary>
- /// 取消报名(删除)
- /// </summary>
- /// <param name="RetakePlanStudentIDs"></param>
- /// <param name="UserIDs"></param>
- public void RetakePlanResultDelete(string RetakePlanStudentIDs)
- {
- try
- {
- List<Guid?> retakePlanStudentIDsList = RetakePlanStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- //查询对应的重修报名信息List(已报名)
- var retakePlanStudentApplyViewList = RetakePlanResultDAL.RetakePlanStudentRepository
- .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID),
- (x => x.ER_RetakePlan),
- (x => x.ER_RetakePlan.CF_Student))
- .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
- .ToList();
- if (retakePlanStudentApplyViewList.Count() > 0)
- {
- //查询对应的重修计划信息
- var retakePlanViewList = retakePlanStudentApplyViewList
- .Select(x => x.ER_RetakePlan).Distinct().ToList();
- //重修报名表
- foreach (var retakePlan in retakePlanViewList)
- {
- //查询存在报名名单的重修计划名单对应的userIDList
- var userIDList = retakePlanStudentApplyViewList
- .Where(x => x.RetakePlanID == retakePlan.RetakePlanID)
- .Select(x => x.UserID).ToList();
- //取消报名(删除)
- retakePlan.CF_Student.RemoveWhere(x => userIDList.Contains(x.UserID));
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|