123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950 |
- 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.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.EducationSchedule;
- using System.Transactions;
- using EMIS.CommonLogic.ScoreManage;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.RetakeManage.General
- {
- public class RetakePlanTaskServices : BaseServices, IRetakePlanTaskServices
- {
- public RetakeConditionDAL RetakeConditionDAL { get; set; }
- public RetakePlanTaskDAL RetakePlanTaskDAL { get; set; }
- public Lazy<IParameterServices> IParameterServices { get; set; }
- public DictionaryItemDAL DictionaryItemDAL { get; set; }
- public IInSchoolSettingServices InSchoolSettingServices { get; set; }
- public IRetakeParameterServices IRetakeParameterServices { get; set; }
- public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; }
- public Lazy<ISpecialityScoreByFinalScoreServices> specialityScoreByFinalScoreServices { get; set; }
- public IRetakePlanStudentApplyServices IRetakePlanStudentApplyServices { get; set; }
- public RetakePlanResultDAL RetakePlanResultDAL { get; set; }
- /// <summary>
- /// 查询学生预查信息列表
- /// </summary>
- /// <param name="conditionView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></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="inSchoolStatus"></param>
- /// <param name="ExamsCategoryID"></param>
- /// <param name="CoursematerialID"></param>
- /// <param name="CourseTypes"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeStudentListView> GetRetakePreStudentView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID,
- int? inSchoolStatus, int? examsCategoryID, Guid? coursematerialID, string courseTypeIDs, int pageIndex, int pageSize)
- {
- try
- {
- //查询对应的预查考试性质List
- var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
- if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
- {
- throw new Exception("未设置预查考试性质,请设置。");
- }
- //学生最终成绩
- Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- //学年学期
- expFinallyScore = expFinallyScore.And(x => x.SchoolyearID == schoolyearID);
- }
- if (departmentID.HasValue)
- {
- //开课教研室
- expFinallyScore = expFinallyScore.And(x => x.DepartmentID == departmentID);
- }
- if (examsCategoryID.HasValue)
- {
- //考试性质
- expFinallyScore = expFinallyScore.And(x => x.ExamsCategoryID == examsCategoryID);
- }
- if (coursematerialID.HasValue)
- {
- //课程信息
- expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == coursematerialID);
- }
- //查询必修课程类型信息List
- var isRequiredCourseTypeIDlist = specialityScoreByFinalScoreServices.Value.GetCourseTypeID().ToList();
- //课程类型List
- var courseTypeIDList = new List<int>();
- if (!string.IsNullOrEmpty(courseTypeIDs))
- {
- courseTypeIDList = courseTypeIDs.Remove(courseTypeIDs.Length - 1).Split(',')
- .Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToList();
- }
- expFinallyScore = expFinallyScore.And(x => courseTypeIDList.Contains(x.CourseTypeID.Value));
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- 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));
- }
- }
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- //查询对应的重修学年学期
- var retakeSchoolyearID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakeSchoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID);
- }
- else
- {
- throw new Exception("未设置重修学年学期,请设置。");
- }
- var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan);
- 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);
- }
- //条件限定List
- var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
- foreach (var condition in retakeConditionList)
- {
- //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
- query = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, query);
- }
- //查询条件
- 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).ThenBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode)
- .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询学生预查信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></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="inSchoolStatus"></param>
- /// <param name="examsCategoryID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeIDs"></param>
- /// <returns></returns>
- public List<RetakeStudentListView> GetRetakePreStudentViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID,
- int? inSchoolStatus, int? examsCategoryID, Guid? coursematerialID, string courseTypeIDs)
- {
- try
- {
- //查询对应的预查考试性质List
- var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
- if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
- {
- throw new Exception("未设置预查考试性质,请设置。");
- }
- //学生最终成绩
- Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- //学年学期
- expFinallyScore = expFinallyScore.And(x => x.SchoolyearID == schoolyearID);
- }
- if (departmentID.HasValue)
- {
- //开课教研室
- expFinallyScore = expFinallyScore.And(x => x.DepartmentID == departmentID);
- }
- if (examsCategoryID.HasValue)
- {
- //考试性质
- expFinallyScore = expFinallyScore.And(x => x.ExamsCategoryID == examsCategoryID);
- }
- if (coursematerialID.HasValue)
- {
- //课程信息
- expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == coursematerialID);
- }
- //查询必修课程类型信息List
- var isRequiredCourseTypeIDlist = specialityScoreByFinalScoreServices.Value.GetCourseTypeID().ToList();
- //课程类型List
- var courseTypeIDList = new List<int>();
- if (!string.IsNullOrEmpty(courseTypeIDs))
- {
- courseTypeIDList = courseTypeIDs.Remove(courseTypeIDs.Length - 1).Split(',')
- .Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToList();
- }
- expFinallyScore = expFinallyScore.And(x => courseTypeIDList.Contains(x.CourseTypeID.Value));
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- 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));
- }
- }
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- //查询对应的重修学年学期
- var retakeSchoolyearID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakeSchoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID);
- }
- else
- {
- throw new Exception("未设置重修学年学期,请设置。");
- }
- var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan);
- 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);
- }
- //条件限定List
- var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
- foreach (var condition in retakeConditionList)
- {
- //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
- query = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, query);
- }
- //查询条件
- 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).ThenBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode)
- .ToList();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 学生预查重修任务生成
- /// </summary>
- /// <param name="finallyScoreIDList"></param>
- /// <param name="retakeTypeID"></param>
- /// <returns></returns>
- public string Generate(List<Guid?> finallyScoreIDList, int? retakeTypeID)
- {
- try
- {
- //查询对应的重修学年学期
- var retakeSchoolyearID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
- if (retakeSchoolyearID == null)
- {
- throw new Exception("未设置重修学年学期,请设置。");
- }
- //查询对应的重修考试性质(此字段需要存到重修计划表中)
- var retakeExamsCatagoryID = IParameterServices.Value.GetParameterValue<int>(CF_ParameterType.RetakeExamsCatagoryID);
- if (retakeExamsCatagoryID == null)
- {
- throw new Exception("未设置重修考试性质,请设置。");
- }
- //查询对应的重修收费项目
- var retakeChargeProjectID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeChargeProjectID);
- if (retakeChargeProjectID == null)
- {
- throw new Exception("未设置重修收费项目,请设置。");
- }
- //查询对应的预查考试性质List
- var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
- if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
- {
- throw new Exception("未设置预查考试性质,请设置。");
- }
- //查询对应的重修类型ID
- var retakeTypeView = DictionaryItemDAL.DictionaryItemRepository.Entities
- .Where(x => x.DictionaryCode == typeof(EMIS.ViewModel.ER_RetakeType).Name && x.Value == retakeTypeID)
- .SingleOrDefault();
- if (retakeTypeView == null)
- {
- throw new Exception("重修类型数据有误,请核查。");
- }
- //学生最终成绩
- Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (finallyScoreIDList == null || finallyScoreIDList.Count() <= 0)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //最终成绩信息ID
- expFinallyScore = expFinallyScore.And(x => finallyScoreIDList.Contains(x.FinallyScoreID));
- }
- //查询对应的学生预查信息View
- var retakeStudentPrescanView = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, x => true, x => true);
- //重修条件限定List
- var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
- foreach (var condition in retakeConditionList)
- {
- //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
- retakeStudentPrescanView = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, retakeStudentPrescanView);
- }
- //学生预查coursematerialIDList
- var coursematerialIDList = retakeStudentPrescanView.Where(x => !string.IsNullOrEmpty(x.CoursematerialID.ToString()))
- .Select(x => x.CoursematerialID).ToList();
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakeSchoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID);
- }
- if (retakeExamsCatagoryID.HasValue)
- {
- //重修考试性质(目前缺少此字段)
- }
- if (retakeTypeID.HasValue)
- {
- //重修类型
- expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID);
- }
- if (coursematerialIDList != null || coursematerialIDList.Count() > 0)
- {
- //重修计划coursematerialIDList
- expRetakePlan = expRetakePlan.And(x => coursematerialIDList.Contains(x.CoursematerialID));
- }
- //查询对应的重修计划信息List
- var retakePlanViewList = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan).ToList();
- //查询对应的重修计划retakePlanIDList
- var retakePlanIDList = retakePlanViewList.Where(x => !string.IsNullOrEmpty(x.RetakePlanID.ToString()))
- .Select(x => x.RetakePlanID).ToList();
- //学生预查userIDList
- var userIDList = retakeStudentPrescanView.Where(x => !string.IsNullOrEmpty(x.UserID.ToString()))
- .Select(x => x.UserID).ToList();
- //重修计划名单
- Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakePlanIDList != null || retakePlanIDList.Count() > 0)
- {
- //重修计划retakePlanIDList
- expRetakePlanStudent = expRetakePlanStudent.And(x => retakePlanIDList.Contains(x.RetakePlanID));
- }
- if (userIDList != null || userIDList.Count() > 0)
- {
- //重修计划名单userIDList
- expRetakePlanStudent = expRetakePlanStudent.And(x => userIDList.Contains(x.UserID));
- }
- //查询对应的重修计划名单List
- var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository
- .GetList(expRetakePlanStudent).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- var retakePlanInList = new List<ER_RetakePlan>(); //重修计划List
- var retakePlanSettingInList = new List<ER_RetakePlanSetting>(); //重修计划设置List
- var retakePlanTeachingSettingInList = new List<ER_RetakePlanTeachingSetting>(); //重修计划教学设置List
- var retakePlanStudentInList = new List<ER_RetakePlanStudent>(); //重修计划学生名单List
- //学生预查分组信息List(分组条件:课程信息ID、课程类型、课程学分、开课教研室ID、重修类型、重修学年学期)
- //注:分组后,可级联出各组对应的明细
- var retakeStudentListViewGroupList = retakeStudentPrescanView.ToList().GroupBy(x => new
- {
- x.CoursematerialID,
- x.Abbreviation,
- x.CourseName,
- x.CourseTypeID,
- x.CourseTypeDesc,
- x.CourseCredit,
- x.DepartmentID
- });
- foreach (var retakeStudentListViewGroup in retakeStudentListViewGroupList)
- {
- //验证对应的重修计划信息(由于有分班功能,可存在多个对应的重修计划信息)
- var retakePlanViewListVerify = retakePlanViewList.Where(x => x.CoursematerialID == retakeStudentListViewGroup.Key.CoursematerialID
- && x.CourseTypeID == retakeStudentListViewGroup.Key.CourseTypeID
- && x.Credit == retakeStudentListViewGroup.Key.CourseCredit
- && x.DepartmentID == retakeStudentListViewGroup.Key.DepartmentID
- && x.RetakeTypeID == retakeTypeID
- && x.SchoolyearID == retakeSchoolyearID
- ).ToList();
- if (retakePlanViewListVerify == null || retakePlanViewListVerify.Count() <= 0)
- {
- //表示不存在对应的重修计划
- ER_RetakePlan retakePlan = new ER_RetakePlan();
- retakePlan.RetakePlanID = Guid.NewGuid();
- retakePlan.CoursematerialID = retakeStudentListViewGroup.Key.CoursematerialID;
- retakePlan.RetakeTypeID = retakeTypeID;
- //重修班级名称
- retakePlan.ClassName = (retakeStudentListViewGroup.Key.Abbreviation ?? retakeStudentListViewGroup.Key.CourseName)
- + "-" + retakeTypeView.Name + "(" + retakeStudentListViewGroup.Key.CourseTypeDesc
- + (retakeStudentListViewGroup.Key.CourseCredit == 0 ? "0" :
- string.Format("{0:#.0}", retakeStudentListViewGroup.Key.CourseCredit))
- + "学分)";
- retakePlan.SchoolyearID = retakeSchoolyearID;
- retakePlan.CourseTypeID = retakeStudentListViewGroup.Key.CourseTypeID;
- retakePlan.Credit = retakeStudentListViewGroup.Key.CourseCredit;
- retakePlan.PeopleNumlower = 0;
- retakePlan.PeopleNumlimit = 0;
- retakePlan.IsDivide = false;
- //重修任务状态默认为未开放
- SetNewStatus(retakePlan, (int)ER_RetakePlanStatus.NotOpened);
- ER_RetakePlanSetting retakePlanSetting = new ER_RetakePlanSetting();
- retakePlanSetting.RetakePlanID = retakePlan.RetakePlanID;
- retakePlanSetting.DepartmentID = retakeStudentListViewGroup.Key.DepartmentID;
- retakePlanSetting.CourseTypeID = retakeStudentListViewGroup.Key.CourseTypeID;
- retakePlanSetting.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
- retakePlanSetting.IsSpecialtycore = false;
- retakePlanSetting.IsCooperation = false;
- retakePlanSetting.IsRequired = true;
- retakePlanSetting.IsElective = false;
- retakePlanSetting.IsNetworkCourse = false;
- retakePlanSetting.IsMainCourse = false;
- SetNewStatus(retakePlanSetting);
- ER_RetakePlanTeachingSetting retakePlanTeachingSetting = new ER_RetakePlanTeachingSetting();
- retakePlanTeachingSetting.RetakePlanID = retakePlan.RetakePlanID;
- retakePlanInList.Add(retakePlan);
- retakePlanSettingInList.Add(retakePlanSetting);
- retakePlanTeachingSettingInList.Add(retakePlanTeachingSetting);
- foreach (var retakeStudentPrescan in retakeStudentListViewGroup.Select(x => x).ToList())
- {
- //对应的重修计划名单
- ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent();
- retakePlanStudent.RetakePlanStudentID = Guid.NewGuid();
- retakePlanStudent.RetakePlanID = retakePlan.RetakePlanID;
- retakePlanStudent.UserID = retakeStudentPrescan.UserID.Value;
- retakePlanStudent.SchoolyearNumID = retakeStudentPrescan.SchoolyearNumID;
- retakePlanStudent.StarttermID = retakeStudentPrescan.StarttermID;
- SetNewStatus(retakePlanStudent);
- retakePlanStudentInList.Add(retakePlanStudent);
- success++;
- }
- }
- else
- {
- //表示存在对应的重修计划
- //由于有分班功能,可存在多个对应的重修计划信息,默认将重修计划名单分配到查询结果的各个重修计划中
- //查询对应的重修计划retakePlanID(由于有分班功能,可存在多个对应的retakePlanID)
- var retakePlanIDVerifyList = retakePlanViewListVerify.Select(x => x.RetakePlanID).ToList();
- foreach (var retakeStudentPrescan in retakeStudentListViewGroup.Select(x => x).ToList())
- {
- //查询对应的重修计划名单信息
- var retakePlanStudentList = retakePlanStudentViewList
- .Where(x => retakePlanIDVerifyList.Contains(x.RetakePlanID)
- && x.UserID == retakeStudentPrescan.UserID).ToList();
- //分别将对应的重修计划名单添加到对应的重修计划中(由于有分班功能,重修计划名单可存在不同的重修任务中)
- foreach (var retakePlanIDVerify in retakePlanIDVerifyList)
- {
- //验证对应的重修计划名单信息
- var retakePlanStudentVerify = retakePlanStudentList
- .Where(x => x.RetakePlanID == retakePlanIDVerify).SingleOrDefault();
- if (retakePlanStudentVerify == null)
- {
- //表示不存在对应的重修计划名单
- ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent();
- retakePlanStudent.RetakePlanStudentID = Guid.NewGuid();
- //存在多个对应的重修计划信息,默认将重修计划名单分配到查询结果的各个重修计划中
- retakePlanStudent.RetakePlanID = retakePlanIDVerify;
- retakePlanStudent.UserID = retakeStudentPrescan.UserID.Value;
- retakePlanStudent.SchoolyearNumID = retakeStudentPrescan.SchoolyearNumID;
- retakePlanStudent.StarttermID = retakeStudentPrescan.StarttermID;
- SetNewStatus(retakePlanStudent);
- retakePlanStudentInList.Add(retakePlanStudent);
- success++;
- }
- else
- {
- //表示存在对应的重修计划名单(数据有误,原因为:同一个学生,不同开课学期修同一门课程)
- fail++;
- }
- }
- }
- }
- }
- //批量插入
- UnitOfWork.BulkInsert(retakePlanInList);
- UnitOfWork.BulkInsert(retakePlanSettingInList);
- UnitOfWork.BulkInsert(retakePlanTeachingSettingInList);
- UnitOfWork.BulkInsert(retakePlanStudentInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的重修任务名单,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <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="statusID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakePlanTaskView> GetRetakePlanTaskView(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);
- 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 = RetakePlanTaskDAL.GetRetakePlanTaskView(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>
- /// <param name="statusID"></param>
- /// <returns></returns>
- public List<RetakePlanTaskView> GetRetakePlanTaskViewList(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);
- 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 = RetakePlanTaskDAL.GetRetakePlanTaskView(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>
- /// 查询重修计划相关信息View(含相关设置信息、排课教室等)
- /// 注:排课明细中目前只支持同一教室的情况
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public RetakePlanTaskSettingView GetRetakePlanTaskUpdateView(Guid? RetakePlanID)
- {
- var retakePlanTaskSettingView = RetakePlanTaskDAL.GetRetakePlanTaskSettingView(x => x.RetakePlanID == RetakePlanID)
- .SingleOrDefault();
- return retakePlanTaskSettingView;
- }
- /// <summary>
- /// 查询重修计划课程表信息List
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public List<RetakePlanSettingSchedulingView> GetSchedulingView(Guid? RetakePlanID)
- {
- var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => x.RetakePlanID == RetakePlanID)
- .OrderBy(x => x.Weekday).ThenBy(x=>x.TimesSegment)
- .ThenBy(x=>x.StartTimes).ToList();
- return schedulingList;
- }
- /// <summary>
- /// 查询重修计划任课老师信息List
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public List<RetakePlanTeacherListView> GetTeacherListView(Guid? RetakePlanID)
- {
- var teacherListView = RetakePlanTaskDAL.GetRetakePlanTeacherViewQueryable(x => x.RetakePlanID == RetakePlanID)
- .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .ThenBy(x => x.TeachingMethod).ToList();
- return teacherListView;
- }
- /// <summary>
- /// 查询重修计划授课方式信息List
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public List<int> GetTeachingModeType(Guid? RetakePlanID)
- {
- var list = RetakePlanTaskDAL.GetTeachingModeType(x => x.RetakePlanID == RetakePlanID)
- .Select(x => x.Value ?? 0).ToList();
- if (list.Count >= 0)
- {
- list.Add((int)EMIS.ViewModel.CF_TeachingMode.Theory);
- }
- return list;
- }
- /// <summary>
- /// 查询重修计划授课地点信息List
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public List<int> GetTeachingPlace(Guid? RetakePlanID)
- {
- var list = RetakePlanTaskDAL.GetTeachingPlace(x => x.RetakePlanID == RetakePlanID)
- .Select(x => x.Value ?? 0).ToList();
- return list;
- }
- /// <summary>
- /// 查询对应的重修计划相关表信息
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public ER_RetakePlan GetRetakePlan(Guid? RetakePlanID)
- {
- return RetakePlanTaskDAL.RetakePlanRepository.GetSingle(x => x.RetakePlanID == RetakePlanID,
- (x => x.ER_RetakePlanSetting),
- (x => x.ER_RetakePlanSettingScheduling),
- (x => x.ER_RetakePlanStudent),
- (x => x.ER_RetakePlanTeacher),
- (x => x.CF_Student),
- (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType),
- (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace),
- (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting));
- }
- /// <summary>
- /// 重修计划修改(排课冲突判断)
- /// </summary>
- /// <param name="RetakePlanTaskSettingView"></param>
- /// <param name="teacherList"></param>
- /// <param name="schedulingList"></param>
- /// <param name="type"></param>
- /// <returns></returns>
- public bool RetakePlanTaskSet(RetakePlanTaskSettingView RetakePlanTaskSettingView, IList<RetakePlanTeacherListView> teacherList,
- IList<RetakePlanSettingSchedulingView> schedulingList, out int? type)
- {
- try
- {
- var retakePlan = GetRetakePlan(RetakePlanTaskSettingView.RetakePlanID);
- //排课明细
- if (schedulingList.Where(x => x.CoursesTimeID == null || x.Weekday == null).ToList().Count > 0)
- {
- throw new Exception("排课信息不能为空");
- }
- else
- {
- //如果IsNeedVerify为false时,不验证冲突
- if (RetakePlanTaskSettingView.IsNeedVerify != false)
- {
- //判断教师和教室冲突,如果有冲突type返回1,页面js根据type弹出选择框
- //用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
- foreach (var scheduling in schedulingList)
- {
- //教室不为空时,判断教室
- if (RetakePlanTaskSettingView.ClassroomID != null)
- {
- //重修计划冲突
- var repeatExecutableClassroom = RetakePlanTaskDAL
- .GetRepeatRetakePlanSettingClassroom(scheduling.CoursesTimeID,
- RetakePlanTaskSettingView.ClassroomID, scheduling.Weekday,
- RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum,
- RetakePlanTaskSettingView.EndWeeklyNum)
- .Where(x => x.ID != RetakePlanTaskSettingView.RetakePlanID).FirstOrDefault();
- if (repeatExecutableClassroom != null)
- {
- type = 1;
- throw new Exception(repeatExecutableClassroom.WeekdayName + repeatExecutableClassroom.StartTimes
- + "时间段教室与重修计划[" + repeatExecutableClassroom.DefaultClassName + "]有冲突");
- }
- //教学任务冲突
- var repeatEducationClassroom = RetakePlanTaskDAL
- .GetRepeatEducationMissionClassroom(scheduling.CoursesTimeID,
- RetakePlanTaskSettingView.ClassroomID, scheduling.Weekday,
- RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum,
- RetakePlanTaskSettingView.EndWeeklyNum).FirstOrDefault();
- if (repeatEducationClassroom != null)
- {
- type = 1;
- throw new Exception("检测到排课冲突," + "该重修上课时间段教室与教学任务班["
- + repeatEducationClassroom.DefaultClassName + "]有冲突");
- }
- }
- //重修计划冲突
- var repeatExecutableTeacher = RetakePlanTaskDAL
- .GetRepeatRetakePlanTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID,
- scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum,
- RetakePlanTaskSettingView.EndWeeklyNum)
- .Where(x => x.ID != RetakePlanTaskSettingView.RetakePlanID).FirstOrDefault();
- if (repeatExecutableTeacher != null)
- {
- type = 1;
- throw new Exception("检测到排课冲突," + repeatExecutableTeacher.WeekdayName
- + repeatExecutableTeacher.StartTimes + "时间段教师与重修计划["
- + repeatExecutableTeacher.DefaultClassName + "]有冲突");
- }
- //教学任务冲突
- var repeatEducationTeacher = RetakePlanTaskDAL
- .GetRepeatEducationMissionTeacher(teacherList.Select(x => x.UserID).ToList(),
- scheduling.CoursesTimeID, scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID,
- RetakePlanTaskSettingView.StartWeeklyNum,
- RetakePlanTaskSettingView.EndWeeklyNum).FirstOrDefault();
- if (repeatEducationTeacher != null)
- {
- type = 1;
- throw new Exception("检测到排课冲突," + "该重修上课时间段教师与教学任务班["
- + repeatEducationTeacher.DefaultClassName + "]有冲突");
- }
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- retakePlan.CoursematerialID = RetakePlanTaskSettingView.CoursematerialID;
- retakePlan.RetakeTypeID = RetakePlanTaskSettingView.RetakeTypeID;
- retakePlan.ClassName = RetakePlanTaskSettingView.ClassName;
- retakePlan.SchoolyearID = RetakePlanTaskSettingView.SchoolyearID;
- retakePlan.CourseTypeID = RetakePlanTaskSettingView.CourseTypeID ;
- //retakePlan.Credit = RetakePlanTaskSettingView.Credit; //目前会出现文本框控件禁用时,取值无效
- retakePlan.PeopleNumlimit = RetakePlanTaskSettingView.PeopleNumlimit;
- retakePlan.PeopleNumlower = RetakePlanTaskSettingView.PeopleNumlower;
- SetModifyStatus(retakePlan);
- //重修计划设置表
- if (retakePlan.ER_RetakePlanSetting == null)
- {
- retakePlan.ER_RetakePlanSetting = new ER_RetakePlanSetting();
- retakePlan.ER_RetakePlanSetting.RetakePlanID = RetakePlanTaskSettingView.RetakePlanID;
- this.SetNewStatus(retakePlan.ER_RetakePlanSetting);
- UnitOfWork.Add(retakePlan.ER_RetakePlanSetting);
- }
- else
- {
- SetModifyStatus(retakePlan.ER_RetakePlanSetting);
- UnitOfWork.Update(retakePlan.ER_RetakePlanSetting);
- }
- retakePlan.ER_RetakePlanSetting.DepartmentID = RetakePlanTaskSettingView.DepartmentID;
- retakePlan.ER_RetakePlanSetting.CourseTypeID = RetakePlanTaskSettingView.CourseTypeID;
- retakePlan.ER_RetakePlanSetting.CourseStructureID = RetakePlanTaskSettingView.CourseStructureID;
- retakePlan.ER_RetakePlanSetting.CourseCategoryID = RetakePlanTaskSettingView.CourseCategoryID;
- retakePlan.ER_RetakePlanSetting.CourseQualityID = RetakePlanTaskSettingView.CourseQualityID;
- retakePlan.ER_RetakePlanSetting.PracticeTypeID = RetakePlanTaskSettingView.PracticeTypeID;
- retakePlan.ER_RetakePlanSetting.ExaminationModeID = RetakePlanTaskSettingView.ExaminationModeID;
- retakePlan.ER_RetakePlanSetting.TeachinglanguageID = RetakePlanTaskSettingView.TeachinglanguageID;
- retakePlan.ER_RetakePlanSetting.CourseFineID = RetakePlanTaskSettingView.CourseFineID;
- retakePlan.ER_RetakePlanSetting.IsSpecialtycore = RetakePlanTaskSettingView.IsSpecialtycore;
- retakePlan.ER_RetakePlanSetting.IsCooperation = RetakePlanTaskSettingView.IsCooperation;
- retakePlan.ER_RetakePlanSetting.IsRequired = RetakePlanTaskSettingView.IsRequired;
- retakePlan.ER_RetakePlanSetting.IsElective = RetakePlanTaskSettingView.IsElective;
- retakePlan.ER_RetakePlanSetting.IsNetworkCourse = RetakePlanTaskSettingView.IsNetworkCourse;
- retakePlan.ER_RetakePlanSetting.IsMainCourse = RetakePlanTaskSettingView.IsMainCourse;
- retakePlan.ER_RetakePlanSetting.IsNeedMaterial = RetakePlanTaskSettingView.IsNeedMaterial;
- retakePlan.ER_RetakePlanSetting.Remarks = RetakePlanTaskSettingView.Remarks;
- //重修计划教学设置表
- if (retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting == null)
- {
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting = new ER_RetakePlanTeachingSetting();
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.RetakePlanID = RetakePlanTaskSettingView.RetakePlanID;
- UnitOfWork.Add(retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting);
- }
- else
- {
- UnitOfWork.Update(retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting);
- }
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse = RetakePlanTaskSettingView.TheoryCourse;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Practicehours = RetakePlanTaskSettingView.Practicehours;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours = RetakePlanTaskSettingView.Trialhours;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum = RetakePlanTaskSettingView.WeeklyNum;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum = RetakePlanTaskSettingView.TheoryWeeklyNum;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.PracticeWeeklyNum = RetakePlanTaskSettingView.PracticeWeeklyNum;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum = RetakePlanTaskSettingView.TrialWeeklyNum;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum = RetakePlanTaskSettingView.StartWeeklyNum;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum = RetakePlanTaskSettingView.EndWeeklyNum;
- retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours = RetakePlanTaskSettingView.WeeklyHours;
- //重修计划授课方式表
- UnitOfWork.Remove<ER_RetakePlanTeachingModeType>(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID);
- if (RetakePlanTaskSettingView.TeachingModeID != null)
- {
- RetakePlanTaskSettingView.TeachingModeID.ForEach(x =>
- {
- ER_RetakePlanTeachingModeType teachingModeType = new ER_RetakePlanTeachingModeType
- {
- RetakePlanTeachingModeTypeID = Guid.NewGuid(),
- RetakePlanID = RetakePlanTaskSettingView.RetakePlanID,
- TeachingModeID = x
- };
- this.SetNewStatus(teachingModeType);
- this.UnitOfWork.Add(teachingModeType);
- });
- }
- //重修计划授课地点表
- UnitOfWork.Remove<ER_RetakePlanTeachingPlace>(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID);
- if (RetakePlanTaskSettingView.TeachingPlaceID != null)
- {
- RetakePlanTaskSettingView.TeachingPlaceID.ForEach(x =>
- {
- ER_RetakePlanTeachingPlace teachingPlace = new ER_RetakePlanTeachingPlace
- {
- RetakePlanTeachingPlaceID = Guid.NewGuid(),
- RetakePlanID = RetakePlanTaskSettingView.RetakePlanID,
- TeachingPlace = x
- };
- this.SetNewStatus(teachingPlace);
- this.UnitOfWork.Add(teachingPlace);
- });
- }
- //重修计划任课教师表
- this.UnitOfWork.Delete<ER_RetakePlanTeacher>(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID);
- teacherList.ToList().ForEach(x =>
- {
- var teacher = new ER_RetakePlanTeacher
- {
- RetakePlanTeacherID = Guid.NewGuid(),
- RetakePlanID = RetakePlanTaskSettingView.RetakePlanID,
- UserID = x.UserID,
- TeachType = x.TeachingMethod
- };
- this.SetNewStatus(teacher);
- this.UnitOfWork.Add(teacher);
- });
- //重修计划课程时间表
- var distinctSchedulingList = schedulingList.GroupBy(x => new { x.Weekday, x.CoursesTimeID })
- .Select(x => new { Weekday = x.Key.Weekday, CoursesTimeID = x.Max(a => a.CoursesTimeID) }).ToList();
- this.UnitOfWork.Delete<ER_RetakePlanSettingScheduling>(x => x.RetakePlanID == retakePlan.RetakePlanID);
- distinctSchedulingList.ToList().ForEach(x =>
- {
- var scheduling = new ER_RetakePlanSettingScheduling
- {
- RetakePlanSettingSchedulingID = Guid.NewGuid(),
- RetakePlanID = retakePlan.RetakePlanID,
- ClassroomID = RetakePlanTaskSettingView.ClassroomID,
- CoursesTimeID = x.CoursesTimeID,
- Weekday = x.Weekday,
- };
- this.SetNewStatus(scheduling);
- this.UnitOfWork.Add(scheduling);
- });
- UnitOfWork.Commit();
- ts.Complete();
- }
- type = 0;
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 排课冲突检查,列出课程进度中的可选教室
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="buildingID"></param>
- /// <param name="schedulingWeek"></param>
- /// <param name="weekday"></param>
- /// <param name="courseTimeID"></param>
- /// <param name="classroomTypeID"></param>
- /// <param name="SchoolYearID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ClassroomView> GetAvailableClassroom(ConfiguretView configuretView, Guid? buildingID, string schedulingWeek,
- int? weekday, Guid courseTimeID, int? classroomTypeID, Guid SchoolYearID, int? pageIndex, int? pageSize)
- {
- List<int?> schedulingWeekList = Array.ConvertAll<string, int?>(schedulingWeek.Split('-'), s => Convert.ToInt32(s)).ToList();
- for (int i = 1; i + schedulingWeekList.Min() < schedulingWeekList.Max(); i++)
- {
- schedulingWeekList.Add(i + schedulingWeekList.Min());
- }
- var classroomView = ClassroomScheduleDAL.GetAvailableClassroom(SchoolYearID,
- schedulingWeekList, weekday.Value, courseTimeID, classroomTypeID > 0 ? classroomTypeID : null);
- if (buildingID.HasValue)
- {
- classroomView = classroomView.Where(x => x.BuildingsInfoID == buildingID);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- classroomView = classroomView.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return classroomView.OrderBy(x => x.BuildingsInfoName)
- .ThenBy(x => x.Name)
- .ThenBy(x => x.Totalseating).ToGridResultSet(pageIndex, pageSize);
- }
- /// <summary>
- /// 删除(需要检测是否存在对应的已报名重修计划名单,根据重修计划ID)
- /// </summary>
- /// <param name="retakePlanIDsList"></param>
- public void DeleteRetakePlanTask(IList<Guid?> retakePlanIDsList)
- {
- try
- {
- var retakePlanViewList = this.RetakePlanTaskDAL.RetakePlanRepository
- .GetList(x => retakePlanIDsList.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList();
- if (retakePlanViewList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened))
- {
- throw new Exception("只能删除未开放状态的重修任务。");
- }
- ////查询对应的重修报名信息List
- //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
- // .GetList(x => retakePlanIDsList.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("存在对应的已报名重修计划名单。");
- //}
- var retakePlanIDList = retakePlanViewList.Select(x => x.RetakePlanID).Distinct().ToList();
- ////删除相应重修计划报名表信息(此句暂时不需要)
- //retakePlanViewList.ForEach(x =>
- //{
- // UnitOfWork.Delete(x, (w => w.CF_Student));
- //});
- //UnitOfWork.RemoveRange(new HashSet<ER_RetakePlanStudent>(retakePlanViewList));
- UnitOfWork.Remove<ER_RetakePlanStudent>(x => retakePlanIDList.Contains(x.RetakePlanID));
- UnitOfWork.Remove<ER_RetakePlanTeachingModeType>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
- UnitOfWork.Remove<ER_RetakePlanTeachingPlace>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
- UnitOfWork.Remove<ER_RetakePlanTeachingSetting>(x => retakePlanIDList.Contains(x.RetakePlanID));
- UnitOfWork.Remove<ER_RetakePlanTeacher>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
- UnitOfWork.Remove<ER_RetakePlanSettingScheduling>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
- UnitOfWork.Remove<ER_RetakePlanSetting>(x => retakePlanIDList.Contains(x.RetakePlanID));
- UnitOfWork.Remove<ER_RetakePlan>(x => retakePlanIDList.Contains(x.RetakePlanID));
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 检测是否存在对应的已报名重修计划名单(根据重修计划ID)
- /// </summary>
- /// <param name="retakePlanIDs"></param>
- /// <returns></returns>
- public bool IsExistsApplyStudentByRetakePlanID(string retakePlanIDs)
- {
- List<Guid?> list = retakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- var retakePlanStudentList = RetakePlanTaskDAL.RetakePlanStudentRepository
- .GetList(x => list.Contains(x.RetakePlanID), (x => x.ER_RetakePlan),
- (x => x.ER_RetakePlan.CF_Student)).ToList();
- var IsExistslist = retakePlanStudentList.Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)).ToList();
- if (IsExistslist.Count() > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 重修计划取消开放(删除对应的重修计划报名名单)
- /// </summary>
- /// <param name="RetakePlanIDsList"></param>
- public void CancleRetakePlanTask(IList<Guid?> RetakePlanIDsList)
- {
- try
- {
- var retakePlanList = this.RetakePlanTaskDAL.RetakePlanRepository
- .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList();
- if (retakePlanList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened))
- {
- throw new Exception("只能取消已开放状态的重修任务。");
- }
- ////查询对应的重修报名信息List
- //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
- // .GetList(x => RetakePlanIDsList.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("存在对应的已报名重修计划名单。");
- //}
- //删除对应的重修计划报名名单
- retakePlanList.ForEach(x =>
- {
- UnitOfWork.Delete(x, (w => w.CF_Student));
- });
- //修改对应的重修计划
- UnitOfWork.Update<ER_RetakePlan>(x => new ER_RetakePlan
- {
- RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened
- }, x => RetakePlanIDsList.Contains(x.RetakePlanID));
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 重修计划开放
- /// </summary>
- /// <param name="RetakePlanIDsList"></param>
- public void OpenRetakePlanTask(IList<Guid?> RetakePlanIDsList)
- {
- try
- {
- var retakeList = this.RetakePlanTaskDAL.RetakePlanRepository
- .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID)).ToList();
- if (retakeList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened))
- {
- throw new Exception("只能开放未开放状态的重修任务。");
- }
- UnitOfWork.Update<ER_RetakePlan>(x => new ER_RetakePlan
- {
- RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened
- }, x => RetakePlanIDsList.Contains(x.RetakePlanID));
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的重修计划分班信息View
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public RetakeDivideIntoClassesView GetDivideIntoClassesView(Guid? RetakePlanID)
- {
- try
- {
- //查询对应的重修计划信息
- var retakePlanTaskView = RetakePlanTaskDAL
- .GetRetakePlanTaskView(x => x.RetakePlanID == RetakePlanID).SingleOrDefault();
- RetakeDivideIntoClassesView divideIntoClassesView = new RetakeDivideIntoClassesView();
- divideIntoClassesView.ClassName = retakePlanTaskView.ClassName;
- divideIntoClassesView.StudentTotalNum = retakePlanTaskView.PlanNumber;
- return divideIntoClassesView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 重修任务分班(此分班形式不需分开人数,只做为分多少个任务班的计算参数)
- /// 注:分多少个任务班,那么各个任务班的人数保持一致
- /// </summary>
- /// <param name="divideIntoClassesView"></param>
- public void DivideIntoClassesSeparate(RetakeDivideIntoClassesView divideIntoClassesView)
- {
- try
- {
- if (divideIntoClassesView.RetakePlanID.HasValue && divideIntoClassesView.RetakePlanID != Guid.Empty)
- {
- //查询对应的重修计划表相关信息
- var retakePlanView = GetRetakePlan(divideIntoClassesView.RetakePlanID);
- if (retakePlanView != null)
- {
- //只能对未开放状态的信息进行分班
- if (retakePlanView.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened)
- {
- throw new Exception("只能对未开放状态的信息进行分班。");
- }
- //查询对应的重修计划名单信息List
- var retakePlanTaskStudentViewList = RetakePlanTaskDAL
- .GetRetakePlanTaskStudentView(x => x.RetakePlanID == divideIntoClassesView.RetakePlanID,
- x => x.RetakePlanID == divideIntoClassesView.RetakePlanID,
- x => true).OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .Select(x => x.UserID).ToList();
- ////查询对应的重修报名信息List
- //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
- // .GetList(x => x.RetakePlanID == retakePlanView.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("存在对应的已报名重修计划名单。");
- //}
- //任务班数(分班个数)
- var separateClassCount = divideIntoClassesView.GroupNum ?? 0;
- ////每班人数
- //var classStudentCount = divideIntoClassesView.StudentNum ?? 0;
- //判断分班的数目
- if (separateClassCount <= 1)
- {
- throw new Exception("任务班数不能小于等于1。");
- }
- else
- {
- using (TransactionScope ts = new TransactionScope())
- {
- for (int i = 0; i < separateClassCount - 1; i++)
- {
- ////要分班的名单
- //var separateStudentList = retakePlanTaskStudentViewList
- // .Take(classStudentCount).ToList();
- ////未分班名单
- //retakePlanTaskStudentViewList = retakePlanTaskStudentViewList
- // .SkipWhile(x => separateStudentList.Contains(x)).ToList();
- //重修计划表
- ER_RetakePlan retakePlan = new ER_RetakePlan
- {
- RetakePlanID = Guid.NewGuid(),
- CoursematerialID = retakePlanView.CoursematerialID,
- RetakeTypeID = retakePlanView.RetakeTypeID,
- ClassName = retakePlanView.ClassName + "—" + (int)(i + 2) + "班",
- SchoolyearID = retakePlanView.SchoolyearID,
- CourseTypeID = retakePlanView.CourseTypeID,
- Credit = retakePlanView.Credit,
- PeopleNumlower = retakePlanView.PeopleNumlower,
- PeopleNumlimit = retakePlanView.PeopleNumlimit,
- IsDivide = true
- };
- ////查询对应的重修计划名单报名信息
- //var applyUserList = retakePlanView.CF_Student
- // .Where(x => separateStudentList.Contains(x.UserID)).ToList();
- //if (applyUserList != null && applyUserList.Count > 0)
- //{
- // retakePlan.CF_Student = new HashSet<CF_Student>(applyUserList);
- //}
- SetNewStatus(retakePlan);
- UnitOfWork.Add(retakePlan);
- //重修计划名单
- retakePlanView.ER_RetakePlanStudent.Where(x => retakePlanTaskStudentViewList.Contains(x.UserID)).ToList()
- .ForEach(x =>
- {
- ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent
- {
- RetakePlanStudentID = Guid.NewGuid(),
- RetakePlanID = retakePlan.RetakePlanID,
- UserID = x.UserID,
- SchoolyearNumID = x.SchoolyearNumID,
- StarttermID = x.StarttermID
- };
- SetNewStatus(retakePlanStudent);
- UnitOfWork.Add(retakePlanStudent);
- });
- //重修计划设置表
- ER_RetakePlanSetting retakePlanSetting = new ER_RetakePlanSetting
- {
- RetakePlanID = retakePlan.RetakePlanID,
- DepartmentID = retakePlanView.ER_RetakePlanSetting.DepartmentID,
- CourseStructureID = retakePlanView.ER_RetakePlanSetting.CourseStructureID,
- CourseCategoryID = retakePlanView.ER_RetakePlanSetting.CourseCategoryID,
- CourseTypeID = retakePlanView.ER_RetakePlanSetting.CourseTypeID,
- CourseQualityID = retakePlanView.ER_RetakePlanSetting.CourseQualityID,
- PracticeTypeID = retakePlanView.ER_RetakePlanSetting.PracticeTypeID,
- ExaminationModeID = retakePlanView.ER_RetakePlanSetting.ExaminationModeID,
- TeachinglanguageID = retakePlanView.ER_RetakePlanSetting.TeachinglanguageID,
- CourseFineID = retakePlanView.ER_RetakePlanSetting.CourseFineID,
- IsSpecialtycore = retakePlanView.ER_RetakePlanSetting.IsSpecialtycore,
- IsCooperation = retakePlanView.ER_RetakePlanSetting.IsCooperation,
- IsRequired = retakePlanView.ER_RetakePlanSetting.IsRequired,
- IsElective = retakePlanView.ER_RetakePlanSetting.IsElective,
- IsNetworkCourse = retakePlanView.ER_RetakePlanSetting.IsNetworkCourse,
- IsMainCourse = retakePlanView.ER_RetakePlanSetting.IsMainCourse,
- IsNeedMaterial = retakePlanView.ER_RetakePlanSetting.IsNeedMaterial,
- Remarks = retakePlanView.ER_RetakePlanSetting.Remarks
- };
- SetNewStatus(retakePlanSetting);
- UnitOfWork.Add(retakePlanSetting);
- //重修计划教学设置表
- ER_RetakePlanTeachingSetting retakePlanTeachingSetting = new ER_RetakePlanTeachingSetting
- {
- RetakePlanID = retakePlan.RetakePlanID,
- TheoryCourse = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse,
- Practicehours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Practicehours,
- Trialhours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours,
- WeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum,
- TheoryWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum,
- PracticeWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.PracticeWeeklyNum,
- TrialWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum,
- StartWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum,
- EndWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum,
- WeeklyHours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours
- };
- UnitOfWork.Add(retakePlanTeachingSetting);
- //重修计划授课方式表
- retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.ToList().ForEach(x =>
- {
- ER_RetakePlanTeachingModeType teachingModeType = new ER_RetakePlanTeachingModeType
- {
- RetakePlanTeachingModeTypeID = Guid.NewGuid(),
- RetakePlanID = retakePlan.RetakePlanID,
- TeachingModeID = x.TeachingModeID
- };
- this.SetNewStatus(teachingModeType);
- this.UnitOfWork.Add(teachingModeType);
- });
- //重修计划授课地点表
- retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace.ToList().ForEach(x =>
- {
- ER_RetakePlanTeachingPlace teachingPlace = new ER_RetakePlanTeachingPlace
- {
- RetakePlanTeachingPlaceID = Guid.NewGuid(),
- RetakePlanID = retakePlan.RetakePlanID,
- TeachingPlace = x.TeachingPlace
- };
- this.SetNewStatus(teachingPlace);
- this.UnitOfWork.Add(teachingPlace);
- });
- //重修计划任课老师表
- retakePlanView.ER_RetakePlanTeacher.ToList().ForEach(x =>
- {
- ER_RetakePlanTeacher teacher = new ER_RetakePlanTeacher
- {
- RetakePlanTeacherID = Guid.NewGuid(),
- RetakePlanID = retakePlan.RetakePlanID,
- UserID = x.UserID,
- TeachType = x.TeachType
- };
- this.SetNewStatus(teacher);
- this.UnitOfWork.Add(teacher);
- });
- ////重修计划课程表(由于要判断排课冲突,分班不需添加)
- //ER_RetakePlanSettingScheduling newRetakePlanSettingScheduling = new ER_RetakePlanSettingScheduling();
- //当运行到最后一次循环时需修改原先的重修计划(加上分班后的班号)
- //把循环中已分配的学生删除(由于需求有变更,此项暂时无效--将相关代码注释)
- if (i == separateClassCount - 2)
- {
- retakePlanView.ClassName = retakePlanView.ClassName + "—" + 1 + "班";
- retakePlanView.IsDivide = true;
- ////删除相应重修计划报名名单
- //retakePlanView.CF_Student.RemoveWhere(x => !retakePlanTaskStudentViewList.Contains(x.UserID));
- ////删除相应的重修计划名单
- //UnitOfWork.Delete<ER_RetakePlanStudent>(x => !retakePlanTaskStudentViewList.Contains(x.UserID)
- // && x.RetakePlanID == retakePlanView.RetakePlanID);
- }
- }
- SetModifyStatus(retakePlanView);
- UnitOfWork.Update(retakePlanView);
- UnitOfWork.Commit();
- ts.Complete();
- }
- }
- }
- else
- {
- throw new Exception("数据有误,请核查。");
- }
- }
- else
- {
- throw new Exception("数据有误,请核查。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的重修计划名单信息View
- /// </summary>
- /// <param name="RetakePlanID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeStudentListView> GetRetakePlanTaskStudentView(Guid? RetakePlanID, int pageIndex, int pageSize)
- {
- var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(x => x.RetakePlanID == RetakePlanID)
- .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID);
- return query.ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的重修计划名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="RetakePlanID"></param>
- /// <returns></returns>
- public List<RetakeStudentListView> GetRetakePlanTaskStudentViewList(ConfiguretView configuretView, Guid? RetakePlanID)
- {
- var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(x => x.RetakePlanID == RetakePlanID)
- .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID);
- return query.ToList();
- }
- /// <summary>
- /// 查询对应的重修计划名单列表(不及格成绩,小于60分)
- /// 不需排除已在其它相应的重修计划中存在的名单
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="RetakePlanID"></param>
- /// <param name="gradeYearID"></param>
- /// <param name="standardID"></param>
- /// <param name="classmajorID"></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)
- {
- try
- {
- //查询对应的预查考试性质List
- var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
- if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
- {
- throw new Exception("未设置预查考试性质,请设置。");
- }
- //查询对应的重修计划相关信息
- var retakePlan = RetakePlanTaskDAL.RetakePlanRepository
- .GetSingle(x => x.RetakePlanID == retakePlanID, x => x.ER_RetakePlanSetting);
- if (retakePlan == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- //学生最终成绩
- Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakePlan.ER_RetakePlanSetting.DepartmentID.HasValue)
- {
- //开课教研室
- expFinallyScore = expFinallyScore.And(x => x.DepartmentID == retakePlan.ER_RetakePlanSetting.DepartmentID);
- }
- if (retakePlan.CoursematerialID.HasValue)
- {
- //课程信息
- expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == retakePlan.CoursematerialID);
- }
- if (retakePlan.CourseTypeID.HasValue)
- {
- //课程类型
- expFinallyScore = expFinallyScore.And(x => x.CourseTypeID == retakePlan.CourseTypeID);
- }
- if (retakePlan.Credit.HasValue)
- {
- //课程学分
- expFinallyScore = expFinallyScore.And(x => x.Credit == retakePlan.Credit);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- 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));
- }
- }
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (retakePlanID.HasValue)
- {
- //重修计划ID
- expRetakePlan = expRetakePlan.And(x => x.RetakePlanID == retakePlanID);
- }
- if (retakePlan.CoursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == retakePlan.CoursematerialID);
- }
- if (retakePlan.RetakeTypeID.HasValue)
- {
- //重修类型
- expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakePlan.RetakeTypeID);
- }
- if (retakePlan.SchoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakePlan.SchoolyearID);
- }
- if (retakePlan.CourseTypeID.HasValue)
- {
- //课程类型
- expRetakePlan = expRetakePlan.And(x => x.CourseTypeID == retakePlan.CourseTypeID);
- }
- if (retakePlan.Credit.HasValue)
- {
- //课程学分
- expRetakePlan = expRetakePlan.And(x => x.Credit == retakePlan.Credit);
- }
- var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan);
- if (gradeYearID.HasValue)
- {
- //年级
- query = query.Where(x => x.Gradeyear == gradeYearID);
- }
- if (standardID.HasValue)
- {
- //专业名称
- query = query.Where(x => x.StandardID == standardID);
- }
- //条件限定List
- var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
- foreach (var condition in retakeConditionList)
- {
- //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
- query = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, query);
- }
- //查询条件
- 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).ThenBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode)
- .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 重修任务页面添加名单确定
- /// </summary>
- /// <param name="retakePlanID"></param>
- /// <param name="finallyScoreIDList"></param>
- public void AddStudent(Guid? retakePlanID, List<Guid?> finallyScoreIDList)
- {
- try
- {
- //查询对应的重修计划信息
- var retakePlan = RetakePlanTaskDAL.RetakePlanRepository
- .GetSingle(x => x.RetakePlanID == retakePlanID, x => x.ER_RetakePlanSetting);
- if (retakePlan == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- //查询对应的最终成绩信息(不及格成绩,小于60分)
- var finallyScoreViewList = RetakePlanTaskDAL.FinallyScoreRepository
- .GetList(x => finallyScoreIDList.Contains(x.FinallyScoreID)).ToList();
- //重修计划名单表
- List<ER_RetakePlanStudent> retakePlanStudentInList = new List<ER_RetakePlanStudent>();
- foreach (var finallyScoreView in finallyScoreViewList)
- {
- ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent();
- retakePlanStudent.RetakePlanStudentID = Guid.NewGuid();
- retakePlanStudent.RetakePlanID = retakePlanID.Value;
- retakePlanStudent.UserID = finallyScoreView.UserID.Value;
- retakePlanStudent.SchoolyearNumID = finallyScoreView.SchoolyearNumID;
- retakePlanStudent.StarttermID = finallyScoreView.StarttermID;
- SetNewStatus(retakePlanStudent);
- retakePlanStudentInList.Add(retakePlanStudent);
- }
- UnitOfWork.BulkInsert<ER_RetakePlanStudent>(retakePlanStudentInList);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除(重修计划名单删除,根据重修计划名单ID)
- /// </summary>
- /// <param name="retakePlanStudentIDsList"></param>
- public void DeleteStudent(IList<Guid?> retakePlanStudentIDsList)
- {
- try
- {
- //查询对应的重修计划名单信息
- var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository
- .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID),
- (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)).ToList();
- if (retakePlanStudentViewList.Any(x => x.ER_RetakePlan.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated))
- {
- throw new Exception("不能删除已开班状态的重修任务名单。");
- }
- //查询对应的重修报名信息List
- var retakePlanStudentApplyList = RetakePlanTaskDAL.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 (retakePlanStudentApplyList.Count() > 0)
- {
- //查询对应的重修计划信息
- var retakePlanViewList = retakePlanStudentApplyList
- .Select(x => x.ER_RetakePlan).Distinct().ToList();
- //重修报名表
- foreach (var retakePlan in retakePlanViewList)
- {
- //查询存在报名名单的重修计划名单对应的userIDList
- var userIDList = retakePlanStudentApplyList
- .Where(x => x.RetakePlanID == retakePlan.RetakePlanID)
- .Select(x => x.UserID).ToList();
- retakePlan.CF_Student.RemoveWhere(x => userIDList.Contains(x.UserID));
- }
-
-
- //throw new Exception("要删除的重修计划名单已进行重修报名。");
- }
-
- //重修计划名单表
- //UnitOfWork.RemoveRange(new HashSet<ER_RetakePlanStudent>(retakePlanStudentViewList));
- UnitOfWork.Remove<ER_RetakePlanStudent>(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID));
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 检测是否存在对应的已报名重修计划名单(根据重修计划名单ID)
- /// </summary>
- /// <param name="retakePlanStudentIDs"></param>
- /// <returns></returns>
- public bool IsExistsApplyStudentByRetakePlanStudentID(string retakePlanStudentIDs)
- {
- List<Guid?> list = retakePlanStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- var retakePlanStudentList = RetakePlanTaskDAL.RetakePlanStudentRepository
- .GetList(x => list.Contains(x.RetakePlanStudentID), (x => x.ER_RetakePlan),
- (x => x.ER_RetakePlan.CF_Student)).ToList();
- ////查询重修计划名单对应的userIDList
- //var userIDList = retakePlanStudentList.Select(x => x.UserID).ToList();
- var IsExistslist = retakePlanStudentList
- .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)).ToList();
- if (IsExistslist.Count() > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
|