123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Students.HighBaseTable;
- using EMIS.DataLogic.SystemSetting;
- using EMIS.DataLogic.Common.CalendarManage;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using System.Transactions;
- namespace EMIS.CommonLogic.Students.HighBaseTable
- {
- public class BachelorSpecialtyStudentCountServices : BaseServices, IBachelorSpecialtyStudentCountServices
- {
- public DictionaryItemDAL DictionaryItemDAL { get; set; }
- public SchoolYearDAL SchoolYearDAL { get; set; }
- public BachelorSpecialtyStudentCountDAL BachelorSpecialtyStudentCountDAL { get; set; }
- public void Update()
- {
- try
- {
- var query = BachelorSpecialtyStudentCountDAL.GetStudent().ToList();
- //var specialty = query.Select(x => x.SpecialtyID).Distinct().ToList();
- //var learningform = query.Select(x => x.LearningformID).Distinct().ToList();
- var sex = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(CF_Sex).Name).Select(x => x.Value).ToList();
- var schoolYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
- //在校生数
- var queryInschool = BachelorSpecialtyStudentCountDAL.GetInschoolCount(schoolYear).ToList();
- //招生数
- var queryRecruit = BachelorSpecialtyStudentCountDAL.GetRecruitCount(schoolYear).ToList();
- //春季招生数,普教需要
- var querySpringRecruit = BachelorSpecialtyStudentCountDAL.SpringRecruitCount(schoolYear).ToList();
- //预计毕业生数
- var queryPlanGraduation = BachelorSpecialtyStudentCountDAL.PlanGraduationCount(schoolYear).ToList();
- //毕业生数
- var queryGraduated = BachelorSpecialtyStudentCountDAL.GetGraduationCount(schoolYear).ToList();
- //应届毕业生数
- var queryGraduating = BachelorSpecialtyStudentCountDAL.GetGraduatingCount(schoolYear).ToList();
- //授予学位数
- var queryDegreed = BachelorSpecialtyStudentCountDAL.GetDegreedCount(schoolYear).ToList();
- List<HB_BachelorSpecialtyStudentCount> SpecialtyStudentCountList = new List<HB_BachelorSpecialtyStudentCount>();
- List<HB_BachelorSpecialtyStudentCountDetail> SpecialtyStudentCountDetailList = new List<HB_BachelorSpecialtyStudentCountDetail>();
- foreach (var i in query)
- {
- foreach (var j in sex)
- {
- HB_BachelorSpecialtyStudentCount SpecialtyStudentCount = new HB_BachelorSpecialtyStudentCount();
- SpecialtyStudentCount.BachelorSpecialtyStudentCountID = Guid.NewGuid();
- SpecialtyStudentCount.Year = schoolYear;
- SpecialtyStudentCount.Sex = j;
- SpecialtyStudentCount.EducationTypeID = (int)EMIS.ViewModel.CF_EducationType.Special;
- SpecialtyStudentCount.LearningformID = i.LearningformID;
- SpecialtyStudentCount.StandardID = i.StandardID;
- SpecialtyStudentCount.LearnSystem = i.LearnSystem;
- SpecialtyStudentCount.IsTeacherIdentification = string.IsNullOrEmpty(i.IsTeacherIdentification) ? false : true;
- //毕业生数
- SpecialtyStudentCount.GraduationCount = queryGraduated.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.GraduationCount).FirstOrDefault();
- //授予学位数
- SpecialtyStudentCount.DegreeCount = queryDegreed.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.DegreeCount).FirstOrDefault();
- //招生数
- SpecialtyStudentCount.RecruitCount = queryRecruit.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.RecruitCount).FirstOrDefault();
- //预计毕业生数
- SpecialtyStudentCount.PlanGraduationCount = queryPlanGraduation.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.SpringRecruitCount).FirstOrDefault();
- //春季招生数
- SpecialtyStudentCount.SpringRecruitCount = querySpringRecruit.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.SpringRecruitCount).FirstOrDefault();
- //应届毕业生数
- SpecialtyStudentCount.GraduatingCount = queryGraduating.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).Select(x => x.GraduatingCount).FirstOrDefault();
- SetNewStatus(SpecialtyStudentCount);
- SpecialtyStudentCountList.Add(SpecialtyStudentCount);
- var list = queryInschool.Where(x => x.LearningformID == i.LearningformID && x.Sex == j
- && x.StandardID == i.StandardID && x.LearnSystem == i.LearnSystem).ToList();
- foreach (var k in list)
- {
- HB_BachelorSpecialtyStudentCountDetail SpecialtyStudentCountDetail = new HB_BachelorSpecialtyStudentCountDetail();
- SpecialtyStudentCountDetail.BachelorSpecialtyStudentCountDetailID = Guid.NewGuid();
- SpecialtyStudentCountDetail.BachelorSpecialtyStudentCountID = SpecialtyStudentCount.BachelorSpecialtyStudentCountID;
- SpecialtyStudentCountDetail.SchoolyearNumID = k.SchoolyearNumID;
- SpecialtyStudentCountDetail.InschoolCount = k.InschoolCount;
- SetNewStatus(SpecialtyStudentCountDetail);
- SpecialtyStudentCountDetailList.Add(SpecialtyStudentCountDetail);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<HB_BachelorSpecialtyStudentCountDetail>(x => x.HB_BachelorSpecialtyStudentCount.Year == schoolYear);
- UnitOfWork.Delete<HB_BachelorSpecialtyStudentCount>(x => x.Year == schoolYear);
- UnitOfWork.BulkInsert(SpecialtyStudentCountList);//统一写入
- UnitOfWork.BulkInsert(SpecialtyStudentCountDetailList);//统一写入
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- //public List<string> SchoolYearDropDownList()
- //{
- // var item = RecruitStatusDAL.RecruitStatusRepository.Entities.Select(x => x.Year.ToString()).Distinct().ToList();
- // return item;
- //}
- }
- }
|