123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- namespace EMIS.ExtensionLogic.ServiceLogic.ScoreManage
- {
- public class FinalExaminationServices : EMIS.CommonLogic.ScoreManage.FinalExaminationServices
- {
- public override void GenerateResitExamination(Guid? schoolyearID, Guid? collegeID, int? gradeID, int? standardID, Guid? classmajorID)
- {
- try
- {
- var startStatusID = this.GetStartStatus();
- var statusList = this.GetStatusViewList();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var curSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
- ER_ExamsStateSetting examsStateSetting = finalExaminationDAL.ExamsStateSettingRepository.GetSingle(x => x.ExamsStateID == (int)CF_ExamsState.Suspension);
- List<ER_FinalExamination> listFinalExamination = new List<ER_FinalExamination>();
- //List<ER_FinalExamination> SlistFinalExamination = new List<ER_FinalExamination>();
- //var studentList = this.DataRangeFunction(finalExaminationDAL.GetResitFinalExaminationStudent(schoolyearID, approvedStatus)).ToList();
- var query = this.GerenateResitDataRangeFunction(finalExaminationDAL.GetNotPassStudent(schoolyearID));
- //var q = finalExaminationDAL.GetSuspensionStudent(schoolyearID);
- //var Squery = this.GerenateResitDataRangeFunction(q);
- if (collegeID.HasValue)
- {//院系所
- query = query.Where(x => x.CollegeID == collegeID);
- //Squery = Squery.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue && gradeID != -1)
- {//年级
- query = query.Where(x => x.Year == gradeID);
- //Squery = Squery.Where(x => x.Year == gradeID);
- }
- if (standardID.HasValue) //专业
- {
- query = query.Where(x => x.StandardID == standardID);
- //Squery = Squery.Where(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- query = query.Where(x => x.ClassmajorID == classmajorID);
- //Squery = Squery.Where(x => x.ClassmajorID == classmajorID);
- }
- var studentList = query.ToList();
- //var SuspensionsutdentList = Squery.ToList();
- var finalIDList = studentList.Select(x => x.FinalExaminationID).ToList();
- var finalList = scoreDAL.finalExaminationRepository.GetList(x => finalIDList.Contains(x.FinalExaminationID), x => x.ER_FinalExaminationStudent).ToList();
- var studentIDList = studentList.Select(x => x.UserID).ToList();
- var stuUserList = finalExaminationDAL.studentRepository.GetList(x => studentIDList.Contains(x.UserID), x => x.CF_Classmajor, x => x.CF_Classmajor.CF_Grademajor).ToList();
- var ExamsStateSettingList = finalExaminationDAL.ExamsStateSettingRepository.Entities.ToList();
- var queryFinalExamination = studentList.GroupBy(x => new
- {
- x.FinalExaminationID,
- //x.Year,
- //x.CollegeID,
- //x.GrademajorID,
- //x.GrademajorName,
- //x.CoursematerialID,
- //x.DepartmentID,
- x.CourseName,
- //x.CourseTypeID,
- //x.ExaminationModeID,
- ////x.StartTermID,
- //x.Credit,
- //////总学时
- //x.TotalHours,
- //x.ResultTypeID,
- x.ExamsCategoryID,
- });
- foreach (var finalExaminationView in queryFinalExamination)
- {
-
- ER_FinalExamination finalExamination = new ER_FinalExamination();
- var dbfianl = finalList.FirstOrDefault(x => x.FinalExaminationID == finalExaminationView.Key.FinalExaminationID);
- var examsCategoryID = ExamsStateSettingList.FirstOrDefault(x => x.ExamsStateID == dbfianl.ExamsCategoryID);
- var grademajorName = studentList.Where(x => x.FinalExaminationID == finalExaminationView.Key.FinalExaminationID).FirstOrDefault().GrademajorName;
- var stuUserID = dbfianl.ER_FinalExaminationStudent.FirstOrDefault().UserID;
- if (stuUserList.Where(x => x.UserID == stuUserID).FirstOrDefault() != null)
- {
- grademajorName = stuUserList.Where(x => x.UserID == stuUserID).FirstOrDefault().CF_Classmajor.CF_Grademajor.Name;
- //如果存在同一条期末设定有多个年级专业的学生,随机取一个年级专业名称
- }
- if (finalExaminationView.Key.ExamsCategoryID == (int)CF_ExamsCategory.Resit)
- {
- string className = finalExaminationView.Key.CourseName + " - " + grademajorName + "-补考";
- finalExamination.FinalExaminationID = Guid.NewGuid();
- finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
- finalExamination.GradeYearID = dbfianl.GradeYearID;
- finalExamination.DepartmentID = dbfianl.DepartmentID;
- finalExamination.ClassName = className;
- finalExamination.CoursematerialID = dbfianl.CoursematerialID;
- finalExamination.CourseTypeID = dbfianl.CourseTypeID;
- finalExamination.ExamsCategoryID = finalExaminationView.Key.ExamsCategoryID;
- //(int)EMIS.ViewModel.CF_ExamsCategory.Resit;
- finalExamination.ExaminationModeID = dbfianl.ExaminationModeID;
- finalExamination.Credit = dbfianl.Credit;
- //总学时
- finalExamination.TotalHours = dbfianl.TotalHours;
- finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- finalExamination.ResultTypeID = dbfianl.ResultTypeID;
- finalExamination.CollegeID = dbfianl.CollegeID;
- finalExamination.IsEntry = false;
- finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
- SetNewStatus(finalExamination);
- }
- else
- {
- string className = finalExaminationView.Key.CourseName + " - " + grademajorName + " - " + IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExamsCategory.ToString()).Where(x => x.Value == finalExaminationView.Key.ExamsCategoryID).Select(x => x.Name).FirstOrDefault();
- finalExamination.FinalExaminationID = Guid.NewGuid();
- finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
- finalExamination.GradeYearID = dbfianl.GradeYearID;
- finalExamination.DepartmentID = dbfianl.DepartmentID;
- finalExamination.ClassName = className;
- finalExamination.CoursematerialID = dbfianl.CoursematerialID;
- finalExamination.CourseTypeID = dbfianl.CourseTypeID;
- finalExamination.ExamsCategoryID = finalExaminationView.Key.ExamsCategoryID;
- //(int)EMIS.ViewModel.CF_ExamsCategory.Resit;
- finalExamination.ExaminationModeID = dbfianl.ExaminationModeID;
- finalExamination.Credit = dbfianl.Credit;
- //总学时
- finalExamination.TotalHours = dbfianl.TotalHours;
- finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- finalExamination.ResultTypeID = dbfianl.ResultTypeID;
- finalExamination.CollegeID = dbfianl.CollegeID;
- finalExamination.IsEntry = false;
- finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
- SetNewStatus(finalExamination);
- }
- var queryStudent = finalExaminationView.Select(x => new ER_FinalExaminationStudent
- {
- FinalExaminationStudentID = Guid.NewGuid(),
- FinalExaminationID = finalExamination.FinalExaminationID,
- UserID = x.UserID,
- SchoolyearNumID = x.SchoolyearNumID,
- StarttermID = x.StartTermID,
- RecordStatus = (int)SYS_STATUS.USABLE,
- CreateTime = DateTime.Now,
- CreateUserID = curUser.UserID,
- ModifyTime = DateTime.Now,
- ModifyUserID = curUser.UserID
- });
- finalExamination.ER_FinalExaminationStudent = new HashSet<ER_FinalExaminationStudent>(queryStudent.ToList());
- listFinalExamination.Add(finalExamination);
- }
- UnitOfWork.BulkInsert(listFinalExamination);
- UnitOfWork.BulkInsert(listFinalExamination.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
- //UnitOfWork.BulkInsert(SlistFinalExamination);
- //UnitOfWork.BulkInsert(SlistFinalExamination.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|