DifferentDynamicServices.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.CommonLogic.SystemServices;
  6. using EMIS.Entities;
  7. using Bowin.Common.Utility;
  8. using EMIS.ViewModel.DifferentDynamic;
  9. using Bowin.Common.Mapping;
  10. using Bowin.Common.Linq.Entity;
  11. using EMIS.ViewModel;
  12. using System.Linq.Expressions;
  13. using Bowin.Common.Linq;
  14. using EMIS.Utility;
  15. using EMIS.CommonLogic.CalendarManage;
  16. using EMIS.CommonLogic.EvaluationManage;
  17. using EMIS.Utility.FormValidate;
  18. using EMIS.ViewModel.Students;
  19. using EMIS.DataLogic.Common.Students;
  20. using EMIS.ViewModel.WorkflowManage;
  21. namespace EMIS.CommonLogic.Students
  22. {
  23. public class DifferentDynamicServices : BaseWorkflowServices<CF_DifferentDynamic>, IDifferentDynamicServices
  24. {
  25. public DifferentDynamicDAL DifferentDynamicDAL { get; set; }
  26. public Lazy<IStudentsServices> StudentsServices { get; set; }
  27. public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
  28. public Lazy<StudentsDAL> StudentsDAL { get; set; }
  29. public void AddOrUpdateDifferentDynamic(DifferentDynamicView model)
  30. {
  31. //TODO;调整验证逻辑、当前用户存在系统待办没有处理完、不能新增相同数据 2016年10月25日12:06:19
  32. var startStatusID = this.GetStartStatus();
  33. var status = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  34. status.Add(startStatusID);
  35. bool IsNext = false;
  36. var hasApprovalEntity = DifferentDynamicDAL.DifferentDynamicRepository
  37. .GetList(w => w.UserID == (Guid)model.UserID
  38. && status.Contains(w.ApprovalStatus)
  39. && model.EntityID != w.StudentChangeID).Any();
  40. if (model.EntityID == Guid.Empty)
  41. {
  42. if (hasApprovalEntity)
  43. {
  44. IsNext = true;
  45. }
  46. }
  47. else
  48. {
  49. CF_DifferentDynamic differentDynamicEntity = DifferentDynamicDAL.DifferentDynamicRepository.Entities.Where(x => x.StudentChangeID == model.EntityID).FirstOrDefault();
  50. //if (hasApprovalEntity && differentDynamicEntity.ApprovalStatus == startStatusID)//防止在一条情况下误判断
  51. //{
  52. // IsNext = true;
  53. //}
  54. //if (model.Action == "update")//防止编辑是误操作
  55. //{
  56. // if (DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => x.UserID == model.UserID
  57. // && status.Contains(x.ApprovalStatus) && x.ID != model.EntityID).Count() > 0)
  58. // {
  59. // IsNext = true;
  60. // }
  61. // else
  62. // {
  63. // IsNext = false;
  64. // }
  65. //}
  66. }
  67. if (IsNext)
  68. {
  69. //throw new Exception("提交申请的学生中已有异动申请在审核中,请不要多次提交异动申请!");
  70. throw new Exception("该学生有未处理的申请记录,请不要重复申请!");
  71. }
  72. CF_DifferentDynamic entity;
  73. if (model.EntityID == Guid.Empty)
  74. {
  75. entity = new CF_DifferentDynamic();
  76. model.DynamicCloneTo(entity);
  77. entity.StudentChangeID = Function.NewPKGuid();
  78. SetNewStatus(entity);
  79. entity.ApprovalStatus = startStatusID.Value;
  80. UnitOfWork.Add(entity);
  81. }
  82. else
  83. {
  84. entity = DifferentDynamicDAL.DifferentDynamicRepository.GetSingle(w => w.StudentChangeID == model.EntityID);
  85. model.DynamicCloneTo(entity);
  86. SetModifyStatus(entity);
  87. //UnitOfWork.Update(entity);
  88. }
  89. UnitOfWork.Commit();
  90. }
  91. public void DeleteDifferentDynamic(List<Guid> ids)
  92. {
  93. var startStatusID = this.GetStartStatus();
  94. var statusList = this.GetStatusViewList();
  95. var status = statusList.Where(x => x.Description.Contains("[CanDelete]")).Select(x => x.ID).ToList();
  96. status.Add(startStatusID);
  97. var DifferentDynamicList = DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => ids.Contains(x.StudentChangeID) && !(status.Contains(x.ApprovalStatus))).ToList();
  98. if (DifferentDynamicList.Count > 0)
  99. {
  100. throw new Exception("只能删除未提交的记录,所选的部分记录已提交,无法删除。");
  101. }
  102. UnitOfWork.Delete<CF_DifferentDynamic>(w => ids.Contains(w.StudentChangeID));
  103. }
  104. public void Submit(List<Guid> ids, Guid userID, string comment = "")
  105. {
  106. StartUp(ids, userID, comment);
  107. }
  108. public void Submit(Guid id, Guid userId, string comment = "")
  109. {
  110. var userIds = DifferentDynamicDAL.DifferentDynamicRepository.GetList(w => w.StudentChangeID == id).Select(s => s.UserID);
  111. var status = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  112. var hasApprovalEntity = DifferentDynamicDAL.DifferentDynamicRepository.GetList(w => userIds.Contains(w.UserID) && status.Contains(w.ApprovalStatus)).Any();
  113. if (hasApprovalEntity)
  114. {
  115. throw new Exception("该学生已有异动申请在审核中,请不要多次提交异动申请!");
  116. }
  117. StartUp(new List<Guid>{ id }, userId, comment);
  118. }
  119. /// <summary>
  120. ///
  121. /// </summary>
  122. /// <param name="configuretView"></param>
  123. /// <param name="campusID">校区</param>
  124. /// <param name="collegeID">院系所</param>
  125. /// <param name="year">年级</param>
  126. /// <param name="standard">专业名称</param>
  127. /// <param name="education">培养层次</param>
  128. /// <param name="learningform">学习形式</param>
  129. /// <param name="classmajorID">班级名称</param>
  130. /// <param name="schoolYearID">异动学期</param>
  131. /// <param name="differentDynamicType">异动类型</param>
  132. /// <param name="differentDynamicStatus">审批状态</param>
  133. /// <param name="pageIndex"></param>
  134. /// <param name="pageSize"></param>
  135. /// <returns></returns>
  136. public IGridResultSet<DifferentDynamicView> GetDifferentDynamicViewGrid(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
  137. int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID,
  138. int? differentDynamicType, int? differentDynamicStatus, string LearnSystem, int pageIndex, int pageSize, int atype)
  139. {
  140. var endStatusID = this.GetCorrectEndStatus();
  141. var statusList = this.GetStatusViewList();
  142. var filter =
  143. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem);
  144. //atype=1 代表是申请列表
  145. if (atype == 1)
  146. {
  147. filter = filter.And(x => x.ApprovalStatus != endStatusID); //根据老师要求,流程通过的数据不要显示在申请列表 20161011 czf
  148. filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
  149. }
  150. var query = GetDifferentDynamicViewGrid(configuretView, filter);
  151. query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);//.OrderBy(w => w.EntityApprovalStatus).ThenByDescending(w => w.SchoolyearCode);
  152. var result = query.ToGridResultSet(pageIndex, pageSize);
  153. result.rows.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  154. return result;
  155. }
  156. public IGridResultSet<DifferentDynamicView> GetApplyDifferentDynamicViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType, int? differentDynamicStatus, int pageIndex, int pageSize)
  157. {
  158. Expression<Func<CF_DifferentDynamic, bool>> filter =
  159. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, null,null);
  160. var statusList = this.GetStatusViewList();
  161. if (differentDynamicStatus.HasValue)
  162. {
  163. filter = filter.And(w => w.ApprovalStatus == differentDynamicStatus);
  164. }
  165. else
  166. {
  167. var approvalStatus = this.GetBackpointStatus();
  168. approvalStatus.Add(this.GetStartStatus());
  169. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  170. }
  171. var result = GetDifferentDynamicViewGrid(configuretView, filter).ToGridResultSet(pageIndex, pageSize);
  172. result.rows.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  173. return result;
  174. }
  175. public IGridResultSet<DifferentDynamicView> GetApprovalDifferentDynamicViewGrid(ConfiguretView configuretView,
  176. Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
  177. Guid? schoolYearID, int? differentDynamicType,string LearnSystem, int pageIndex, int pageSize)
  178. {
  179. Expression<Func<CF_DifferentDynamic, bool>> filter =
  180. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
  181. null, LearnSystem);
  182. filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
  183. var statusList = this.GetStatusViewList();
  184. var approvalStatus = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  185. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  186. var query = GetDifferentDynamicViewGrid(configuretView, filter);
  187. query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
  188. var result = query.ToGridResultSet(pageIndex, pageSize);
  189. result.rows.ForEach(x => x.ApprovalStatusName = statusList
  190. .Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  191. return result;
  192. }
  193. public IGridResultSet<DifferentDynamicView> GetCollegeApprovalDifferentDynamicViewGrid(ConfiguretView configuretView,
  194. Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
  195. Guid? schoolYearID, int? differentDynamicType, string LearnSystem, int pageIndex, int pageSize)
  196. {
  197. Expression<Func<CF_DifferentDynamic, bool>> filter =
  198. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
  199. null, LearnSystem);
  200. filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
  201. var statusList = this.GetStatusViewList();
  202. var approvalStatus = this.GetApproveStatusViewList()
  203. .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_COLLEGEAPPROVE_FLAG))
  204. .Select(x => x.ID).ToList();
  205. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  206. var query = GetDifferentDynamicViewGrid(configuretView, filter);
  207. query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
  208. var result = query.ToGridResultSet(pageIndex, pageSize);
  209. result.rows.ForEach(x => x.ApprovalStatusName = statusList
  210. .Where(w => w.ID == x.EntityApprovalStatus)
  211. .Select(w => w.Name).FirstOrDefault());
  212. return result;
  213. }
  214. public IGridResultSet<DifferentDynamicView> GetAdminApprovalDifferentDynamicViewGrid(ConfiguretView configuretView,
  215. Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
  216. Guid? schoolYearID, int? differentDynamicType, string LearnSystem, int pageIndex, int pageSize)
  217. {
  218. Expression<Func<CF_DifferentDynamic, bool>> filter =
  219. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
  220. null, LearnSystem);
  221. var statusList = this.GetStatusViewList();
  222. var approvalStatus = this.GetApproveStatusViewList()
  223. .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_ADMINAPPROVE_FLAG))
  224. .Select(x => x.ID).ToList();
  225. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  226. var query = GetDifferentDynamicViewGrid(configuretView, filter);
  227. query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
  228. var result = query.ToGridResultSet(pageIndex, pageSize);
  229. result.rows.ForEach(x => x.ApprovalStatusName = statusList
  230. .Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  231. return result;
  232. }
  233. private static Expression<Func<CF_DifferentDynamic, bool>> GetFilter(Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType, int? differentDynamicStatus, string LearnSystem)
  234. {
  235. Expression<Func<CF_DifferentDynamic, bool>> filter = w => true;
  236. if (campusID.HasValue && campusID != Guid.Empty)
  237. {
  238. filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID == campusID);
  239. }
  240. if (collegeID.HasValue && collegeID != Guid.Empty)
  241. {
  242. filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  243. }
  244. if (education.HasValue)
  245. {
  246. filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education);
  247. }
  248. if (year.HasValue)
  249. {
  250. filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
  251. }
  252. if (learningform.HasValue)
  253. {
  254. filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningform);
  255. }
  256. if (standard.HasValue)
  257. {
  258. //filter = filter.And(w => w.StandardID == standard);
  259. }
  260. if (classmajorID.HasValue && classmajorID != Guid.Empty)
  261. {
  262. filter = filter.And(w => w.BeforeClassmajorID == classmajorID);
  263. }
  264. if (schoolYearID.HasValue && schoolYearID != Guid.Empty)
  265. {
  266. filter = filter.And(w => w.SchoolyearID == schoolYearID);
  267. }
  268. if (differentDynamicType.HasValue)
  269. {
  270. filter = filter.And(w => w.ChangeTypeID == differentDynamicType);
  271. }
  272. if (differentDynamicStatus.HasValue)
  273. {
  274. filter = filter.And(w => w.ApprovalStatus == differentDynamicStatus);
  275. }
  276. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  277. if (user != null && user.IsStudent)
  278. {
  279. filter = filter.And(w => w.UserID == user.UserID);
  280. }
  281. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  282. {
  283. var LearnSystems = Convert.ToDecimal(LearnSystem);
  284. filter = filter.And(x => x.BeforeClassmajorID_Nav.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  285. }
  286. return filter;
  287. }
  288. public ICollection<DifferentDynamicStatisticsView> GetDifferentDynamicStatistics(ViewModel.ConfiguretView configuretView,
  289. Guid? campusID, Guid? collegeID, Guid? schoolYearID)
  290. {
  291. var filter = GetFilter(campusID, collegeID, null, null, null, null, null, schoolYearID, null, this.GetCorrectEndStatus(),null);
  292. var query = DifferentDynamicDAL.GetDifferentDynamicStatisticsQueryable(filter);
  293. query = GetQueryByDataRangeByCollege(query);
  294. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  295. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  296. query = query.OrderBy(o => o.CampusID).ThenBy(o => o.CollegeID);
  297. return query.ToList();
  298. }
  299. public ICollection<DifferentDynamicView> GetDifferentDynamicViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
  300. int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID,
  301. int? differentDynamicType, int? differentDynamicStatus, string LearnSystem, int atype, List<Guid?> UserIDList = null)
  302. {
  303. var endStatusID = this.GetCorrectEndStatus();
  304. var statusList = this.GetStatusViewList();
  305. var filter =
  306. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem);
  307. //filter = filter.And(x => x.ApplyTypeID == (int)CF_DifferentDynamicApplyType.Normal);
  308. if (atype == 1)
  309. filter = filter.And(x => x.ApprovalStatus != endStatusID);
  310. if (UserIDList != null && UserIDList.Count() > 0)
  311. {
  312. filter = filter.And(x => UserIDList.Contains(x.UserID));
  313. }
  314. var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
  315. result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  316. return result;
  317. }
  318. public ICollection<DifferentDynamicView> GetDifferentDynamicViewListNotDataRange(ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
  319. int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID,
  320. int? differentDynamicType, int? differentDynamicStatus, string LearnSystem, int atype, List<Guid?> UserIDList = null)
  321. {
  322. var endStatusID = this.GetCorrectEndStatus();
  323. var statusList = this.GetStatusViewList();
  324. var filter =
  325. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem);
  326. //filter = filter.And(x => x.ApplyTypeID == (int)CF_DifferentDynamicApplyType.Normal);
  327. if (atype == 1)
  328. filter = filter.And(x => x.ApprovalStatus != endStatusID);
  329. if (UserIDList != null && UserIDList.Count() > 0)
  330. {
  331. filter = filter.And(x => UserIDList.Contains(x.UserID));
  332. }
  333. var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter);
  334. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  335. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  336. var result = query.OrderByDescending(o => o.EntityCreateTime).ThenByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
  337. result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  338. return result;
  339. }
  340. public ICollection<DifferentDynamicView> GetApprovalDifferentDynamicViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType,string LearnSystem)
  341. {
  342. var statusList = this.GetStatusViewList();
  343. Expression<Func<CF_DifferentDynamic, bool>> filter =
  344. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, null, LearnSystem);
  345. filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
  346. var approvalStatus = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  347. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  348. var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
  349. result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  350. return result;
  351. }
  352. public ICollection<DifferentDynamicView> GetCollegeApprovalDifferentDynamicViewList(ConfiguretView configuretView,
  353. Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
  354. Guid? schoolYearID, int? differentDynamicType, string LearnSystem)
  355. {
  356. var statusList = this.GetStatusViewList();
  357. Expression<Func<CF_DifferentDynamic, bool>> filter =
  358. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
  359. null, LearnSystem);
  360. filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
  361. var approvalStatus = this.GetApproveStatusViewList()
  362. .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_COLLEGEAPPROVE_FLAG))
  363. .Select(x => x.ID).ToList();
  364. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  365. var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
  366. result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  367. return result;
  368. }
  369. public ICollection<DifferentDynamicView> GetAdminApprovalDifferentDynamicViewList(ConfiguretView configuretView,
  370. Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
  371. Guid? schoolYearID, int? differentDynamicType, string LearnSystem)
  372. {
  373. var statusList = this.GetStatusViewList();
  374. Expression<Func<CF_DifferentDynamic, bool>> filter =
  375. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
  376. null, LearnSystem);
  377. filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
  378. var approvalStatus = this.GetApproveStatusViewList()
  379. .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_ADMINAPPROVE_FLAG))
  380. .Select(x => x.ID).ToList();
  381. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  382. var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
  383. result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  384. return result;
  385. }
  386. public ICollection<DifferentDynamicView> GetApplyDifferentDynamicViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType, int? differentDynamicStatus)
  387. {
  388. Expression<Func<CF_DifferentDynamic, bool>> filter =
  389. GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, null,null);
  390. var statusList = this.GetStatusViewList();
  391. if (differentDynamicStatus.HasValue)
  392. {
  393. filter = filter.And(w => w.ApprovalStatus == differentDynamicStatus);
  394. }
  395. else
  396. {
  397. var approvalStatus = this.GetBackpointStatus();
  398. approvalStatus.Add(this.GetStartStatus());
  399. filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
  400. }
  401. var result = GetDifferentDynamicViewGrid(configuretView, filter).ToList();
  402. result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  403. return result;
  404. }
  405. public DifferentDynamicView GetDifferentDynamicView(Guid? id)
  406. {
  407. var result = new DifferentDynamicView();
  408. if (id.HasValue && id != Guid.Empty)
  409. result = DifferentDynamicDAL.GetDifferentDynamicQueryable(w => w.StudentChangeID == id).FirstOrDefault();
  410. result.ApprovalStatusName = this.GetStatusViewList().Where(x => x.ID == result.EntityApprovalStatus).Select(x => x.Name).FirstOrDefault();
  411. return result;
  412. }
  413. public void Approve(DifferentDynamicView model, Guid userID, ActionView actionView, string comment = "")
  414. {
  415. AddOrUpdateDifferentDynamic(model); //保存审核过程中的修改操作。
  416. Approve(new List<Guid>{ model.EntityID }, userID, actionView.ActionID, comment);
  417. }
  418. private IQueryable<DifferentDynamicView> GetDifferentDynamicViewGrid(ConfiguretView configuretView, Expression<Func<CF_DifferentDynamic, bool>> filter)
  419. {
  420. var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter);
  421. query = GetQueryByDataRangeByCollege(query);
  422. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  423. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  424. query = query.OrderByDescending(o => o.EntityCreateTime);
  425. return query;
  426. }
  427. /// <summary>
  428. /// 查询学生异动信息
  429. /// </summary>
  430. /// <param name="userID"></param>
  431. /// <returns></returns>
  432. public IGridResultSet<DifferentDynamicView> GetStudentDifferentInfoViewGrid(Guid? userID)
  433. {
  434. var endStatusID = this.GetCorrectEndStatus();
  435. var statusList = this.GetStatusViewList();
  436. Expression<Func<CF_DifferentDynamic, bool>> filter = w => true;
  437. filter = filter.And(x => x.ApprovalStatus == endStatusID); //根据老师要求,流程通过的数据不要显示在申请列表 20161011 czf
  438. filter = filter.And(x => x.UserID == userID);
  439. var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter);
  440. query = GetQueryByDataRangeByCollege(query);
  441. query = query.OrderByDescending(w => w.EntityCreateTime);//.OrderBy(w => w.EntityApprovalStatus).ThenByDescending(w => w.SchoolyearCode);
  442. var result = query.ToGridResultSet<DifferentDynamicView>();
  443. result.rows.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
  444. return result;
  445. }
  446. /// <summary>
  447. /// 查询异动报表下拉(已弃用)
  448. /// </summary>
  449. /// <param name="configuretView"></param>
  450. /// <returns></returns>
  451. //public IGridResultSet<DifferentDynamicView> GetDifferentDynamicViewGrid(ConfiguretView configuretView)
  452. //{
  453. // var query = DifferentDynamicDAL.GetSelectReport();
  454. // return query.OrderBy(x=>x.ReportUrl).ToGridResultSet<DifferentDynamicView>();
  455. //}
  456. public void OnApproveEnd(List<Guid> differentDynamicIDList, Guid? userID)
  457. {
  458. var differentDynamicList = this.DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => differentDynamicIDList.Contains(x.StudentChangeID)).ToList();
  459. this.DifferentDynamicEnd(differentDynamicList);
  460. }
  461. private void DifferentDynamicEnd(List<CF_DifferentDynamic> entityViewList)
  462. {
  463. var schoolYear = SchoolYearServices.Value.GetCurrentSchoolYear();
  464. int? schoolYearValue = schoolYear.Value;//获取当前学年学期Value值
  465. var differentDynamicIDList = entityViewList.Select(x => x.StudentChangeID).ToList();
  466. Expression<Func<CF_DifferentDynamic, bool>> exp = x => differentDynamicIDList.Contains(x.StudentChangeID);
  467. var studentIDList = entityViewList.Select(x => x.UserID).Distinct().ToList();
  468. var studentEntityList = StudentsDAL.Value.StudentRepository.GetList(x => studentIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();//要转班的学生
  469. var afterClassmajorIDList = entityViewList.Where(x => x.AfterClassmajorID.HasValue).Select(x => x.AfterClassmajorID).ToList();
  470. var afterClassMajorList = DifferentDynamicDAL.ClassmajorRepository.GetList(w => afterClassmajorIDList.Contains(w.ClassmajorID), i => i.CF_Grademajor.CF_Schoolyear).ToList();
  471. #region 1.0 教学任务删除异动学生代码段......
  472. var educationSchedulingClassStudent = DifferentDynamicDAL.GetEducationSchedulingClassStudent(exp).ToList();
  473. var educationSchedulingIDList = educationSchedulingClassStudent.Select(u => u.TepTableID).ToList();
  474. var edustudentList = DifferentDynamicDAL.EducationSchedulingClassRepository.GetList(x => educationSchedulingIDList.Contains(x.EducationSchedulingClassID), (x => x.CF_Student));
  475. educationSchedulingClassStudent.ForEach(e =>
  476. {
  477. var educationScheduleClass = edustudentList.FirstOrDefault(x => x.EducationSchedulingClassID == e.TepTableID);
  478. var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == e.UserID);
  479. educationScheduleClass.CF_Student.Remove(studentEntity);
  480. });
  481. #endregion
  482. #region 2.0 考场安排删除异动学生代码段......
  483. var examinationRoomStudent = DifferentDynamicDAL.GetExaminationRoomStudent(exp).ToList();
  484. var examinationPlanStudent = DifferentDynamicDAL.GetExaminationPlanStudent(exp).ToList();
  485. var examinationPlanIDList = examinationPlanStudent.Select(u => u.TepTableID).ToList();
  486. var examinationPlanList = DifferentDynamicDAL.ExaminationPlanRepository.GetList(x => examinationPlanIDList.Contains(x.ExaminationPlanID), (x => x.CF_Student)).ToList();
  487. var examinationRoomStudentIDList = examinationRoomStudent.Select(u => u.TepTableID).ToList();
  488. //EX_ExaminationPlan_CF_Student考试计划相关学生表原先没删除成功掉,又往EX_ExaminationPlan_CF_Student插数据,一直没发现这个问题,但如果是同一个ExaminationPlanID时就会报重复错误
  489. UnitOfWork.Remove<EX_ExaminationRoomStudent>(x => examinationRoomStudentIDList.Contains(x.ExaminationRoomStudentID));
  490. examinationPlanStudent.ForEach(e =>
  491. {
  492. var examinationPlan = examinationPlanList.FirstOrDefault(x => x.ExaminationPlanID == e.TepTableID);
  493. var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == e.UserID);
  494. examinationPlan.CF_Student.Remove(studentEntity);
  495. });
  496. #endregion
  497. #region 3.0 成绩管理删除异动学生代码段......
  498. var scoreStudent = DifferentDynamicDAL.GetScoreStudent(exp).ToList();
  499. var finalExaminationIDList = scoreStudent.Select(u => u.TepTableID).ToList();
  500. var finalExaminationList = DifferentDynamicDAL.FinalExaminationRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID), (x => x.ER_FinalExaminationStudent), (x => x.ER_Score)).ToList();
  501. var finalExaminationStudentIDList = (
  502. from ss in scoreStudent
  503. join fe in finalExaminationList on ss.TepTableID equals fe.FinalExaminationID
  504. from fes in fe.ER_FinalExaminationStudent
  505. where ss.UserID == fes.UserID
  506. select fes.FinalExaminationStudentID
  507. ).ToList();
  508. var scoreIDList = (
  509. from ss in scoreStudent
  510. join fe in finalExaminationList on ss.TepTableID equals fe.FinalExaminationID
  511. from s in fe.ER_Score
  512. where ss.UserID == s.UserID
  513. select s.ScoreID
  514. ).ToList();
  515. UnitOfWork.Remove<ER_ScoreDetail>(x => scoreIDList.Contains(x.ScoreID.Value));
  516. UnitOfWork.Remove<ER_Score>(x => scoreIDList.Contains(x.ScoreID));
  517. UnitOfWork.Remove<ER_FinalExaminationStudent>(x => finalExaminationStudentIDList.Contains(x.FinalExaminationStudentID));
  518. #endregion
  519. #region 4.0 教学评价删除异动学生代码段......
  520. var evaluationSettingStudent = DifferentDynamicDAL.GetEvaluationSettingStudent(exp).ToList();
  521. var evaluationSettingIDList = evaluationSettingStudent.Select(u => u.TepTableID).ToList();
  522. var evaluationSettingStudentList = DifferentDynamicDAL.EvaluationSettingRepository.GetList(x => evaluationSettingIDList.Contains(x.EvaluationSettingID), (x => x.CF_Student));
  523. evaluationSettingStudent.ForEach(e =>
  524. {
  525. var evaluationSetting = evaluationSettingStudentList.FirstOrDefault(x => x.EvaluationSettingID == e.TepTableID);
  526. var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == e.UserID);
  527. evaluationSetting.CF_Student.Remove(studentEntity);
  528. });
  529. #endregion
  530. //这堆查询太慢了,不涉及班级转换的异动就不要跑了
  531. if (entityViewList.Where(x => x.AfterClassmajorID != null).Count() > 0)
  532. {
  533. #region 5.0 教学任务插入异动学生代码段......
  534. var studentSchedulingClassList = DifferentDynamicDAL.GetStudentRelateCourseViewQueryable(exp).ToList();
  535. List<StudentsView> educationSchedulingClassStudentInsert = new List<StudentsView>();
  536. foreach (var studentSchedulingClass in studentSchedulingClassList)
  537. {
  538. //情况1:找到同班同学,并且自己学号最小,塞同班同学的第一个班
  539. var classmateSchdulingList = studentSchedulingClass
  540. .StudentRelateSchedulingClassViewList
  541. .Where(x => x.ClassmajorIDList.Contains(studentSchedulingClass.ClassmajorID))
  542. .OrderBy(x => x.EducationMissionClassName)
  543. .ToList();
  544. if (classmateSchdulingList.Count > 0 && studentSchedulingClass.LoginID.CompareTo(classmateSchdulingList.Max(x => x.MinLoginID)) < 0)
  545. {
  546. var minMissionClassName = classmateSchdulingList.Min(x => x.EducationMissionClassName);
  547. var minSchedulingClassID = classmateSchdulingList.Where(x => x.EducationMissionClassName == minMissionClassName).Select(x => x.EducationSchedulingClassID).FirstOrDefault();
  548. if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID))
  549. {
  550. educationSchedulingClassStudentInsert.Add(new StudentsView
  551. {
  552. UserID = studentSchedulingClass.UserID ?? Guid.Empty,
  553. TepTableID = minSchedulingClassID
  554. });
  555. }
  556. }
  557. //情况2:找到同班同学,并且自己学号不是最小,塞第一个自己不是最大的班,如果没有,塞最后一个班
  558. else if (classmateSchdulingList.Count > 0 && studentSchedulingClass.LoginID.CompareTo(classmateSchdulingList.Max(x => x.MinLoginID)) >= 0)
  559. {
  560. foreach (var classmateScheduling in classmateSchdulingList)
  561. {
  562. if (studentSchedulingClass.LoginID.CompareTo(classmateScheduling.MaxLoginID) <= 0)
  563. {
  564. if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == classmateScheduling.EducationSchedulingClassID))
  565. {
  566. educationSchedulingClassStudentInsert.Add(new StudentsView
  567. {
  568. UserID = studentSchedulingClass.UserID ?? Guid.Empty,
  569. TepTableID = classmateScheduling.EducationSchedulingClassID
  570. });
  571. break;
  572. }
  573. }
  574. if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == classmateScheduling.EducationSchedulingClassID))
  575. {
  576. educationSchedulingClassStudentInsert.Add(new StudentsView
  577. {
  578. UserID = studentSchedulingClass.UserID ?? Guid.Empty,
  579. TepTableID = classmateScheduling.EducationSchedulingClassID
  580. });
  581. }
  582. }
  583. }
  584. //情况3:找不到同班同学,但排课班已经有人,塞顺序下来人最少的班
  585. else if (classmateSchdulingList.Count == 0 && studentSchedulingClass.StudentRelateSchedulingClassViewList.Any(x => x.StudentCount > 0))
  586. {
  587. var minStudentCount = studentSchedulingClass.StudentRelateSchedulingClassViewList.Min(x => x.StudentCount);
  588. var minSchedulingClassID = studentSchedulingClass.StudentRelateSchedulingClassViewList.Where(x => x.StudentCount == minStudentCount)
  589. .OrderBy(x => x.EducationMissionClassName)
  590. .Select(x => x.EducationSchedulingClassID).FirstOrDefault();
  591. if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID))
  592. {
  593. educationSchedulingClassStudentInsert.Add(new StudentsView
  594. {
  595. UserID = studentSchedulingClass.UserID ?? Guid.Empty,
  596. TepTableID = minSchedulingClassID
  597. });
  598. }
  599. }
  600. //情况4:找不到同班同学,而且排课班没人,塞第一个班
  601. else if (classmateSchdulingList.Count == 0 && !studentSchedulingClass.StudentRelateSchedulingClassViewList.Any(x => x.StudentCount > 0))
  602. {
  603. var minSchedulingClassID = studentSchedulingClass.StudentRelateSchedulingClassViewList
  604. .OrderBy(x => x.EducationMissionClassName)
  605. .Select(x => x.EducationSchedulingClassID).FirstOrDefault();
  606. if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID))
  607. {
  608. educationSchedulingClassStudentInsert.Add(new StudentsView
  609. {
  610. UserID = studentSchedulingClass.UserID ?? Guid.Empty,
  611. TepTableID = minSchedulingClassID
  612. });
  613. }
  614. }
  615. }
  616. var educationSchedulingClassIDInsertList = educationSchedulingClassStudentInsert.Select(x => x.TepTableID).Distinct().ToList();
  617. var educationSchedulingClassInsertList = DifferentDynamicDAL.EducationSchedulingClassRepository.GetList(x => educationSchedulingClassIDInsertList.Contains(x.EducationSchedulingClassID), x => x.CF_Student).ToList();
  618. foreach (var educationScheduling in educationSchedulingClassStudentInsert)
  619. {
  620. Guid? educationSchedulingClassID = educationScheduling.TepTableID;
  621. EM_EducationSchedulingClass educationSchedulingClassEntity = educationSchedulingClassInsertList.FirstOrDefault(x => x.EducationSchedulingClassID == educationSchedulingClassID);
  622. if (educationSchedulingClassEntity != null && educationScheduling.UserID != null)
  623. {
  624. if (!educationSchedulingClassEntity.CF_Student.Where(x => x.UserID == educationScheduling.UserID).Any())
  625. {
  626. var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == educationScheduling.UserID);
  627. educationSchedulingClassEntity.CF_Student.Add(studentEntity);
  628. UnitOfWork.Update(educationSchedulingClassEntity);
  629. }
  630. }
  631. }
  632. #endregion
  633. #region 6.0 考场安排插入异动学生代码段......
  634. var educationPlanInsertList = DifferentDynamicDAL.GetExaminationPlanStudentInsert(exp,
  635. (x => x.EM_EducationSchedulingClass
  636. .Any(w => educationSchedulingClassIDInsertList.Contains(w.EducationSchedulingClassID)))).ToList();
  637. var educationPlanIDList = educationPlanInsertList.Select(x => x.TepTableID).ToList();
  638. var educationPlanList = DifferentDynamicDAL.ExaminationPlanRepository.GetList(x => educationPlanIDList.Contains(x.ExaminationPlanID), (x => x.CF_Student)).ToList();
  639. educationPlanInsertList.ForEach(x =>
  640. {
  641. var educationPlan = educationPlanList.FirstOrDefault(w => w.ExaminationPlanID == x.TepTableID);
  642. var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == x.UserID);
  643. educationPlan.CF_Student.Add(studentEntity);
  644. });
  645. //2016年11月8日11:32:50 zhanghl
  646. //TODO: 由于考场安排涉及座位安排、暂时不做插入数据处理......
  647. #endregion
  648. #region 7.0 成绩管理插入异动学生代码段......
  649. var scoreStudentInsert = DifferentDynamicDAL.GetScoreStudentInsert(exp,
  650. (x => x.EM_EducationSchedulingClass
  651. .Any(w => educationSchedulingClassIDInsertList.Contains(w.EducationSchedulingClassID)))
  652. ).Distinct().ToList();
  653. var finalExaminationInsertIDList = scoreStudentInsert.Select(x => x.TepTableID).ToList();
  654. var finalExaminationEntityList = DifferentDynamicDAL.FinalExaminationRepository.GetList(x => finalExaminationInsertIDList.Contains(x.FinalExaminationID), (x => x.CF_Schoolyear)).ToList();
  655. foreach (var score in scoreStudentInsert)
  656. {
  657. Guid? finalExaminationID = score.TepTableID;
  658. var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == score.UserID);
  659. var finalExaminationEntity = finalExaminationEntityList.FirstOrDefault(x => x.FinalExaminationID == score.TepTableID);
  660. var afterClassMajor = (from c in afterClassMajorList
  661. join dd in entityViewList on c.ClassmajorID equals dd.AfterClassmajorID
  662. where dd.UserID == score.UserID
  663. select c
  664. ).LastOrDefault();
  665. if (finalExaminationEntity != null && afterClassMajor != null)
  666. {
  667. if (!finalExaminationEntity.ER_FinalExaminationStudent.Where(x => x.UserID == score.UserID).Any())
  668. {
  669. finalExaminationEntity.ER_FinalExaminationStudent.Add(new ER_FinalExaminationStudent
  670. {
  671. FinalExaminationStudentID = Guid.NewGuid(),
  672. FinalExaminationID = finalExaminationEntity.FinalExaminationID,
  673. SchoolyearNumID = (finalExaminationEntity.CF_Schoolyear.Value - ((afterClassMajor.CF_Grademajor.GradeID * 2) - 1 + (afterClassMajor.CF_Grademajor.SemesterID - 1)) - (finalExaminationEntity.CF_Schoolyear.SchoolcodeID == afterClassMajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1,
  674. StarttermID = finalExaminationEntity.CF_Schoolyear.Value - ((afterClassMajor.CF_Grademajor.GradeID * 2) - 1 + (afterClassMajor.CF_Grademajor.SemesterID - 1)) + 1,
  675. UserID = studentEntity.UserID,
  676. RecordStatus = (int)SYS_STATUS.USABLE,
  677. CreateUserID = CustomPrincipal.Current.UserID,
  678. CreateTime = DateTime.Now,
  679. ModifyUserID = CustomPrincipal.Current.UserID,
  680. ModifyTime = DateTime.Now
  681. });
  682. }
  683. }
  684. }
  685. #endregion
  686. #region 8.0 教学评价插入异动学生代码段......
  687. var evaluationSettingStudentInsert = DifferentDynamicDAL.GetEvaluationSettingStudentInsert(exp).Distinct().ToList();
  688. var evaluationSettingStudentInsertIDList = evaluationSettingStudentInsert.Select(x => x.TepTableID).ToList();
  689. var evaluationSettingStudentInsertList = DifferentDynamicDAL.EvaluationSettingRepository.GetList(x => evaluationSettingStudentInsertIDList.Contains(x.EvaluationSettingID) && x.OpenStatus == (int)CF_YesOrNoStatus.No, (x => x.CF_Student)).ToList();
  690. foreach (var evaluationSetting in evaluationSettingStudentInsert)
  691. {
  692. Guid? evaluationSettingID = evaluationSetting.TepTableID;
  693. EM_EvaluationSetting evaluationSettingEntity = evaluationSettingStudentInsertList.FirstOrDefault(x => x.EvaluationSettingID == evaluationSettingID);
  694. if (evaluationSettingEntity != null)
  695. {
  696. if (!evaluationSettingEntity.CF_Student.Where(x => x.UserID == evaluationSetting.UserID).Any())
  697. {
  698. var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == evaluationSetting.UserID);
  699. evaluationSettingEntity.CF_Student.Add(studentEntity);
  700. UnitOfWork.Update(evaluationSettingEntity);
  701. }
  702. }
  703. }
  704. #endregion
  705. }
  706. #region 9.0学生征订
  707. var studentOrderAddList = DifferentDynamicDAL.GetAddStudentsOrder(exp).ToList();
  708. studentOrderAddList.ForEach(x => x.OrderQty++);
  709. var studentOrderDecreaseList = DifferentDynamicDAL.GetDecreaseStudentsOrder(exp).ToList();
  710. studentOrderDecreaseList.ForEach(x => x.OrderQty--);
  711. #endregion
  712. #region 10.0学生发放
  713. var studentDistributeAddList = DifferentDynamicDAL.GetAddStudentDistribute(exp).ToList();
  714. studentDistributeAddList.ForEach(x => x.DistributeQty++);
  715. var studentDistributeDecreaseList = DifferentDynamicDAL.GetDecreaseStudentDistribute(exp).ToList();
  716. studentDistributeDecreaseList.ForEach(x => x.DistributeQty--);
  717. #endregion
  718. foreach (var entityView in entityViewList)
  719. {
  720. var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == entityView.UserID);
  721. var afterClassMajor = afterClassMajorList.FirstOrDefault(w => w.ClassmajorID == entityView.AfterClassmajorID);
  722. if (entityView.AfterClassmajorID.HasValue && entityView.AfterClassmajorID != Guid.Empty) //班级
  723. {
  724. studentEntity.ClassmajorID = entityView.AfterClassmajorID;
  725. // student.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(classMajor.CF_Grademajor.CF_Schoolyear);
  726. var PlanningGraduateDate = StudentsServices.Value.GetPlanningGraduate((Guid)afterClassMajor.GrademajorID);
  727. if (PlanningGraduateDate != "")
  728. {
  729. studentEntity.PlanningGraduateDate = Convert.ToDateTime(PlanningGraduateDate);
  730. }
  731. }
  732. if (entityView.AfterInSchoolStatusID.HasValue && entityView.AfterInSchoolStatusID != -1) //在校状态
  733. {
  734. studentEntity.InSchoolStatusID = entityView.AfterInSchoolStatusID;
  735. }
  736. if (entityView.AfterStudentStatus.HasValue && entityView.AfterStudentStatus != -1) //学籍状态
  737. {
  738. studentEntity.StudentStatus = entityView.AfterStudentStatus;
  739. }
  740. //异动后修改异动时间
  741. entityView.ChangeDate = DateTime.Now;
  742. }
  743. UnitOfWork.Commit();
  744. }
  745. }
  746. }