MinorSpecialtyPlanServices.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.MinorManage.MinorPlanManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.MinorManage.MinorPlanManage;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using Bowin.Common.Linq;
  12. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  13. using EMIS.DataLogic.Common.CalendarManage;
  14. namespace EMIS.CommonLogic.MinorManage.MinorPlanManage
  15. {
  16. public class MinorSpecialtyPlanServices : BaseServices, IMinorSpecialtyPlanServices
  17. {
  18. public MinorSpecialtyPlanDAL MinorSpecialtyPlanDAL { get; set; }
  19. public SchoolYearDAL schoolYearDAL { get; set; }
  20. public MinorPlanApplyDAL MinorPlanApplyDAL { get; set; }
  21. public IGridResultSet<MinorSpecialtyPlanView> GetMinorSpecialtyViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? CollegeID, int? yearID, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, int pageIndex, int pageSize)
  22. {
  23. Expression<Func<EM_MinorPlan, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  24. if (yearID.HasValue)
  25. exp = exp.And(x => x.CF_Grademinor.YearID == yearID);
  26. if (standardID.HasValue)
  27. exp = exp.And(x => x.CF_Grademinor.StandardID == standardID);
  28. if (CollegeID.HasValue)
  29. exp = exp.And(x => x.CF_Grademinor.CollegeID == CollegeID);
  30. if (schoolYearID.HasValue)
  31. exp = exp.And(x => x.SchoolyearID == schoolYearID);
  32. if (CoursematerialID.HasValue)
  33. exp = exp.And(x => x.CoursematerialID == CoursematerialID);
  34. if (SchoolcodeID.HasValue)
  35. exp = exp.And(x => x.CF_Schoolyear.SchoolcodeID == SchoolcodeID);
  36. var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp);
  37. if (SchoolyearNumID.HasValue)
  38. query = query.Where(x => x.SchoolyearNumID == SchoolyearNumID);
  39. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  40. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  41. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr)
  42. .ToGridResultSet<MinorSpecialtyPlanView>(pageIndex, pageSize);
  43. return result;
  44. }
  45. public IGridResultSet<MinorSpecialtyPlanView> GetMinorSpecialtyViewByMinorSpecialtyIDGrid(Guid? minorSpecialtyID, int pageIndex, int pageSize)
  46. {
  47. Expression<Func<EM_MinorPlan, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.GrademinorID == minorSpecialtyID);
  48. var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp);
  49. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr)
  50. .ToGridResultSet<MinorSpecialtyPlanView>(pageIndex, pageSize);
  51. return result;
  52. }
  53. public List<MinorSpecialtyPlanView> GetMinorSpecialtyViewList(ConfiguretView configuretView, Guid? schoolYearID, Guid? CollegeID, int? yearID, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, List<Guid?> MinorPlanIDList)
  54. {
  55. Expression<Func<EM_MinorPlan, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  56. if (MinorPlanIDList != null)
  57. exp = exp.And(x => MinorPlanIDList.Contains(x.MinorPlanID));
  58. if (yearID.HasValue)
  59. exp = exp.And(x => x.CF_Grademinor.YearID == yearID);
  60. if (standardID.HasValue)
  61. exp = exp.And(x => x.CF_Grademinor.StandardID == standardID);
  62. if (CollegeID.HasValue)
  63. exp = exp.And(x => x.CF_Grademinor.CollegeID == CollegeID);
  64. if (schoolYearID.HasValue)
  65. exp = exp.And(x => x.SchoolyearID == schoolYearID);
  66. if (CoursematerialID.HasValue)
  67. exp = exp.And(x => x.CoursematerialID == CoursematerialID);
  68. if (SchoolcodeID.HasValue)
  69. exp = exp.And(x => x.CF_Schoolyear.SchoolcodeID == SchoolcodeID);
  70. var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp);
  71. if (SchoolyearNumID.HasValue)
  72. query = query.Where(x => x.SchoolyearNumID == SchoolyearNumID);
  73. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  74. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  75. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr).ToList();
  76. }
  77. public MinorSpecialtyPlanView GetMinorSpecialtyView(Guid? MinorPlanID)
  78. {
  79. Expression<Func<EM_MinorPlan, bool>> exp = (x => x.MinorPlanID == MinorPlanID);
  80. var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp).FirstOrDefault();
  81. return query;
  82. }
  83. /// <summary>
  84. /// 获取辅修计划信息
  85. /// </summary>
  86. /// <param name="MinorPlanID">辅修计划ID</param>
  87. /// <returns></returns>
  88. public Entities.EM_MinorPlan GetMinorPlan(Guid? MinorPlanID)
  89. {
  90. //查询条件
  91. Expression<Func<EM_MinorPlan, bool>> exp = (x => x.MinorPlanID == MinorPlanID);
  92. return MinorSpecialtyPlanDAL.MinorPlanRepository.GetSingle(exp, (x => x.CF_Department), (x => x.EM_Coursematerial), (x => x.EM_MinorPlanTeachingSetting));
  93. }
  94. /// <summary>
  95. /// 辅修计划设置表
  96. /// </summary>
  97. /// <param name="MinorPlanID">辅修计划ID</param>
  98. /// <returns></returns>
  99. public EM_MinorPlanTeachingSetting GetMinorPlanTeachingSetting(Guid? MinorPlanID)
  100. {
  101. //查询条件
  102. Expression<Func<EM_MinorPlanTeachingSetting, bool>> exp = (x => x.MinorPlanID == MinorPlanID);
  103. return MinorSpecialtyPlanDAL.MinorPlanTeachingSettingRepository.GetSingle(exp);
  104. }
  105. /// <summary>
  106. /// 根据专业课程获取授课方式
  107. /// </summary>
  108. /// <param name="MinorCourseID">辅修课程</param>
  109. /// <returns></returns>
  110. public List<string> GetTeachingModeType(Guid? MinorPlanID)
  111. {
  112. return MinorSpecialtyPlanDAL.GetTeachingModeTypeQueryble(MinorPlanID);
  113. }
  114. /// <summary>
  115. /// 根据专业课程获取授课地点
  116. /// </summary>
  117. /// <param name="MinorCourseID">辅修课程ID</param>
  118. /// <returns></returns>
  119. public List<string> GetTeachingPlace(Guid? MinorPlanID)
  120. {
  121. return MinorSpecialtyPlanDAL.GetTeachingPlaceQueryble(MinorPlanID);
  122. }
  123. /// <summary>
  124. /// 获取未使用的课程
  125. /// </summary>
  126. /// <param name="yearID"></param>
  127. /// <param name="standardID"></param>
  128. /// <param name="pageIndex"></param>
  129. /// <param name="pageSize"></param>
  130. /// <returns></returns>
  131. public IGridResultSet<MinorPlanApplyView> StandardAndMinorSpecialtyCourseViewGrid(int? yearID, int? standardID, int pageIndex, int pageSize)
  132. {
  133. Expression<Func<EM_MinorCourse, bool>> exp = (x => x.IsEnable == true);
  134. var query = MinorSpecialtyPlanDAL.StandardAndMinorSpecialtyCourseView(exp, yearID);
  135. if (standardID.HasValue)
  136. {
  137. query = query.Where(x => x.StandardID == standardID);
  138. }
  139. return this.GetQueryByDataRangeByCollege(query)
  140. .OrderBy(x => x.SchoolyearNumID).ThenBy(x => x.CourseCode)
  141. .ToGridResultSet<MinorPlanApplyView>(pageIndex, pageSize);
  142. }
  143. public IList<MinorSpecialtyPlanView> GetStandardIDList(ConfiguretView configuretView, int? yearID)
  144. {
  145. Expression<Func<CF_Grademinor, bool>> exp = (x => true);
  146. if(yearID.HasValue){
  147. exp = exp.And(x => x.YearID == yearID);
  148. }
  149. var query = MinorSpecialtyPlanDAL.GetStandardView(exp);
  150. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  151. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  152. return query.Distinct().ToList();
  153. }
  154. public void MinorSpecialtyCourseEdit(MinorSpecialtyPlanView minorSpecialtyPlanView)
  155. {
  156. EM_MinorPlan MinorPlan = null;
  157. EM_MinorPlanTeachingSetting MinorPlanTeachingSetting = null;
  158. MinorPlan = GetMinorPlan(minorSpecialtyPlanView.MinorPlanID);
  159. MinorPlanTeachingSetting = GetMinorPlanTeachingSetting(minorSpecialtyPlanView.MinorPlanID);
  160. MinorPlan.ResultTypeID = minorSpecialtyPlanView.ResultTypeID;
  161. MinorPlan.Remarks = minorSpecialtyPlanView.Remarks;
  162. SetModifyStatus(MinorPlan);
  163. MinorPlanTeachingSetting.Credit = minorSpecialtyPlanView.Credit;
  164. MinorPlanTeachingSetting.TheoryCourse = minorSpecialtyPlanView.TheoryCourse;
  165. MinorPlanTeachingSetting.Practicehours = minorSpecialtyPlanView.Practicehours;
  166. MinorPlanTeachingSetting.Trialhours = minorSpecialtyPlanView.Trialhours;
  167. MinorPlanTeachingSetting.WeeklyNum = minorSpecialtyPlanView.WeeklyNum;
  168. MinorPlanTeachingSetting.TheoryWeeklyNum = minorSpecialtyPlanView.TheoryWeeklyNum;
  169. MinorPlanTeachingSetting.PracticeWeeklyNum = minorSpecialtyPlanView.PracticeWeeklyNum;
  170. MinorPlanTeachingSetting.TrialWeeklyNum = minorSpecialtyPlanView.TrialWeeklyNum;
  171. MinorPlanTeachingSetting.StartWeeklyNum = minorSpecialtyPlanView.StartWeeklyNum;
  172. MinorPlanTeachingSetting.EndWeeklyNum = minorSpecialtyPlanView.EndWeeklyNum;
  173. MinorPlanTeachingSetting.WeeklyHours = minorSpecialtyPlanView.WeeklyHours;
  174. UnitOfWork.Update(MinorPlanTeachingSetting);
  175. if (minorSpecialtyPlanView.TeachingModeID != null)
  176. {
  177. UnitOfWork.Delete<EM_MinorPlanTeachingModeType>(x => x.MinorPlanID == MinorPlan.MinorPlanID);
  178. foreach (var i in minorSpecialtyPlanView.TeachingModeID)
  179. {
  180. EM_MinorPlanTeachingModeType MinorPlanTeachingModeType = new EM_MinorPlanTeachingModeType();
  181. MinorPlanTeachingModeType.MinorPlanTeachingModeTypeID = Guid.NewGuid();
  182. MinorPlanTeachingModeType.MinorPlanID = MinorPlan.MinorPlanID;
  183. MinorPlanTeachingModeType.TeachingModeID = i;
  184. SetNewStatus(MinorPlanTeachingModeType);
  185. UnitOfWork.Add(MinorPlanTeachingModeType);
  186. }
  187. }
  188. if (minorSpecialtyPlanView.TeachingPlaceID != null)
  189. {
  190. UnitOfWork.Delete<EM_MinorPlanTeachingPlace>(x => x.MinorPlanID == MinorPlan.MinorPlanID);
  191. foreach (var i in minorSpecialtyPlanView.TeachingPlaceID)
  192. {
  193. EM_MinorPlanTeachingPlace MinorPlanTeachingPlace = new EM_MinorPlanTeachingPlace();
  194. MinorPlanTeachingPlace.MinorPlanTeachingPlaceID = Guid.NewGuid();
  195. MinorPlanTeachingPlace.MinorPlanID = MinorPlan.MinorPlanID;
  196. MinorPlanTeachingPlace.TeachingPlace = i;
  197. SetNewStatus(MinorPlanTeachingPlace);
  198. UnitOfWork.Add(MinorPlanTeachingPlace);
  199. }
  200. }
  201. UnitOfWork.Commit();
  202. }
  203. public void MinorPlanAdd(MinorSpecialtyPlanView minorPlanApplyView, List<MinorSpecialtyPlanView> minorSpecialCourseViewList)
  204. {
  205. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  206. if (graduatingSemester == null)
  207. {
  208. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  209. }
  210. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  211. var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  212. var Grademinor = MinorSpecialtyPlanDAL.GrademinorRepository.GetList(x => x.YearID == minorPlanApplyView.YearID && x.StandardID == minorPlanApplyView.StandardID).FirstOrDefault();
  213. var minorSpecialCourseIDList = minorSpecialCourseViewList.Select(x => x.MinorCourseID).ToList();
  214. var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorCourseTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList();
  215. var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorCourseTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList();
  216. List<EM_MinorPlan> insertList = new List<EM_MinorPlan>();
  217. List<EM_MinorPlanTeachingSetting> insertSettingList = new List<EM_MinorPlanTeachingSetting>();
  218. List<EM_MinorPlanTeachingModeType> insertTeachingModeTypeList = new List<EM_MinorPlanTeachingModeType>();
  219. List<EM_MinorPlanTeachingPlace> insertTeachingPlaceList = new List<EM_MinorPlanTeachingPlace>();
  220. foreach (var specialtyCourse in minorSpecialCourseViewList)
  221. {
  222. var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID);
  223. if (startSchoolyear == null)
  224. {
  225. throw new Exception("未能匹配到学年学期,请设置学年学期。");
  226. }
  227. var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1)));
  228. if (courseSchoolyear == null)
  229. {
  230. throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。");
  231. }
  232. EM_MinorPlan MinorPlan = new EM_MinorPlan();
  233. MinorPlan.MinorPlanID = Guid.NewGuid();
  234. MinorPlan.MinorPlanApplicationID = null;
  235. MinorPlan.GrademinorID = Grademinor.GrademinorID;
  236. MinorPlan.SchoolyearID = courseSchoolyear.SchoolyearID;
  237. MinorPlan.DepartmentID = specialtyCourse.DepartmentID;
  238. MinorPlan.CoursematerialID = specialtyCourse.CoursematerialID;
  239. MinorPlan.CourseStructureID = specialtyCourse.CourseStructureID;
  240. MinorPlan.CourseCategoryID = specialtyCourse.CourseCategoryID;
  241. MinorPlan.CourseTypeID = specialtyCourse.CourseTypeID;
  242. MinorPlan.CourseQualityID = specialtyCourse.CourseQualityID;
  243. MinorPlan.PracticeTypeID = specialtyCourse.PracticeTypeID;
  244. MinorPlan.ExaminationModeID = specialtyCourse.ExaminationModeID;
  245. MinorPlan.CourseFineID = specialtyCourse.CourseFineID;
  246. MinorPlan.IsSpecialtycore = specialtyCourse.IsSpecialtycore;
  247. MinorPlan.IsCooperation = specialtyCourse.IsCooperation;
  248. MinorPlan.IsRequired = specialtyCourse.IsRequired;
  249. MinorPlan.IsElective = specialtyCourse.IsElective;
  250. MinorPlan.IsNetworkCourse = specialtyCourse.IsNetworkCourse;
  251. MinorPlan.IsMainCourse = specialtyCourse.IsMainCourse;
  252. MinorPlan.TeachinglanguageID = specialtyCourse.TeachinglanguageID;
  253. MinorPlan.HandleModeID = specialtyCourse.HandleModeID;
  254. MinorPlan.IsNeedMaterial = specialtyCourse.IsNeedMaterial;
  255. MinorPlan.ResultTypeID = specialtyCourse.ResultTypeID;
  256. MinorPlan.Remarks = minorPlanApplyView.Remarks;
  257. SetNewStatus(MinorPlan);
  258. insertList.Add(MinorPlan);
  259. EM_MinorPlanTeachingSetting MinorPlanTeachingSetting = new EM_MinorPlanTeachingSetting();
  260. MinorPlanTeachingSetting.MinorPlanID = MinorPlan.MinorPlanID;
  261. MinorPlanTeachingSetting.Credit = specialtyCourse.Credit;
  262. MinorPlanTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse;
  263. MinorPlanTeachingSetting.Practicehours = specialtyCourse.Practicehours;
  264. MinorPlanTeachingSetting.Trialhours = specialtyCourse.Trialhours;
  265. MinorPlanTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum;
  266. MinorPlanTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum;
  267. MinorPlanTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum;
  268. MinorPlanTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum;
  269. MinorPlanTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum;
  270. MinorPlanTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum;
  271. MinorPlanTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours;
  272. insertSettingList.Add(MinorPlanTeachingSetting);
  273. minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  274. {
  275. EM_MinorPlanTeachingModeType specialtyTeachingModeType = new EM_MinorPlanTeachingModeType();
  276. specialtyTeachingModeType.MinorPlanTeachingModeTypeID = Guid.NewGuid();
  277. specialtyTeachingModeType.MinorPlanID = MinorPlan.MinorPlanID;
  278. specialtyTeachingModeType.TeachingModeID = x.TeachingModeID;
  279. this.SetNewStatus(specialtyTeachingModeType);
  280. insertTeachingModeTypeList.Add(specialtyTeachingModeType);
  281. });
  282. minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  283. {
  284. EM_MinorPlanTeachingPlace specialtyTeachingPlace = new EM_MinorPlanTeachingPlace();
  285. specialtyTeachingPlace.MinorPlanTeachingPlaceID = Guid.NewGuid();
  286. specialtyTeachingPlace.MinorPlanID = MinorPlan.MinorPlanID;
  287. specialtyTeachingPlace.TeachingPlace = x.TeachingPlace;
  288. this.SetNewStatus(specialtyTeachingPlace);
  289. insertTeachingPlaceList.Add(specialtyTeachingPlace);
  290. });
  291. }
  292. UnitOfWork.BulkInsert(insertList);
  293. UnitOfWork.BulkInsert(insertSettingList);
  294. UnitOfWork.BulkInsert(insertTeachingModeTypeList);
  295. UnitOfWork.BulkInsert(insertTeachingPlaceList);
  296. }
  297. public bool MinorPlanDelete(List<Guid?> MinorPlanIDList)
  298. {
  299. try
  300. {
  301. if (MinorPlanIDList.Count > 0)
  302. {
  303. UnitOfWork.Delete<EM_MinorPlanTeachingSetting>(x => MinorPlanIDList.Contains(x.MinorPlanID));
  304. UnitOfWork.Delete<EM_MinorPlanTeachingModeType>(x => MinorPlanIDList.Contains(x.MinorPlanID));
  305. UnitOfWork.Delete<EM_MinorPlanTeachingPlace>(x => MinorPlanIDList.Contains(x.MinorPlanID));
  306. UnitOfWork.Delete<EM_MinorPlan>(x => MinorPlanIDList.Contains(x.MinorPlanID));
  307. }
  308. return true;
  309. }
  310. catch (Exception)
  311. {
  312. throw;
  313. }
  314. }
  315. }
  316. }