RetakePlanTaskServices.cs 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq.Entity;
  7. using Bowin.Common.Linq;
  8. using EMIS.DataLogic.RetakeManage;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.RetakeManage;
  12. using EMIS.Utility;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.ViewModel.EducationManage;
  15. using EMIS.DataLogic.EducationManage;
  16. using EMIS.CommonLogic.EducationSchedule;
  17. using EMIS.DataLogic.SystemSetting;
  18. using EMIS.CommonLogic.RetakeManage.General;
  19. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  20. using EMIS.DataLogic.EducationSchedule;
  21. using System.Transactions;
  22. using EMIS.CommonLogic.ScoreManage;
  23. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  24. namespace EMIS.CommonLogic.RetakeManage.General
  25. {
  26. public class RetakePlanTaskServices : BaseServices, IRetakePlanTaskServices
  27. {
  28. public RetakeConditionDAL RetakeConditionDAL { get; set; }
  29. public RetakePlanTaskDAL RetakePlanTaskDAL { get; set; }
  30. public Lazy<IParameterServices> IParameterServices { get; set; }
  31. public DictionaryItemDAL DictionaryItemDAL { get; set; }
  32. public IInSchoolSettingServices InSchoolSettingServices { get; set; }
  33. public IRetakeParameterServices IRetakeParameterServices { get; set; }
  34. public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; }
  35. public Lazy<ISpecialityScoreByFinalScoreServices> specialityScoreByFinalScoreServices { get; set; }
  36. public IRetakePlanStudentApplyServices IRetakePlanStudentApplyServices { get; set; }
  37. public RetakePlanResultDAL RetakePlanResultDAL { get; set; }
  38. /// <summary>
  39. /// 查询学生预查信息列表
  40. /// </summary>
  41. /// <param name="conditionView"></param>
  42. /// <param name="schoolyearID"></param>
  43. /// <param name="collegeID"></param>
  44. /// <param name="departmentID"></param>
  45. /// <param name="yearID"></param>
  46. /// <param name="standardID"></param>
  47. /// <param name="educationID"></param>
  48. /// <param name="learningformID"></param>
  49. /// <param name="learnSystem"></param>
  50. /// <param name="classmajorID"></param>
  51. /// <param name="inSchoolStatus"></param>
  52. /// <param name="ExamsCategoryID"></param>
  53. /// <param name="CoursematerialID"></param>
  54. /// <param name="CourseTypes"></param>
  55. /// <param name="pageIndex"></param>
  56. /// <param name="pageSize"></param>
  57. /// <returns></returns>
  58. public IGridResultSet<RetakeStudentListView> GetRetakePreStudentView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
  59. Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID,
  60. int? inSchoolStatus, int? examsCategoryID, Guid? coursematerialID, string courseTypeIDs, int pageIndex, int pageSize)
  61. {
  62. try
  63. {
  64. //查询对应的预查考试性质List
  65. var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
  66. if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
  67. {
  68. throw new Exception("未设置预查考试性质,请设置。");
  69. }
  70. //学生最终成绩
  71. Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  72. if (schoolyearID.HasValue)
  73. {
  74. //学年学期
  75. expFinallyScore = expFinallyScore.And(x => x.SchoolyearID == schoolyearID);
  76. }
  77. if (departmentID.HasValue)
  78. {
  79. //开课教研室
  80. expFinallyScore = expFinallyScore.And(x => x.DepartmentID == departmentID);
  81. }
  82. if (examsCategoryID.HasValue)
  83. {
  84. //考试性质
  85. expFinallyScore = expFinallyScore.And(x => x.ExamsCategoryID == examsCategoryID);
  86. }
  87. if (coursematerialID.HasValue)
  88. {
  89. //课程信息
  90. expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == coursematerialID);
  91. }
  92. //查询必修课程类型信息List
  93. var isRequiredCourseTypeIDlist = specialityScoreByFinalScoreServices.Value.GetCourseTypeID().ToList();
  94. //课程类型List
  95. var courseTypeIDList = new List<int>();
  96. if (!string.IsNullOrEmpty(courseTypeIDs))
  97. {
  98. courseTypeIDList = courseTypeIDs.Remove(courseTypeIDs.Length - 1).Split(',')
  99. .Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToList();
  100. }
  101. expFinallyScore = expFinallyScore.And(x => courseTypeIDList.Contains(x.CourseTypeID.Value));
  102. //学生信息
  103. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  104. if (inSchoolStatus != null && inSchoolStatus > -1)
  105. {
  106. //在校状态
  107. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  108. if (inSchoolStatus == 1)
  109. {
  110. //表示在校
  111. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  112. }
  113. if (inSchoolStatus == 0)
  114. {
  115. //不在校
  116. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  117. }
  118. }
  119. if (classmajorID.HasValue)
  120. {
  121. //班级信息
  122. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  123. }
  124. //查询对应的重修学年学期
  125. var retakeSchoolyearID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
  126. //重修计划
  127. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  128. if (retakeSchoolyearID.HasValue)
  129. {
  130. //重修学年学期
  131. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID);
  132. }
  133. else
  134. {
  135. throw new Exception("未设置重修学年学期,请设置。");
  136. }
  137. var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan);
  138. if (collegeID.HasValue)
  139. {
  140. //院系所
  141. query = query.Where(x => x.CollegeID == collegeID);
  142. }
  143. if (yearID.HasValue)
  144. {
  145. //年级
  146. query = query.Where(x => x.Gradeyear == yearID);
  147. }
  148. if (standardID.HasValue)
  149. {
  150. //专业名称
  151. query = query.Where(x => x.StandardID == standardID);
  152. }
  153. if (educationID.HasValue)
  154. {
  155. //培养层次
  156. query = query.Where(x => x.EducationID == educationID);
  157. }
  158. if (learningformID.HasValue)
  159. {
  160. //学习形式
  161. query = query.Where(x => x.LearningformID == learningformID);
  162. }
  163. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  164. {
  165. //学制
  166. var LearnSystems = Convert.ToDecimal(learnSystem);
  167. query = query.Where(x => x.LearnSystem == LearnSystems);
  168. }
  169. //条件限定List
  170. var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
  171. foreach (var condition in retakeConditionList)
  172. {
  173. //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
  174. query = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, query);
  175. }
  176. //查询条件
  177. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  178. {
  179. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  180. }
  181. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length)
  182. .ThenBy(x => x.LoginID).ThenBy(x => x.SchoolyearCode)
  183. .ThenBy(x => x.CourseCode)
  184. .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
  185. }
  186. catch (Exception ex)
  187. {
  188. throw new Exception(ex.Message);
  189. }
  190. }
  191. /// <summary>
  192. /// 查询学生预查信息List
  193. /// </summary>
  194. /// <param name="configuretView"></param>
  195. /// <param name="schoolyearID"></param>
  196. /// <param name="collegeID"></param>
  197. /// <param name="departmentID"></param>
  198. /// <param name="yearID"></param>
  199. /// <param name="standardID"></param>
  200. /// <param name="educationID"></param>
  201. /// <param name="learningformID"></param>
  202. /// <param name="learnSystem"></param>
  203. /// <param name="classmajorID"></param>
  204. /// <param name="inSchoolStatus"></param>
  205. /// <param name="examsCategoryID"></param>
  206. /// <param name="coursematerialID"></param>
  207. /// <param name="courseTypeIDs"></param>
  208. /// <returns></returns>
  209. public List<RetakeStudentListView> GetRetakePreStudentViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
  210. Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID,
  211. int? inSchoolStatus, int? examsCategoryID, Guid? coursematerialID, string courseTypeIDs)
  212. {
  213. try
  214. {
  215. //查询对应的预查考试性质List
  216. var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
  217. if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
  218. {
  219. throw new Exception("未设置预查考试性质,请设置。");
  220. }
  221. //学生最终成绩
  222. Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  223. if (schoolyearID.HasValue)
  224. {
  225. //学年学期
  226. expFinallyScore = expFinallyScore.And(x => x.SchoolyearID == schoolyearID);
  227. }
  228. if (departmentID.HasValue)
  229. {
  230. //开课教研室
  231. expFinallyScore = expFinallyScore.And(x => x.DepartmentID == departmentID);
  232. }
  233. if (examsCategoryID.HasValue)
  234. {
  235. //考试性质
  236. expFinallyScore = expFinallyScore.And(x => x.ExamsCategoryID == examsCategoryID);
  237. }
  238. if (coursematerialID.HasValue)
  239. {
  240. //课程信息
  241. expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == coursematerialID);
  242. }
  243. //查询必修课程类型信息List
  244. var isRequiredCourseTypeIDlist = specialityScoreByFinalScoreServices.Value.GetCourseTypeID().ToList();
  245. //课程类型List
  246. var courseTypeIDList = new List<int>();
  247. if (!string.IsNullOrEmpty(courseTypeIDs))
  248. {
  249. courseTypeIDList = courseTypeIDs.Remove(courseTypeIDs.Length - 1).Split(',')
  250. .Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToList();
  251. }
  252. expFinallyScore = expFinallyScore.And(x => courseTypeIDList.Contains(x.CourseTypeID.Value));
  253. //学生信息
  254. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  255. if (inSchoolStatus != null && inSchoolStatus > -1)
  256. {
  257. //在校状态
  258. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  259. if (inSchoolStatus == 1)
  260. {
  261. //表示在校
  262. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  263. }
  264. if (inSchoolStatus == 0)
  265. {
  266. //不在校
  267. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  268. }
  269. }
  270. if (classmajorID.HasValue)
  271. {
  272. //班级信息
  273. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  274. }
  275. //查询对应的重修学年学期
  276. var retakeSchoolyearID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
  277. //重修计划
  278. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  279. if (retakeSchoolyearID.HasValue)
  280. {
  281. //重修学年学期
  282. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID);
  283. }
  284. else
  285. {
  286. throw new Exception("未设置重修学年学期,请设置。");
  287. }
  288. var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan);
  289. if (collegeID.HasValue)
  290. {
  291. //院系所
  292. query = query.Where(x => x.CollegeID == collegeID);
  293. }
  294. if (yearID.HasValue)
  295. {
  296. //年级
  297. query = query.Where(x => x.Gradeyear == yearID);
  298. }
  299. if (standardID.HasValue)
  300. {
  301. //专业名称
  302. query = query.Where(x => x.StandardID == standardID);
  303. }
  304. if (educationID.HasValue)
  305. {
  306. //培养层次
  307. query = query.Where(x => x.EducationID == educationID);
  308. }
  309. if (learningformID.HasValue)
  310. {
  311. //学习形式
  312. query = query.Where(x => x.LearningformID == learningformID);
  313. }
  314. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  315. {
  316. //学制
  317. var LearnSystems = Convert.ToDecimal(learnSystem);
  318. query = query.Where(x => x.LearnSystem == LearnSystems);
  319. }
  320. //条件限定List
  321. var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
  322. foreach (var condition in retakeConditionList)
  323. {
  324. //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
  325. query = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, query);
  326. }
  327. //查询条件
  328. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  329. {
  330. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  331. }
  332. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length)
  333. .ThenBy(x => x.LoginID).ThenBy(x => x.SchoolyearCode)
  334. .ThenBy(x => x.CourseCode)
  335. .ToList();
  336. }
  337. catch (Exception ex)
  338. {
  339. throw new Exception(ex.Message);
  340. }
  341. }
  342. /// <summary>
  343. /// 学生预查重修任务生成
  344. /// </summary>
  345. /// <param name="finallyScoreIDList"></param>
  346. /// <param name="retakeTypeID"></param>
  347. /// <returns></returns>
  348. public string Generate(List<Guid?> finallyScoreIDList, int? retakeTypeID)
  349. {
  350. try
  351. {
  352. //查询对应的重修学年学期
  353. var retakeSchoolyearID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
  354. if (retakeSchoolyearID == null)
  355. {
  356. throw new Exception("未设置重修学年学期,请设置。");
  357. }
  358. //查询对应的重修考试性质(此字段需要存到重修计划表中)
  359. var retakeExamsCatagoryID = IParameterServices.Value.GetParameterValue<int>(CF_ParameterType.RetakeExamsCatagoryID);
  360. if (retakeExamsCatagoryID == null)
  361. {
  362. throw new Exception("未设置重修考试性质,请设置。");
  363. }
  364. //查询对应的重修收费项目
  365. var retakeChargeProjectID = IParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeChargeProjectID);
  366. if (retakeChargeProjectID == null)
  367. {
  368. throw new Exception("未设置重修收费项目,请设置。");
  369. }
  370. //查询对应的预查考试性质List
  371. var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
  372. if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
  373. {
  374. throw new Exception("未设置预查考试性质,请设置。");
  375. }
  376. //查询对应的重修类型ID
  377. var retakeTypeView = DictionaryItemDAL.DictionaryItemRepository.Entities
  378. .Where(x => x.DictionaryCode == typeof(EMIS.ViewModel.ER_RetakeType).Name && x.Value == retakeTypeID)
  379. .SingleOrDefault();
  380. if (retakeTypeView == null)
  381. {
  382. throw new Exception("重修类型数据有误,请核查。");
  383. }
  384. //学生最终成绩
  385. Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  386. if (finallyScoreIDList == null || finallyScoreIDList.Count() <= 0)
  387. {
  388. throw new Exception("数据有误,请核查。");
  389. }
  390. else
  391. {
  392. //最终成绩信息ID
  393. expFinallyScore = expFinallyScore.And(x => finallyScoreIDList.Contains(x.FinallyScoreID));
  394. }
  395. //查询对应的学生预查信息View
  396. var retakeStudentPrescanView = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, x => true, x => true);
  397. //重修条件限定List
  398. var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
  399. foreach (var condition in retakeConditionList)
  400. {
  401. //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
  402. retakeStudentPrescanView = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, retakeStudentPrescanView);
  403. }
  404. //学生预查coursematerialIDList
  405. var coursematerialIDList = retakeStudentPrescanView.Where(x => !string.IsNullOrEmpty(x.CoursematerialID.ToString()))
  406. .Select(x => x.CoursematerialID).ToList();
  407. //重修计划
  408. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  409. if (retakeSchoolyearID.HasValue)
  410. {
  411. //重修学年学期
  412. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID);
  413. }
  414. if (retakeExamsCatagoryID.HasValue)
  415. {
  416. //重修考试性质(目前缺少此字段)
  417. }
  418. if (retakeTypeID.HasValue)
  419. {
  420. //重修类型
  421. expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID);
  422. }
  423. if (coursematerialIDList != null || coursematerialIDList.Count() > 0)
  424. {
  425. //重修计划coursematerialIDList
  426. expRetakePlan = expRetakePlan.And(x => coursematerialIDList.Contains(x.CoursematerialID));
  427. }
  428. //查询对应的重修计划信息List
  429. var retakePlanViewList = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan).ToList();
  430. //查询对应的重修计划retakePlanIDList
  431. var retakePlanIDList = retakePlanViewList.Where(x => !string.IsNullOrEmpty(x.RetakePlanID.ToString()))
  432. .Select(x => x.RetakePlanID).ToList();
  433. //学生预查userIDList
  434. var userIDList = retakeStudentPrescanView.Where(x => !string.IsNullOrEmpty(x.UserID.ToString()))
  435. .Select(x => x.UserID).ToList();
  436. //重修计划名单
  437. Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  438. if (retakePlanIDList != null || retakePlanIDList.Count() > 0)
  439. {
  440. //重修计划retakePlanIDList
  441. expRetakePlanStudent = expRetakePlanStudent.And(x => retakePlanIDList.Contains(x.RetakePlanID));
  442. }
  443. if (userIDList != null || userIDList.Count() > 0)
  444. {
  445. //重修计划名单userIDList
  446. expRetakePlanStudent = expRetakePlanStudent.And(x => userIDList.Contains(x.UserID));
  447. }
  448. //查询对应的重修计划名单List
  449. var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository
  450. .GetList(expRetakePlanStudent).ToList();
  451. int success = 0; //成功
  452. int fail = 0; //失败
  453. string tipMessage = null; //提示消息
  454. var retakePlanInList = new List<ER_RetakePlan>(); //重修计划List
  455. var retakePlanSettingInList = new List<ER_RetakePlanSetting>(); //重修计划设置List
  456. var retakePlanTeachingSettingInList = new List<ER_RetakePlanTeachingSetting>(); //重修计划教学设置List
  457. var retakePlanStudentInList = new List<ER_RetakePlanStudent>(); //重修计划学生名单List
  458. //学生预查分组信息List(分组条件:课程信息ID、课程类型、课程学分、开课教研室ID、重修类型、重修学年学期)
  459. //注:分组后,可级联出各组对应的明细
  460. var retakeStudentListViewGroupList = retakeStudentPrescanView.ToList().GroupBy(x => new
  461. {
  462. x.CoursematerialID,
  463. x.Abbreviation,
  464. x.CourseName,
  465. x.CourseTypeID,
  466. x.CourseTypeDesc,
  467. x.CourseCredit,
  468. x.DepartmentID
  469. });
  470. foreach (var retakeStudentListViewGroup in retakeStudentListViewGroupList)
  471. {
  472. //验证对应的重修计划信息(由于有分班功能,可存在多个对应的重修计划信息)
  473. var retakePlanViewListVerify = retakePlanViewList.Where(x => x.CoursematerialID == retakeStudentListViewGroup.Key.CoursematerialID
  474. && x.CourseTypeID == retakeStudentListViewGroup.Key.CourseTypeID
  475. && x.Credit == retakeStudentListViewGroup.Key.CourseCredit
  476. && x.DepartmentID == retakeStudentListViewGroup.Key.DepartmentID
  477. && x.RetakeTypeID == retakeTypeID
  478. && x.SchoolyearID == retakeSchoolyearID
  479. ).ToList();
  480. if (retakePlanViewListVerify == null || retakePlanViewListVerify.Count() <= 0)
  481. {
  482. //表示不存在对应的重修计划
  483. ER_RetakePlan retakePlan = new ER_RetakePlan();
  484. retakePlan.RetakePlanID = Guid.NewGuid();
  485. retakePlan.CoursematerialID = retakeStudentListViewGroup.Key.CoursematerialID;
  486. retakePlan.RetakeTypeID = retakeTypeID;
  487. //重修班级名称
  488. retakePlan.ClassName = (retakeStudentListViewGroup.Key.Abbreviation ?? retakeStudentListViewGroup.Key.CourseName)
  489. + "-" + retakeTypeView.Name + "(" + retakeStudentListViewGroup.Key.CourseTypeDesc
  490. + (retakeStudentListViewGroup.Key.CourseCredit == 0 ? "0" :
  491. string.Format("{0:#.0}", retakeStudentListViewGroup.Key.CourseCredit))
  492. + "学分)";
  493. retakePlan.SchoolyearID = retakeSchoolyearID;
  494. retakePlan.CourseTypeID = retakeStudentListViewGroup.Key.CourseTypeID;
  495. retakePlan.Credit = retakeStudentListViewGroup.Key.CourseCredit;
  496. retakePlan.PeopleNumlower = 0;
  497. retakePlan.PeopleNumlimit = 0;
  498. retakePlan.IsDivide = false;
  499. //重修任务状态默认为未开放
  500. SetNewStatus(retakePlan, (int)ER_RetakePlanStatus.NotOpened);
  501. ER_RetakePlanSetting retakePlanSetting = new ER_RetakePlanSetting();
  502. retakePlanSetting.RetakePlanID = retakePlan.RetakePlanID;
  503. retakePlanSetting.DepartmentID = retakeStudentListViewGroup.Key.DepartmentID;
  504. retakePlanSetting.CourseTypeID = retakeStudentListViewGroup.Key.CourseTypeID;
  505. retakePlanSetting.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  506. retakePlanSetting.IsSpecialtycore = false;
  507. retakePlanSetting.IsCooperation = false;
  508. retakePlanSetting.IsRequired = true;
  509. retakePlanSetting.IsElective = false;
  510. retakePlanSetting.IsNetworkCourse = false;
  511. retakePlanSetting.IsMainCourse = false;
  512. SetNewStatus(retakePlanSetting);
  513. ER_RetakePlanTeachingSetting retakePlanTeachingSetting = new ER_RetakePlanTeachingSetting();
  514. retakePlanTeachingSetting.RetakePlanID = retakePlan.RetakePlanID;
  515. retakePlanInList.Add(retakePlan);
  516. retakePlanSettingInList.Add(retakePlanSetting);
  517. retakePlanTeachingSettingInList.Add(retakePlanTeachingSetting);
  518. foreach (var retakeStudentPrescan in retakeStudentListViewGroup.Select(x => x).ToList())
  519. {
  520. //对应的重修计划名单
  521. ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent();
  522. retakePlanStudent.RetakePlanStudentID = Guid.NewGuid();
  523. retakePlanStudent.RetakePlanID = retakePlan.RetakePlanID;
  524. retakePlanStudent.UserID = retakeStudentPrescan.UserID.Value;
  525. retakePlanStudent.SchoolyearNumID = retakeStudentPrescan.SchoolyearNumID;
  526. retakePlanStudent.StarttermID = retakeStudentPrescan.StarttermID;
  527. SetNewStatus(retakePlanStudent);
  528. retakePlanStudentInList.Add(retakePlanStudent);
  529. success++;
  530. }
  531. }
  532. else
  533. {
  534. //表示存在对应的重修计划
  535. //由于有分班功能,可存在多个对应的重修计划信息,默认将重修计划名单分配到查询结果的各个重修计划中
  536. //查询对应的重修计划retakePlanID(由于有分班功能,可存在多个对应的retakePlanID)
  537. var retakePlanIDVerifyList = retakePlanViewListVerify.Select(x => x.RetakePlanID).ToList();
  538. foreach (var retakeStudentPrescan in retakeStudentListViewGroup.Select(x => x).ToList())
  539. {
  540. //查询对应的重修计划名单信息
  541. var retakePlanStudentList = retakePlanStudentViewList
  542. .Where(x => retakePlanIDVerifyList.Contains(x.RetakePlanID)
  543. && x.UserID == retakeStudentPrescan.UserID).ToList();
  544. //分别将对应的重修计划名单添加到对应的重修计划中(由于有分班功能,重修计划名单可存在不同的重修任务中)
  545. foreach (var retakePlanIDVerify in retakePlanIDVerifyList)
  546. {
  547. //验证对应的重修计划名单信息
  548. var retakePlanStudentVerify = retakePlanStudentList
  549. .Where(x => x.RetakePlanID == retakePlanIDVerify).SingleOrDefault();
  550. if (retakePlanStudentVerify == null)
  551. {
  552. //表示不存在对应的重修计划名单
  553. ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent();
  554. retakePlanStudent.RetakePlanStudentID = Guid.NewGuid();
  555. //存在多个对应的重修计划信息,默认将重修计划名单分配到查询结果的各个重修计划中
  556. retakePlanStudent.RetakePlanID = retakePlanIDVerify;
  557. retakePlanStudent.UserID = retakeStudentPrescan.UserID.Value;
  558. retakePlanStudent.SchoolyearNumID = retakeStudentPrescan.SchoolyearNumID;
  559. retakePlanStudent.StarttermID = retakeStudentPrescan.StarttermID;
  560. SetNewStatus(retakePlanStudent);
  561. retakePlanStudentInList.Add(retakePlanStudent);
  562. success++;
  563. }
  564. else
  565. {
  566. //表示存在对应的重修计划名单(数据有误,原因为:同一个学生,不同开课学期修同一门课程)
  567. fail++;
  568. }
  569. }
  570. }
  571. }
  572. }
  573. //批量插入
  574. UnitOfWork.BulkInsert(retakePlanInList);
  575. UnitOfWork.BulkInsert(retakePlanSettingInList);
  576. UnitOfWork.BulkInsert(retakePlanTeachingSettingInList);
  577. UnitOfWork.BulkInsert(retakePlanStudentInList);
  578. if (success > 0 && fail <= 0)
  579. {
  580. tipMessage = success + "条";
  581. }
  582. else
  583. {
  584. tipMessage = success + "条," + fail + "条失败,原因:已存在相同的重修任务名单,请检查";
  585. }
  586. return tipMessage;
  587. }
  588. catch (Exception ex)
  589. {
  590. throw new Exception(ex.Message);
  591. }
  592. }
  593. /// <summary>
  594. /// 查询重修任务信息View
  595. /// </summary>
  596. /// <param name="configuretView"></param>
  597. /// <param name="schoolyearID"></param>
  598. /// <param name="collegeID"></param>
  599. /// <param name="departmentID"></param>
  600. /// <param name="coursematerialID"></param>
  601. /// <param name="retakeTypeID"></param>
  602. /// <param name="statusID"></param>
  603. /// <param name="pageIndex"></param>
  604. /// <param name="pageSize"></param>
  605. /// <returns></returns>
  606. public IGridResultSet<RetakePlanTaskView> GetRetakePlanTaskView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
  607. Guid? departmentID, Guid? coursematerialID, int? retakeTypeID, int? statusID, int pageIndex, int pageSize)
  608. {
  609. //重修计划
  610. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  611. if (schoolyearID.HasValue)
  612. {
  613. //重修学年学期
  614. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
  615. }
  616. if (coursematerialID.HasValue)
  617. {
  618. //课程信息
  619. expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
  620. }
  621. if (retakeTypeID.HasValue)
  622. {
  623. //重修类型
  624. expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID);
  625. }
  626. if (statusID.HasValue)
  627. {
  628. //重修任务状态
  629. expRetakePlan = expRetakePlan.And(x => x.RecordStatus == statusID);
  630. }
  631. //查询对应的重修任务信息View
  632. var query = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan);
  633. if (collegeID.HasValue)
  634. {
  635. //开课院系所
  636. query = query.Where(x => x.CourseCollegeID == collegeID);
  637. }
  638. if (departmentID.HasValue)
  639. {
  640. //开课教研室
  641. query = query.Where(x => x.DepartmentID == departmentID);
  642. }
  643. //查询条件()
  644. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  645. {
  646. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  647. }
  648. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode.Length)
  649. .ThenBy(x => x.SchoolyearCode).ThenBy(x => x.DepartmentCode.Length)
  650. .ThenBy(x => x.DepartmentCode).ThenBy(x => x.RetakeTypeID)
  651. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  652. .ThenBy(x => x.CourseTypeID).ThenBy(x => x.ClassName)
  653. .ToGridResultSet<RetakePlanTaskView>(pageIndex, pageSize);
  654. //查询对应的重修计划IDList
  655. var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
  656. //查询对应的课程表信息
  657. var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
  658. //查询合并显示的课程表信息
  659. var weekdayTimesList = IRetakePlanStudentApplyServices.GetWeekdayTimesSegmentName(schedulingList);
  660. result.rows.ForEach(x =>
  661. {
  662. var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
  663. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  664. x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
  665. });
  666. //查询合并显示的任课老师信息
  667. var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
  668. result.rows.ForEach(x =>
  669. x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
  670. return result;
  671. }
  672. /// <summary>
  673. /// 查询重修任务信息List
  674. /// </summary>
  675. /// <param name="configuretView"></param>
  676. /// <param name="schoolyearID"></param>
  677. /// <param name="collegeID"></param>
  678. /// <param name="departmentID"></param>
  679. /// <param name="coursematerialID"></param>
  680. /// <param name="retakeTypeID"></param>
  681. /// <param name="statusID"></param>
  682. /// <returns></returns>
  683. public List<RetakePlanTaskView> GetRetakePlanTaskViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
  684. Guid? departmentID, Guid? coursematerialID, int? retakeTypeID, int? statusID)
  685. {
  686. //重修计划
  687. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  688. if (schoolyearID.HasValue)
  689. {
  690. //重修学年学期
  691. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
  692. }
  693. if (coursematerialID.HasValue)
  694. {
  695. //课程信息
  696. expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
  697. }
  698. if (retakeTypeID.HasValue)
  699. {
  700. //重修类型
  701. expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID);
  702. }
  703. if (statusID.HasValue)
  704. {
  705. //重修任务状态
  706. expRetakePlan = expRetakePlan.And(x => x.RecordStatus == statusID);
  707. }
  708. //查询对应的重修任务信息View
  709. var query = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan);
  710. if (collegeID.HasValue)
  711. {
  712. //开课院系所
  713. query = query.Where(x => x.CourseCollegeID == collegeID);
  714. }
  715. if (departmentID.HasValue)
  716. {
  717. //开课教研室
  718. query = query.Where(x => x.DepartmentID == departmentID);
  719. }
  720. //查询条件()
  721. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  722. {
  723. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  724. }
  725. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode.Length)
  726. .ThenBy(x => x.SchoolyearCode).ThenBy(x => x.DepartmentCode.Length)
  727. .ThenBy(x => x.DepartmentCode).ThenBy(x => x.RetakeTypeID)
  728. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  729. .ThenBy(x => x.CourseTypeID).ThenBy(x => x.ClassName)
  730. .ToList();
  731. //查询对应的重修计划IDList
  732. var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
  733. //查询对应的课程表信息
  734. var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
  735. //查询合并显示的课程表信息
  736. var weekdayTimesList = IRetakePlanStudentApplyServices.GetWeekdayTimesSegmentName(schedulingList);
  737. result.ForEach(x =>
  738. {
  739. var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
  740. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  741. x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
  742. });
  743. //查询合并显示的任课老师信息
  744. var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
  745. result.ForEach(x =>
  746. x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
  747. return result;
  748. }
  749. /// <summary>
  750. /// 查询重修计划相关信息View(含相关设置信息、排课教室等)
  751. /// 注:排课明细中目前只支持同一教室的情况
  752. /// </summary>
  753. /// <param name="RetakePlanID"></param>
  754. /// <returns></returns>
  755. public RetakePlanTaskSettingView GetRetakePlanTaskUpdateView(Guid? RetakePlanID)
  756. {
  757. var retakePlanTaskSettingView = RetakePlanTaskDAL.GetRetakePlanTaskSettingView(x => x.RetakePlanID == RetakePlanID)
  758. .SingleOrDefault();
  759. return retakePlanTaskSettingView;
  760. }
  761. /// <summary>
  762. /// 查询重修计划课程表信息List
  763. /// </summary>
  764. /// <param name="RetakePlanID"></param>
  765. /// <returns></returns>
  766. public List<RetakePlanSettingSchedulingView> GetSchedulingView(Guid? RetakePlanID)
  767. {
  768. var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => x.RetakePlanID == RetakePlanID)
  769. .OrderBy(x => x.Weekday).ThenBy(x=>x.TimesSegment)
  770. .ThenBy(x=>x.StartTimes).ToList();
  771. return schedulingList;
  772. }
  773. /// <summary>
  774. /// 查询重修计划任课老师信息List
  775. /// </summary>
  776. /// <param name="RetakePlanID"></param>
  777. /// <returns></returns>
  778. public List<RetakePlanTeacherListView> GetTeacherListView(Guid? RetakePlanID)
  779. {
  780. var teacherListView = RetakePlanTaskDAL.GetRetakePlanTeacherViewQueryable(x => x.RetakePlanID == RetakePlanID)
  781. .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
  782. .ThenBy(x => x.TeachingMethod).ToList();
  783. return teacherListView;
  784. }
  785. /// <summary>
  786. /// 查询重修计划授课方式信息List
  787. /// </summary>
  788. /// <param name="RetakePlanID"></param>
  789. /// <returns></returns>
  790. public List<int> GetTeachingModeType(Guid? RetakePlanID)
  791. {
  792. var list = RetakePlanTaskDAL.GetTeachingModeType(x => x.RetakePlanID == RetakePlanID)
  793. .Select(x => x.Value ?? 0).ToList();
  794. if (list.Count >= 0)
  795. {
  796. list.Add((int)EMIS.ViewModel.CF_TeachingMode.Theory);
  797. }
  798. return list;
  799. }
  800. /// <summary>
  801. /// 查询重修计划授课地点信息List
  802. /// </summary>
  803. /// <param name="RetakePlanID"></param>
  804. /// <returns></returns>
  805. public List<int> GetTeachingPlace(Guid? RetakePlanID)
  806. {
  807. var list = RetakePlanTaskDAL.GetTeachingPlace(x => x.RetakePlanID == RetakePlanID)
  808. .Select(x => x.Value ?? 0).ToList();
  809. return list;
  810. }
  811. /// <summary>
  812. /// 查询对应的重修计划相关表信息
  813. /// </summary>
  814. /// <param name="RetakePlanID"></param>
  815. /// <returns></returns>
  816. public ER_RetakePlan GetRetakePlan(Guid? RetakePlanID)
  817. {
  818. return RetakePlanTaskDAL.RetakePlanRepository.GetSingle(x => x.RetakePlanID == RetakePlanID,
  819. (x => x.ER_RetakePlanSetting),
  820. (x => x.ER_RetakePlanSettingScheduling),
  821. (x => x.ER_RetakePlanStudent),
  822. (x => x.ER_RetakePlanTeacher),
  823. (x => x.CF_Student),
  824. (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType),
  825. (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace),
  826. (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting));
  827. }
  828. /// <summary>
  829. /// 重修计划修改(排课冲突判断)
  830. /// </summary>
  831. /// <param name="RetakePlanTaskSettingView"></param>
  832. /// <param name="teacherList"></param>
  833. /// <param name="schedulingList"></param>
  834. /// <param name="type"></param>
  835. /// <returns></returns>
  836. public bool RetakePlanTaskSet(RetakePlanTaskSettingView RetakePlanTaskSettingView, IList<RetakePlanTeacherListView> teacherList,
  837. IList<RetakePlanSettingSchedulingView> schedulingList, out int? type)
  838. {
  839. try
  840. {
  841. var retakePlan = GetRetakePlan(RetakePlanTaskSettingView.RetakePlanID);
  842. //排课明细
  843. if (schedulingList.Where(x => x.CoursesTimeID == null || x.Weekday == null).ToList().Count > 0)
  844. {
  845. throw new Exception("排课信息不能为空");
  846. }
  847. else
  848. {
  849. //如果IsNeedVerify为false时,不验证冲突
  850. if (RetakePlanTaskSettingView.IsNeedVerify != false)
  851. {
  852. //判断教师和教室冲突,如果有冲突type返回1,页面js根据type弹出选择框
  853. //用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
  854. foreach (var scheduling in schedulingList)
  855. {
  856. //教室不为空时,判断教室
  857. if (RetakePlanTaskSettingView.ClassroomID != null)
  858. {
  859. //重修计划冲突
  860. var repeatExecutableClassroom = RetakePlanTaskDAL
  861. .GetRepeatRetakePlanSettingClassroom(scheduling.CoursesTimeID,
  862. RetakePlanTaskSettingView.ClassroomID, scheduling.Weekday,
  863. RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum,
  864. RetakePlanTaskSettingView.EndWeeklyNum)
  865. .Where(x => x.ID != RetakePlanTaskSettingView.RetakePlanID).FirstOrDefault();
  866. if (repeatExecutableClassroom != null)
  867. {
  868. type = 1;
  869. throw new Exception(repeatExecutableClassroom.WeekdayName + repeatExecutableClassroom.StartTimes
  870. + "时间段教室与重修计划[" + repeatExecutableClassroom.DefaultClassName + "]有冲突");
  871. }
  872. //教学任务冲突
  873. var repeatEducationClassroom = RetakePlanTaskDAL
  874. .GetRepeatEducationMissionClassroom(scheduling.CoursesTimeID,
  875. RetakePlanTaskSettingView.ClassroomID, scheduling.Weekday,
  876. RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum,
  877. RetakePlanTaskSettingView.EndWeeklyNum).FirstOrDefault();
  878. if (repeatEducationClassroom != null)
  879. {
  880. type = 1;
  881. throw new Exception("检测到排课冲突," + "该重修上课时间段教室与教学任务班["
  882. + repeatEducationClassroom.DefaultClassName + "]有冲突");
  883. }
  884. }
  885. //重修计划冲突
  886. var repeatExecutableTeacher = RetakePlanTaskDAL
  887. .GetRepeatRetakePlanTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID,
  888. scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum,
  889. RetakePlanTaskSettingView.EndWeeklyNum)
  890. .Where(x => x.ID != RetakePlanTaskSettingView.RetakePlanID).FirstOrDefault();
  891. if (repeatExecutableTeacher != null)
  892. {
  893. type = 1;
  894. throw new Exception("检测到排课冲突," + repeatExecutableTeacher.WeekdayName
  895. + repeatExecutableTeacher.StartTimes + "时间段教师与重修计划["
  896. + repeatExecutableTeacher.DefaultClassName + "]有冲突");
  897. }
  898. //教学任务冲突
  899. var repeatEducationTeacher = RetakePlanTaskDAL
  900. .GetRepeatEducationMissionTeacher(teacherList.Select(x => x.UserID).ToList(),
  901. scheduling.CoursesTimeID, scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID,
  902. RetakePlanTaskSettingView.StartWeeklyNum,
  903. RetakePlanTaskSettingView.EndWeeklyNum).FirstOrDefault();
  904. if (repeatEducationTeacher != null)
  905. {
  906. type = 1;
  907. throw new Exception("检测到排课冲突," + "该重修上课时间段教师与教学任务班["
  908. + repeatEducationTeacher.DefaultClassName + "]有冲突");
  909. }
  910. }
  911. }
  912. }
  913. using (TransactionScope ts = new TransactionScope())
  914. {
  915. retakePlan.CoursematerialID = RetakePlanTaskSettingView.CoursematerialID;
  916. retakePlan.RetakeTypeID = RetakePlanTaskSettingView.RetakeTypeID;
  917. retakePlan.ClassName = RetakePlanTaskSettingView.ClassName;
  918. retakePlan.SchoolyearID = RetakePlanTaskSettingView.SchoolyearID;
  919. retakePlan.CourseTypeID = RetakePlanTaskSettingView.CourseTypeID ;
  920. //retakePlan.Credit = RetakePlanTaskSettingView.Credit; //目前会出现文本框控件禁用时,取值无效
  921. retakePlan.PeopleNumlimit = RetakePlanTaskSettingView.PeopleNumlimit;
  922. retakePlan.PeopleNumlower = RetakePlanTaskSettingView.PeopleNumlower;
  923. SetModifyStatus(retakePlan);
  924. //重修计划设置表
  925. if (retakePlan.ER_RetakePlanSetting == null)
  926. {
  927. retakePlan.ER_RetakePlanSetting = new ER_RetakePlanSetting();
  928. retakePlan.ER_RetakePlanSetting.RetakePlanID = RetakePlanTaskSettingView.RetakePlanID;
  929. this.SetNewStatus(retakePlan.ER_RetakePlanSetting);
  930. UnitOfWork.Add(retakePlan.ER_RetakePlanSetting);
  931. }
  932. else
  933. {
  934. SetModifyStatus(retakePlan.ER_RetakePlanSetting);
  935. UnitOfWork.Update(retakePlan.ER_RetakePlanSetting);
  936. }
  937. retakePlan.ER_RetakePlanSetting.DepartmentID = RetakePlanTaskSettingView.DepartmentID;
  938. retakePlan.ER_RetakePlanSetting.CourseTypeID = RetakePlanTaskSettingView.CourseTypeID;
  939. retakePlan.ER_RetakePlanSetting.CourseStructureID = RetakePlanTaskSettingView.CourseStructureID;
  940. retakePlan.ER_RetakePlanSetting.CourseCategoryID = RetakePlanTaskSettingView.CourseCategoryID;
  941. retakePlan.ER_RetakePlanSetting.CourseQualityID = RetakePlanTaskSettingView.CourseQualityID;
  942. retakePlan.ER_RetakePlanSetting.PracticeTypeID = RetakePlanTaskSettingView.PracticeTypeID;
  943. retakePlan.ER_RetakePlanSetting.ExaminationModeID = RetakePlanTaskSettingView.ExaminationModeID;
  944. retakePlan.ER_RetakePlanSetting.TeachinglanguageID = RetakePlanTaskSettingView.TeachinglanguageID;
  945. retakePlan.ER_RetakePlanSetting.CourseFineID = RetakePlanTaskSettingView.CourseFineID;
  946. retakePlan.ER_RetakePlanSetting.IsSpecialtycore = RetakePlanTaskSettingView.IsSpecialtycore;
  947. retakePlan.ER_RetakePlanSetting.IsCooperation = RetakePlanTaskSettingView.IsCooperation;
  948. retakePlan.ER_RetakePlanSetting.IsRequired = RetakePlanTaskSettingView.IsRequired;
  949. retakePlan.ER_RetakePlanSetting.IsElective = RetakePlanTaskSettingView.IsElective;
  950. retakePlan.ER_RetakePlanSetting.IsNetworkCourse = RetakePlanTaskSettingView.IsNetworkCourse;
  951. retakePlan.ER_RetakePlanSetting.IsMainCourse = RetakePlanTaskSettingView.IsMainCourse;
  952. retakePlan.ER_RetakePlanSetting.IsNeedMaterial = RetakePlanTaskSettingView.IsNeedMaterial;
  953. retakePlan.ER_RetakePlanSetting.Remarks = RetakePlanTaskSettingView.Remarks;
  954. //重修计划教学设置表
  955. if (retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting == null)
  956. {
  957. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting = new ER_RetakePlanTeachingSetting();
  958. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.RetakePlanID = RetakePlanTaskSettingView.RetakePlanID;
  959. UnitOfWork.Add(retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting);
  960. }
  961. else
  962. {
  963. UnitOfWork.Update(retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting);
  964. }
  965. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse = RetakePlanTaskSettingView.TheoryCourse;
  966. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Practicehours = RetakePlanTaskSettingView.Practicehours;
  967. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours = RetakePlanTaskSettingView.Trialhours;
  968. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum = RetakePlanTaskSettingView.WeeklyNum;
  969. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum = RetakePlanTaskSettingView.TheoryWeeklyNum;
  970. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.PracticeWeeklyNum = RetakePlanTaskSettingView.PracticeWeeklyNum;
  971. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum = RetakePlanTaskSettingView.TrialWeeklyNum;
  972. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum = RetakePlanTaskSettingView.StartWeeklyNum;
  973. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum = RetakePlanTaskSettingView.EndWeeklyNum;
  974. retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours = RetakePlanTaskSettingView.WeeklyHours;
  975. //重修计划授课方式表
  976. UnitOfWork.Remove<ER_RetakePlanTeachingModeType>(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID);
  977. if (RetakePlanTaskSettingView.TeachingModeID != null)
  978. {
  979. RetakePlanTaskSettingView.TeachingModeID.ForEach(x =>
  980. {
  981. ER_RetakePlanTeachingModeType teachingModeType = new ER_RetakePlanTeachingModeType
  982. {
  983. RetakePlanTeachingModeTypeID = Guid.NewGuid(),
  984. RetakePlanID = RetakePlanTaskSettingView.RetakePlanID,
  985. TeachingModeID = x
  986. };
  987. this.SetNewStatus(teachingModeType);
  988. this.UnitOfWork.Add(teachingModeType);
  989. });
  990. }
  991. //重修计划授课地点表
  992. UnitOfWork.Remove<ER_RetakePlanTeachingPlace>(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID);
  993. if (RetakePlanTaskSettingView.TeachingPlaceID != null)
  994. {
  995. RetakePlanTaskSettingView.TeachingPlaceID.ForEach(x =>
  996. {
  997. ER_RetakePlanTeachingPlace teachingPlace = new ER_RetakePlanTeachingPlace
  998. {
  999. RetakePlanTeachingPlaceID = Guid.NewGuid(),
  1000. RetakePlanID = RetakePlanTaskSettingView.RetakePlanID,
  1001. TeachingPlace = x
  1002. };
  1003. this.SetNewStatus(teachingPlace);
  1004. this.UnitOfWork.Add(teachingPlace);
  1005. });
  1006. }
  1007. //重修计划任课教师表
  1008. this.UnitOfWork.Delete<ER_RetakePlanTeacher>(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID);
  1009. teacherList.ToList().ForEach(x =>
  1010. {
  1011. var teacher = new ER_RetakePlanTeacher
  1012. {
  1013. RetakePlanTeacherID = Guid.NewGuid(),
  1014. RetakePlanID = RetakePlanTaskSettingView.RetakePlanID,
  1015. UserID = x.UserID,
  1016. TeachType = x.TeachingMethod
  1017. };
  1018. this.SetNewStatus(teacher);
  1019. this.UnitOfWork.Add(teacher);
  1020. });
  1021. //重修计划课程时间表
  1022. var distinctSchedulingList = schedulingList.GroupBy(x => new { x.Weekday, x.CoursesTimeID })
  1023. .Select(x => new { Weekday = x.Key.Weekday, CoursesTimeID = x.Max(a => a.CoursesTimeID) }).ToList();
  1024. this.UnitOfWork.Delete<ER_RetakePlanSettingScheduling>(x => x.RetakePlanID == retakePlan.RetakePlanID);
  1025. distinctSchedulingList.ToList().ForEach(x =>
  1026. {
  1027. var scheduling = new ER_RetakePlanSettingScheduling
  1028. {
  1029. RetakePlanSettingSchedulingID = Guid.NewGuid(),
  1030. RetakePlanID = retakePlan.RetakePlanID,
  1031. ClassroomID = RetakePlanTaskSettingView.ClassroomID,
  1032. CoursesTimeID = x.CoursesTimeID,
  1033. Weekday = x.Weekday,
  1034. };
  1035. this.SetNewStatus(scheduling);
  1036. this.UnitOfWork.Add(scheduling);
  1037. });
  1038. UnitOfWork.Commit();
  1039. ts.Complete();
  1040. }
  1041. type = 0;
  1042. return true;
  1043. }
  1044. catch (Exception ex)
  1045. {
  1046. throw new Exception(ex.Message);
  1047. }
  1048. }
  1049. /// <summary>
  1050. /// 排课冲突检查,列出课程进度中的可选教室
  1051. /// </summary>
  1052. /// <param name="configuretView"></param>
  1053. /// <param name="buildingID"></param>
  1054. /// <param name="schedulingWeek"></param>
  1055. /// <param name="weekday"></param>
  1056. /// <param name="courseTimeID"></param>
  1057. /// <param name="classroomTypeID"></param>
  1058. /// <param name="SchoolYearID"></param>
  1059. /// <param name="pageIndex"></param>
  1060. /// <param name="pageSize"></param>
  1061. /// <returns></returns>
  1062. public IGridResultSet<ClassroomView> GetAvailableClassroom(ConfiguretView configuretView, Guid? buildingID, string schedulingWeek,
  1063. int? weekday, Guid courseTimeID, int? classroomTypeID, Guid SchoolYearID, int? pageIndex, int? pageSize)
  1064. {
  1065. List<int?> schedulingWeekList = Array.ConvertAll<string, int?>(schedulingWeek.Split('-'), s => Convert.ToInt32(s)).ToList();
  1066. for (int i = 1; i + schedulingWeekList.Min() < schedulingWeekList.Max(); i++)
  1067. {
  1068. schedulingWeekList.Add(i + schedulingWeekList.Min());
  1069. }
  1070. var classroomView = ClassroomScheduleDAL.GetAvailableClassroom(SchoolYearID,
  1071. schedulingWeekList, weekday.Value, courseTimeID, classroomTypeID > 0 ? classroomTypeID : null);
  1072. if (buildingID.HasValue)
  1073. {
  1074. classroomView = classroomView.Where(x => x.BuildingsInfoID == buildingID);
  1075. }
  1076. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1077. classroomView = classroomView.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  1078. return classroomView.OrderBy(x => x.BuildingsInfoName)
  1079. .ThenBy(x => x.Name)
  1080. .ThenBy(x => x.Totalseating).ToGridResultSet(pageIndex, pageSize);
  1081. }
  1082. /// <summary>
  1083. /// 删除(需要检测是否存在对应的已报名重修计划名单,根据重修计划ID)
  1084. /// </summary>
  1085. /// <param name="retakePlanIDsList"></param>
  1086. public void DeleteRetakePlanTask(IList<Guid?> retakePlanIDsList)
  1087. {
  1088. try
  1089. {
  1090. var retakePlanViewList = this.RetakePlanTaskDAL.RetakePlanRepository
  1091. .GetList(x => retakePlanIDsList.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList();
  1092. if (retakePlanViewList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened))
  1093. {
  1094. throw new Exception("只能删除未开放状态的重修任务。");
  1095. }
  1096. ////查询对应的重修报名信息List
  1097. //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1098. // .GetList(x => retakePlanIDsList.Contains(x.RetakePlanID),
  1099. // (x => x.ER_RetakePlan),
  1100. // (x => x.ER_RetakePlan.CF_Student))
  1101. // .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
  1102. // .ToList();
  1103. //if (retakePlanStudentApplyList.Count() > 0)
  1104. //{
  1105. // throw new Exception("存在对应的已报名重修计划名单。");
  1106. //}
  1107. var retakePlanIDList = retakePlanViewList.Select(x => x.RetakePlanID).Distinct().ToList();
  1108. ////删除相应重修计划报名表信息(此句暂时不需要)
  1109. //retakePlanViewList.ForEach(x =>
  1110. //{
  1111. // UnitOfWork.Delete(x, (w => w.CF_Student));
  1112. //});
  1113. //UnitOfWork.RemoveRange(new HashSet<ER_RetakePlanStudent>(retakePlanViewList));
  1114. UnitOfWork.Remove<ER_RetakePlanStudent>(x => retakePlanIDList.Contains(x.RetakePlanID));
  1115. UnitOfWork.Remove<ER_RetakePlanTeachingModeType>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
  1116. UnitOfWork.Remove<ER_RetakePlanTeachingPlace>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
  1117. UnitOfWork.Remove<ER_RetakePlanTeachingSetting>(x => retakePlanIDList.Contains(x.RetakePlanID));
  1118. UnitOfWork.Remove<ER_RetakePlanTeacher>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
  1119. UnitOfWork.Remove<ER_RetakePlanSettingScheduling>(x => retakePlanIDList.Contains(x.RetakePlanID.Value));
  1120. UnitOfWork.Remove<ER_RetakePlanSetting>(x => retakePlanIDList.Contains(x.RetakePlanID));
  1121. UnitOfWork.Remove<ER_RetakePlan>(x => retakePlanIDList.Contains(x.RetakePlanID));
  1122. UnitOfWork.Commit();
  1123. }
  1124. catch (Exception ex)
  1125. {
  1126. throw new Exception(ex.Message);
  1127. }
  1128. }
  1129. /// <summary>
  1130. /// 检测是否存在对应的已报名重修计划名单(根据重修计划ID)
  1131. /// </summary>
  1132. /// <param name="retakePlanIDs"></param>
  1133. /// <returns></returns>
  1134. public bool IsExistsApplyStudentByRetakePlanID(string retakePlanIDs)
  1135. {
  1136. List<Guid?> list = retakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  1137. .Select(x => (Guid?)new Guid(x)).ToList();
  1138. var retakePlanStudentList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1139. .GetList(x => list.Contains(x.RetakePlanID), (x => x.ER_RetakePlan),
  1140. (x => x.ER_RetakePlan.CF_Student)).ToList();
  1141. var IsExistslist = retakePlanStudentList.Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)).ToList();
  1142. if (IsExistslist.Count() > 0)
  1143. {
  1144. return true;
  1145. }
  1146. else
  1147. {
  1148. return false;
  1149. }
  1150. }
  1151. /// <summary>
  1152. /// 重修计划取消开放(删除对应的重修计划报名名单)
  1153. /// </summary>
  1154. /// <param name="RetakePlanIDsList"></param>
  1155. public void CancleRetakePlanTask(IList<Guid?> RetakePlanIDsList)
  1156. {
  1157. try
  1158. {
  1159. var retakePlanList = this.RetakePlanTaskDAL.RetakePlanRepository
  1160. .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList();
  1161. if (retakePlanList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened))
  1162. {
  1163. throw new Exception("只能取消已开放状态的重修任务。");
  1164. }
  1165. ////查询对应的重修报名信息List
  1166. //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1167. // .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID),
  1168. // (x => x.ER_RetakePlan),
  1169. // (x => x.ER_RetakePlan.CF_Student))
  1170. // .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
  1171. // .ToList();
  1172. //if (retakePlanStudentApplyList.Count() > 0)
  1173. //{
  1174. // throw new Exception("存在对应的已报名重修计划名单。");
  1175. //}
  1176. //删除对应的重修计划报名名单
  1177. retakePlanList.ForEach(x =>
  1178. {
  1179. UnitOfWork.Delete(x, (w => w.CF_Student));
  1180. });
  1181. //修改对应的重修计划
  1182. UnitOfWork.Update<ER_RetakePlan>(x => new ER_RetakePlan
  1183. {
  1184. RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened
  1185. }, x => RetakePlanIDsList.Contains(x.RetakePlanID));
  1186. UnitOfWork.Commit();
  1187. }
  1188. catch (Exception ex)
  1189. {
  1190. throw new Exception(ex.Message);
  1191. }
  1192. }
  1193. /// <summary>
  1194. /// 重修计划开放
  1195. /// </summary>
  1196. /// <param name="RetakePlanIDsList"></param>
  1197. public void OpenRetakePlanTask(IList<Guid?> RetakePlanIDsList)
  1198. {
  1199. try
  1200. {
  1201. var retakeList = this.RetakePlanTaskDAL.RetakePlanRepository
  1202. .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID)).ToList();
  1203. if (retakeList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened))
  1204. {
  1205. throw new Exception("只能开放未开放状态的重修任务。");
  1206. }
  1207. UnitOfWork.Update<ER_RetakePlan>(x => new ER_RetakePlan
  1208. {
  1209. RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened
  1210. }, x => RetakePlanIDsList.Contains(x.RetakePlanID));
  1211. UnitOfWork.Commit();
  1212. }
  1213. catch (Exception ex)
  1214. {
  1215. throw new Exception(ex.Message);
  1216. }
  1217. }
  1218. /// <summary>
  1219. /// 查询对应的重修计划分班信息View
  1220. /// </summary>
  1221. /// <param name="RetakePlanID"></param>
  1222. /// <returns></returns>
  1223. public RetakeDivideIntoClassesView GetDivideIntoClassesView(Guid? RetakePlanID)
  1224. {
  1225. try
  1226. {
  1227. //查询对应的重修计划信息
  1228. var retakePlanTaskView = RetakePlanTaskDAL
  1229. .GetRetakePlanTaskView(x => x.RetakePlanID == RetakePlanID).SingleOrDefault();
  1230. RetakeDivideIntoClassesView divideIntoClassesView = new RetakeDivideIntoClassesView();
  1231. divideIntoClassesView.ClassName = retakePlanTaskView.ClassName;
  1232. divideIntoClassesView.StudentTotalNum = retakePlanTaskView.PlanNumber;
  1233. return divideIntoClassesView;
  1234. }
  1235. catch (Exception ex)
  1236. {
  1237. throw new Exception(ex.Message);
  1238. }
  1239. }
  1240. /// <summary>
  1241. /// 重修任务分班(此分班形式不需分开人数,只做为分多少个任务班的计算参数)
  1242. /// 注:分多少个任务班,那么各个任务班的人数保持一致
  1243. /// </summary>
  1244. /// <param name="divideIntoClassesView"></param>
  1245. public void DivideIntoClassesSeparate(RetakeDivideIntoClassesView divideIntoClassesView)
  1246. {
  1247. try
  1248. {
  1249. if (divideIntoClassesView.RetakePlanID.HasValue && divideIntoClassesView.RetakePlanID != Guid.Empty)
  1250. {
  1251. //查询对应的重修计划表相关信息
  1252. var retakePlanView = GetRetakePlan(divideIntoClassesView.RetakePlanID);
  1253. if (retakePlanView != null)
  1254. {
  1255. //只能对未开放状态的信息进行分班
  1256. if (retakePlanView.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened)
  1257. {
  1258. throw new Exception("只能对未开放状态的信息进行分班。");
  1259. }
  1260. //查询对应的重修计划名单信息List
  1261. var retakePlanTaskStudentViewList = RetakePlanTaskDAL
  1262. .GetRetakePlanTaskStudentView(x => x.RetakePlanID == divideIntoClassesView.RetakePlanID,
  1263. x => x.RetakePlanID == divideIntoClassesView.RetakePlanID,
  1264. x => true).OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
  1265. .Select(x => x.UserID).ToList();
  1266. ////查询对应的重修报名信息List
  1267. //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1268. // .GetList(x => x.RetakePlanID == retakePlanView.RetakePlanID,
  1269. // (x => x.ER_RetakePlan),
  1270. // (x => x.ER_RetakePlan.CF_Student))
  1271. // .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
  1272. // .ToList();
  1273. //if (retakePlanStudentApplyList.Count() > 0)
  1274. //{
  1275. // throw new Exception("存在对应的已报名重修计划名单。");
  1276. //}
  1277. //任务班数(分班个数)
  1278. var separateClassCount = divideIntoClassesView.GroupNum ?? 0;
  1279. ////每班人数
  1280. //var classStudentCount = divideIntoClassesView.StudentNum ?? 0;
  1281. //判断分班的数目
  1282. if (separateClassCount <= 1)
  1283. {
  1284. throw new Exception("任务班数不能小于等于1。");
  1285. }
  1286. else
  1287. {
  1288. using (TransactionScope ts = new TransactionScope())
  1289. {
  1290. for (int i = 0; i < separateClassCount - 1; i++)
  1291. {
  1292. ////要分班的名单
  1293. //var separateStudentList = retakePlanTaskStudentViewList
  1294. // .Take(classStudentCount).ToList();
  1295. ////未分班名单
  1296. //retakePlanTaskStudentViewList = retakePlanTaskStudentViewList
  1297. // .SkipWhile(x => separateStudentList.Contains(x)).ToList();
  1298. //重修计划表
  1299. ER_RetakePlan retakePlan = new ER_RetakePlan
  1300. {
  1301. RetakePlanID = Guid.NewGuid(),
  1302. CoursematerialID = retakePlanView.CoursematerialID,
  1303. RetakeTypeID = retakePlanView.RetakeTypeID,
  1304. ClassName = retakePlanView.ClassName + "—" + (int)(i + 2) + "班",
  1305. SchoolyearID = retakePlanView.SchoolyearID,
  1306. CourseTypeID = retakePlanView.CourseTypeID,
  1307. Credit = retakePlanView.Credit,
  1308. PeopleNumlower = retakePlanView.PeopleNumlower,
  1309. PeopleNumlimit = retakePlanView.PeopleNumlimit,
  1310. IsDivide = true
  1311. };
  1312. ////查询对应的重修计划名单报名信息
  1313. //var applyUserList = retakePlanView.CF_Student
  1314. // .Where(x => separateStudentList.Contains(x.UserID)).ToList();
  1315. //if (applyUserList != null && applyUserList.Count > 0)
  1316. //{
  1317. // retakePlan.CF_Student = new HashSet<CF_Student>(applyUserList);
  1318. //}
  1319. SetNewStatus(retakePlan);
  1320. UnitOfWork.Add(retakePlan);
  1321. //重修计划名单
  1322. retakePlanView.ER_RetakePlanStudent.Where(x => retakePlanTaskStudentViewList.Contains(x.UserID)).ToList()
  1323. .ForEach(x =>
  1324. {
  1325. ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent
  1326. {
  1327. RetakePlanStudentID = Guid.NewGuid(),
  1328. RetakePlanID = retakePlan.RetakePlanID,
  1329. UserID = x.UserID,
  1330. SchoolyearNumID = x.SchoolyearNumID,
  1331. StarttermID = x.StarttermID
  1332. };
  1333. SetNewStatus(retakePlanStudent);
  1334. UnitOfWork.Add(retakePlanStudent);
  1335. });
  1336. //重修计划设置表
  1337. ER_RetakePlanSetting retakePlanSetting = new ER_RetakePlanSetting
  1338. {
  1339. RetakePlanID = retakePlan.RetakePlanID,
  1340. DepartmentID = retakePlanView.ER_RetakePlanSetting.DepartmentID,
  1341. CourseStructureID = retakePlanView.ER_RetakePlanSetting.CourseStructureID,
  1342. CourseCategoryID = retakePlanView.ER_RetakePlanSetting.CourseCategoryID,
  1343. CourseTypeID = retakePlanView.ER_RetakePlanSetting.CourseTypeID,
  1344. CourseQualityID = retakePlanView.ER_RetakePlanSetting.CourseQualityID,
  1345. PracticeTypeID = retakePlanView.ER_RetakePlanSetting.PracticeTypeID,
  1346. ExaminationModeID = retakePlanView.ER_RetakePlanSetting.ExaminationModeID,
  1347. TeachinglanguageID = retakePlanView.ER_RetakePlanSetting.TeachinglanguageID,
  1348. CourseFineID = retakePlanView.ER_RetakePlanSetting.CourseFineID,
  1349. IsSpecialtycore = retakePlanView.ER_RetakePlanSetting.IsSpecialtycore,
  1350. IsCooperation = retakePlanView.ER_RetakePlanSetting.IsCooperation,
  1351. IsRequired = retakePlanView.ER_RetakePlanSetting.IsRequired,
  1352. IsElective = retakePlanView.ER_RetakePlanSetting.IsElective,
  1353. IsNetworkCourse = retakePlanView.ER_RetakePlanSetting.IsNetworkCourse,
  1354. IsMainCourse = retakePlanView.ER_RetakePlanSetting.IsMainCourse,
  1355. IsNeedMaterial = retakePlanView.ER_RetakePlanSetting.IsNeedMaterial,
  1356. Remarks = retakePlanView.ER_RetakePlanSetting.Remarks
  1357. };
  1358. SetNewStatus(retakePlanSetting);
  1359. UnitOfWork.Add(retakePlanSetting);
  1360. //重修计划教学设置表
  1361. ER_RetakePlanTeachingSetting retakePlanTeachingSetting = new ER_RetakePlanTeachingSetting
  1362. {
  1363. RetakePlanID = retakePlan.RetakePlanID,
  1364. TheoryCourse = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse,
  1365. Practicehours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Practicehours,
  1366. Trialhours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours,
  1367. WeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum,
  1368. TheoryWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum,
  1369. PracticeWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.PracticeWeeklyNum,
  1370. TrialWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum,
  1371. StartWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum,
  1372. EndWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum,
  1373. WeeklyHours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours
  1374. };
  1375. UnitOfWork.Add(retakePlanTeachingSetting);
  1376. //重修计划授课方式表
  1377. retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.ToList().ForEach(x =>
  1378. {
  1379. ER_RetakePlanTeachingModeType teachingModeType = new ER_RetakePlanTeachingModeType
  1380. {
  1381. RetakePlanTeachingModeTypeID = Guid.NewGuid(),
  1382. RetakePlanID = retakePlan.RetakePlanID,
  1383. TeachingModeID = x.TeachingModeID
  1384. };
  1385. this.SetNewStatus(teachingModeType);
  1386. this.UnitOfWork.Add(teachingModeType);
  1387. });
  1388. //重修计划授课地点表
  1389. retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace.ToList().ForEach(x =>
  1390. {
  1391. ER_RetakePlanTeachingPlace teachingPlace = new ER_RetakePlanTeachingPlace
  1392. {
  1393. RetakePlanTeachingPlaceID = Guid.NewGuid(),
  1394. RetakePlanID = retakePlan.RetakePlanID,
  1395. TeachingPlace = x.TeachingPlace
  1396. };
  1397. this.SetNewStatus(teachingPlace);
  1398. this.UnitOfWork.Add(teachingPlace);
  1399. });
  1400. //重修计划任课老师表
  1401. retakePlanView.ER_RetakePlanTeacher.ToList().ForEach(x =>
  1402. {
  1403. ER_RetakePlanTeacher teacher = new ER_RetakePlanTeacher
  1404. {
  1405. RetakePlanTeacherID = Guid.NewGuid(),
  1406. RetakePlanID = retakePlan.RetakePlanID,
  1407. UserID = x.UserID,
  1408. TeachType = x.TeachType
  1409. };
  1410. this.SetNewStatus(teacher);
  1411. this.UnitOfWork.Add(teacher);
  1412. });
  1413. ////重修计划课程表(由于要判断排课冲突,分班不需添加)
  1414. //ER_RetakePlanSettingScheduling newRetakePlanSettingScheduling = new ER_RetakePlanSettingScheduling();
  1415. //当运行到最后一次循环时需修改原先的重修计划(加上分班后的班号)
  1416. //把循环中已分配的学生删除(由于需求有变更,此项暂时无效--将相关代码注释)
  1417. if (i == separateClassCount - 2)
  1418. {
  1419. retakePlanView.ClassName = retakePlanView.ClassName + "—" + 1 + "班";
  1420. retakePlanView.IsDivide = true;
  1421. ////删除相应重修计划报名名单
  1422. //retakePlanView.CF_Student.RemoveWhere(x => !retakePlanTaskStudentViewList.Contains(x.UserID));
  1423. ////删除相应的重修计划名单
  1424. //UnitOfWork.Delete<ER_RetakePlanStudent>(x => !retakePlanTaskStudentViewList.Contains(x.UserID)
  1425. // && x.RetakePlanID == retakePlanView.RetakePlanID);
  1426. }
  1427. }
  1428. SetModifyStatus(retakePlanView);
  1429. UnitOfWork.Update(retakePlanView);
  1430. UnitOfWork.Commit();
  1431. ts.Complete();
  1432. }
  1433. }
  1434. }
  1435. else
  1436. {
  1437. throw new Exception("数据有误,请核查。");
  1438. }
  1439. }
  1440. else
  1441. {
  1442. throw new Exception("数据有误,请核查。");
  1443. }
  1444. }
  1445. catch (Exception ex)
  1446. {
  1447. throw new Exception(ex.Message);
  1448. }
  1449. }
  1450. /// <summary>
  1451. /// 查询对应的重修计划名单信息View
  1452. /// </summary>
  1453. /// <param name="RetakePlanID"></param>
  1454. /// <param name="pageIndex"></param>
  1455. /// <param name="pageSize"></param>
  1456. /// <returns></returns>
  1457. public IGridResultSet<RetakeStudentListView> GetRetakePlanTaskStudentView(Guid? RetakePlanID, int pageIndex, int pageSize)
  1458. {
  1459. var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(x => x.RetakePlanID == RetakePlanID)
  1460. .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID);
  1461. return query.ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
  1462. }
  1463. /// <summary>
  1464. /// 查询对应的重修计划名单信息List
  1465. /// </summary>
  1466. /// <param name="configuretView"></param>
  1467. /// <param name="RetakePlanID"></param>
  1468. /// <returns></returns>
  1469. public List<RetakeStudentListView> GetRetakePlanTaskStudentViewList(ConfiguretView configuretView, Guid? RetakePlanID)
  1470. {
  1471. var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(x => x.RetakePlanID == RetakePlanID)
  1472. .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID);
  1473. return query.ToList();
  1474. }
  1475. /// <summary>
  1476. /// 查询对应的重修计划名单列表(不及格成绩,小于60分)
  1477. /// 不需排除已在其它相应的重修计划中存在的名单
  1478. /// </summary>
  1479. /// <param name="configuretView"></param>
  1480. /// <param name="RetakePlanID"></param>
  1481. /// <param name="gradeYearID"></param>
  1482. /// <param name="standardID"></param>
  1483. /// <param name="classmajorID"></param>
  1484. /// <param name="pageIndex"></param>
  1485. /// <param name="pageSize"></param>
  1486. /// <returns></returns>
  1487. public IGridResultSet<RetakeStudentListView> GetStudentView(ConfiguretView configuretView, Guid? retakePlanID,
  1488. int? gradeYearID, int? standardID, Guid? classmajorID, int? inSchoolStatus, int pageIndex, int pageSize)
  1489. {
  1490. try
  1491. {
  1492. //查询对应的预查考试性质List
  1493. var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList();
  1494. if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0)
  1495. {
  1496. throw new Exception("未设置预查考试性质,请设置。");
  1497. }
  1498. //查询对应的重修计划相关信息
  1499. var retakePlan = RetakePlanTaskDAL.RetakePlanRepository
  1500. .GetSingle(x => x.RetakePlanID == retakePlanID, x => x.ER_RetakePlanSetting);
  1501. if (retakePlan == null)
  1502. {
  1503. throw new Exception("数据有误,请核查。");
  1504. }
  1505. //学生最终成绩
  1506. Expression<Func<ER_FinallyScore, bool>> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1507. if (retakePlan.ER_RetakePlanSetting.DepartmentID.HasValue)
  1508. {
  1509. //开课教研室
  1510. expFinallyScore = expFinallyScore.And(x => x.DepartmentID == retakePlan.ER_RetakePlanSetting.DepartmentID);
  1511. }
  1512. if (retakePlan.CoursematerialID.HasValue)
  1513. {
  1514. //课程信息
  1515. expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == retakePlan.CoursematerialID);
  1516. }
  1517. if (retakePlan.CourseTypeID.HasValue)
  1518. {
  1519. //课程类型
  1520. expFinallyScore = expFinallyScore.And(x => x.CourseTypeID == retakePlan.CourseTypeID);
  1521. }
  1522. if (retakePlan.Credit.HasValue)
  1523. {
  1524. //课程学分
  1525. expFinallyScore = expFinallyScore.And(x => x.Credit == retakePlan.Credit);
  1526. }
  1527. //学生信息
  1528. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1529. if (inSchoolStatus != null && inSchoolStatus > -1)
  1530. {
  1531. //在校状态
  1532. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  1533. if (inSchoolStatus == 1)
  1534. {
  1535. //表示在校
  1536. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  1537. }
  1538. if (inSchoolStatus == 0)
  1539. {
  1540. //不在校
  1541. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  1542. }
  1543. }
  1544. if (classmajorID.HasValue)
  1545. {
  1546. //班级信息
  1547. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  1548. }
  1549. //重修计划
  1550. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1551. if (retakePlanID.HasValue)
  1552. {
  1553. //重修计划ID
  1554. expRetakePlan = expRetakePlan.And(x => x.RetakePlanID == retakePlanID);
  1555. }
  1556. if (retakePlan.CoursematerialID.HasValue)
  1557. {
  1558. //课程信息
  1559. expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == retakePlan.CoursematerialID);
  1560. }
  1561. if (retakePlan.RetakeTypeID.HasValue)
  1562. {
  1563. //重修类型
  1564. expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakePlan.RetakeTypeID);
  1565. }
  1566. if (retakePlan.SchoolyearID.HasValue)
  1567. {
  1568. //重修学年学期
  1569. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakePlan.SchoolyearID);
  1570. }
  1571. if (retakePlan.CourseTypeID.HasValue)
  1572. {
  1573. //课程类型
  1574. expRetakePlan = expRetakePlan.And(x => x.CourseTypeID == retakePlan.CourseTypeID);
  1575. }
  1576. if (retakePlan.Credit.HasValue)
  1577. {
  1578. //课程学分
  1579. expRetakePlan = expRetakePlan.And(x => x.Credit == retakePlan.Credit);
  1580. }
  1581. var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan);
  1582. if (gradeYearID.HasValue)
  1583. {
  1584. //年级
  1585. query = query.Where(x => x.Gradeyear == gradeYearID);
  1586. }
  1587. if (standardID.HasValue)
  1588. {
  1589. //专业名称
  1590. query = query.Where(x => x.StandardID == standardID);
  1591. }
  1592. //条件限定List
  1593. var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList();
  1594. foreach (var condition in retakeConditionList)
  1595. {
  1596. //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据)
  1597. query = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, query);
  1598. }
  1599. //查询条件
  1600. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1601. {
  1602. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1603. }
  1604. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length)
  1605. .ThenBy(x => x.LoginID).ThenBy(x => x.SchoolyearCode)
  1606. .ThenBy(x => x.CourseCode)
  1607. .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
  1608. }
  1609. catch (Exception ex)
  1610. {
  1611. throw new Exception(ex.Message);
  1612. }
  1613. }
  1614. /// <summary>
  1615. /// 重修任务页面添加名单确定
  1616. /// </summary>
  1617. /// <param name="retakePlanID"></param>
  1618. /// <param name="finallyScoreIDList"></param>
  1619. public void AddStudent(Guid? retakePlanID, List<Guid?> finallyScoreIDList)
  1620. {
  1621. try
  1622. {
  1623. //查询对应的重修计划信息
  1624. var retakePlan = RetakePlanTaskDAL.RetakePlanRepository
  1625. .GetSingle(x => x.RetakePlanID == retakePlanID, x => x.ER_RetakePlanSetting);
  1626. if (retakePlan == null)
  1627. {
  1628. throw new Exception("数据有误,请核查。");
  1629. }
  1630. //查询对应的最终成绩信息(不及格成绩,小于60分)
  1631. var finallyScoreViewList = RetakePlanTaskDAL.FinallyScoreRepository
  1632. .GetList(x => finallyScoreIDList.Contains(x.FinallyScoreID)).ToList();
  1633. //重修计划名单表
  1634. List<ER_RetakePlanStudent> retakePlanStudentInList = new List<ER_RetakePlanStudent>();
  1635. foreach (var finallyScoreView in finallyScoreViewList)
  1636. {
  1637. ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent();
  1638. retakePlanStudent.RetakePlanStudentID = Guid.NewGuid();
  1639. retakePlanStudent.RetakePlanID = retakePlanID.Value;
  1640. retakePlanStudent.UserID = finallyScoreView.UserID.Value;
  1641. retakePlanStudent.SchoolyearNumID = finallyScoreView.SchoolyearNumID;
  1642. retakePlanStudent.StarttermID = finallyScoreView.StarttermID;
  1643. SetNewStatus(retakePlanStudent);
  1644. retakePlanStudentInList.Add(retakePlanStudent);
  1645. }
  1646. UnitOfWork.BulkInsert<ER_RetakePlanStudent>(retakePlanStudentInList);
  1647. }
  1648. catch (Exception ex)
  1649. {
  1650. throw new Exception(ex.Message);
  1651. }
  1652. }
  1653. /// <summary>
  1654. /// 删除(重修计划名单删除,根据重修计划名单ID)
  1655. /// </summary>
  1656. /// <param name="retakePlanStudentIDsList"></param>
  1657. public void DeleteStudent(IList<Guid?> retakePlanStudentIDsList)
  1658. {
  1659. try
  1660. {
  1661. //查询对应的重修计划名单信息
  1662. var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1663. .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID),
  1664. (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)).ToList();
  1665. if (retakePlanStudentViewList.Any(x => x.ER_RetakePlan.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated))
  1666. {
  1667. throw new Exception("不能删除已开班状态的重修任务名单。");
  1668. }
  1669. //查询对应的重修报名信息List
  1670. var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1671. .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID),
  1672. (x => x.ER_RetakePlan),
  1673. (x => x.ER_RetakePlan.CF_Student))
  1674. .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
  1675. .ToList();
  1676. if (retakePlanStudentApplyList.Count() > 0)
  1677. {
  1678. //查询对应的重修计划信息
  1679. var retakePlanViewList = retakePlanStudentApplyList
  1680. .Select(x => x.ER_RetakePlan).Distinct().ToList();
  1681. //重修报名表
  1682. foreach (var retakePlan in retakePlanViewList)
  1683. {
  1684. //查询存在报名名单的重修计划名单对应的userIDList
  1685. var userIDList = retakePlanStudentApplyList
  1686. .Where(x => x.RetakePlanID == retakePlan.RetakePlanID)
  1687. .Select(x => x.UserID).ToList();
  1688. retakePlan.CF_Student.RemoveWhere(x => userIDList.Contains(x.UserID));
  1689. }
  1690. //throw new Exception("要删除的重修计划名单已进行重修报名。");
  1691. }
  1692. //重修计划名单表
  1693. //UnitOfWork.RemoveRange(new HashSet<ER_RetakePlanStudent>(retakePlanStudentViewList));
  1694. UnitOfWork.Remove<ER_RetakePlanStudent>(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID));
  1695. UnitOfWork.Commit();
  1696. }
  1697. catch (Exception ex)
  1698. {
  1699. throw new Exception(ex.Message);
  1700. }
  1701. }
  1702. /// <summary>
  1703. /// 检测是否存在对应的已报名重修计划名单(根据重修计划名单ID)
  1704. /// </summary>
  1705. /// <param name="retakePlanStudentIDs"></param>
  1706. /// <returns></returns>
  1707. public bool IsExistsApplyStudentByRetakePlanStudentID(string retakePlanStudentIDs)
  1708. {
  1709. List<Guid?> list = retakePlanStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  1710. .Select(x => (Guid?)new Guid(x)).ToList();
  1711. var retakePlanStudentList = RetakePlanTaskDAL.RetakePlanStudentRepository
  1712. .GetList(x => list.Contains(x.RetakePlanStudentID), (x => x.ER_RetakePlan),
  1713. (x => x.ER_RetakePlan.CF_Student)).ToList();
  1714. ////查询重修计划名单对应的userIDList
  1715. //var userIDList = retakePlanStudentList.Select(x => x.UserID).ToList();
  1716. var IsExistslist = retakePlanStudentList
  1717. .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)).ToList();
  1718. if (IsExistslist.Count() > 0)
  1719. {
  1720. return true;
  1721. }
  1722. else
  1723. {
  1724. return false;
  1725. }
  1726. }
  1727. }
  1728. }