123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Students.HighBaseTable;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.Students.HighBaseTable
- {
- public class StudentChangeServices : BaseServices, IStudentChangeServices
- {
- public StudentChangeDAL StudentChangeDAL { get; set; }
- public Lazy<IWorkflowServices> WorkflowServices { get; set; }
- public void GenerateReport(int year)
- {
- var endStatusID = WorkflowServices.Value.GetCorrectEndStatus(typeof(CF_DifferentDynamic).Name);
- //获取上学年初报表在校生数
- var lastReportList = StudentChangeDAL.GetLastInschoolStudentCount(year).ToList();
- //获取招生数
- var recruitStudentList = StudentChangeDAL.GetRecruitStudentCount(year).ToList();
- //获取毕业数
- var graduationStudentList = StudentChangeDAL.GetGraduationStudentCount(year).ToList();
- //获取结业数
- var graduationOverStudentList = StudentChangeDAL.GetGraduationOverStudentCount(year).ToList();
- //获取本学期报表在校学生数
- var currentStudentList = StudentChangeDAL.GetCurrentInschoolStudentCount().ToList();
- //获取异动学生数
- var studentChangeList = StudentChangeDAL.GetStudentChangeCount(year, endStatusID).ToList();
- this.UnitOfWork.Remove<HB_StudentChangeDetail>(x => x.HB_StudentChange.Year == year);
- this.UnitOfWork.Remove<HB_StudentChange>(x => x.Year == year);
- #region 合并各种主表数据,并生成主表实体
- var studentChangeTableList = lastReportList
- .Select(x => new
- {
- x.EducationTypeID,
- LastInschoolCount = x.CurrentInschoolCount,
- RecruitCount = (int?)0,
- GraduationCount = (int?)0,
- CompleteCount = (int?)0,
- CurrentInschoolCount = (int?)0
- }).Concat(recruitStudentList
- .Select(x => new
- {
- x.EducationTypeID,
- LastInschoolCount = (int?)0,
- RecruitCount = x.StudentCount,
- GraduationCount = (int?)0,
- CompleteCount = (int?)0,
- CurrentInschoolCount = (int?)0
- })).Concat(graduationStudentList
- .Select(x => new
- {
- x.EducationTypeID,
- LastInschoolCount = (int?)0,
- RecruitCount = (int?)0,
- GraduationCount = x.StudentCount,
- CompleteCount = (int?)0,
- CurrentInschoolCount = (int?)0
- })).Concat(graduationOverStudentList
- .Select(x => new
- {
- x.EducationTypeID,
- LastInschoolCount = (int?)0,
- RecruitCount = (int?)0,
- GraduationCount = (int?)0,
- CompleteCount = x.StudentCount,
- CurrentInschoolCount = (int?)0
- })).Concat(currentStudentList
- .Select(x => new
- {
- x.EducationTypeID,
- LastInschoolCount = (int?)0,
- RecruitCount = (int?)0,
- GraduationCount = (int?)0,
- CompleteCount = (int?)0,
- CurrentInschoolCount = x.StudentCount
- }))
- .GroupBy(x => x.EducationTypeID).Select(x => new HB_StudentChange
- {
- StudentChangeID = Guid.NewGuid(),
- Year = year,
- EducationTypeID = x.Key,
- LastInschoolCount = x.Sum(w => w.LastInschoolCount),
- RecruitCount = x.Sum(w => w.RecruitCount),
- GraduationCount = x.Sum(w => w.GraduationCount),
- CompleteCount = x.Sum(w => w.CompleteCount),
- CurrentInschoolCount = x.Sum(w => w.CurrentInschoolCount)
- })
- .ToList();
- #endregion
- studentChangeTableList.ForEach(x =>
- {
- this.SetNewStatus(x);
- var detailList = studentChangeList.Where(w => w.EducationTypeID == x.EducationTypeID)
- .Select(w => new HB_StudentChangeDetail
- {
- StudentChangeDetailID = Guid.NewGuid(),
- StudentChangeID = x.StudentChangeID,
- DifferentDynamicType = w.DifferentDynamicType ?? 0,
- StudentInCount = w.StudentInCount,
- StudentOutCount = w.StudentOutCount
- }).ToList();
- detailList.ForEach(w => this.SetNewStatus(w));
- x.HB_StudentChangeDetail = new HashSet<HB_StudentChangeDetail>(detailList);
- this.UnitOfWork.Add(x);
- });
- this.UnitOfWork.Commit();
- }
- }
- }
|