BachelorSpecialtyStudentCountServices.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.Students.HighBaseTable;
  6. using EMIS.DataLogic.SystemSetting;
  7. using EMIS.DataLogic.Common.CalendarManage;
  8. using EMIS.ViewModel;
  9. using EMIS.Entities;
  10. using System.Transactions;
  11. namespace EMIS.CommonLogic.Students.HighBaseTable
  12. {
  13. public class BachelorSpecialtyStudentCountServices : BaseServices, IBachelorSpecialtyStudentCountServices
  14. {
  15. public DictionaryItemDAL DictionaryItemDAL { get; set; }
  16. public SchoolYearDAL SchoolYearDAL { get; set; }
  17. public BachelorSpecialtyStudentCountDAL BachelorSpecialtyStudentCountDAL { get; set; }
  18. public void Update()
  19. {
  20. try
  21. {
  22. var query = BachelorSpecialtyStudentCountDAL.GetStudent().ToList();
  23. //var specialty = query.Select(x => x.SpecialtyID).Distinct().ToList();
  24. //var learningform = query.Select(x => x.LearningformID).Distinct().ToList();
  25. var sex = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(CF_Sex).Name).Select(x => x.Value).ToList();
  26. var schoolYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  27. //在校生数
  28. var queryInschool = BachelorSpecialtyStudentCountDAL.GetInschoolCount(schoolYear).ToList();
  29. //招生数
  30. var queryRecruit = BachelorSpecialtyStudentCountDAL.GetRecruitCount(schoolYear).ToList();
  31. //春季招生数,普教需要
  32. var querySpringRecruit = BachelorSpecialtyStudentCountDAL.SpringRecruitCount(schoolYear).ToList();
  33. //预计毕业生数
  34. var queryPlanGraduation = BachelorSpecialtyStudentCountDAL.PlanGraduationCount(schoolYear).ToList();
  35. //毕业生数
  36. var queryGraduated = BachelorSpecialtyStudentCountDAL.GetGraduationCount(schoolYear).ToList();
  37. //应届毕业生数
  38. var queryGraduating = BachelorSpecialtyStudentCountDAL.GetGraduatingCount(schoolYear).ToList();
  39. //授予学位数
  40. var queryDegreed = BachelorSpecialtyStudentCountDAL.GetDegreedCount(schoolYear).ToList();
  41. List<HB_BachelorSpecialtyStudentCount> SpecialtyStudentCountList = new List<HB_BachelorSpecialtyStudentCount>();
  42. List<HB_BachelorSpecialtyStudentCountDetail> SpecialtyStudentCountDetailList = new List<HB_BachelorSpecialtyStudentCountDetail>();
  43. foreach (var i in query)
  44. {
  45. foreach (var j in sex)
  46. {
  47. HB_BachelorSpecialtyStudentCount SpecialtyStudentCount = new HB_BachelorSpecialtyStudentCount();
  48. SpecialtyStudentCount.BachelorSpecialtyStudentCountID = Guid.NewGuid();
  49. SpecialtyStudentCount.Year = schoolYear;
  50. SpecialtyStudentCount.Sex = j;
  51. SpecialtyStudentCount.EducationTypeID = (int)EMIS.ViewModel.CF_EducationType.Special;
  52. SpecialtyStudentCount.LearningformID = i.LearningformID;
  53. SpecialtyStudentCount.StandardID = i.StandardID;
  54. SpecialtyStudentCount.LearnSystem = i.LearnSystem;
  55. SpecialtyStudentCount.IsTeacherIdentification = string.IsNullOrEmpty(i.IsTeacherIdentification) ? false : true;
  56. //毕业生数
  57. SpecialtyStudentCount.GraduationCount = queryGraduated.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  58. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.GraduationCount).FirstOrDefault();
  59. //授予学位数
  60. SpecialtyStudentCount.DegreeCount = queryDegreed.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  61. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.DegreeCount).FirstOrDefault();
  62. //招生数
  63. SpecialtyStudentCount.RecruitCount = queryRecruit.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  64. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.RecruitCount).FirstOrDefault();
  65. //预计毕业生数
  66. SpecialtyStudentCount.PlanGraduationCount = queryPlanGraduation.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  67. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.SpringRecruitCount).FirstOrDefault();
  68. //春季招生数
  69. SpecialtyStudentCount.SpringRecruitCount = querySpringRecruit.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  70. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.SpringRecruitCount).FirstOrDefault();
  71. //应届毕业生数
  72. SpecialtyStudentCount.GraduatingCount = queryGraduating.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  73. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.GraduatingCount).FirstOrDefault();
  74. SetNewStatus(SpecialtyStudentCount);
  75. SpecialtyStudentCountList.Add(SpecialtyStudentCount);
  76. var list = queryInschool.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
  77. && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).ToList();
  78. foreach (var k in list)
  79. {
  80. HB_BachelorSpecialtyStudentCountDetail SpecialtyStudentCountDetail = new HB_BachelorSpecialtyStudentCountDetail();
  81. SpecialtyStudentCountDetail.BachelorSpecialtyStudentCountDetailID = Guid.NewGuid();
  82. SpecialtyStudentCountDetail.BachelorSpecialtyStudentCountID = SpecialtyStudentCount.BachelorSpecialtyStudentCountID;
  83. SpecialtyStudentCountDetail.SchoolyearNumID = k.SchoolyearNumID;
  84. SpecialtyStudentCountDetail.InschoolCount = k.InschoolCount;
  85. SetNewStatus(SpecialtyStudentCountDetail);
  86. SpecialtyStudentCountDetailList.Add(SpecialtyStudentCountDetail);
  87. }
  88. }
  89. }
  90. using (TransactionScope ts = new TransactionScope())
  91. {
  92. UnitOfWork.Delete<HB_BachelorSpecialtyStudentCountDetail>(x => x.HB_BachelorSpecialtyStudentCount.Year == schoolYear);
  93. UnitOfWork.Delete<HB_BachelorSpecialtyStudentCount>(x => x.Year == schoolYear);
  94. UnitOfWork.BulkInsert(SpecialtyStudentCountList);//统一写入
  95. UnitOfWork.BulkInsert(SpecialtyStudentCountDetailList);//统一写入
  96. ts.Complete();
  97. }
  98. }
  99. catch (Exception ex)
  100. {
  101. throw new Exception(ex.Message);
  102. }
  103. }
  104. //public List<string> SchoolYearDropDownList()
  105. //{
  106. // var item = RecruitStatusDAL.RecruitStatusRepository.Entities.Select(x => x.Year.ToString()).Distinct().ToList();
  107. // return item;
  108. //}
  109. }
  110. }