123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970 |
- using EMIS.DataLogic.SelectCourse.SelectCourseResult;
- using EMIS.Entities;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.SelectCourse.SelectCourseResult;
- using EMIS.ViewModel.Students;
- using EMIS.Utility;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.DataLogic.SelectCourse;
- using EMIS.DataLogic.UniversityManage.SpecialtyClassManage;
- using EMIS.DataLogic.EducationManage;
- using EMIS.DataLogic.Repositories;
- using Bowin.Common.Linq;
- using EMIS.ViewModel;
- namespace EMIS.CommonLogic.SelectCourse.SelectCourseResult
- {
- public class SelectCourseResultServices : BaseServices, ISelectCourseResultServices
- {
- public EducationMissionClassDAL educationMissionClassDAL { get; set; }
- public MissionClassTeacherRepository missionClassTeacherRepository { get; set; }
- public SelectCourseResultDAL SelectCourseResultDAL { get; set; }
- public OptionalCourseSettingDAL optionalCourseSettingDAL { get; set; }
- public ClassmajorDAL classmajorDAL { get; set; }
- public ExecutablePlanDAL ExecutablePlanDAL { get; set; }
- public OptionalCourseSettingDAL OptionalCourseSettingDAL { get; set; }
- public OpenControlSettingDAL OpenControlSettingDAL { get; set; }
- public ExecutableFreeSelectionCouseDAL ExecutableFreeSelectionCouseDAL { get; set; }
- public IStudentSelectCourseServices IStudentSelectCourseServices { get; set; }
- public IGridResultSet<SelectCourseResultView> GetSelectCourseResultViewList
- (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID,
- Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened, int pageIndex, int pageSize)
- {
- Expression<Func<EM_ExecutableOptionalCourse, bool>> eocExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efcExp = (x => true);
- var query = SelectCourseResultDAL.GetSelectCourseResultViewQueryable(eocExp, efcExp);
- var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp);
- var query2 = SelectCourseResultDAL.GetSelectCourseResultTeachingMode(eocExp, efcExp);
- if (schoolYearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == schoolYearID);
- query1 = query1.Where(x => x.SchoolyearID == schoolYearID);
- efcExp.And(x => x.SchoolyearID == schoolYearID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- efcExp.And(x => x.CF_Department.CollegeID == collegeID);
- }
- if (courseID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == courseID);
- efcExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == courseID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- query1 = query1.Where(x => x.CourseTypeID == courseTypeID);
- efcExp.And(x => x.CourseTypeID == courseTypeID);
- }
- if (selectCourseTypeID.HasValue)
- {
- query = query.Where(x => x.SelectCourseType == selectCourseTypeID);
- query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID);
- }
- if (isCreated.HasValue)
- {
- query = query.Where(x => x.RecordStatus == isCreated);
- efcExp.And(x => x.RecordStatus == isCreated);
- //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
- // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo)
- // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- }
- if (isOpened.HasValue)
- {
- query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- }
- //未提交状态不显示
- query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- query2 = query2.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- //任选具体上课时间
- var queryScheduling = SelectCourseResultDAL.GetScheduling(efcExp).ToList();
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToGridResultSet<SelectCourseResultView>(pageIndex, pageSize);
- var teacher = query1.ToList().OrderBy(x => x.SelectCourseType);
- var teachingMode = query2.ToList().OrderBy(x => x.SelectCourseType);
- result.rows.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName)));
- if (queryScheduling.Count > 0)
- {
- var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(queryScheduling);
- result.rows.ForEach(x =>
- {
- var list = schedulingList.Where(w => w.ID == x.ID);
- x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
- });
- }
- return result;
- }
- public List<ViewModel.SelectCourse.SelectCourseResult.SelectCourseResultView> GetSelectCourseResultViewList
- (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID,
- Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened)
- {
- Expression<Func<EM_ExecutableOptionalCourse, bool>> eocExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efcExp = (x => true);
- var query = SelectCourseResultDAL.GetSelectCourseResultViewQueryable(eocExp, efcExp);
- var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp);
- if (schoolYearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == schoolYearID);
- query1 = query1.Where(x => x.SchoolyearID == schoolYearID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (courseID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == courseID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- query1 = query1.Where(x => x.CourseTypeID == courseTypeID);
- }
- if (selectCourseTypeID.HasValue)
- {
- query = query.Where(x => x.SelectCourseType == selectCourseTypeID);
- query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID);
- }
- if (isCreated.HasValue)
- {
- query = query.Where(x => x.RecordStatus == isCreated);
- //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
- // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo)
- // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- }
- if (isOpened.HasValue)
- {
- query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- }
- //未提交状态不显示
- query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- //任选具体上课时间
- var queryScheduling = SelectCourseResultDAL.GetScheduling(efcExp).ToList();
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var teacher = query1.ToList().OrderBy(x => x.SelectCourseType);
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToList();
- result.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName)));
- if (queryScheduling.Count > 0)
- {
- var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(queryScheduling);
- result.ForEach(x =>
- {
- var list = schedulingList.Where(w => w.ID == x.ID);
- x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
- });
- }
- return result;
- }
- public IGridResultSet<BaseStudentView> GetSelectCourseStudentViewGrid(Guid ID, string type, int pageIndex, int pageSize)
- {
- if (type == "0")
- {
- var query = OptionalCourseSettingDAL.GetSelectCourseStudent(x => x.ExecutableOptionalCourseID == ID).OrderBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(1, null);
- //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
- //return result;
- return query;
- }
- else
- {
- var query = OptionalCourseSettingDAL.GetSelectCourseStudent1(x => x.ExecutableFreeSelectionCouseID == ID).OrderBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(1, null);
- //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
- //return result;
- return query;
- }
- }
- /// <summary>
- /// 学生选课名单,区分限选学生和任选学生(0-限选,1-任选)
- /// </summary>
- /// <param name="ID"></param>
- /// <param name="type"></param>
- /// <returns></returns>
- public List<BaseStudentView> GetSelectCourseStudentViewList(Guid ID, string type)
- {
- if (type == "0")
- {
- var result = OptionalCourseSettingDAL.GetSelectCourseStudent(x => x.ExecutableOptionalCourseID == ID).OrderBy(x => x.LoginID).ToList();
- return result;
- }
- else
- {
- var result = OptionalCourseSettingDAL.GetSelectCourseStudent1(x => x.ExecutableFreeSelectionCouseID == ID).OrderBy(x => x.LoginID).ToList();
- return result;
- }
- }
- /// <summary>
- /// 生成教学任务班,Type为0时生成限选,1生成任选
- /// </summary>
- /// <param name="executablePlanIDs"></param>
- /// <param name="isOverride"></param>
- /// <param name="Type"></param>
- public void ChooseEducationMissionClass(List<Guid?> executablePlanIDs, string Type)
- {
- if (Type == "0")
- GenerateEducationMissionClassOptionalCourse(executablePlanIDs);
- else
- GenerateEducationMissionClassFreeSelection(executablePlanIDs);
- }
- /// <summary>
- /// 取消开班
- /// </summary>
- /// <param name="executablePlanIDs"></param>
- /// <param name="isOverride"></param>
- /// <param name="Type"></param>
- public void CancelEducationMissionClass(List<Guid?> executablePlanIDs)
- {
- List<EM_ExecutableOptionalCourse> ExecutableOptionalCourse = new List<EM_ExecutableOptionalCourse>();
- List<EM_ExecutableFreeSelectionCouse> ExecutableFreeSelectionCouse = new List<EM_ExecutableFreeSelectionCouse>();
- var OptionalCourseList = SelectCourseResultDAL.ExecutableOptionalCourseRepository.GetList(x => executablePlanIDs.Contains(x.ExecutableOptionalCourseID)).ToList();
- var FreeSelectionList = SelectCourseResultDAL.ExecutableFreeSelectionCouseRepository.GetList(x => executablePlanIDs.Contains(x.ExecutableFreeSelectionCouseID)).ToList();
- foreach (var OptionalCourse in OptionalCourseList)
- {
- OptionalCourse.RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate;
- ExecutableOptionalCourse.Add(OptionalCourse);
- }
- foreach (var FreeSelection in FreeSelectionList)
- {
- FreeSelection.RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate;
- ExecutableFreeSelectionCouse.Add(FreeSelection);
- }
- UnitOfWork.Commit();
- }
- /// <summary>
- /// 生成限选教学任务班
- /// </summary>
- /// <param name="executableOptionalCourseIDs"></param>
- /// <param name="teachingTypeNames"></param>
- public void GenerateEducationMissionClassOptionalCourse(List<Guid?> executableOptionalCourseIDs)
- {
- try
- {
- var executableOptionalCourseList = OptionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetList(x => executableOptionalCourseIDs.Contains(x.ExecutableOptionalCourseID),
- (x => x.CF_Grademajor.CF_Classmajor),
- (x => x.CF_Classmajor),
- (x => x.CF_Student),
- //(x => x.CF_Schoolyear),
- (x => x.EM_ExecutableOptionalCourseTeachingMode),
- (x => x.EM_ExecutableOptionalCourseTeacher),
- (x => x.EM_ExecutableOptionalCourseTeachingSetting),
- (x => x.EM_OptionalCoursePlan.EM_Coursematerial),
- (x => x.EM_OptionalCoursePlan.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings),
- (x => x.CF_Grademajor.CF_Facultymajor),
- (x => x.EM_OptionalCoursePlan.CF_Department)
- ).ToList();
- //不是“未开班”状态不能开班
- var submitedList = executableOptionalCourseList.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened && x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate).ToList();
- if (submitedList.Count > 0)
- {
- throw new Exception("不是“已开放”状态不能进行开班,请核查。");
- }
- //开放时间未结束,不能进行开班
- var OpenControlSettingGrademajorIDList = executableOptionalCourseList.Select(w => w.GrademajorID); //找到要开班的所有年级专业
- var OpenControlSettingList = OpenControlSettingDAL.SelectCourseOpenControlSettingRepository.Entities.Where(x =>
- OpenControlSettingGrademajorIDList.Contains(x.GrademajorID)).ToList(); //找到年级专业对应的开放结束时间
- //验证同一学年学期同一课程下,是否有重复学生
- var valid = OptionalCourseSettingDAL.GetDuplicateOptionCourseViewQueryable(x => executableOptionalCourseIDs.Contains(x.ExecutableOptionalCourseID)).ToList();
- if (valid.Count > 0)
- {
- List<string> validMessageList = new List<string>();
- for (int i = 0; i < valid.Count; i++)
- {
- validMessageList.Add("任务班【" + valid[i].SourceName + "】和【" + valid[i].DestinationName + "】有重复的学生,请核查。");
-
- }
- if (valid.Count > 0)
- {
- throw new Exception(string.Join(",", validMessageList));
- }
- }
- //判断是否有设置授课方式
- var noTeachingModeTypeList = executableOptionalCourseList.Where(x => x.EM_ExecutableOptionalCourseTeachingMode.Count == 0)
- .Concat(executableOptionalCourseList.Where(x => !x.EM_ExecutableOptionalCourseTeachingMode.Any(w => w.TeachingModeID != null))).ToList();
- if (noTeachingModeTypeList.Count > 0)
- {
- throw new Exception("没有设置授课方式的计划不能提交,请核查。");
- }
- var existsMissionClassStudentList = this.optionalCourseSettingDAL.GetEducationMissionClassStudentByExecutableOptionalCourseID(executableOptionalCourseIDs).ToList();
- var grademajorIDs = executableOptionalCourseList.Select(x => x.GrademajorID)
- .ToList();
- //var queryclassmajorList = classmajorDAL.classmajorRepository.GetList(x => grademajorIDs.Contains(x.GrademajorID),
- // (x => x.CF_Student)).ToList();
- var resultMissionList = new List<EM_EducationMission>();
- var resultMissionClassList = new List<EM_EducationMissionClass>();
- var resultMissionClassTeachingSettingList = new List<EM_EducationMissionClassTeachingSetting>();
- var resultSchedulingClassList = new List<EM_EducationSchedulingClass>();
- var resultTeacherList = new List<EM_MissionClassTeacher>();
- var noStudentList = executableOptionalCourseList.Where(x => x.CF_Student.Count == 0).Select(x => x.DefaultClassName).ToList();
- if (noStudentList.Count > 0)
- {
- throw new Exception("任务班" + string.Join(",", noStudentList) + "没有报名的学生,请核查!");
- }
- if (executableOptionalCourseList.Count > 0)
- {
- executableOptionalCourseList.ForEach(x => x.RecordStatus = (int)EMIS.ViewModel.EM_ExecuteStatus.Submited);
- string coursematerialName = "";
- var courseNames = executableOptionalCourseList.Where(x => x.EM_OptionalCoursePlan.EM_Coursematerial != null && x.EM_OptionalCoursePlan.EM_Coursematerial.EM_ClassGrouping == null).Select(x => x.EM_OptionalCoursePlan.EM_Coursematerial.CourseName).Distinct().ToArray();
- coursematerialName = string.Join(",", courseNames);
- if (courseNames.Length > 0)
- {
- throw new Exception("以下计划所对应的课程并未设置上课类型,无法确定任务班的分班方式,请到课程资料菜单完成设置后再次进行提交:\r\n" + coursematerialName);
- }
- }
- var query = (
- from eop in
- (
- //先找出上课类型没有设置的授课方式,然后单独成一个班
- (from eop in executableOptionalCourseList
- where eop.EM_ExecutableOptionalCourseTeachingMode
- .Any(x => !eop.EM_OptionalCoursePlan.EM_Coursematerial
- .EM_ClassGrouping
- .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID))
- select new
- {
- ExecutableOptionalCourse = eop,
- TeachingMode = eop.EM_ExecutableOptionalCourseTeachingMode
- .FirstOrDefault(x => !eop.EM_OptionalCoursePlan.EM_Coursematerial
- .EM_ClassGrouping
- .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID))
- .TeachingModeID
- })
- //接下来对除理论班之外的其他分班设置进行匹配,如果该专业课程有这个授课方式的话,就单独再分一个班
- .Concat(
- from eop in executableOptionalCourseList
- from tmt in eop.EM_ExecutableOptionalCourseTeachingMode
- from cgs in eop.EM_OptionalCoursePlan.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings
- where tmt.TeachingModeID == cgs.TeachingModeID
- select new
- {
- ExecutableOptionalCourse = eop,
- TeachingMode = cgs.TeachingModeID
- }))
- join dtm in DictionaryHelper.GetDictionaryValue(ViewModel.DictionaryItem.CF_TeachingMode) on eop.TeachingMode equals dtm.Value
- group dtm by new
- {
- //Classmajor = sp.Classmajor,
- ExecutableOptionalCourse = eop.ExecutableOptionalCourse
- } into g
- select new
- {
- ExecutableOptionalCourse = g.Key.ExecutableOptionalCourse,
- Classmajor = g.Key.ExecutableOptionalCourse.CF_Classmajor,
- TeachingMode = g.Select(x => x).ToList(),
- Teacher = g.Key.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeacher,
- Student = g.Key.ExecutableOptionalCourse.CF_Student, //选此课的学生
- }
- );
- 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.ExecutableOptionalCourse.DefaultClassName;
- educationMission.DepartmentID = mission.ExecutableOptionalCourse.DepartmentID;
- educationMission.CollegeID = mission.ExecutableOptionalCourse.CF_Grademajor.CF_Facultymajor.CollegeID;
- educationMission.SchoolyearID = mission.ExecutableOptionalCourse.SchoolyearID;
- SetNewStatus(educationMission);
- resultMissionList.Add(educationMission);
- foreach (var tm in mission.TeachingMode)
- {
- EM_EducationMissionClass educationMissionClass = new EM_EducationMissionClass();
- educationMissionClass.EducationMissionClassID = Guid.NewGuid();
- educationMissionClass.MainScheduleClassID = mission.Classmajor.OrderBy(x => x.No).FirstOrDefault().ClassmajorID;
- educationMissionClass.OrderNo = 0;
- educationMissionClass.EducationMissionID = educationMission.EducationMissionID;
- educationMissionClass.Name = mission.ExecutableOptionalCourse.DefaultClassName;
- educationMissionClass.TeachingModeID = tm.Value;
- if (mission.TeachingMode.Count > 0)
- {
- educationMissionClass.Name += "【" + tm.Name + "】";
- }
- educationMissionClass.OptionalCourseTypeID = (int)CF_CourseSelectType.OptionalCourse;
- educationMissionClass.CoursematerialID = mission.ExecutableOptionalCourse.EM_OptionalCoursePlan.CoursematerialID;
- educationMissionClass.CourseStructureID = mission.ExecutableOptionalCourse.CourseStructureID;
- educationMissionClass.CourseCategoryID = mission.ExecutableOptionalCourse.CourseCategoryID;
- educationMissionClass.CourseTypeID = mission.ExecutableOptionalCourse.CourseTypeID;
- educationMissionClass.CourseQualityID = mission.ExecutableOptionalCourse.CourseQualityID;
- educationMissionClass.ExaminationModeID = mission.ExecutableOptionalCourse.ExaminationModeID;
- educationMissionClass.TeachinglanguageID = mission.ExecutableOptionalCourse.TeachinglanguageID;
- educationMissionClass.HandleModeID = (int)CF_HandleMode.SelectionCourse;
- educationMissionClass.IsNeedMaterial = false;
- educationMissionClass.CF_Classmajor = mission.Classmajor;
- educationMissionClass.ResultTypeID = mission.ExecutableOptionalCourse.ResultTypeID;
- foreach (var list in mission.Teacher.Select(x => new { x.UserID, x.TeachingMethod }))
- {
- EM_MissionClassTeacher teacher = new EM_MissionClassTeacher();
- teacher.MissionClassTeacherID = Guid.NewGuid();
- teacher.MissionClassID = educationMissionClass.EducationMissionClassID;
- teacher.TeachType = list.TeachingMethod;
- teacher.UserID = list.UserID;
- SetNewStatus(teacher);
- educationMissionClass.EM_MissionClassTeacher.Add(teacher);
- resultTeacherList.Add(teacher);
- }
- //educationMissionClass.EM_MissionClassTeacher = mission.Teacher;
- SetNewStatus(educationMissionClass);
- educationMissionClass.RecordStatus = (int)EMIS.ViewModel.CF_ApprovalStatus.NotSubmitted;
- //插入教学设置
- EM_EducationMissionClassTeachingSetting educationMissionClassTeachingSetting = new EM_EducationMissionClassTeachingSetting();
- educationMissionClassTeachingSetting.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- educationMissionClassTeachingSetting.Credit = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.Credit;
- educationMissionClassTeachingSetting.TheoryCourse = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.TheoryCourse;
- educationMissionClassTeachingSetting.Practicehours = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.Practicehours;
- educationMissionClassTeachingSetting.Trialhours = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.Trialhours;
- educationMissionClassTeachingSetting.WeeklyNum = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.WeeklyNum;
- educationMissionClassTeachingSetting.TheoryWeeklyNum = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.TheoryWeeklyNum;
- educationMissionClassTeachingSetting.PracticeWeeklyNum = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.PracticeWeeklyNum;
- educationMissionClassTeachingSetting.TrialWeeklyNum = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.TrialWeeklyNum;
- educationMissionClassTeachingSetting.StartWeeklyNum = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.StartWeeklyNum;
- educationMissionClassTeachingSetting.EndWeeklyNum = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.EndWeeklyNum;
- educationMissionClassTeachingSetting.WeeklyHours = mission.ExecutableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting.WeeklyHours;
- //插入排课班
- EM_EducationSchedulingClass educationSchedulingClass = new EM_EducationSchedulingClass();
- educationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid();
- educationSchedulingClass.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- educationSchedulingClass.TaskGroupName = "1班";
- SetNewStatus(educationSchedulingClass);
- List<Guid> educationMissionClassUserIDs = existsMissionClassStudentList
- .Where(x => x.CoursematerialID == educationMissionClass.CoursematerialID
- && x.SchoolyearID == educationMission.SchoolyearID
- && x.HandleModeID == educationMissionClass.HandleModeID
- && x.CourseSelectTypeID == educationMissionClass.OptionalCourseTypeID).Select(x => x.UserID.Value).ToList();
- //查询要开班的教学任务班对应学生
- List<Guid> missionUserIDs = mission.Student.Select(x => x.UserID).ToList();
- //添加排课任务班学生(先查出要开班的学生与已存在的排课班对应学生的差集,排除重复学生,分班后删除再重新开班时存在重复学生)
- educationSchedulingClass.CF_Student = new HashSet<CF_Student>(mission.Student.Where(x => missionUserIDs.Except(educationMissionClassUserIDs).Contains(x.UserID))); //选此课的学生
- resultMissionClassList.Add(educationMissionClass);
- resultMissionClassTeachingSettingList.Add(educationMissionClassTeachingSetting);
- resultSchedulingClassList.Add(educationSchedulingClass);
- }
- mission.ExecutableOptionalCourse.RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created;
- }
- UnitOfWork.BulkInsert(resultMissionList);
- UnitOfWork.BulkInsert(resultMissionClassList);
- UnitOfWork.BulkInsert(resultMissionClassTeachingSettingList);
- UnitOfWork.BulkInsert(resultMissionClassList, (x => x.CF_Classmajor));
- UnitOfWork.BulkInsert(resultMissionClassList, (x => x.EM_MissionClassTeacher));
- UnitOfWork.BulkInsert(resultTeacherList);
- UnitOfWork.BulkInsert(resultSchedulingClassList);
- UnitOfWork.BulkInsert(resultSchedulingClassList, (x => x.CF_Student));
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 生成任选教学任务班
- /// </summary>
- /// <param name="executableFreeSelectionCourseIDs"></param>
- /// <param name="isOverride"></param>
- public void GenerateEducationMissionClassFreeSelection(List<Guid?> executableFreeSelectionCourseIDs)
- {
- try
- {
- var executableFreeSelectionCourseList = OptionalCourseSettingDAL.ExecutableFreeSelectionCouseRepository.GetList(x => executableFreeSelectionCourseIDs.Contains(x.ExecutableFreeSelectionCouseID),
- (x => x.CF_Student),
- (x => x.EM_ExecutableFreeSelectionCouseTeachingMode),
- (x => x.EM_ExecutableFreeSelectionCouseTeacher),
- (x => x.EM_ExecutableFreeSelectionCouseTeachingSetting),
- (x => x.EM_FreeSelectionCouse.EM_Coursematerial),
- (x => x.EM_FreeSelectionCouse.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings),
- (x => x.EM_ExecutableFreeSelectionCouseScheduling),
- (x => x.CF_Department)
- ).ToList();
- var submitedList = executableFreeSelectionCourseList.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened && x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate).ToList();
- if (submitedList.Count > 0)
- {
- throw new Exception("不是已开放状态不能进行开班,请核查。");
- }
- var noTeachingModeTypeList = executableFreeSelectionCourseList.Where(x => x.EM_ExecutableFreeSelectionCouseTeachingMode.Count == 0)
- .Concat(executableFreeSelectionCourseList.Where(x => !x.EM_ExecutableFreeSelectionCouseTeachingMode.Any(w => w.TeachingModeID != null))).ToList();
- if (noTeachingModeTypeList.Count > 0)
- {
- throw new Exception("没有设置授课方式的计划不能提交,请核查。");
- }
- var noSchedulingList = executableFreeSelectionCourseList.Where(x => x.EM_ExecutableFreeSelectionCouseScheduling.Count == 0).FirstOrDefault();
- if (noSchedulingList != null)
- throw new Exception(noSchedulingList.DefaultClassName + "缺少排课信息,不能开班");
- 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 noStudentList = executableFreeSelectionCourseList.Where(x => x.CF_Student.Count == 0).Select(x => x.DefaultClassName).ToList();
- if (noStudentList.Count > 0)
- {
- throw new Exception("任务班" + string.Join(",", noStudentList) + "未分配学生!");
- }
- if (executableFreeSelectionCourseList.Count > 0)
- {
- executableFreeSelectionCourseList.ForEach(x => x.RecordStatus = (int)EMIS.ViewModel.EM_ExecuteStatus.Submited);
- string coursematerialName = "";
- var courseNames = executableFreeSelectionCourseList.Where(x => x.EM_FreeSelectionCouse.EM_Coursematerial != null && x.EM_FreeSelectionCouse.EM_Coursematerial.EM_ClassGrouping == null).Select(x => x.EM_FreeSelectionCouse.EM_Coursematerial.CourseName).Distinct().ToArray();
- coursematerialName = string.Join(",", courseNames);
- if (courseNames.Length > 0)
- {
- throw new Exception("以下计划所对应的课程并未设置上课类型,无法确定任务班的分班方式,请到课程资料菜单完成设置后再次进行提交:\r\n" + coursematerialName);
- }
- }
- var query = (
- from efsc in
- (
- //先找出上课类型没有设置的授课方式,然后单独成一个班
- (from efsc in executableFreeSelectionCourseList
- where efsc.EM_ExecutableFreeSelectionCouseTeachingMode
- .Any(x => !efsc.EM_FreeSelectionCouse.EM_Coursematerial
- .EM_ClassGrouping
- .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID))
- select new
- {
- ExecutableFreeSelectionCourse = efsc,
- TeachingMode = efsc.EM_ExecutableFreeSelectionCouseTeachingMode
- .FirstOrDefault(x => !efsc.EM_FreeSelectionCouse.EM_Coursematerial
- .EM_ClassGrouping
- .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID))
- .TeachingModeID
- })
- //接下来对除理论班之外的其他分班设置进行匹配,如果该专业课程有这个授课方式的话,就单独再分一个班
- .Concat(
- from efsc in executableFreeSelectionCourseList
- from tmt in efsc.EM_ExecutableFreeSelectionCouseTeachingMode
- from cgs in efsc.EM_FreeSelectionCouse.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings
- where tmt.TeachingModeID == cgs.TeachingModeID
- select new
- {
- ExecutableFreeSelectionCourse = efsc,
- TeachingMode = cgs.TeachingModeID
- }))
- join dtm in DictionaryHelper.GetDictionaryValue(ViewModel.DictionaryItem.CF_TeachingMode) on efsc.TeachingMode equals dtm.Value
- group dtm by new
- {
- ExecutableFreeSelectionCourse = efsc.ExecutableFreeSelectionCourse
- } into g
- select new
- {
- ExecutableFreeSelectionCourse = g.Key.ExecutableFreeSelectionCourse,
- TeachingSetting = g.Key.ExecutableFreeSelectionCourse.EM_ExecutableFreeSelectionCouseTeachingSetting,
- TeachingMode = g.Select(x => x).ToList(),
- Teacher = g.Key.ExecutableFreeSelectionCourse.EM_ExecutableFreeSelectionCouseTeacher,
- Scheduling = g.Key.ExecutableFreeSelectionCourse.EM_ExecutableFreeSelectionCouseScheduling,
- Student = g.Key.ExecutableFreeSelectionCourse.CF_Student, //选此课的学生
- }
- );
- 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.ExecutableFreeSelectionCourse.DefaultClassName;
- educationMission.DepartmentID = mission.ExecutableFreeSelectionCourse.DepartmentID;
- educationMission.SchoolyearID = mission.ExecutableFreeSelectionCourse.SchoolyearID;
- educationMission.CollegeID = mission.ExecutableFreeSelectionCourse.CF_Department.CollegeID;
- SetNewStatus(educationMission);
- //educationMission.CF_Classmajor.Add(mission.Classmajor);
- resultMissionList.Add(educationMission);
- foreach (var tm in mission.TeachingMode)
- {
- var executableFreeSelectionCouseScheduling = mission.ExecutableFreeSelectionCourse.EM_ExecutableFreeSelectionCouseScheduling.FirstOrDefault();
- EM_EducationMissionClass educationMissionClass = new EM_EducationMissionClass();
- educationMissionClass.EducationMissionClassID = Guid.NewGuid();
- educationMissionClass.OrderNo = 0;
- educationMissionClass.EducationMissionID = educationMission.EducationMissionID;
- educationMissionClass.Name = mission.ExecutableFreeSelectionCourse.DefaultClassName;
- //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 = null;
- educationMissionClass.OptionalCourseTypeID = (int)CF_CourseSelectType.FreeSelectionCourse;
- educationMissionClass.CoursematerialID = mission.ExecutableFreeSelectionCourse.EM_FreeSelectionCouse.CoursematerialID;
- educationMissionClass.CourseStructureID = mission.ExecutableFreeSelectionCourse.CourseStructureID;
- educationMissionClass.CourseCategoryID = mission.ExecutableFreeSelectionCourse.CourseCategoryID;
- educationMissionClass.CourseTypeID = mission.ExecutableFreeSelectionCourse.CourseTypeID;
- educationMissionClass.CourseQualityID = mission.ExecutableFreeSelectionCourse.CourseQualityID;
- educationMissionClass.ExaminationModeID = mission.ExecutableFreeSelectionCourse.ExaminationModeID;
- educationMissionClass.TeachinglanguageID = mission.ExecutableFreeSelectionCourse.TeachinglanguageID;
- educationMissionClass.HandleModeID = mission.ExecutableFreeSelectionCourse.HandleModeID;
- educationMissionClass.IsNeedMaterial = mission.ExecutableFreeSelectionCourse.IsNeedMaterial;
- educationMissionClass.ResultTypeID = mission.ExecutableFreeSelectionCourse.ResultTypeID;
- SetNewStatus(educationMissionClass);
- educationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Scheduled;
- //插入教学设置
- EM_EducationMissionClassTeachingSetting educationMissionClassTeachingSetting = new EM_EducationMissionClassTeachingSetting();
- educationMissionClassTeachingSetting.EducationMissionClassID = educationMissionClass.EducationMissionClassID;
- educationMissionClassTeachingSetting.Credit = mission.TeachingSetting.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.TeachingMethod }))
- {
- EM_MissionClassTeacher teacher = new EM_MissionClassTeacher();
- teacher.MissionClassTeacherID = Guid.NewGuid();
- teacher.MissionClassID = educationMissionClass.EducationMissionClassID;
- teacher.TeachType = list.TeachingMethod;
- teacher.UserID = list.UserID;
- SetNewStatus(teacher);
- educationMissionClass.EM_MissionClassTeacher.Add(teacher);
- resultTeacherList.Add(teacher);
- }
- int? ClassroomType = null; //教室类型,教学任务班表和课程进度需要
- if (executableFreeSelectionCouseScheduling != null && executableFreeSelectionCouseScheduling.ClassroomID != null)
- {
- var classRoom = educationMissionClassDAL.ClassroomRepository.GetList(x => x.ClassroomID == executableFreeSelectionCouseScheduling.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 = executableFreeSelectionCouseScheduling.ClassroomID;
- }
- if (executableFreeSelectionCouseScheduling.CoursesTimeID != null)
- {
- var coursesTime = educationMissionClassDAL.CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == executableFreeSelectionCouseScheduling.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);
- //添加排课任务班学生
- educationSchedulingClass.CF_Student = mission.Student; //选此课的学生
- //resultMissionClassList.Add(educationMissionClass);
- //resultSchedulingClassList.Add(educationSchedulingClass);
- //根据开始和结束周,得到所有周的列表
- 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.TeachingMethod }))
- {
- ES_EducationSchedulingTeacher teacher = new ES_EducationSchedulingTeacher();
- teacher.EducationSchedulingTeacherID = Guid.NewGuid();
- teacher.EducationSchedulingID = educationScheduling.EducationSchedulingID;
- teacher.TeachingMethod = teacherlist.TeachingMethod;
- 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.TeachingMethod }))
- {
- EM_CourseProcessTeacher teacher = new EM_CourseProcessTeacher();
- teacher.CourseProcessTeacherID = Guid.NewGuid();
- teacher.CourseProcessID = process.CourseProcessID;
- teacher.UserID = teacherlist.UserID;
- teacher.TeachType = teacherlist.TeachingMethod;
- SetNewStatus(teacher);
- resultCourseProcessTeacherList.Add(teacher);
- }
- }
- }
- //UnitOfWork.Add(educationMission);
- EM_ExecutableFreeSelectionCouse eoc = GetExecutableFreeSelectionCouseEntity(mission.ExecutableFreeSelectionCourse.ExecutableFreeSelectionCouseID);
- if (eoc != null) //状态改为已开班
- eoc.RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created;
- }
- 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); //课程进度任课老师表
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- public bool EditStudent(SelectCourseResultView selectCourseResult, IList<StudentsView> studentList)
- {
- try
- {
- var executableOptionalCourse = OptionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetList(x => x.ExecutableOptionalCourseID == selectCourseResult.ID,
- (x => x.CF_Student)
- ).FirstOrDefault();
- var executableFreeSelectionCouse = OptionalCourseSettingDAL.ExecutableFreeSelectionCouseRepository.GetList(x => x.ExecutableFreeSelectionCouseID == selectCourseResult.ID,
- (x => x.CF_Student)
- ).FirstOrDefault();
- var ids = studentList.Select(x => x.UserID).ToList();
- var list = SelectCourseResultDAL.StudentRepository.GetList(x => ids.Contains(x.UserID));
- if (executableOptionalCourse != null)
- {
- if (executableOptionalCourse.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created)
- throw new Exception("已生成教学任务班,不能修改学生");
- executableOptionalCourse.CF_Student = new HashSet<CF_Student>();
- //UnitOfWork.Delete(executableFreeSelectionCouse, (x => x.CF_Student));
- foreach (var student in list)
- {
- executableOptionalCourse.CF_Student.Add(student);
- }
- //UnitOfWork.Update<EM_ExecutableFreeSelectionCouse>(executableFreeSelectionCouse);
- }
- else if (executableFreeSelectionCouse != null)
- {
- if (executableFreeSelectionCouse.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created)
- throw new Exception("已生成教学任务班,不能修改学生");
- executableFreeSelectionCouse.CF_Student = new HashSet<CF_Student>();
- foreach (var student in list)
- {
- executableFreeSelectionCouse.CF_Student.Add(student);
- }
- //UnitOfWork.Update<EM_ExecutableFreeSelectionCouse>(executableFreeSelectionCouse);
- }
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 更新
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- public void OptionalCourseSettingUpdate(OptionalCourseSettingView optionalCourseSettingView, IList<OptionalCourseTeacherListView> teacherList)
- {
- try
- {
- //删除教师
- UnitOfWork.Delete<EM_ExecutableOptionalCourseTeacher>(x => x.ExecutableOptionalCourseID == optionalCourseSettingView.ExecutableOptionalCourseID);
- //添加教师
- if (teacherList.Count > 0)
- {
- foreach (var teacher in teacherList)
- {
- EM_ExecutableOptionalCourseTeacher executableOptionalCourseTeacher = new EM_ExecutableOptionalCourseTeacher();
- executableOptionalCourseTeacher.ExecutableOptionalCourseTeacherID = Guid.NewGuid();
- executableOptionalCourseTeacher.ExecutableOptionalCourseID = optionalCourseSettingView.ExecutableOptionalCourseID;
- executableOptionalCourseTeacher.UserID = teacher.UserID;
- executableOptionalCourseTeacher.TeachingMethod = teacher.TeachingMethod;
- SetNewStatus(executableOptionalCourseTeacher);
- UnitOfWork.Add(executableOptionalCourseTeacher);
- }
- UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取教学任务授课老师
- /// </summary>
- /// <param name="educationMissionClassID"></param>
- /// <returns></returns>
- public List<EMIS.ViewModel.SelectCourse.OptionalCourseTeacherListView> GetTeacherList(Guid? ID, string Type)
- {
- if (Type == "0")
- return OptionalCourseSettingDAL.GetTeacherList().Where(x => x.ID == ID).OrderBy(x => x.TeachingMethod).ToList();
- else
- return OptionalCourseSettingDAL.GetTeacherList1().Where(x => x.ID == ID).OrderBy(x => x.TeachingMethod).ToList();
- }
- public EM_ExecutableFreeSelectionCouse GetExecutableFreeSelectionCouseEntity(Guid? executableOptionalCourseID)
- {
- return SelectCourseResultDAL.ExecutableFreeSelectionCouseRepository.GetSingle(x => x.ExecutableFreeSelectionCouseID == executableOptionalCourseID);
- }
- /// <summary>
- /// 选课结果人数是否达到下限
- /// </summary>
- /// <param name="IDs"></param>
- /// <returns></returns>
- public bool CheckEnouthNum(IList<Guid?> IDs)
- {
- var query = SelectCourseResultDAL.GetCheckEnouthNumSelectCourseResult(IDs).Where(x => x.StudentTotalNum < x.PeopleNumlower);
- if (query.ToList().Count > 0)
- return true;
- else
- return false;
- }
- /// <summary>
- /// 选课结果判断是否有教师、教室
- /// </summary>
- /// <param name="IDs"></param>
- /// <returns></returns>
- //public bool CheckHaveTeacherOrClassroom(IList<Guid?> IDs)
- //{
- // var query = SelectCourseResultDAL
- // if (query.ToList().Count > 0)
- // return true;
- // else
- // return false;
- //}
- }
- }
|