123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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 JuniorSpecialtyStudentCountServices : BaseServices, IJuniorSpecialtyStudentCountServices
- {
- public DictionaryItemDAL DictionaryItemDAL { get; set; }
- public SchoolYearDAL SchoolYearDAL { get; set; }
- public JuniorSpecialtyStudentCountDAL JuniorSpecialtyStudentCountDAL { get; set; }
- public void Update()
- {
- try
- {
- var query = JuniorSpecialtyStudentCountDAL.GetStudent().OrderBy(x => x.LearningformID).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 = JuniorSpecialtyStudentCountDAL.GetInschoolCount(schoolYear).ToList();
- //招生数
- var queryRecruit = JuniorSpecialtyStudentCountDAL.GetRecruitCount(schoolYear).ToList();
- //春季招生数,普教需要
- var querySpringRecruit = JuniorSpecialtyStudentCountDAL.SpringRecruitCount(schoolYear).ToList();
- //预计毕业生数
- var queryPlanGraduation = JuniorSpecialtyStudentCountDAL.PlanGraduationCount(schoolYear).ToList();
- //毕业生数
- var queryGraduated = JuniorSpecialtyStudentCountDAL.GetGraduationCount(schoolYear).ToList();
- //应届毕业生数
- var queryGraduating = JuniorSpecialtyStudentCountDAL.GetGraduatingCount(schoolYear).ToList();
- List<HB_JuniorSpecialtyStudentCount> SpecialtyStudentCountList = new List<HB_JuniorSpecialtyStudentCount>();
- List<HB_JuniorSpecialtyStudentCountDetail> SpecialtyStudentCountDetailList = new List<HB_JuniorSpecialtyStudentCountDetail>();
- foreach (var i in query)
- {
- foreach (var j in sex)
- {
- HB_JuniorSpecialtyStudentCount SpecialtyStudentCount = new HB_JuniorSpecialtyStudentCount();
- SpecialtyStudentCount.JuniorSpecialtyStudentCountID = 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.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.PlanGraduationCount).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).OrderBy(x => x.StandardID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToList();
- foreach (var k in list)
- {
- HB_JuniorSpecialtyStudentCountDetail SpecialtyStudentCountDetail = new HB_JuniorSpecialtyStudentCountDetail();
- SpecialtyStudentCountDetail.JuniorSpecialtyStudentCountDetailID = Guid.NewGuid();
- SpecialtyStudentCountDetail.JuniorSpecialtyStudentCountID = SpecialtyStudentCount.JuniorSpecialtyStudentCountID;
- SpecialtyStudentCountDetail.SchoolyearNumID = k.SchoolyearNumID;
- SpecialtyStudentCountDetail.InschoolCount = k.InschoolCount;
- SetNewStatus(SpecialtyStudentCountDetail);
- SpecialtyStudentCountDetailList.Add(SpecialtyStudentCountDetail);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<HB_JuniorSpecialtyStudentCountDetail>(x => x.HB_JuniorSpecialtyStudentCount.Year == schoolYear);
- UnitOfWork.Delete<HB_JuniorSpecialtyStudentCount>(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;
- //}
- }
- }
|