FinalExaminationServices.cs 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.ScoreManage;
  8. using EMIS.ViewModel;
  9. using Bowin.Common.Linq.Entity;
  10. using Bowin.Common.Linq;
  11. using EMIS.ViewModel.ScoreManage;
  12. using EMIS.ViewModel.Students;
  13. using EMIS.DataLogic.Repositories;
  14. using EMIS.CommonLogic.CalendarManage;
  15. using EMIS.Utility.FormValidate;
  16. using EMIS.DataLogic.ChargeManage.ArrearsSituation;
  17. using EMIS.CommonLogic.SystemServices;
  18. using EMIS.ViewModel.CacheManage;
  19. namespace EMIS.CommonLogic.ScoreManage
  20. {
  21. public class FinalExaminationServices : BaseWorkflowServices<ER_FinalExamination>, IFinalExaminationServices
  22. {
  23. public Lazy<IStudentScoreServices> StudentScoreServices { get; set; }
  24. public ScoreDAL scoreDAL { get; set; }
  25. public FinalExaminationDAL finalExaminationDAL { get; set; }
  26. public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
  27. public ScoreRepository scoreRepository { get; set; }
  28. public MisconductDAL MisconductDAL { get; set; }
  29. public Lazy<IScoreServices> ScoreServices { get; set; }
  30. public ExamsStateSettingDAL examsStateSettingDAL { get; set; }
  31. public Lazy<IParameterServices> ParameterServices { get; set; }
  32. public RetakePlanStudentRepository retakePlanStudentRepository { get; set; }
  33. protected Func<IQueryable<FinalExaminationView>, IQueryable<FinalExaminationView>> DataRangeFunction { get; set; }
  34. protected Func<IQueryable<ResitStudentView>, IQueryable<ResitStudentView>> GerenateResitDataRangeFunction { get; set; }
  35. protected Func<Guid?, Expression<Func<ER_FinalExamination, bool>>> CollegeExpression { get; set; }
  36. public FinalExaminationServices()
  37. {
  38. DataRangeFunction = (x => this.GetQueryByDataRangeByDepartment(x));
  39. GerenateResitDataRangeFunction = (x => this.GetQueryByDataRangeByDepartment(x));
  40. DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByDepartment<ER_FinalExamination>(x, y));
  41. CollegeExpression = (w => (x => x.CF_Department.CF_College.CollegeID == w));
  42. }
  43. /// <summary>
  44. /// 获取工作流可录入状态
  45. /// </summary>
  46. /// <returns></returns>
  47. public int? GetIsEntryStatus()
  48. {
  49. var status = this.GetStatusViewList().Where(x => (x.Description ?? "").Contains("[ENTRY]")).Select(x => x.ID).FirstOrDefault();
  50. return status;
  51. }
  52. /// <summary>
  53. /// 查询期末设定
  54. /// </summary>
  55. /// <param name="configuretView"></param>
  56. /// <param name="collegeID"></param>
  57. /// <param name="departmentID"></param>
  58. /// <param name="schoolyearID"></param>
  59. /// <param name="coursematerialID"></param>
  60. /// <param name="courseTypeID"></param>
  61. /// <param name="courseQualityID"></param>
  62. /// <param name="pageIndex"></param>
  63. /// <param name="pageSize"></param>
  64. /// <returns></returns>
  65. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ScoreManage.FinalExaminationView> GetFinalExaminationViewGrid(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID,
  66. Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus, int? gradeYearID, int pageIndex, int pageSize)
  67. {
  68. var statusList = this.GetStatusViewList();
  69. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  70. if (collegeID.HasValue)
  71. exp = exp.And(this.CollegeExpression(collegeID));
  72. if (departmentID.HasValue)
  73. exp = exp.And(x => x.DepartmentID == departmentID);
  74. if (schoolyearID.HasValue)
  75. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  76. if (coursematerialID.HasValue)
  77. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  78. if (courseTypeID.HasValue)
  79. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  80. if (examsCategoryID.HasValue)
  81. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  82. if (examinationType.HasValue)
  83. exp = exp.And(x => x.ExaminationType == examinationType);
  84. if (approvalStatus.HasValue)
  85. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  86. if (gradeYearID.HasValue)
  87. exp = exp.And(x => x.GradeYearID == gradeYearID);
  88. var query = finalExaminationDAL.GetFinalExaminationViewQueryable(exp);
  89. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  90. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  91. var resultQueryable = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName);
  92. var result = resultQueryable.ToGridResultSet<FinalExaminationView>(pageIndex, pageSize);
  93. result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  94. return result;
  95. }
  96. /// <summary>
  97. /// 查询期末设定
  98. /// </summary>
  99. /// <param name="configuretView"></param>
  100. /// <param name="collegeID"></param>
  101. /// <param name="departmentID"></param>
  102. /// <param name="schoolyearID"></param>
  103. /// <param name="coursematerialID"></param>
  104. /// <param name="courseTypeID"></param>
  105. /// <param name="courseQualityID"></param>
  106. /// <param name="pageIndex"></param>
  107. /// <param name="pageSize"></param>
  108. /// <returns></returns>
  109. public List<ViewModel.ScoreManage.FinalExaminationView> GetFinalExaminationViewList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus)
  110. {
  111. var statusList = this.GetStatusViewList();
  112. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  113. if (collegeID.HasValue)
  114. exp = exp.And(this.CollegeExpression(collegeID));
  115. if (departmentID.HasValue)
  116. exp = exp.And(x => x.DepartmentID == departmentID);
  117. if (schoolyearID.HasValue)
  118. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  119. if (coursematerialID.HasValue)
  120. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  121. if (courseTypeID.HasValue)
  122. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  123. if (examsCategoryID.HasValue)
  124. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  125. if (examinationType.HasValue)
  126. exp = exp.And(x => x.ExaminationType == examinationType);
  127. if (approvalStatus.HasValue)
  128. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  129. var query = finalExaminationDAL.GetFinalExaminationViewQueryable(exp);
  130. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  131. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  132. var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ToList();
  133. result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  134. return result;
  135. }
  136. /// <summary>
  137. /// 查询考试设定相关学生明细表,按兵良要求,暂时用于补考设定学生明细导出功能
  138. /// </summary>
  139. /// <param name="configuretView"></param>
  140. /// <param name="collegeID"></param>
  141. /// <param name="departmentID"></param>
  142. /// <param name="schoolyearID"></param>
  143. /// <param name="coursematerialID"></param>
  144. /// <param name="courseTypeID"></param>
  145. /// <param name="examsCategoryID"></param>
  146. /// <param name="examinationType"></param>
  147. /// <param name="approvalStatus"></param>
  148. /// <returns></returns>
  149. public List<ViewModel.ScoreManage.ResitStudentView> GetFinalExaminationStudentDetailsList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus, int? gradeYearID, List<Guid?> FinalExaminationIDList)
  150. {
  151. var statusList = this.GetStatusViewList();
  152. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  153. if (FinalExaminationIDList != null)
  154. exp = exp.And(x => FinalExaminationIDList.Contains(x.FinalExaminationID));
  155. if (collegeID.HasValue)
  156. exp = exp.And(this.CollegeExpression(collegeID));
  157. if (departmentID.HasValue)
  158. exp = exp.And(x => x.DepartmentID == departmentID);
  159. if (schoolyearID.HasValue)
  160. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  161. if (coursematerialID.HasValue)
  162. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  163. if (courseTypeID.HasValue)
  164. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  165. if (examsCategoryID.HasValue)
  166. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  167. if (examinationType.HasValue)
  168. exp = exp.And(x => x.ExaminationType == examinationType);
  169. if (approvalStatus.HasValue)
  170. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  171. if (gradeYearID.HasValue)
  172. exp = exp.And(x => x.GradeYearID == gradeYearID);
  173. var query = finalExaminationDAL.GetFinalExaminationStudentDetailsList(exp);
  174. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  175. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  176. var result = this.GerenateResitDataRangeFunction(query).OrderBy(x => x.SchoolyearCode).ThenBy(x => x.ClassmajorNo).ThenByDescending(x => x.CourseName).ToList();
  177. //result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  178. return result;
  179. }
  180. /// <summary>
  181. /// 查询期末设定实体
  182. /// </summary>
  183. /// <param name="finalExaminationID"></param>
  184. /// <returns></returns>
  185. public ViewModel.ScoreManage.FinalExaminationView GetFinalExaminationView(Guid? finalExaminationID)
  186. {
  187. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.FinalExaminationID == finalExaminationID);
  188. return finalExaminationDAL.GetFinalExaminationViewQueryable(exp).FirstOrDefault();
  189. }
  190. /// <summary>
  191. /// 查询期末设定实体
  192. /// </summary>
  193. /// <param name="finalExaminationID"></param>
  194. /// <returns></returns>
  195. public Entities.ER_FinalExamination GetFinalExamination(Guid? finalExaminationID)
  196. {
  197. return finalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_FinalExaminationStudent), (x => x.ER_FinalExaminationStudent.Select(w => w.CF_Student)), (x => x.ER_Score), (x => x.CF_Schoolyear));
  198. }
  199. /// <summary>
  200. /// 添加,加上总学时
  201. /// </summary>
  202. /// <param name="finalExaminationView"></param>
  203. public void FinalExaminationAdd(ViewModel.ScoreManage.FinalExaminationView finalExaminationView, List<Guid?> ClassmajorIDList)
  204. {
  205. try
  206. {
  207. var statusList = this.GetStatusViewList(); //获取工作流列表
  208. ER_FinalExamination finalExamination = null;
  209. var schoolyear = SchoolYearServices.Value.GetSchoolYear(finalExaminationView.SchoolyearID);
  210. var listStudent=new List<CF_Student>();
  211. //var finalExaminationRepeat = finalExaminationDAL.finalExaminationRepository.GetSingle(x => x.ClassName == finalExaminationView.ClassName && x.FinalExaminationID != finalExaminationView.FinalExaminationID);
  212. //if (finalExaminationRepeat!=null)
  213. //{
  214. // throw new Exception("录入班级名称重复!");
  215. //}
  216. //取消期末设定,补考设定 录入班级名称唯一性判断
  217. if (finalExaminationView.isAutoAdd==true)
  218. {
  219. listStudent= finalExaminationDAL.studentRepository.GetList(x => ClassmajorIDList.Contains(x.ClassmajorID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();
  220. }
  221. var userIDs = listStudent.Select(x => x.UserID).ToList();
  222. if (finalExaminationView.FinalExaminationID == null || finalExaminationView.FinalExaminationID == Guid.Empty)
  223. {
  224. finalExaminationView.IsEntry = false;
  225. finalExamination = new ER_FinalExamination();
  226. finalExamination.FinalExaminationID = Guid.NewGuid();
  227. finalExamination.SchoolyearID = finalExaminationView.SchoolyearID;
  228. finalExamination.GradeYearID = finalExaminationView.GradeYearID;
  229. finalExamination.CollegeID = finalExaminationView.CollegeID;
  230. //finalExamination.ClassmajorID = finalExaminationView.ClassmajorID;
  231. finalExamination.DepartmentID = finalExaminationView.DepartmentID;
  232. finalExamination.ClassName = finalExaminationView.ClassName;
  233. finalExamination.CoursematerialID = finalExaminationView.CoursematerialID;
  234. finalExamination.CourseTypeID = finalExaminationView.CourseTypeID;
  235. finalExamination.ExamsCategoryID = finalExaminationView.ExamsCategoryID;
  236. finalExamination.ExaminationModeID = finalExaminationView.ExaminationModeID;
  237. finalExamination.Credit = finalExaminationView.Credit;
  238. //总学时
  239. finalExamination.TotalHours = finalExaminationView.TotalHours;
  240. finalExamination.ExamsDatetime = finalExaminationView.ExamsDatetime;
  241. finalExamination.ResultTypeID = finalExaminationView.ResultTypeID;
  242. finalExamination.CreatorUserID = finalExaminationView.CreatorUserID;
  243. finalExamination.EntryDeadlineTime = finalExaminationView.EntryDeadlineTime;
  244. finalExamination.IsEntry = finalExaminationView.IsEntry;
  245. finalExamination.ExaminationType = finalExaminationView.ExaminationType;
  246. finalExamination.ApprovalStatus = this.GetStartStatus();
  247. finalExamination.IsGenerate = false;
  248. SetNewStatus(finalExamination);
  249. UnitOfWork.Add(finalExamination);
  250. if (finalExaminationView.IsEntry == true)
  251. { //当考试设定改为可录入时,调用工作流
  252. StartUp(new List<Guid> { finalExamination.FinalExaminationID }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, null);
  253. }
  254. }
  255. else
  256. {
  257. finalExamination = GetFinalExamination(finalExaminationView.FinalExaminationID);
  258. if (finalExamination == null)
  259. {
  260. throw new Exception("未找到相对应的数据!");
  261. }
  262. //审核中的数据(节点的Description为[AP])和end的节点不能修改
  263. var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
  264. if (status.Contains(finalExamination.ApprovalStatus))
  265. {
  266. //|| finalExamination.ApprovalStatus == (int)EMIS.ViewModel.CF_ScoreState.Rebut 取消审核驳回,在期末设定及补考设定功能中应可进行信息修改 2016年11月4日14:56:58
  267. throw new Exception("该数据已经成绩录入或者已审核,不能做任何修改!");
  268. }
  269. finalExamination.SchoolyearID = finalExaminationView.SchoolyearID;
  270. finalExamination.GradeYearID = finalExaminationView.GradeYearID;
  271. finalExamination.CollegeID = finalExaminationView.CollegeID;
  272. //finalExamination.ClassmajorID = finalExaminationView.ClassmajorID;
  273. finalExamination.DepartmentID = finalExaminationView.DepartmentID;
  274. finalExamination.ClassName = finalExaminationView.ClassName;
  275. finalExamination.CoursematerialID = finalExaminationView.CoursematerialID;
  276. finalExamination.CourseTypeID = finalExaminationView.CourseTypeID;
  277. finalExamination.ExamsCategoryID = finalExaminationView.ExamsCategoryID;
  278. finalExamination.ExaminationModeID = finalExaminationView.ExaminationModeID;
  279. finalExamination.Credit = finalExaminationView.Credit;
  280. //总学时
  281. finalExamination.TotalHours = finalExaminationView.TotalHours;
  282. finalExamination.ExamsDatetime = finalExaminationView.ExamsDatetime;
  283. finalExamination.ResultTypeID = finalExaminationView.ResultTypeID;
  284. finalExamination.CreatorUserID = finalExaminationView.CreatorUserID;
  285. finalExamination.EntryDeadlineTime = finalExaminationView.EntryDeadlineTime;
  286. finalExamination.ExaminationType = finalExaminationView.ExaminationType;
  287. if (finalExamination.IsEntry != finalExaminationView.IsEntry && finalExaminationView.IsEntry == true)
  288. { //当考试设定改为可录入时,调用工作流
  289. StartUp(new List<Guid> { finalExamination.FinalExaminationID }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, "");
  290. finalExamination.IsEntry = finalExaminationView.IsEntry;
  291. }
  292. //if (finalExamination.ApprovalStatus == (int)EMIS.ViewModel.CF_ScoreState.Rebut)
  293. //{
  294. // finalExamination.ApprovalStatus = (int)EMIS.ViewModel.CF_ScoreState.Rebut;
  295. //}
  296. //else
  297. //{
  298. // finalExamination.ApprovalStatus = finalExaminationView.IsEntry == true ? (int)EMIS.ViewModel.CF_ScoreState.CanInput : (int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
  299. //}
  300. SetModifyStatus(finalExamination);
  301. }
  302. List<ER_FinalExaminationStudent> finalExaminationStudentList = new List<ER_FinalExaminationStudent>();
  303. //如果是补考或者毕业补考,需要读出添加学生的期末考试状况,注意还有补考设定编辑的那一边
  304. if (finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit || finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
  305. {
  306. finalExaminationStudentList = finalExaminationDAL
  307. .GetFinalExaminationByResitStudent(x => x.CoursematerialID == finalExaminationView.CoursematerialID,
  308. userIDs.Select(x => (Guid?)x).ToList()).ToList();
  309. }
  310. List<ER_FinalExaminationStudent> newFinalExaminationStudentList = new List<ER_FinalExaminationStudent>();
  311. foreach (var student in listStudent)
  312. {
  313. int? schoolyearNumID, startTermID;
  314. schoolyearNumID = (finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) - (finalExamination.CF_Schoolyear.SchoolcodeID == student.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1;
  315. startTermID = finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1;
  316. var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
  317. if (lastFinalExamination != null)
  318. {
  319. schoolyearNumID = lastFinalExamination.SchoolyearNumID;
  320. startTermID = lastFinalExamination.StarttermID;
  321. }
  322. newFinalExaminationStudentList.Add(new ER_FinalExaminationStudent
  323. {
  324. FinalExaminationStudentID = Guid.NewGuid(),
  325. FinalExaminationID = finalExamination.FinalExaminationID,
  326. SchoolyearNumID = schoolyearNumID,
  327. StarttermID = startTermID,
  328. UserID = student.UserID,
  329. RecordStatus = (int)SYS_STATUS.USABLE,
  330. CreateUserID = CustomPrincipal.Current.UserID,
  331. CreateTime = DateTime.Now,
  332. ModifyUserID = CustomPrincipal.Current.UserID,
  333. ModifyTime = DateTime.Now
  334. });
  335. }
  336. if (finalExaminationView.isAutoAdd == true && ClassmajorIDList.Count>0)
  337. {
  338. UnitOfWork.Remove<ER_FinalExaminationStudent>(x => x.FinalExaminationID == finalExamination.FinalExaminationID);
  339. UnitOfWork.Remove<ER_Score>(x => !userIDs.Contains((Guid)x.UserID) && x.FinalExaminationID == finalExamination.FinalExaminationID);
  340. }
  341. UnitOfWork.Commit();
  342. UnitOfWork.BulkInsert<ER_FinalExaminationStudent>(newFinalExaminationStudentList);
  343. }
  344. catch (Exception)
  345. {
  346. throw;
  347. }
  348. }
  349. /// <summary>
  350. /// 删除
  351. /// </summary>
  352. /// <param name="finalExaminationIDs"></param>
  353. public void FinalExaminationDelete(List<Guid?> finalExaminationIDs)
  354. {
  355. try
  356. {
  357. if (finalExaminationIDs.Count > 0)
  358. {
  359. var startStatus=this.GetStartStatus();
  360. var finalExamination = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID) && x.ApprovalStatus != startStatus).FirstOrDefault();
  361. if (finalExamination != null)
  362. throw new Exception("不是未开放状态,不能删除该考试设定!");
  363. UnitOfWork.Remove<ER_FinalExaminationStudent>(x => finalExaminationIDs.Contains(x.FinalExaminationID));
  364. UnitOfWork.Remove<ER_FinalExamination>(x => finalExaminationIDs.Contains(x.FinalExaminationID));
  365. this.UnitOfWork.Commit();
  366. }
  367. }
  368. catch (Exception)
  369. {
  370. throw;
  371. }
  372. }
  373. /// <summary>
  374. /// 删除学生
  375. /// </summary>
  376. /// <param name="finalExaminationIDs"></param>
  377. public void FinalExaminationStudentDelete(Guid finalExaminationID,List<Guid?> UserID)
  378. {
  379. try
  380. {
  381. if (UserID.Count > 0)
  382. {
  383. var StatusViewList=this.GetStatusViewList();
  384. var status = StatusViewList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
  385. var finalExamination = finalExaminationDAL.finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID&& status.Contains(x.ApprovalStatus)).FirstOrDefault();
  386. if (finalExamination != null)
  387. throw new Exception("不是未开放状态或重录待审状态,不能删除该考试设定的学生!");
  388. var query = scoreDAL.finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID, (x => x.CF_Schoolyear), x => x.ER_FinalExaminationStudent).ToList();
  389. var scoreList = scoreRepository.GetList(x => x.FinalExaminationID == finalExaminationID && UserID.Contains(x.UserID)).ToList();
  390. foreach (var score in scoreList)
  391. {
  392. if (score.RecordStatus == (int)SYS_STATUS.UNUSABLE)
  393. {
  394. throw new Exception("选中的学生不是能够重录的学生,不能删除该考试设定的学生!");
  395. }
  396. }
  397. var scoreIDList = scoreList.Select(x => x.ScoreID).ToList();
  398. UnitOfWork.Remove<ER_ScoreDetail>(x => scoreIDList.Contains(x.ScoreID.Value));
  399. UnitOfWork.Remove<ER_Score>(x => x.FinalExaminationID == finalExaminationID && UserID.Contains((Guid)x.UserID));
  400. UnitOfWork.Remove<ER_FinalExaminationStudent>(x => x.FinalExaminationID == finalExaminationID && UserID.Contains(x.UserID));
  401. this.UnitOfWork.Commit();
  402. }
  403. }
  404. catch (Exception)
  405. {
  406. throw;
  407. }
  408. }
  409. /// <summary>
  410. /// 根据教学任务生成期末设定,加上总学时
  411. /// </summary>
  412. public void GenerateFinalExamination(Guid? schoolyearID, Guid? collegeID, int? gradeID, int? standardID, bool isGenerateNotSubmit)
  413. {
  414. try
  415. {
  416. List<CF_Classmajor> listClassmajor = new List<CF_Classmajor>();
  417. List<ER_FinalExamination> list = new List<ER_FinalExamination>();
  418. Expression<Func<EM_EducationMissionClass, bool>> educationMissionClassExp = (x => true);
  419. Expression<Func<EM_EducationMission, bool>> exp = x => true;
  420. if (!isGenerateNotSubmit)
  421. {
  422. educationMissionClassExp = (x => x.RecordStatus != (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted);
  423. }
  424. var schoolYear = this.SchoolYearServices.Value.GetSchoolYear(schoolyearID);
  425. var queryEducationMission = this.DataRangeFunction(finalExaminationDAL.GetEducationMission(schoolyearID, exp, educationMissionClassExp)); //获取教学任务
  426. if (collegeID.HasValue)
  427. {
  428. queryEducationMission = queryEducationMission.Where(x => x.CollegeID == collegeID);
  429. }
  430. if (gradeID.HasValue && gradeID != -1)
  431. {
  432. queryEducationMission = queryEducationMission.Where(x => x.GradeYearID == gradeID);
  433. }
  434. if (standardID.HasValue)
  435. {
  436. queryEducationMission = queryEducationMission.Where(x => x.StandardID == standardID);
  437. }
  438. var educationMissionIDs = queryEducationMission.Select(x => x.EducationMissionID).ToList(); //教学任务ID
  439. var queryEducationMissionClassList = finalExaminationDAL.educationMissionClassRepository
  440. .GetList(x => educationMissionIDs.Contains(x.EducationMissionID),
  441. (x => x.EM_MissionClassTeacher),
  442. (x => x.EM_EducationSchedulingClass.Select(w => w.ES_AdultEducationSchedule.Select(y => y.ES_AdultEducationScheduleTeacher))),
  443. (x => x.EM_CourseProcess.Select(w => w.EM_CourseProcessTeacher))).ToList();
  444. var educationMissionClassIDs = queryEducationMissionClassList.ToList().Select(x => x.EducationMissionClassID).ToList();
  445. var queryEducationSchedulingClass = finalExaminationDAL.educationSchedulingClassRepository
  446. .GetList(x => educationMissionClassIDs.Contains((Guid)x.EducationMissionClassID), (x => x.EM_EducationMissionClass),
  447. (x => x.CF_Student),
  448. (x => x.CF_Student.Select(w => w.CF_Classmajor.CF_Grademajor)),
  449. (x => x.CF_Student.Select(w => w.ER_RetakePlanStudent))).ToList();
  450. var EducationMissionList = queryEducationMission.ToList();
  451. //查出由重修计划生成的教学任务的ID,通过重修名单表ER_RetakePlanStudent的EducationMissionID确定
  452. var retakePlanEducationMissionIDs = retakePlanStudentRepository.GetList(x => educationMissionIDs.Contains(x.EducationMissionID)).Select(x => x.EducationMissionID).ToList();
  453. //重修考试性质
  454. int? retakeExamsCategoryID = ParameterServices.Value.GetParameterValue<int>(CF_ParameterType.RetakeExamsCatagoryID);
  455. var startStatusID = this.GetStartStatus();
  456. foreach (var educationMission in EducationMissionList)
  457. {
  458. var maxCourseTeacher = (
  459. from missionClass in queryEducationMissionClassList
  460. from courseProcess in missionClass.EM_CourseProcess
  461. from courseTeacher in courseProcess.EM_CourseProcessTeacher
  462. where courseTeacher.TeachType == (int)EMIS.ViewModel.EM_TeachingMethod.Lecturer
  463. && missionClass.EducationMissionID == educationMission.EducationMissionID
  464. group courseProcess by courseTeacher.UserID into g
  465. select new { UserID = g.Key, CourseTimes = g.Sum(x => x.Times) }
  466. ).OrderByDescending(x => x.CourseTimes).FirstOrDefault();
  467. if (maxCourseTeacher == null)
  468. {
  469. maxCourseTeacher = (
  470. from missionClass in queryEducationMissionClassList
  471. from teacher in missionClass.EM_MissionClassTeacher
  472. from schedule in missionClass.EM_EducationSchedulingClass
  473. .SelectMany(x => x.ES_AdultEducationSchedule)
  474. .SelectMany(x => x.ES_AdultEducationScheduleTeacher)
  475. .Where(x => x.UserID == teacher.UserID)
  476. .GroupBy(x => x.UserID)
  477. .Select(x => new { UserID = x.Key, CourseTimes = (int?)x.Count() }).DefaultIfEmpty()
  478. where teacher.TeachType == (int)EMIS.ViewModel.EM_TeachingMethod.Lecturer
  479. && missionClass.EducationMissionID == educationMission.EducationMissionID
  480. select new { UserID = teacher.UserID, CourseTimes = (int?)(schedule == null ? 0 : schedule.CourseTimes) }
  481. ).OrderByDescending(x => x.CourseTimes).FirstOrDefault();
  482. }
  483. var userID = maxCourseTeacher != null ? maxCourseTeacher.UserID : null;
  484. var mainEducationMissionClass = queryEducationMissionClassList.Where(x => x.EducationMissionID == educationMission.EducationMissionID).FirstOrDefault();
  485. var mainEducationSchedulingClassList = queryEducationSchedulingClass.Where(x => x.EM_EducationMissionClass.EducationMissionID == educationMission.EducationMissionID).ToList();
  486. var studentList = mainEducationSchedulingClassList.SelectMany(x => x.CF_Student).GroupBy(x => x.UserID)
  487. .Select(x => x.FirstOrDefault()).ToList();
  488. ER_FinalExamination finalExamination = new ER_FinalExamination();
  489. finalExamination.FinalExaminationID = Guid.NewGuid();
  490. finalExamination.SchoolyearID = educationMission.SchoolyearID;
  491. //如果教学任务中的年级为空,默认取学年学期对应的学年,适用于选修课(任选课)
  492. finalExamination.GradeYearID = educationMission.GradeYearID == null ? schoolYear.Years : educationMission.GradeYearID;
  493. if (educationMission.HandleModeID == (int)CF_HandleMode.MinorCourse)
  494. {
  495. string gradeStr = educationMission.ClassName.Substring(0, 4);
  496. int grade = Convert.ToInt32(gradeStr);
  497. finalExamination.GradeYearID = grade;
  498. }
  499. else
  500. {
  501. //如果教学任务中的年级为空,默认取学年学期对应的学年,适用于选修课(任选课)
  502. finalExamination.GradeYearID = educationMission.GradeYearID == null ? schoolYear.Years : educationMission.GradeYearID;
  503. }
  504. finalExamination.DepartmentID = educationMission.DepartmentID;
  505. finalExamination.ClassName = educationMission.ClassName;
  506. finalExamination.CoursematerialID = educationMission.CoursematerialID;
  507. finalExamination.EducationMissionID = educationMission.EducationMissionID;
  508. finalExamination.CourseTypeID = educationMission.CourseTypeID;
  509. //由重修计划生成的教学任务,其考试性质为重修设置 -> 参数设定设置的重修考试性质
  510. if (retakePlanEducationMissionIDs.Contains(educationMission.EducationMissionID))
  511. finalExamination.ExamsCategoryID = retakeExamsCategoryID;
  512. else
  513. finalExamination.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam;
  514. finalExamination.ExaminationModeID = educationMission.ExaminationModeID;
  515. finalExamination.Credit = educationMission.Credit;
  516. //总学时
  517. finalExamination.TotalHours = educationMission.TotalHours;
  518. finalExamination.CreatorUserID = userID;
  519. finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.FinalExamination;
  520. finalExamination.ApprovalStatus = startStatusID;//(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
  521. finalExamination.ResultTypeID = educationMission.ResultTypeID;
  522. finalExamination.CollegeID = educationMission.CollegeID;
  523. finalExamination.ClassmajorID = educationMission.ClassmajorID;
  524. finalExamination.IsGenerate = false;
  525. finalExamination.IsEntry = false;
  526. SetNewStatus(finalExamination);
  527. finalExamination.ER_FinalExaminationStudent = new HashSet<ER_FinalExaminationStudent>();
  528. foreach (var student in studentList)
  529. {
  530. //(schoolyear - startSchoolyear.Value - (specialtyCourse.SchoolcodeID == grademajor.SchoolcodeID ? 0 : 1)) / 2 + 1 = specialtyCourse.SchoolyearNumID
  531. var gradeSchoolyearValue = ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1));
  532. //需要检查生成的学生有否该教学任务的重修记录,如果有,需要将开课学年和开课学期替换成重修记录中的开课学年和开课学期
  533. var retakePlanStudent = student.ER_RetakePlanStudent.FirstOrDefault(x => x.EducationMissionID == educationMission.EducationMissionID);
  534. var newFinalExaminationStudent = new ER_FinalExaminationStudent
  535. {
  536. FinalExaminationStudentID = Guid.NewGuid(),
  537. FinalExaminationID = finalExamination.FinalExaminationID,
  538. SchoolyearNumID = (retakePlanStudent != null) ? retakePlanStudent.SchoolyearNumID :
  539. (schoolYear.Value - gradeSchoolyearValue - (schoolYear.SchoolcodeID == student.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1,
  540. StarttermID = (retakePlanStudent != null) ? retakePlanStudent.StarttermID :
  541. (schoolYear.Value - gradeSchoolyearValue + 1),
  542. UserID = student.UserID
  543. };
  544. this.SetNewStatus(newFinalExaminationStudent);
  545. finalExamination.ER_FinalExaminationStudent.Add(newFinalExaminationStudent);
  546. }
  547. list.Add(finalExamination);
  548. }
  549. UnitOfWork.BulkInsert(list);
  550. UnitOfWork.BulkInsert(list.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
  551. }
  552. catch (Exception ex)
  553. {
  554. throw;
  555. }
  556. }
  557. /// <summary>
  558. /// 获取期末设定学生
  559. /// </summary>
  560. /// <param name="finalExaminationID"></param>
  561. /// <param name="pageIndex"></param>
  562. /// <param name="pageSize"></param>
  563. /// <returns></returns>
  564. public IGridResultSet<BaseStudentView> GetFinalExaminationStudent(Guid? finalExaminationID)
  565. {
  566. return finalExaminationDAL.GetFinalExaminationStudentList(finalExaminationID,null).OrderBy(x => x.LoginID).ToGridResultSet<BaseStudentView>();
  567. }
  568. /// <summary>
  569. /// 获取期末设定学生
  570. /// </summary>
  571. /// <param name="finalExaminationID"></param>
  572. /// <param name="pageIndex"></param>
  573. /// <param name="pageSize"></param>
  574. /// <returns></returns>
  575. public BaseStudentView GetFinalExaminationStudentForStudentAdd(Guid? finalExaminationID,Guid? userID)
  576. {
  577. return finalExaminationDAL.GetFinalExaminationStudentList(finalExaminationID, userID).FirstOrDefault();
  578. }
  579. /// <summary>
  580. /// 添加期末设定学生
  581. /// </summary>
  582. /// <param name="finalExaminationID"></param>
  583. /// <param name="userIDs"></param>
  584. public void FinalExaminationStudentAdd(Guid? finalExaminationID, List<BaseStudentView> listBaseStudentView)
  585. {
  586. try
  587. {
  588. var queryUserIDList = listBaseStudentView.Select(x => x.UserID).ToList();
  589. ER_FinalExamination finalExamination = GetFinalExamination(finalExaminationID);
  590. if (finalExamination != null)
  591. {
  592. var statusList = this.GetStatusViewList();
  593. //审核中的数据(节点的Description为[AP])和end的节点不能修改
  594. var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") && (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
  595. List<ER_FinalExaminationStudent> finalExaminationStudentList = new List<ER_FinalExaminationStudent>();
  596. if (status.Contains(finalExamination.ApprovalStatus))
  597. {
  598. throw new Exception("该数据已经提交或已审核,不能修改学生!");
  599. }
  600. UnitOfWork.Remove<ER_FinalExaminationStudent>(x => x.FinalExaminationID == finalExamination.FinalExaminationID);
  601. UnitOfWork.Remove<ER_Score>(x => !queryUserIDList.Contains((Guid)x.UserID) && x.FinalExaminationID == finalExamination.FinalExaminationID);
  602. //如果是补考或者毕业补考,需要读出添加学生的期末考试状况,注意还有补考设定编辑的那一边
  603. if (finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit || finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
  604. {
  605. finalExaminationStudentList = finalExaminationDAL
  606. .GetFinalExaminationByResitStudent(x => x.FinalExaminationID == finalExaminationID,
  607. queryUserIDList.Select(x => (Guid?)x).ToList()).ToList();
  608. }
  609. var listStudent = finalExaminationDAL.studentRepository.GetList(x => queryUserIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();
  610. foreach (var student in listStudent)
  611. {
  612. int? schoolyearNumID, startTermID;
  613. schoolyearNumID = (finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) - (finalExamination.CF_Schoolyear.SchoolcodeID == student.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1;
  614. startTermID = finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1;
  615. var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
  616. if (lastFinalExamination != null)
  617. {
  618. schoolyearNumID = lastFinalExamination.SchoolyearNumID;
  619. startTermID = lastFinalExamination.StarttermID;
  620. }
  621. finalExamination.ER_FinalExaminationStudent.Add(new ER_FinalExaminationStudent
  622. {
  623. FinalExaminationStudentID = Guid.NewGuid(),
  624. FinalExaminationID = finalExamination.FinalExaminationID,
  625. SchoolyearNumID = schoolyearNumID,
  626. StarttermID = startTermID,
  627. UserID = student.UserID,
  628. RecordStatus = (int)SYS_STATUS.USABLE,
  629. CreateUserID = CustomPrincipal.Current.UserID,
  630. CreateTime = DateTime.Now,
  631. ModifyUserID = CustomPrincipal.Current.UserID,
  632. ModifyTime = DateTime.Now
  633. });
  634. }
  635. UnitOfWork.Commit();
  636. }
  637. }
  638. catch (Exception)
  639. {
  640. throw;
  641. }
  642. }
  643. /// <summary>
  644. /// 添加期末设定学生
  645. /// </summary>
  646. /// <param name="finalExaminationID"></param>
  647. /// <param name="userIDs"></param>
  648. public void StudentAdd(FinalExaminationView finalExaminationView)
  649. {
  650. try
  651. {
  652. List<Guid?> sutdentIDList = new List<Guid?>();
  653. sutdentIDList.Add(finalExaminationView.UserID);
  654. var queryUserIDList = sutdentIDList;
  655. ER_FinalExamination finalExamination = GetFinalExamination(finalExaminationView.FinalExaminationID);
  656. if (finalExamination != null)
  657. {
  658. var addOrUpdate = finalExaminationDAL.FinalExaminationStudentRepository.Entities.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID && x.UserID == finalExaminationView.UserID).FirstOrDefault();
  659. var statusList = this.GetStatusViewList();
  660. //审核中的数据(节点的Description为[AP])和end的节点不能修改
  661. var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
  662. List<ER_FinalExaminationStudent> finalExaminationStudentList = new List<ER_FinalExaminationStudent>();
  663. if (status.Contains(finalExamination.ApprovalStatus))
  664. {
  665. throw new Exception("不是未开放状态或重录待审状态,不能更变该考试设定的学生!");
  666. }
  667. //学生在数据库中的考试科目
  668. var OtrerStudentList = finalExaminationDAL.FinalExaminationStudentRepository.GetList(x => queryUserIDList.Contains((Guid)x.UserID) && x.FinalExaminationID != finalExaminationView.FinalExaminationID).ToList();
  669. //学生在数据库中的期末设定ID
  670. var OtrerFinalExaminationIDList = finalExaminationDAL.FinalExaminationStudentRepository.GetList(x => queryUserIDList.Contains((Guid)x.UserID) && x.FinalExaminationID != finalExaminationView.FinalExaminationID).Select(x => x.FinalExaminationID).ToList();
  671. //学生在数据库中的期末设定
  672. var OtrerFinalExaminationList = finalExaminationDAL.finalExaminationRepository.GetList(x => OtrerFinalExaminationIDList.Contains(x.FinalExaminationID)).ToList();
  673. //foreach (var of in OtrerFinalExaminationList)
  674. //{
  675. // if (of.CoursematerialID == finalExamination.CoursematerialID
  676. // && of.ExamsCategoryID == finalExamination.ExamsCategoryID)
  677. // {
  678. // int? schoolyearNumID, startTermID;
  679. // double StarttermID = Convert.ToDouble(finalExaminationView.StarttermID);
  680. // double two = 2.0;
  681. // double Startterm = Convert.ToDouble(StarttermID / two);
  682. // schoolyearNumID = Convert.ToInt32(Math.Ceiling(Startterm));
  683. // startTermID = finalExaminationView.StarttermID;
  684. // foreach (var os in OtrerStudentList)
  685. // {
  686. // if (os.StarttermID == startTermID)
  687. // {
  688. // throw new Exception("该学生数据重复,重复的录入班名称为:" + of.ClassName + "请检查!");
  689. // }
  690. // }
  691. // }
  692. //}
  693. //如果是补考或者毕业补考,需要读出添加学生的期末考试状况,注意还有补考设定编辑的那一边
  694. if (finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit || finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
  695. {
  696. finalExaminationStudentList = finalExaminationDAL
  697. .GetFinalExaminationByResitStudent(x => x.FinalExaminationID == finalExaminationView.FinalExaminationID,
  698. queryUserIDList.Select(x => (Guid?)x).ToList()).ToList();
  699. }
  700. var listStudent = finalExaminationDAL.studentRepository.GetList(x => queryUserIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();
  701. if (addOrUpdate == null)
  702. {
  703. foreach (var student in listStudent)
  704. {
  705. int? schoolyearNumID, startTermID;
  706. double StarttermID = Convert.ToDouble(finalExaminationView.StarttermID);
  707. double two = 2.0;
  708. double Startterm = Convert.ToDouble(StarttermID / two);
  709. schoolyearNumID = Convert.ToInt32(Math.Ceiling(Startterm));
  710. startTermID = finalExaminationView.StarttermID;
  711. var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
  712. if (lastFinalExamination != null)
  713. {
  714. schoolyearNumID = lastFinalExamination.SchoolyearNumID;
  715. startTermID = lastFinalExamination.StarttermID;
  716. }
  717. finalExamination.ER_FinalExaminationStudent.Add(new ER_FinalExaminationStudent
  718. {
  719. FinalExaminationStudentID = Guid.NewGuid(),
  720. FinalExaminationID = finalExamination.FinalExaminationID,
  721. SchoolyearNumID = schoolyearNumID,
  722. StarttermID = startTermID,
  723. UserID = student.UserID,
  724. RecordStatus = (int)SYS_STATUS.USABLE,
  725. CreateUserID = CustomPrincipal.Current.UserID,
  726. CreateTime = DateTime.Now,
  727. ModifyUserID = CustomPrincipal.Current.UserID,
  728. ModifyTime = DateTime.Now
  729. });
  730. }
  731. }
  732. else
  733. {
  734. foreach (var student in listStudent)
  735. {
  736. int? schoolyearNumID, startTermID;
  737. double StarttermID = Convert.ToDouble(finalExaminationView.StarttermID);
  738. double two = 2.0;
  739. double Startterm = Convert.ToDouble(StarttermID / two);
  740. schoolyearNumID = Convert.ToInt32(Math.Ceiling(Startterm));
  741. startTermID = finalExaminationView.StarttermID;
  742. var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
  743. if (lastFinalExamination != null)
  744. {
  745. schoolyearNumID = lastFinalExamination.SchoolyearNumID;
  746. startTermID = lastFinalExamination.StarttermID;
  747. }
  748. addOrUpdate.FinalExaminationID = finalExamination.FinalExaminationID;
  749. addOrUpdate.SchoolyearNumID = schoolyearNumID;
  750. addOrUpdate.StarttermID = startTermID;
  751. addOrUpdate.UserID = student.UserID;
  752. addOrUpdate.RecordStatus = (int)SYS_STATUS.USABLE;
  753. addOrUpdate.CreateUserID = CustomPrincipal.Current.UserID;
  754. addOrUpdate.CreateTime = DateTime.Now;
  755. addOrUpdate.ModifyUserID = CustomPrincipal.Current.UserID;
  756. addOrUpdate.ModifyTime = DateTime.Now;
  757. }
  758. }
  759. UnitOfWork.Commit();
  760. }
  761. }
  762. catch (Exception)
  763. {
  764. throw;
  765. }
  766. }
  767. /// <summary>
  768. /// 期末生成,按兵良要求,加上院系所、年级、专业下拉条件 增加班级条件,加上总学时
  769. /// </summary>
  770. public virtual void GenerateResitExamination(Guid? schoolyearID, Guid? collegeID, int? gradeID, int? standardID, Guid? classmajorID)
  771. {
  772. try
  773. {
  774. var startStatusID = this.GetStartStatus();
  775. var statusList = this.GetStatusViewList();
  776. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  777. var curSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
  778. ER_ExamsStateSetting examsStateSetting = finalExaminationDAL.ExamsStateSettingRepository.GetSingle(x => x.ExamsStateID == (int)CF_ExamsState.Suspension);
  779. List<ER_FinalExamination> listFinalExamination = new List<ER_FinalExamination>();
  780. //List<ER_FinalExamination> SlistFinalExamination = new List<ER_FinalExamination>();
  781. //var studentList = this.DataRangeFunction(finalExaminationDAL.GetResitFinalExaminationStudent(schoolyearID, approvedStatus)).ToList();
  782. var query = this.GerenateResitDataRangeFunction(finalExaminationDAL.GetNotPassStudent(schoolyearID));
  783. //var q = finalExaminationDAL.GetSuspensionStudent(schoolyearID);
  784. //var Squery = this.GerenateResitDataRangeFunction(q);
  785. if (collegeID.HasValue)
  786. {//院系所
  787. query = query.Where(x => x.CollegeID == collegeID);
  788. //Squery = Squery.Where(x => x.CollegeID == collegeID);
  789. }
  790. if (gradeID.HasValue && gradeID != -1)
  791. {//年级
  792. query = query.Where(x => x.Year == gradeID);
  793. //Squery = Squery.Where(x => x.Year == gradeID);
  794. }
  795. if (standardID.HasValue) //专业
  796. {
  797. query = query.Where(x => x.StandardID == standardID);
  798. //Squery = Squery.Where(x => x.StandardID == standardID);
  799. }
  800. if (classmajorID.HasValue)
  801. {
  802. query = query.Where(x => x.ClassmajorID == classmajorID);
  803. //Squery = Squery.Where(x => x.ClassmajorID == classmajorID);
  804. }
  805. var studentList = query.ToList();
  806. //var SuspensionsutdentList = Squery.ToList();
  807. var queryFinalExamination = studentList.GroupBy(x => new
  808. {
  809. x.Year,
  810. x.CollegeID,
  811. x.GrademajorID,
  812. x.GrademajorName,
  813. x.CoursematerialID,
  814. x.DepartmentID,
  815. x.CourseName,
  816. x.CourseTypeID,
  817. x.ExaminationModeID,
  818. x.StartTermID,
  819. x.Credit,
  820. //总学时
  821. x.TotalHours,
  822. x.ResultTypeID,
  823. x.ExamsCategoryID,
  824. });
  825. //var queryFinal = SuspensionsutdentList.GroupBy(x => new
  826. //{
  827. // x.Year,
  828. // x.CollegeID,
  829. // x.GrademajorID,
  830. // x.GrademajorName,
  831. // x.CoursematerialID,
  832. // x.DepartmentID,
  833. // x.CourseName,
  834. // x.CourseTypeID,
  835. // x.ExaminationModeID,
  836. // x.StartTermID,
  837. // x.Credit,
  838. // x.ResultTypeID
  839. //});
  840. foreach (var finalExaminationView in queryFinalExamination)
  841. {
  842. ER_FinalExamination finalExamination = new ER_FinalExamination();
  843. if (finalExaminationView.Key.ExamsCategoryID == (int)CF_ExamsCategory.Resit)
  844. {
  845. string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + "-补考";
  846. finalExamination.FinalExaminationID = Guid.NewGuid();
  847. finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
  848. finalExamination.GradeYearID = finalExaminationView.Key.Year;
  849. finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
  850. finalExamination.ClassName = className;
  851. finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
  852. finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
  853. finalExamination.ExamsCategoryID = finalExaminationView.Key.ExamsCategoryID;
  854. //(int)EMIS.ViewModel.CF_ExamsCategory.Resit;
  855. finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
  856. finalExamination.Credit = finalExaminationView.Key.Credit;
  857. //总学时
  858. finalExamination.TotalHours = finalExaminationView.Key.TotalHours;
  859. finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
  860. finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
  861. finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
  862. finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
  863. finalExamination.IsEntry = false;
  864. finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
  865. SetNewStatus(finalExamination);
  866. }
  867. else
  868. {
  869. string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + " - " + IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExamsCategory.ToString()).Where(x => x.Value == finalExaminationView.Key.ExamsCategoryID).Select(x => x.Name).FirstOrDefault();
  870. finalExamination.FinalExaminationID = Guid.NewGuid();
  871. finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
  872. finalExamination.GradeYearID = finalExaminationView.Key.Year;
  873. finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
  874. finalExamination.ClassName = className;
  875. finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
  876. finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
  877. finalExamination.ExamsCategoryID = finalExaminationView.Key.ExamsCategoryID;
  878. //(int)EMIS.ViewModel.CF_ExamsCategory.Resit;
  879. finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
  880. finalExamination.Credit = finalExaminationView.Key.Credit;
  881. //总学时
  882. finalExamination.TotalHours = finalExaminationView.Key.TotalHours;
  883. finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
  884. finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
  885. finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
  886. finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
  887. finalExamination.IsEntry = false;
  888. finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
  889. SetNewStatus(finalExamination);
  890. }
  891. var queryStudent = finalExaminationView.Select(x => new ER_FinalExaminationStudent
  892. {
  893. FinalExaminationStudentID = Guid.NewGuid(),
  894. FinalExaminationID = finalExamination.FinalExaminationID,
  895. UserID = x.UserID,
  896. SchoolyearNumID = x.SchoolyearNumID,
  897. StarttermID = x.StartTermID,
  898. RecordStatus = (int)SYS_STATUS.USABLE,
  899. CreateTime = DateTime.Now,
  900. CreateUserID = curUser.UserID,
  901. ModifyTime = DateTime.Now,
  902. ModifyUserID = curUser.UserID
  903. });
  904. finalExamination.ER_FinalExaminationStudent = new HashSet<ER_FinalExaminationStudent>(queryStudent.ToList());
  905. listFinalExamination.Add(finalExamination);
  906. }
  907. //foreach (var finalExaminationView in queryFinal)
  908. //{
  909. // string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + "-缓考补考";
  910. // ER_FinalExamination finalExamination = new ER_FinalExamination();
  911. // finalExamination.FinalExaminationID = Guid.NewGuid();
  912. // finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
  913. // finalExamination.GradeYearID = finalExaminationView.Key.Year;
  914. // finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
  915. // finalExamination.ClassName = className;
  916. // finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
  917. // finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
  918. // finalExamination.ExamsCategoryID = (int)CF_ExamsCategory.DelayExam;
  919. // finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
  920. // finalExamination.Credit = finalExaminationView.Key.Credit;
  921. // finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
  922. // finalExamination.ApprovalStatus = this.GetStartStatus(); //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
  923. // finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
  924. // finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
  925. // finalExamination.IsEntry = false;
  926. // SetNewStatus(finalExamination);
  927. // var queryStudent = finalExaminationView.Select(x => new ER_FinalExaminationStudent
  928. // {
  929. // FinalExaminationStudentID = Guid.NewGuid(),
  930. // FinalExaminationID = finalExamination.FinalExaminationID,
  931. // UserID = x.UserID,
  932. // SchoolyearNumID = x.SchoolyearNumID,
  933. // //StarttermID = x.StartTermID,
  934. // RecordStatus = (int)SYS_STATUS.USABLE,
  935. // CreateTime = DateTime.Now,
  936. // CreateUserID = curUser.UserID,
  937. // ModifyTime = DateTime.Now,
  938. // ModifyUserID = curUser.UserID
  939. // });
  940. // finalExamination.ER_FinalExaminationStudent = new HashSet<ER_FinalExaminationStudent>(queryStudent.ToList());
  941. // SlistFinalExamination.Add(finalExamination);
  942. //}
  943. UnitOfWork.BulkInsert(listFinalExamination);
  944. UnitOfWork.BulkInsert(listFinalExamination.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
  945. //UnitOfWork.BulkInsert(SlistFinalExamination);
  946. //UnitOfWork.BulkInsert(SlistFinalExamination.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
  947. UnitOfWork.Commit();
  948. }
  949. catch (Exception)
  950. {
  951. throw;
  952. }
  953. }
  954. /// <summary>
  955. /// 毕业生成 增加院系所、专业、班级条件,加上总学时
  956. /// </summary>
  957. public void GenerateGraduationExam(int? year, Guid? collegeID, int? standardID, Guid? classmajorID, decimal? learnSystem)
  958. {
  959. try
  960. {
  961. var startStatusID = this.GetStartStatus();
  962. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  963. var curSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
  964. List<ER_FinalExamination> listFinalExamination = new List<ER_FinalExamination>();
  965. var query = this.GerenateResitDataRangeFunction(finalExaminationDAL.GetGraduationExamStudent(year));
  966. if (collegeID.HasValue) //院系所
  967. query = query.Where(x => x.CollegeID == collegeID);
  968. if (year.HasValue && year != -1) //年级
  969. query = query.Where(x => x.Year == year);
  970. if (standardID.HasValue) //专业
  971. query = query.Where(x => x.StandardID == standardID);
  972. if (classmajorID.HasValue)
  973. query = query.Where(x => x.ClassmajorID == classmajorID);
  974. if (learnSystem.HasValue && learnSystem != -1)
  975. query = query.Where(x => x.LearnSystem == learnSystem);
  976. var studentList = query.ToList();
  977. var queryFinalExamination = studentList.GroupBy(x => new
  978. {
  979. x.Year,
  980. x.CollegeID,
  981. x.GrademajorID,
  982. x.GrademajorName,
  983. x.CoursematerialID,
  984. x.DepartmentID,
  985. x.CourseName,
  986. x.CourseTypeID,
  987. x.ExaminationModeID,
  988. x.StartTermID,
  989. x.Credit,
  990. //总学时
  991. x.TotalHours,
  992. x.ResultTypeID,
  993. });
  994. foreach (var finalExaminationView in queryFinalExamination)
  995. {
  996. string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + "-毕业补考";
  997. ER_FinalExamination finalExamination = new ER_FinalExamination();
  998. finalExamination.FinalExaminationID = Guid.NewGuid();
  999. finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
  1000. finalExamination.GradeYearID = finalExaminationView.Key.Year;
  1001. finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
  1002. finalExamination.ClassName = className;
  1003. finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
  1004. finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
  1005. finalExamination.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.GraduationExam;
  1006. finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
  1007. finalExamination.Credit = finalExaminationView.Key.Credit;
  1008. //总学时
  1009. finalExamination.TotalHours = finalExaminationView.Key.TotalHours;
  1010. finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
  1011. finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
  1012. finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
  1013. finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
  1014. finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
  1015. finalExamination.IsEntry = false;
  1016. SetNewStatus(finalExamination);
  1017. var queryStudent = finalExaminationView.Select(x => new ER_FinalExaminationStudent
  1018. {
  1019. FinalExaminationStudentID = Guid.NewGuid(),
  1020. FinalExaminationID = finalExamination.FinalExaminationID,
  1021. UserID = x.UserID,
  1022. SchoolyearNumID = x.SchoolyearNumID,
  1023. StarttermID = x.StartTermID,
  1024. RecordStatus = (int)SYS_STATUS.USABLE,
  1025. CreateTime = DateTime.Now,
  1026. CreateUserID = curUser.UserID,
  1027. ModifyTime = DateTime.Now,
  1028. ModifyUserID = curUser.UserID
  1029. });
  1030. finalExamination.ER_FinalExaminationStudent = new HashSet<ER_FinalExaminationStudent>(queryStudent.ToList());
  1031. listFinalExamination.Add(finalExamination);
  1032. }
  1033. UnitOfWork.BulkInsert(listFinalExamination);
  1034. UnitOfWork.BulkInsert(listFinalExamination.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
  1035. UnitOfWork.Commit();
  1036. }
  1037. catch (Exception)
  1038. {
  1039. throw;
  1040. }
  1041. }
  1042. /// <summary>
  1043. /// 更新 是否可录入字段
  1044. /// </summary>
  1045. /// <param name="finalExaminationIDs"></param>
  1046. public void GetFinal_ResitExaminationIsEntry(List<Guid> finalExaminationIDs)
  1047. {
  1048. try
  1049. {
  1050. var statusList = this.GetStatusViewList();
  1051. var startStatus = this.GetStartStatus(); //
  1052. //可录入节点的Description用[ENTRY]标识
  1053. var status = statusList.Where(x => (x.Description ?? "").Contains("[ENTRY]")).Select(x => x.ID).FirstOrDefault();
  1054. if (finalExaminationIDs.Count > 0)
  1055. {
  1056. var query = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID)).ToList();
  1057. if (query.Where(x => x.ApprovalStatus != startStatus).FirstOrDefault() != null)
  1058. throw new Exception("只能操作未开放的数据!");
  1059. StartUp(finalExaminationIDs, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, null);
  1060. query.ForEach(x => x.IsEntry = true);
  1061. //query.ForEach(x => x.ApprovalStatus = status);
  1062. UnitOfWork.Commit();
  1063. }
  1064. }
  1065. catch (Exception)
  1066. {
  1067. throw;
  1068. }
  1069. }
  1070. /// <summary>
  1071. /// 撤销录入
  1072. /// </summary>
  1073. /// <param name="finalExaminationIDs"></param>
  1074. public void GetFinal_ResitExaminationBack(List<Guid> finalExaminationIDs)
  1075. {
  1076. try
  1077. {
  1078. var statusList = this.GetStatusViewList();
  1079. var startStatus = this.GetStartStatus(); //
  1080. var actionList = WorkflowServices.Value.GetActionView("ER_FinalExamination", finalExaminationIDs[0], CustomPrincipal.Current.UserID).ToList();
  1081. var actionID = actionList.Where(x => (x.Description ?? "").Contains("[Cancel]")).Select(w => w.ActionID).FirstOrDefault();
  1082. //可录入节点的Description用[ENTRY]标识
  1083. if (actionID == null || actionID==Guid.Empty)
  1084. {
  1085. throw new Exception("没有对应的流程,请添加!");
  1086. }
  1087. var status = statusList.Where(x => (x.Description ?? "").Contains("[ENTRY]")).FirstOrDefault();
  1088. if (finalExaminationIDs.Count > 0)
  1089. {
  1090. var query = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID)).ToList();
  1091. if (query.Where(x => x.ApprovalStatus != status.ID).FirstOrDefault() != null)
  1092. throw new Exception("只能操作可录入状态的数据!");
  1093. Approve(finalExaminationIDs, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionID, null);
  1094. query.ForEach(x => x.IsEntry = true);
  1095. UnitOfWork.Commit();
  1096. }
  1097. ScoreServices.Value.ScoreDelete(finalExaminationIDs);
  1098. }
  1099. catch (Exception)
  1100. {
  1101. throw;
  1102. }
  1103. }
  1104. public List<FinalExaminationView> GetFinalExaminationViewList_Excel(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus, int? gradeYearID, List<Guid?> FinalExaminationIDList)
  1105. {
  1106. var statusList = this.GetStatusViewList();
  1107. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1108. if (FinalExaminationIDList != null)
  1109. exp = exp.And(x => FinalExaminationIDList.Contains(x.FinalExaminationID));
  1110. if (collegeID.HasValue)
  1111. exp = exp.And(this.CollegeExpression(collegeID));
  1112. if (departmentID.HasValue)
  1113. exp = exp.And(x => x.DepartmentID == departmentID);
  1114. if (schoolyearID.HasValue)
  1115. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  1116. if (coursematerialID.HasValue)
  1117. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  1118. if (courseTypeID.HasValue)
  1119. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  1120. if (examsCategoryID.HasValue)
  1121. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  1122. if (examinationType.HasValue)
  1123. exp = exp.And(x => x.ExaminationType == examinationType);
  1124. if (approvalStatus.HasValue)
  1125. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  1126. if (gradeYearID.HasValue)
  1127. exp = exp.And(x => x.GradeYearID == gradeYearID);
  1128. var query = finalExaminationDAL.GetFinalExaminationViewQueryable(exp);
  1129. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1130. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1131. var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ToList();
  1132. result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  1133. return result;
  1134. }
  1135. public FinalExaminationView GetStarttermID(Guid? finalExaminationID, Guid? UserID)
  1136. {
  1137. FinalExaminationView f = new FinalExaminationView();
  1138. var finalExamination = GetFinalExamination(finalExaminationID);
  1139. var student = finalExaminationDAL.studentRepository.GetSingle(x => x.UserID == UserID, (x => x.CF_Classmajor.CF_Grademajor),(x=>x.Sys_User));
  1140. var startTermID = finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1;
  1141. f.StarttermID = startTermID;
  1142. f.UserName = student.Sys_User.Name;
  1143. return f;
  1144. }
  1145. //public string CanBatchEdit(List<Guid?> finalExaminationIDs)
  1146. //{
  1147. // var finalExaminationList = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID)).ToList();
  1148. // var statusList = this.GetStatusViewList(); //获取工作流列表
  1149. // var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
  1150. // foreach(var f in finalExaminationList){
  1151. // if (status.Contains(f.ApprovalStatus))
  1152. // {
  1153. // return "不能修改";
  1154. // }
  1155. // }
  1156. // return "可以修改";
  1157. //}
  1158. }
  1159. }