RetakePlanStudentServices.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.CommonLogic.SystemServices;
  8. using EMIS.Entities;
  9. using EMIS.DataLogic.RetakeManage;
  10. using EMIS.CommonLogic.EducationSchedule;
  11. using System.Linq.Expressions;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.RetakeManage;
  14. using EMIS.ViewModel.EducationManage;
  15. using EMIS.Utility.FormValidate;
  16. using EMIS.DataLogic.ChargeManage.ArrearsSituation;
  17. namespace EMIS.CommonLogic.RetakeManage
  18. {
  19. public class RetakePlanStudentServices : BaseWorkflowServices<ER_RetakePlanStudent>, IRetakePlanStudentServices
  20. {
  21. public RetakeConditionDAL RetakeConditionDAL { get; set; }
  22. public RetakeOpenControlDAL RetakeOpenControlDAL { get; set; }
  23. public RetakePlanDAL RetakePlanDAL { get; set; }
  24. public ChargeControlDAL ChargeControlDAL { get; set; }
  25. public Lazy<IEducationMissionClassScheduleAdultServices> EducationMissionClassScheduleAdultServices { get; set; }
  26. public Lazy<IParameterServices> ParameterServices { get; set; }
  27. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.RetakeManage.RetakeStudentListView> GetRetakeStudentListViewList(
  28. ViewModel.ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,
  29. bool? isNoArrear, int? learningformID, int? education, string LearnSystem, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  32. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  33. if (schoolyearID.HasValue)
  34. {
  35. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  36. }
  37. if (collegeID.HasValue)
  38. {
  39. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  40. }
  41. if (year.HasValue)
  42. {
  43. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  44. }
  45. if (standardID.HasValue)
  46. {
  47. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  48. }
  49. if (classmajorID != null)
  50. {
  51. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  52. }
  53. if (learningformID.HasValue)
  54. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  55. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  56. {
  57. var LearnSystems = Convert.ToDecimal(LearnSystem);
  58. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  59. }
  60. if (education.HasValue)
  61. {
  62. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  63. }
  64. var query = this.RetakePlanDAL.GetRetakeStudentListViewQuery(planExp, studentExp);
  65. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  66. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  67. if (isNoArrear==false)
  68. {
  69. query = query.Where(x => x.AmountSum == 0 || x.AmountSum == null);
  70. }
  71. if (isNoArrear == true)
  72. {
  73. query = query.Where(x => x.AmountSum>0);
  74. }
  75. query = this.GetQueryByDataRangeByCollege(query);
  76. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  77. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  78. return query.ToGridResultSet(pageIndex, pageSize);
  79. }
  80. //Excel导出
  81. public List<RetakeStudentListView> GetRetakeExcelList(ViewModel.ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,bool? isNoArrear,int? learningformID,int? education,string LearnSystem)
  82. {
  83. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  84. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  85. if (schoolyearID.HasValue)
  86. {
  87. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  88. }
  89. if (collegeID.HasValue)
  90. {
  91. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  92. }
  93. if (year.HasValue)
  94. {
  95. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  96. }
  97. if (standardID.HasValue)
  98. {
  99. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  100. }
  101. if (classmajorID != null)
  102. {
  103. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  104. }
  105. if (learningformID.HasValue)
  106. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  107. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  108. {
  109. var LearnSystems = Convert.ToDecimal(LearnSystem);
  110. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  111. }
  112. if (education.HasValue)
  113. {
  114. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  115. }
  116. var query = this.RetakePlanDAL.GetRetakeStudentListViewQuery(planExp, studentExp);
  117. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  118. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  119. if (isNoArrear == false)
  120. {
  121. query = query.Where(x => x.AmountSum == 0 || x.AmountSum == null);
  122. }
  123. if (isNoArrear == true)
  124. {
  125. query = query.Where(x => x.AmountSum > 0);
  126. }
  127. query = this.GetQueryByDataRangeByCollege(query);
  128. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  129. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  130. return query.ToList();
  131. }
  132. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.RetakeManage.RetakeStudentListView> GetRetakeStudentDetailListView(
  133. Guid? userID, Guid? schoolyearID, int pageIndex, int pageSize)
  134. {
  135. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  136. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  137. if (schoolyearID.HasValue)
  138. {
  139. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  140. }
  141. var query = this.RetakePlanDAL.GetRetakeStudentDetailListViewQuery(planExp, studentExp);
  142. if (userID.HasValue)
  143. {
  144. query = query.Where(x => x.UserID == userID);
  145. }
  146. query = this.GetQueryByDataRangeByCollege(query);
  147. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  148. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  149. return query.ToGridResultSet(pageIndex, pageSize);
  150. }
  151. public List<ViewModel.RetakeManage.RetakeStudentListView> GetRetakeStudentListViewList(ViewModel.ConfiguretView retakePlanConditionView,
  152. Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, bool? isNoArrear)
  153. {
  154. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  155. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  156. if (schoolyearID.HasValue)
  157. {
  158. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  159. }
  160. if (collegeID.HasValue)
  161. {
  162. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  163. }
  164. if (year.HasValue)
  165. {
  166. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  167. }
  168. if (standardID.HasValue)
  169. {
  170. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  171. }
  172. if (classmajorID != null)
  173. {
  174. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  175. }
  176. var query = this.RetakePlanDAL.GetRetakeStudentListViewQuery(planExp, studentExp);
  177. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  178. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  179. if (isNoArrear.HasValue)
  180. {
  181. query = query.Where(x => x.IsNoArrears == isNoArrear);
  182. }
  183. query = this.GetQueryByDataRangeByCollege(query);
  184. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  185. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  186. return query.ToList();
  187. }
  188. public void ChargePush(IList<Guid?> userIDList)
  189. {
  190. var startStatusID = this.GetStartStatus();
  191. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus == startStatusID);
  192. if (userIDList.Count > 0)
  193. {
  194. studentExp = studentExp.And(x => userIDList.Contains(x.UserID));
  195. }
  196. var chargeInsertList = this.RetakePlanDAL.GetStudentChargeQueryable(x => true, studentExp).ToList()
  197. .Select(x => new EC_StudentCharge
  198. {
  199. StudentChargeID = x.StudentChargeID,
  200. UserID = x.UserID,
  201. ChargeProjectID = x.ChargeProjectID,
  202. ChargeYear = x.ChargeYear,
  203. Amount = 0,
  204. ActualAmount = 0,
  205. ChargeTag = (int)EC_ChargeTag.Retake,
  206. Remark = ""
  207. }).ToList();
  208. chargeInsertList.ForEach(x => this.SetNewStatus(x));
  209. UnitOfWork.BulkInsert(chargeInsertList);
  210. }
  211. public void DeleteStudent(IList<Guid?> userIDList)
  212. {
  213. var startStatusID = this.GetStartStatus();
  214. var retakeStudentList = this.RetakePlanDAL.RetakePlanStudentRepository.GetList(x => userIDList.Contains(x.UserID),
  215. (x => x.ER_RetakePlan)).ToList();
  216. if (retakeStudentList.Any(x => x.RecordStatus != startStatusID))
  217. {
  218. throw new Exception("部分学生的重修记录已提交,不能删除,请检查所选记录的状态。");
  219. }
  220. var retakePlanIDList = retakeStudentList.Select(x => x.RetakePlanID).Distinct().ToList();
  221. UnitOfWork.RemoveRange(new HashSet<ER_RetakePlanStudent>(retakeStudentList));
  222. UnitOfWork.Remove<ER_RetakePlan>(x => retakePlanIDList.Contains(x.RetakePlanID) && x.ER_RetakePlanStudent.Count() == 0);
  223. UnitOfWork.Commit();
  224. }
  225. public void AddStudent(Guid userID)
  226. {
  227. var startStatusID = this.GetStartStatus();
  228. var schoolyearID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
  229. var retakeStudentViewQueryable = this.RetakeConditionDAL.GetRetakeStudentView().Where(x => x.UserID == userID);
  230. var retakeStudentViewList = retakeStudentViewQueryable.ToList();
  231. var retakePlanGroup = retakeStudentViewList
  232. .GroupBy(x => new { x.CoursematerialID, x.Abbreviation, x.CourseName, x.CourseTypeID, x.CourseTypeDesc, x.Credit });
  233. var existRetakePlanList = this.RetakePlanDAL.GetRetakePlanByStudentQueryable(retakeStudentViewQueryable, startStatusID).ToList();
  234. var planInsertList = new List<ER_RetakePlan>();
  235. var planStudentInsertList = new List<ER_RetakePlanStudent>();
  236. foreach (var retakePlan in retakePlanGroup)
  237. {
  238. bool isNewPlan = false;
  239. var plan = existRetakePlanList.FirstOrDefault(x => x.CoursematerialID == retakePlan.Key.CoursematerialID
  240. && x.CourseTypeID == retakePlan.Key.CourseTypeID && x.Credit == retakePlan.Key.Credit);
  241. if (plan == null)
  242. {
  243. isNewPlan = true;
  244. plan = new ER_RetakePlan
  245. {
  246. RetakePlanID = Guid.NewGuid(),
  247. CoursematerialID = retakePlan.Key.CoursematerialID,
  248. ClassName = (retakePlan.Key.Abbreviation ?? retakePlan.Key.CourseName) + "-重修(" + retakePlan.Key.CourseTypeDesc +
  249. string.Format("{0:#.00}", retakePlan.Key.Credit) + "学分)",
  250. SchoolyearID = schoolyearID,
  251. CourseTypeID = retakePlan.Key.CourseTypeID,
  252. Credit = retakePlan.Key.Credit
  253. };
  254. this.SetNewStatus(plan);
  255. }
  256. foreach (var retakePlanStudent in retakePlan.Select(w => w).ToList())
  257. {
  258. var planStudent = new ER_RetakePlanStudent
  259. {
  260. RetakePlanStudentID = Guid.NewGuid(),
  261. RetakePlanID = plan.RetakePlanID,
  262. UserID = retakePlanStudent.UserID.Value,
  263. SchoolyearNumID = retakePlanStudent.SchoolyearNumID,
  264. StarttermID = retakePlanStudent.StarttermID
  265. };
  266. this.SetNewStatus(planStudent);
  267. planStudent.RecordStatus = startStatusID;
  268. planStudentInsertList.Add(planStudent);
  269. }
  270. if (isNewPlan)
  271. {
  272. planInsertList.Add(plan);
  273. }
  274. }
  275. UnitOfWork.BulkInsert(planInsertList);
  276. UnitOfWork.BulkInsert(planStudentInsertList);
  277. }
  278. public List<RetakeStudentApplyView> GetRetakeStudentApplyViewStudentList(Guid userID)
  279. {
  280. Expression<Func<ER_RetakePlanStudent, bool>> exp = (x => x.UserID == userID);
  281. var startStatusID = this.GetStartStatus();
  282. var statusList = this.GetStatusViewList();
  283. var backpointList = this.GetBackpointStatus();
  284. var nowDate = DateTime.Today;
  285. var openControl = this.RetakeOpenControlDAL.GetRetakeOpenControlViewQuery(x => x.CF_Schoolyear.IsCurrent == true
  286. && x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  287. var studentApplyViewQueryable = this.RetakePlanDAL.GetRetakeStudentApplyViewQueryable(exp);
  288. var teacherViewQueryable = this.RetakePlanDAL.GetRetakePlanStudentTeacherViewQueryable(exp);
  289. var studentApplyViewList = studentApplyViewQueryable.ToList();
  290. var teacherViewList = teacherViewQueryable.ToList();
  291. studentApplyViewList.ForEach(x => {
  292. x.RetakePlanStudentTeacherView = teacherViewList.Where(w => w.RetakePlanStudentID == x.RetakePlanStudentID).ToList();
  293. x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault();
  294. x.IsCanApply = (x.RecordStatus == startStatusID || backpointList.Contains(x.RecordStatus)) && openControl.Any(w => x.SchoolyearID == w.SchoolyearID
  295. && (w.StartDate ?? DateTime.MinValue).Date <= nowDate && (w.EndDate ?? DateTime.MaxValue).Date >= nowDate);
  296. });
  297. return studentApplyViewList;
  298. }
  299. public List<EducationMissionImportClassView> GetEducationMissionImportClassViewList(Guid? coursematerialID)
  300. {
  301. var schoolyearID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
  302. var educationMissionList = EducationMissionClassScheduleAdultServices.Value.GetEducationMissionClassScheduleViewGridExcel(new ConfiguretView(),
  303. null, null, schoolyearID, null, coursematerialID, (int)EM_EducationMissionClassStatus.Scheduled, null, null, null, null,null,null,null,null,null);
  304. return educationMissionList;
  305. }
  306. public void Submit(Guid retakePlanStudentID, Guid? educationMissionID)
  307. {
  308. this.CheckCanSubmit(retakePlanStudentID);
  309. var startStatusID = this.GetStartStatus();
  310. var retakePlanStudent = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.RetakePlanStudentID == retakePlanStudentID);
  311. if (educationMissionID.HasValue)
  312. {
  313. retakePlanStudent.EducationMissionID = educationMissionID;
  314. }
  315. else
  316. {
  317. throw new Exception("请选择教学任务。");
  318. }
  319. if (retakePlanStudent.RecordStatus == startStatusID)
  320. {
  321. this.StartUp(new List<Guid> { retakePlanStudentID }, CustomPrincipal.Current.UserID);
  322. }
  323. else
  324. {
  325. var actionList = this.GetActionView(retakePlanStudentID, CustomPrincipal.Current.UserID);
  326. if (actionList.Count == 0)
  327. {
  328. throw new Exception("该用户没有审核下一步环节的权限。");
  329. }
  330. this.Approve(new List<Guid> { retakePlanStudentID }, CustomPrincipal.Current.UserID, actionList[0].ActionID);
  331. }
  332. }
  333. public void CheckCanSubmit(Guid retakePlanStudentID)
  334. {
  335. var startStatusID = this.GetStartStatus();
  336. var backPointIDList = this.GetBackpointStatus();
  337. var retakePlanStudent = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.RetakePlanStudentID == retakePlanStudentID,
  338. (x => x.ER_RetakePlan.CF_Schoolyear));
  339. if (retakePlanStudent == null)
  340. {
  341. throw new Exception("重修记录不存在。");
  342. }
  343. if (retakePlanStudent.RecordStatus != startStatusID && !backPointIDList.Contains(retakePlanStudent.RecordStatus))
  344. {
  345. throw new Exception("该重修课程已经提交,请不要重复提交。");
  346. }
  347. var duplicatePlan = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.ER_RetakePlan.CoursematerialID == retakePlanStudent.ER_RetakePlan.CoursematerialID
  348. && x.ER_RetakePlan.SchoolyearID == retakePlanStudent.ER_RetakePlan.SchoolyearID
  349. && x.RecordStatus != startStatusID
  350. && !backPointIDList.Contains(x.RecordStatus));
  351. if (duplicatePlan != null)
  352. {
  353. throw new Exception("你已经在这个学期申请过同一课程的重修,不能重复申请。");
  354. }
  355. if (ChargeControlDAL.GetRetakeArrearsAmountView(x => x.UserID == retakePlanStudent.UserID,
  356. retakePlanStudent.ER_RetakePlan.CF_Schoolyear.Years).Count() > 0)
  357. {
  358. throw new Exception("你的重修费用还没有缴,不能申请重修,请先缴清重修费用再进行申请。");
  359. }
  360. }
  361. public IGridResultSet<RetakeStudentApproveView> GetRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, Guid? schoolyearID,
  362. Guid? collegeID, int? year, int? standardID, Guid? classmajorID,int? learningformID, int? education,string LearnSystem, int pageIndex, int pageSize)
  363. {
  364. var statusList = this.GetStatusViewList();
  365. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  366. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  367. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => approveStatusIDList.Contains(x.RecordStatus));
  368. if (schoolyearID.HasValue)
  369. {
  370. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  371. }
  372. if (collegeID.HasValue)
  373. {
  374. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  375. }
  376. if (year.HasValue)
  377. {
  378. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  379. }
  380. if (standardID.HasValue)
  381. {
  382. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  383. }
  384. if (classmajorID != null)
  385. {
  386. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  387. }
  388. if (learningformID.HasValue)
  389. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  390. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  391. {
  392. var LearnSystems = Convert.ToDecimal(LearnSystem);
  393. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  394. }
  395. if (education.HasValue)
  396. {
  397. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  398. }
  399. var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp);
  400. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  401. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  402. query = this.GetQueryByDataRangeByCollege(query);
  403. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  404. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  405. var result = query.ToGridResultSet(pageIndex, pageSize);
  406. result.rows.ForEach(x =>
  407. {
  408. x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault();
  409. });
  410. return result;
  411. }
  412. public List<RetakeStudentApproveView> GetRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, IList<Guid?> retakePlanStudentIDList,
  413. Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID)
  414. {
  415. var statusList = this.GetStatusViewList();
  416. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  417. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  418. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => approveStatusIDList.Contains(x.RecordStatus));
  419. if (retakePlanStudentIDList.Count > 0)
  420. {
  421. studentExp = studentExp.And(x => retakePlanStudentIDList.Contains(x.RetakePlanStudentID));
  422. }
  423. else
  424. {
  425. if (schoolyearID.HasValue)
  426. {
  427. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  428. }
  429. if (collegeID.HasValue)
  430. {
  431. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  432. }
  433. if (year.HasValue)
  434. {
  435. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  436. }
  437. if (standardID.HasValue)
  438. {
  439. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  440. }
  441. if (classmajorID != null)
  442. {
  443. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  444. }
  445. }
  446. var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp);
  447. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  448. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  449. query = this.GetQueryByDataRangeByCollege(query);
  450. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  451. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  452. var result = query.ToList();
  453. result.ForEach(x =>
  454. {
  455. x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault();
  456. });
  457. return result;
  458. }
  459. public void OnApproveEnd(Guid? retakePlanStudentID, Guid? userID)
  460. {
  461. var retakePlanStudent = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.RetakePlanStudentID == retakePlanStudentID, (x => x.CF_Student));
  462. if (retakePlanStudent == null)
  463. {
  464. throw new Exception("重修记录不存在。");
  465. }
  466. var educationSchedulingClassList = this.RetakePlanDAL.EducationSchedulingClassRepository.GetList(x => x.EM_EducationMissionClass.EducationMissionID == retakePlanStudent.EducationMissionID,
  467. (x => x.CF_Student)).ToList();
  468. educationSchedulingClassList.ForEach(x => x.CF_Student.Add(retakePlanStudent.CF_Student));
  469. this.UnitOfWork.Commit();
  470. }
  471. public IGridResultSet<RetakeStudentApproveView> GetFinalRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,int? learningformID, int? education,string LearnSystem, int pageIndex, int pageSize)
  472. {
  473. var statusList = this.GetStatusViewList();
  474. var endStatus = this.GetCorrectEndStatus();
  475. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  476. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus == endStatus);
  477. if (schoolyearID.HasValue)
  478. {
  479. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  480. }
  481. if (collegeID.HasValue)
  482. {
  483. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  484. }
  485. if (year.HasValue)
  486. {
  487. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  488. }
  489. if (standardID.HasValue)
  490. {
  491. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  492. }
  493. if (classmajorID != null)
  494. {
  495. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  496. }
  497. if (learningformID.HasValue)
  498. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  499. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  500. {
  501. var LearnSystems = Convert.ToDecimal(LearnSystem);
  502. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  503. }
  504. if (education.HasValue)
  505. {
  506. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  507. }
  508. var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp);
  509. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  510. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  511. query = this.GetQueryByDataRangeByCollege(query);
  512. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  513. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  514. var result = query.ToGridResultSet(pageIndex, pageSize);
  515. result.rows.ForEach(x =>
  516. {
  517. x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault();
  518. });
  519. return result;
  520. }
  521. public List<RetakeStudentApproveView> GetFinalRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, IList<Guid?> retakePlanStudentIDList, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, int? learningformID, int? education, string LearnSystem)
  522. {
  523. var statusList = this.GetStatusViewList();
  524. var endStatus = this.GetCorrectEndStatus();
  525. Expression<Func<ER_RetakePlan, bool>> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  526. Expression<Func<ER_RetakePlanStudent, bool>> studentExp = (x => x.RecordStatus == endStatus);
  527. if (retakePlanStudentIDList.Count > 0)
  528. {
  529. studentExp = studentExp.And(x => retakePlanStudentIDList.Contains(x.RetakePlanStudentID));
  530. }
  531. else
  532. {
  533. if (schoolyearID.HasValue)
  534. {
  535. planExp = planExp.And(x => x.SchoolyearID == schoolyearID);
  536. }
  537. if (collegeID.HasValue)
  538. {
  539. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  540. }
  541. if (year.HasValue)
  542. {
  543. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  544. }
  545. if (standardID.HasValue)
  546. {
  547. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  548. }
  549. if (classmajorID != null)
  550. {
  551. studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  552. }
  553. if (learningformID.HasValue)
  554. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  555. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  556. {
  557. var LearnSystems = Convert.ToDecimal(LearnSystem);
  558. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  559. }
  560. if (education.HasValue)
  561. {
  562. studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  563. }
  564. }
  565. var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp);
  566. if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute))
  567. query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue);
  568. query = this.GetQueryByDataRangeByCollege(query);
  569. query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  570. .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID);
  571. var result = query.ToList();
  572. result.ForEach(x =>
  573. {
  574. x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault();
  575. });
  576. return result;
  577. }
  578. }
  579. }