MinorPlanApproveServices.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 EMIS.DataLogic.MinorManage.MinorPlanManage;
  8. using EMIS.DataLogic.Common.CalendarManage;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.ViewModel.MinorManage.MinorPlanManage;
  11. using EMIS.ViewModel;
  12. using System.Linq.Expressions;
  13. using Bowin.Common.Linq;
  14. namespace EMIS.CommonLogic.MinorManage.MinorPlanManage
  15. {
  16. public class MinorPlanApproveServices : BaseWorkflowServices<CF_GrademinorApplication>, IMinorPlanApproveServices
  17. {
  18. public MinorPlanApplyDAL MinorPlanApplyDAL { get; set; }
  19. public SchoolYearDAL schoolYearDAL { get; set; }
  20. public IGridResultSet<MinorPlanApplyView> GetMinorPlanApplyViewGrid(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, int pageIndex, int pageSize)
  21. {
  22. var statusList = this.GetStatusViewList();
  23. Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  24. if (yearID.HasValue)
  25. exp = exp.And(x => x.YearID == yearID);
  26. if (standardID.HasValue)
  27. exp = exp.And(x => x.StandardID == standardID);
  28. if (collegeID.HasValue)
  29. exp = exp.And(x => x.CollegeID == collegeID);
  30. if (approvalStatus.HasValue)
  31. exp = exp.And(x => x.RecordStatus == approvalStatus);
  32. var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp);
  33. query = query.Where(x => x.ApprovalStatus == 3);
  34. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  35. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  36. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  37. .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToGridResultSet<MinorPlanApplyView>(pageIndex, pageSize);
  38. result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  39. return result;
  40. }
  41. public List<MinorPlanApplyView> GetMinorPlanApplyViewList(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, List<Guid?> GradeMinorApplicationIDList)
  42. {
  43. Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  44. if (GradeMinorApplicationIDList != null)
  45. exp = exp.And(x => GradeMinorApplicationIDList.Contains(x.GradeMinorApplicationID));
  46. if (yearID.HasValue)
  47. exp = exp.And(x => x.YearID == yearID);
  48. if (standardID.HasValue)
  49. exp = exp.And(x => x.StandardID == standardID);
  50. if (collegeID.HasValue)
  51. exp = exp.And(x => x.CollegeID == collegeID);
  52. if (approvalStatus.HasValue)
  53. exp = exp.And(x => x.RecordStatus == approvalStatus);
  54. var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp);
  55. query = query.Where(x => x.ApprovalStatus == 3);
  56. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  57. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  58. return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  59. .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToList();
  60. }
  61. /// <summary>
  62. /// 审核完成事件,由工作流自动触发
  63. /// </summary>
  64. /// <param name="GradeMinorApplicationIDList"></param>
  65. /// <param name="userID"></param>
  66. public void OnApproveEnd(IList<Guid> GradeMinorApplicationIDList, Guid? userID)
  67. {
  68. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  69. if (graduatingSemester == null)
  70. {
  71. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  72. }
  73. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  74. var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  75. var GradeMinorApplicationList = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(x => GradeMinorApplicationIDList.Contains(x.GradeMinorApplicationID)).ToList();
  76. var GradeMinorApplicationIDsList = GradeMinorApplicationList.Select(x => x.GradeMinorApplicationID).ToList();
  77. var minorSpecialCourseList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x=>GradeMinorApplicationIDsList.Contains(x.GrademinorApplicationID)).ToList();
  78. var minorSpecialCourseIDList = minorSpecialCourseList.Select(x => x.MinorPlanApplicationID).ToList();
  79. var minorSpecialCourseTeachingSettingList = MinorPlanApplyDAL.MinorPlanApplicationTeachingSettingRepository.GetList(x => minorSpecialCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList();
  80. var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorPlanApplicationTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList();
  81. var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorPlanApplicationTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList();
  82. #region 插入数据
  83. List<CF_Grademinor> GrademinorList = new List<CF_Grademinor>();
  84. List<EM_MinorPlan> MinorPlanList = new List<EM_MinorPlan>();
  85. List<EM_MinorPlanTeachingModeType> MinorPlanTeachingModeTypeList = new List<EM_MinorPlanTeachingModeType>();
  86. List<EM_MinorPlanTeachingPlace> MinorPlanTeachingPlaceList = new List<EM_MinorPlanTeachingPlace>();
  87. List<EM_MinorPlanTeachingSetting> MinorPlanTeachingSettingList = new List<EM_MinorPlanTeachingSetting>();
  88. //添加辅修专业
  89. foreach (var GrademinorPlan in GradeMinorApplicationList)
  90. {
  91. CF_Grademinor Grademinor = new CF_Grademinor();
  92. Grademinor.GrademinorID = Guid.NewGuid();
  93. Grademinor.GrademinorApplicationID = GrademinorPlan.GradeMinorApplicationID;
  94. Grademinor.SchoolyearID = GrademinorPlan.SchoolyearID;
  95. Grademinor.CollegeID=GrademinorPlan.CollegeID;
  96. Grademinor.YearID=GrademinorPlan.YearID;
  97. Grademinor.StandardID=GrademinorPlan.StandardID;
  98. Grademinor.StudentLimit = GrademinorPlan.StudentLimit;
  99. SetNewStatus(Grademinor);
  100. GrademinorList.Add(Grademinor);
  101. //添加辅修计划
  102. foreach (var minorSpecialCourse in minorSpecialCourseList)
  103. {
  104. if (minorSpecialCourse.GrademinorApplicationID == GrademinorPlan.GradeMinorApplicationID)
  105. {
  106. var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == GrademinorPlan.YearID && x.SchoolcodeID == SchoolcodeID);
  107. var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + minorSpecialCourse.StarttermID - 1));
  108. EM_MinorPlan MinorPlan = new EM_MinorPlan();
  109. MinorPlan.MinorPlanID = Guid.NewGuid();
  110. MinorPlan.MinorPlanApplicationID = minorSpecialCourse.MinorPlanApplicationID;
  111. MinorPlan.CoursematerialID = minorSpecialCourse.CoursematerialID;
  112. MinorPlan.DepartmentID = minorSpecialCourse.DepartmentID;
  113. MinorPlan.GrademinorID = Grademinor.GrademinorID;
  114. MinorPlan.SchoolyearID = courseSchoolyear.SchoolyearID;
  115. MinorPlan.CourseStructureID=minorSpecialCourse.CourseStructureID;
  116. MinorPlan.CourseCategoryID=minorSpecialCourse.CourseCategoryID;
  117. MinorPlan.CourseTypeID=minorSpecialCourse.CourseTypeID;
  118. MinorPlan.CourseQualityID=minorSpecialCourse.CourseQualityID;
  119. MinorPlan.PracticeTypeID=minorSpecialCourse.PracticeTypeID;
  120. MinorPlan.ExaminationModeID=minorSpecialCourse.ExaminationModeID;
  121. MinorPlan.CourseFineID=minorSpecialCourse.CourseFineID;
  122. MinorPlan.IsSpecialtycore=minorSpecialCourse.IsSpecialtycore;
  123. MinorPlan.IsCooperation=minorSpecialCourse.IsCooperation;
  124. MinorPlan.IsRequired=minorSpecialCourse.IsRequired;
  125. MinorPlan.IsElective=minorSpecialCourse.IsElective;
  126. MinorPlan.IsNetworkCourse=minorSpecialCourse.IsNetworkCourse;
  127. MinorPlan.IsMainCourse=minorSpecialCourse.IsMainCourse;
  128. MinorPlan.TeachinglanguageID=minorSpecialCourse.TeachinglanguageID;
  129. MinorPlan.HandleModeID=minorSpecialCourse.HandleModeID;
  130. MinorPlan.IsNeedMaterial=minorSpecialCourse.IsNeedMaterial;
  131. MinorPlan.ResultTypeID = minorSpecialCourse.ResultTypeID;
  132. MinorPlan.Remarks = minorSpecialCourse.Remarks;
  133. SetNewStatus(MinorPlan);
  134. MinorPlanList.Add(MinorPlan);
  135. var minorSpecialCourseTeachingSetting = minorSpecialCourseTeachingSettingList.Where(x => x.MinorPlanApplicationID == minorSpecialCourse.MinorPlanApplicationID).FirstOrDefault();
  136. EM_MinorPlanTeachingSetting MinorPlanTeachingSetting = new EM_MinorPlanTeachingSetting();
  137. MinorPlanTeachingSetting.MinorPlanID = MinorPlan.MinorPlanID;
  138. MinorPlanTeachingSetting.Credit = minorSpecialCourseTeachingSetting.Credit;
  139. MinorPlanTeachingSetting.TheoryCourse = minorSpecialCourseTeachingSetting.TheoryCourse;
  140. MinorPlanTeachingSetting.Practicehours = minorSpecialCourseTeachingSetting.Practicehours;
  141. MinorPlanTeachingSetting.Trialhours = minorSpecialCourseTeachingSetting.Trialhours;
  142. MinorPlanTeachingSetting.WeeklyNum = minorSpecialCourseTeachingSetting.WeeklyNum;
  143. MinorPlanTeachingSetting.TheoryWeeklyNum = minorSpecialCourseTeachingSetting.TheoryWeeklyNum;
  144. MinorPlanTeachingSetting.PracticeWeeklyNum = minorSpecialCourseTeachingSetting.PracticeWeeklyNum;
  145. MinorPlanTeachingSetting.TrialWeeklyNum = minorSpecialCourseTeachingSetting.TrialWeeklyNum;
  146. MinorPlanTeachingSetting.StartWeeklyNum = minorSpecialCourseTeachingSetting.StartWeeklyNum;
  147. MinorPlanTeachingSetting.EndWeeklyNum = minorSpecialCourseTeachingSetting.EndWeeklyNum;
  148. MinorPlanTeachingSetting.WeeklyHours = minorSpecialCourseTeachingSetting.WeeklyHours;
  149. MinorPlanTeachingSettingList.Add(MinorPlanTeachingSetting);
  150. minorSpecialCourseTeachModeTypeList.Where(x => x.MinorPlanApplicationID == minorSpecialCourse.MinorPlanApplicationID).ToList().ForEach(x =>
  151. {
  152. EM_MinorPlanTeachingModeType MinorPlanTeachingModeType = new EM_MinorPlanTeachingModeType();
  153. MinorPlanTeachingModeType.MinorPlanTeachingModeTypeID = Guid.NewGuid();
  154. MinorPlanTeachingModeType.MinorPlanID = MinorPlan.MinorPlanID;
  155. MinorPlanTeachingModeType.TeachingModeID = x.TeachingModeID;
  156. this.SetNewStatus(MinorPlanTeachingModeType);
  157. MinorPlanTeachingModeTypeList.Add(MinorPlanTeachingModeType);
  158. });
  159. minorSpecialCourseTeachPlaceList.Where(x => x.MinorPlanApplicationID == minorSpecialCourse.MinorPlanApplicationID).ToList().ForEach(x =>
  160. {
  161. EM_MinorPlanTeachingPlace MinorPlanTeachingPlace = new EM_MinorPlanTeachingPlace();
  162. MinorPlanTeachingPlace.MinorPlanTeachingPlaceID = Guid.NewGuid();
  163. MinorPlanTeachingPlace.MinorPlanID = MinorPlan.MinorPlanID;
  164. MinorPlanTeachingPlace.TeachingPlace = x.TeachingPlace;
  165. this.SetNewStatus(MinorPlanTeachingPlace);
  166. MinorPlanTeachingPlaceList.Add(MinorPlanTeachingPlace);
  167. });
  168. }
  169. }
  170. }
  171. UnitOfWork.BulkInsert(GrademinorList);
  172. UnitOfWork.BulkInsert(MinorPlanList);
  173. UnitOfWork.BulkInsert(MinorPlanTeachingModeTypeList);
  174. UnitOfWork.BulkInsert(MinorPlanTeachingPlaceList);
  175. UnitOfWork.BulkInsert(MinorPlanTeachingSettingList);
  176. UnitOfWork.Commit();
  177. #endregion
  178. }
  179. }
  180. }