12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.DataLogic.ScoreManage;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.ViewModel.Students;
- using EMIS.DataLogic.Repositories;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.Utility.FormValidate;
- using EMIS.DataLogic.ChargeManage.ArrearsSituation;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.CacheManage;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class FinalExaminationServices : BaseWorkflowServices<ER_FinalExamination>, IFinalExaminationServices
- {
- public Lazy<IStudentScoreServices> StudentScoreServices { get; set; }
- public ScoreDAL scoreDAL { get; set; }
- public FinalExaminationDAL finalExaminationDAL { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public ScoreRepository scoreRepository { get; set; }
- public MisconductDAL MisconductDAL { get; set; }
- public Lazy<IScoreServices> ScoreServices { get; set; }
- public ExamsStateSettingDAL examsStateSettingDAL { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- public RetakePlanStudentRepository retakePlanStudentRepository { get; set; }
- protected Func<IQueryable<FinalExaminationView>, IQueryable<FinalExaminationView>> DataRangeFunction { get; set; }
- protected Func<IQueryable<ResitStudentView>, IQueryable<ResitStudentView>> GerenateResitDataRangeFunction { get; set; }
- protected Func<Guid?, Expression<Func<ER_FinalExamination, bool>>> CollegeExpression { get; set; }
- public FinalExaminationServices()
- {
- DataRangeFunction = (x => this.GetQueryByDataRangeByDepartment(x));
- GerenateResitDataRangeFunction = (x => this.GetQueryByDataRangeByDepartment(x));
- DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByDepartment<ER_FinalExamination>(x, y));
- CollegeExpression = (w => (x => x.CF_Department.CF_College.CollegeID == w));
- }
- /// <summary>
- /// 获取工作流可录入状态
- /// </summary>
- /// <returns></returns>
- public int? GetIsEntryStatus()
- {
- var status = this.GetStatusViewList().Where(x => (x.Description ?? "").Contains("[ENTRY]")).Select(x => x.ID).FirstOrDefault();
- return status;
- }
- /// <summary>
- /// 查询期末设定
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="courseQualityID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ScoreManage.FinalExaminationView> GetFinalExaminationViewGrid(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID,
- Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus, int? gradeYearID, int pageIndex, int pageSize)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- exp = exp.And(this.CollegeExpression(collegeID));
- if (departmentID.HasValue)
- exp = exp.And(x => x.DepartmentID == departmentID);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- if (courseTypeID.HasValue)
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- if (examsCategoryID.HasValue)
- exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
- if (examinationType.HasValue)
- exp = exp.And(x => x.ExaminationType == examinationType);
- if (approvalStatus.HasValue)
- exp = exp.And(x => x.ApprovalStatus == approvalStatus);
- if (gradeYearID.HasValue)
- exp = exp.And(x => x.GradeYearID == gradeYearID);
- var query = finalExaminationDAL.GetFinalExaminationViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- var resultQueryable = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName);
-
- var result = resultQueryable.ToGridResultSet<FinalExaminationView>(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询期末设定
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="courseQualityID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public List<ViewModel.ScoreManage.FinalExaminationView> GetFinalExaminationViewList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- exp = exp.And(this.CollegeExpression(collegeID));
- if (departmentID.HasValue)
- exp = exp.And(x => x.DepartmentID == departmentID);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- if (courseTypeID.HasValue)
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- if (examsCategoryID.HasValue)
- exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
- if (examinationType.HasValue)
- exp = exp.And(x => x.ExaminationType == examinationType);
- if (approvalStatus.HasValue)
- exp = exp.And(x => x.ApprovalStatus == approvalStatus);
- var query = finalExaminationDAL.GetFinalExaminationViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询考试设定相关学生明细表,按兵良要求,暂时用于补考设定学生明细导出功能
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="examsCategoryID"></param>
- /// <param name="examinationType"></param>
- /// <param name="approvalStatus"></param>
- /// <returns></returns>
- public List<ViewModel.ScoreManage.ResitStudentView> GetFinalExaminationStudentDetailsList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus, int? gradeYearID, List<Guid?> FinalExaminationIDList)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (FinalExaminationIDList != null)
- exp = exp.And(x => FinalExaminationIDList.Contains(x.FinalExaminationID));
- if (collegeID.HasValue)
- exp = exp.And(this.CollegeExpression(collegeID));
- if (departmentID.HasValue)
- exp = exp.And(x => x.DepartmentID == departmentID);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- if (courseTypeID.HasValue)
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- if (examsCategoryID.HasValue)
- exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
- if (examinationType.HasValue)
- exp = exp.And(x => x.ExaminationType == examinationType);
- if (approvalStatus.HasValue)
- exp = exp.And(x => x.ApprovalStatus == approvalStatus);
- if (gradeYearID.HasValue)
- exp = exp.And(x => x.GradeYearID == gradeYearID);
- var query = finalExaminationDAL.GetFinalExaminationStudentDetailsList(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- var result = this.GerenateResitDataRangeFunction(query).OrderBy(x => x.SchoolyearCode).ThenBy(x => x.ClassmajorNo).ThenByDescending(x => x.CourseName).ToList();
- //result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询期末设定实体
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public ViewModel.ScoreManage.FinalExaminationView GetFinalExaminationView(Guid? finalExaminationID)
- {
- Expression<Func<ER_FinalExamination, bool>> exp = (x => x.FinalExaminationID == finalExaminationID);
- return finalExaminationDAL.GetFinalExaminationViewQueryable(exp).FirstOrDefault();
- }
- /// <summary>
- /// 查询期末设定实体
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public Entities.ER_FinalExamination GetFinalExamination(Guid? finalExaminationID)
- {
- return finalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_FinalExaminationStudent), (x => x.ER_FinalExaminationStudent.Select(w => w.CF_Student)), (x => x.ER_Score), (x => x.CF_Schoolyear));
- }
- /// <summary>
- /// 添加,加上总学时
- /// </summary>
- /// <param name="finalExaminationView"></param>
- public void FinalExaminationAdd(ViewModel.ScoreManage.FinalExaminationView finalExaminationView, List<Guid?> ClassmajorIDList)
- {
- try
- {
- var statusList = this.GetStatusViewList(); //获取工作流列表
- ER_FinalExamination finalExamination = null;
- var schoolyear = SchoolYearServices.Value.GetSchoolYear(finalExaminationView.SchoolyearID);
- var listStudent=new List<CF_Student>();
- //var finalExaminationRepeat = finalExaminationDAL.finalExaminationRepository.GetSingle(x => x.ClassName == finalExaminationView.ClassName && x.FinalExaminationID != finalExaminationView.FinalExaminationID);
- //if (finalExaminationRepeat!=null)
- //{
- // throw new Exception("录入班级名称重复!");
- //}
- //取消期末设定,补考设定 录入班级名称唯一性判断
- if (finalExaminationView.isAutoAdd==true)
- {
- listStudent= finalExaminationDAL.studentRepository.GetList(x => ClassmajorIDList.Contains(x.ClassmajorID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();
- }
- var userIDs = listStudent.Select(x => x.UserID).ToList();
- if (finalExaminationView.FinalExaminationID == null || finalExaminationView.FinalExaminationID == Guid.Empty)
- {
- finalExaminationView.IsEntry = false;
- finalExamination = new ER_FinalExamination();
- finalExamination.FinalExaminationID = Guid.NewGuid();
- finalExamination.SchoolyearID = finalExaminationView.SchoolyearID;
- finalExamination.GradeYearID = finalExaminationView.GradeYearID;
- finalExamination.CollegeID = finalExaminationView.CollegeID;
- //finalExamination.ClassmajorID = finalExaminationView.ClassmajorID;
- finalExamination.DepartmentID = finalExaminationView.DepartmentID;
- finalExamination.ClassName = finalExaminationView.ClassName;
- finalExamination.CoursematerialID = finalExaminationView.CoursematerialID;
- finalExamination.CourseTypeID = finalExaminationView.CourseTypeID;
- finalExamination.ExamsCategoryID = finalExaminationView.ExamsCategoryID;
- finalExamination.ExaminationModeID = finalExaminationView.ExaminationModeID;
- finalExamination.Credit = finalExaminationView.Credit;
- //总学时
- finalExamination.TotalHours = finalExaminationView.TotalHours;
- finalExamination.ExamsDatetime = finalExaminationView.ExamsDatetime;
- finalExamination.ResultTypeID = finalExaminationView.ResultTypeID;
- finalExamination.CreatorUserID = finalExaminationView.CreatorUserID;
- finalExamination.EntryDeadlineTime = finalExaminationView.EntryDeadlineTime;
- finalExamination.IsEntry = finalExaminationView.IsEntry;
- finalExamination.ExaminationType = finalExaminationView.ExaminationType;
- finalExamination.ApprovalStatus = this.GetStartStatus();
- finalExamination.IsGenerate = false;
- SetNewStatus(finalExamination);
- UnitOfWork.Add(finalExamination);
- if (finalExaminationView.IsEntry == true)
- { //当考试设定改为可录入时,调用工作流
- StartUp(new List<Guid> { finalExamination.FinalExaminationID }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, null);
- }
- }
- else
- {
- finalExamination = GetFinalExamination(finalExaminationView.FinalExaminationID);
- if (finalExamination == null)
- {
- throw new Exception("未找到相对应的数据!");
- }
- //审核中的数据(节点的Description为[AP])和end的节点不能修改
- var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
- if (status.Contains(finalExamination.ApprovalStatus))
- {
- //|| finalExamination.ApprovalStatus == (int)EMIS.ViewModel.CF_ScoreState.Rebut 取消审核驳回,在期末设定及补考设定功能中应可进行信息修改 2016年11月4日14:56:58
- throw new Exception("该数据已经成绩录入或者已审核,不能做任何修改!");
- }
- finalExamination.SchoolyearID = finalExaminationView.SchoolyearID;
- finalExamination.GradeYearID = finalExaminationView.GradeYearID;
- finalExamination.CollegeID = finalExaminationView.CollegeID;
- //finalExamination.ClassmajorID = finalExaminationView.ClassmajorID;
- finalExamination.DepartmentID = finalExaminationView.DepartmentID;
- finalExamination.ClassName = finalExaminationView.ClassName;
- finalExamination.CoursematerialID = finalExaminationView.CoursematerialID;
- finalExamination.CourseTypeID = finalExaminationView.CourseTypeID;
- finalExamination.ExamsCategoryID = finalExaminationView.ExamsCategoryID;
- finalExamination.ExaminationModeID = finalExaminationView.ExaminationModeID;
- finalExamination.Credit = finalExaminationView.Credit;
- //总学时
- finalExamination.TotalHours = finalExaminationView.TotalHours;
- finalExamination.ExamsDatetime = finalExaminationView.ExamsDatetime;
- finalExamination.ResultTypeID = finalExaminationView.ResultTypeID;
- finalExamination.CreatorUserID = finalExaminationView.CreatorUserID;
- finalExamination.EntryDeadlineTime = finalExaminationView.EntryDeadlineTime;
- finalExamination.ExaminationType = finalExaminationView.ExaminationType;
- if (finalExamination.IsEntry != finalExaminationView.IsEntry && finalExaminationView.IsEntry == true)
- { //当考试设定改为可录入时,调用工作流
- StartUp(new List<Guid> { finalExamination.FinalExaminationID }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, "");
- finalExamination.IsEntry = finalExaminationView.IsEntry;
- }
- //if (finalExamination.ApprovalStatus == (int)EMIS.ViewModel.CF_ScoreState.Rebut)
- //{
- // finalExamination.ApprovalStatus = (int)EMIS.ViewModel.CF_ScoreState.Rebut;
- //}
- //else
- //{
- // finalExamination.ApprovalStatus = finalExaminationView.IsEntry == true ? (int)EMIS.ViewModel.CF_ScoreState.CanInput : (int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- //}
- SetModifyStatus(finalExamination);
- }
-
- List<ER_FinalExaminationStudent> finalExaminationStudentList = new List<ER_FinalExaminationStudent>();
- //如果是补考或者毕业补考,需要读出添加学生的期末考试状况,注意还有补考设定编辑的那一边
- if (finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit || finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
- {
- finalExaminationStudentList = finalExaminationDAL
- .GetFinalExaminationByResitStudent(x => x.CoursematerialID == finalExaminationView.CoursematerialID,
- userIDs.Select(x => (Guid?)x).ToList()).ToList();
- }
- List<ER_FinalExaminationStudent> newFinalExaminationStudentList = new List<ER_FinalExaminationStudent>();
- foreach (var student in listStudent)
- {
- int? schoolyearNumID, startTermID;
- schoolyearNumID = (finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) - (finalExamination.CF_Schoolyear.SchoolcodeID == student.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1;
- startTermID = finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1;
- var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
- if (lastFinalExamination != null)
- {
- schoolyearNumID = lastFinalExamination.SchoolyearNumID;
- startTermID = lastFinalExamination.StarttermID;
- }
- newFinalExaminationStudentList.Add(new ER_FinalExaminationStudent
- {
- FinalExaminationStudentID = Guid.NewGuid(),
- FinalExaminationID = finalExamination.FinalExaminationID,
- SchoolyearNumID = schoolyearNumID,
- StarttermID = startTermID,
- UserID = student.UserID,
- RecordStatus = (int)SYS_STATUS.USABLE,
- CreateUserID = CustomPrincipal.Current.UserID,
- CreateTime = DateTime.Now,
- ModifyUserID = CustomPrincipal.Current.UserID,
- ModifyTime = DateTime.Now
- });
- }
- if (finalExaminationView.isAutoAdd == true && ClassmajorIDList.Count>0)
- {
- UnitOfWork.Remove<ER_FinalExaminationStudent>(x => x.FinalExaminationID == finalExamination.FinalExaminationID);
- UnitOfWork.Remove<ER_Score>(x => !userIDs.Contains((Guid)x.UserID) && x.FinalExaminationID == finalExamination.FinalExaminationID);
- }
- UnitOfWork.Commit();
- UnitOfWork.BulkInsert<ER_FinalExaminationStudent>(newFinalExaminationStudentList);
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- public void FinalExaminationDelete(List<Guid?> finalExaminationIDs)
- {
- try
- {
- if (finalExaminationIDs.Count > 0)
- {
- var startStatus=this.GetStartStatus();
- var finalExamination = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID) && x.ApprovalStatus != startStatus).FirstOrDefault();
- if (finalExamination != null)
- throw new Exception("不是未开放状态,不能删除该考试设定!");
- UnitOfWork.Remove<ER_FinalExaminationStudent>(x => finalExaminationIDs.Contains(x.FinalExaminationID));
- UnitOfWork.Remove<ER_FinalExamination>(x => finalExaminationIDs.Contains(x.FinalExaminationID));
- this.UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除学生
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- public void FinalExaminationStudentDelete(Guid finalExaminationID,List<Guid?> UserID)
- {
- try
- {
- if (UserID.Count > 0)
- {
- var StatusViewList=this.GetStatusViewList();
- var status = StatusViewList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
- var finalExamination = finalExaminationDAL.finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID&& status.Contains(x.ApprovalStatus)).FirstOrDefault();
- if (finalExamination != null)
- throw new Exception("不是未开放状态或重录待审状态,不能删除该考试设定的学生!");
- var query = scoreDAL.finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID, (x => x.CF_Schoolyear), x => x.ER_FinalExaminationStudent).ToList();
- var scoreList = scoreRepository.GetList(x => x.FinalExaminationID == finalExaminationID && UserID.Contains(x.UserID)).ToList();
- foreach (var score in scoreList)
- {
- if (score.RecordStatus == (int)SYS_STATUS.UNUSABLE)
- {
- throw new Exception("选中的学生不是能够重录的学生,不能删除该考试设定的学生!");
- }
- }
- var scoreIDList = scoreList.Select(x => x.ScoreID).ToList();
- UnitOfWork.Remove<ER_ScoreDetail>(x => scoreIDList.Contains(x.ScoreID.Value));
- UnitOfWork.Remove<ER_Score>(x => x.FinalExaminationID == finalExaminationID && UserID.Contains((Guid)x.UserID));
- UnitOfWork.Remove<ER_FinalExaminationStudent>(x => x.FinalExaminationID == finalExaminationID && UserID.Contains(x.UserID));
-
- this.UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 根据教学任务生成期末设定,加上总学时
- /// </summary>
- public void GenerateFinalExamination(Guid? schoolyearID, Guid? collegeID, int? gradeID, int? standardID, bool isGenerateNotSubmit)
- {
- try
- {
- List<CF_Classmajor> listClassmajor = new List<CF_Classmajor>();
- List<ER_FinalExamination> list = new List<ER_FinalExamination>();
- Expression<Func<EM_EducationMissionClass, bool>> educationMissionClassExp = (x => true);
- Expression<Func<EM_EducationMission, bool>> exp = x => true;
- if (!isGenerateNotSubmit)
- {
- educationMissionClassExp = (x => x.RecordStatus != (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted);
- }
-
- var schoolYear = this.SchoolYearServices.Value.GetSchoolYear(schoolyearID);
- var queryEducationMission = this.DataRangeFunction(finalExaminationDAL.GetEducationMission(schoolyearID, exp, educationMissionClassExp)); //获取教学任务
- if (collegeID.HasValue)
- {
- queryEducationMission = queryEducationMission.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue && gradeID != -1)
- {
- queryEducationMission = queryEducationMission.Where(x => x.GradeYearID == gradeID);
- }
- if (standardID.HasValue)
- {
- queryEducationMission = queryEducationMission.Where(x => x.StandardID == standardID);
- }
- var educationMissionIDs = queryEducationMission.Select(x => x.EducationMissionID).ToList(); //教学任务ID
- var queryEducationMissionClassList = finalExaminationDAL.educationMissionClassRepository
- .GetList(x => educationMissionIDs.Contains(x.EducationMissionID),
- (x => x.EM_MissionClassTeacher),
- (x => x.EM_EducationSchedulingClass.Select(w => w.ES_AdultEducationSchedule.Select(y => y.ES_AdultEducationScheduleTeacher))),
- (x => x.EM_CourseProcess.Select(w => w.EM_CourseProcessTeacher))).ToList();
- var educationMissionClassIDs = queryEducationMissionClassList.ToList().Select(x => x.EducationMissionClassID).ToList();
- var queryEducationSchedulingClass = finalExaminationDAL.educationSchedulingClassRepository
- .GetList(x => educationMissionClassIDs.Contains((Guid)x.EducationMissionClassID), (x => x.EM_EducationMissionClass),
- (x => x.CF_Student),
- (x => x.CF_Student.Select(w => w.CF_Classmajor.CF_Grademajor)),
- (x => x.CF_Student.Select(w => w.ER_RetakePlanStudent))).ToList();
- var EducationMissionList = queryEducationMission.ToList();
- //查出由重修计划生成的教学任务的ID,通过重修名单表ER_RetakePlanStudent的EducationMissionID确定
- var retakePlanEducationMissionIDs = retakePlanStudentRepository.GetList(x => educationMissionIDs.Contains(x.EducationMissionID)).Select(x => x.EducationMissionID).ToList();
- //重修考试性质
- int? retakeExamsCategoryID = ParameterServices.Value.GetParameterValue<int>(CF_ParameterType.RetakeExamsCatagoryID);
- var startStatusID = this.GetStartStatus();
- foreach (var educationMission in EducationMissionList)
- {
- var maxCourseTeacher = (
- from missionClass in queryEducationMissionClassList
- from courseProcess in missionClass.EM_CourseProcess
- from courseTeacher in courseProcess.EM_CourseProcessTeacher
- where courseTeacher.TeachType == (int)EMIS.ViewModel.EM_TeachingMethod.Lecturer
- && missionClass.EducationMissionID == educationMission.EducationMissionID
- group courseProcess by courseTeacher.UserID into g
- select new { UserID = g.Key, CourseTimes = g.Sum(x => x.Times) }
- ).OrderByDescending(x => x.CourseTimes).FirstOrDefault();
- if (maxCourseTeacher == null)
- {
- maxCourseTeacher = (
- from missionClass in queryEducationMissionClassList
- from teacher in missionClass.EM_MissionClassTeacher
- from schedule in missionClass.EM_EducationSchedulingClass
- .SelectMany(x => x.ES_AdultEducationSchedule)
- .SelectMany(x => x.ES_AdultEducationScheduleTeacher)
- .Where(x => x.UserID == teacher.UserID)
- .GroupBy(x => x.UserID)
- .Select(x => new { UserID = x.Key, CourseTimes = (int?)x.Count() }).DefaultIfEmpty()
- where teacher.TeachType == (int)EMIS.ViewModel.EM_TeachingMethod.Lecturer
- && missionClass.EducationMissionID == educationMission.EducationMissionID
- select new { UserID = teacher.UserID, CourseTimes = (int?)(schedule == null ? 0 : schedule.CourseTimes) }
- ).OrderByDescending(x => x.CourseTimes).FirstOrDefault();
- }
- var userID = maxCourseTeacher != null ? maxCourseTeacher.UserID : null;
- var mainEducationMissionClass = queryEducationMissionClassList.Where(x => x.EducationMissionID == educationMission.EducationMissionID).FirstOrDefault();
- var mainEducationSchedulingClassList = queryEducationSchedulingClass.Where(x => x.EM_EducationMissionClass.EducationMissionID == educationMission.EducationMissionID).ToList();
- var studentList = mainEducationSchedulingClassList.SelectMany(x => x.CF_Student).GroupBy(x => x.UserID)
- .Select(x => x.FirstOrDefault()).ToList();
- ER_FinalExamination finalExamination = new ER_FinalExamination();
- finalExamination.FinalExaminationID = Guid.NewGuid();
- finalExamination.SchoolyearID = educationMission.SchoolyearID;
- //如果教学任务中的年级为空,默认取学年学期对应的学年,适用于选修课(任选课)
- finalExamination.GradeYearID = educationMission.GradeYearID == null ? schoolYear.Years : educationMission.GradeYearID;
- if (educationMission.HandleModeID == (int)CF_HandleMode.MinorCourse)
- {
- string gradeStr = educationMission.ClassName.Substring(0, 4);
- int grade = Convert.ToInt32(gradeStr);
- finalExamination.GradeYearID = grade;
- }
- else
- {
- //如果教学任务中的年级为空,默认取学年学期对应的学年,适用于选修课(任选课)
- finalExamination.GradeYearID = educationMission.GradeYearID == null ? schoolYear.Years : educationMission.GradeYearID;
- }
- finalExamination.DepartmentID = educationMission.DepartmentID;
- finalExamination.ClassName = educationMission.ClassName;
- finalExamination.CoursematerialID = educationMission.CoursematerialID;
- finalExamination.EducationMissionID = educationMission.EducationMissionID;
- finalExamination.CourseTypeID = educationMission.CourseTypeID;
- //由重修计划生成的教学任务,其考试性质为重修设置 -> 参数设定设置的重修考试性质
- if (retakePlanEducationMissionIDs.Contains(educationMission.EducationMissionID))
- finalExamination.ExamsCategoryID = retakeExamsCategoryID;
- else
- finalExamination.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam;
- finalExamination.ExaminationModeID = educationMission.ExaminationModeID;
- finalExamination.Credit = educationMission.Credit;
- //总学时
- finalExamination.TotalHours = educationMission.TotalHours;
- finalExamination.CreatorUserID = userID;
- finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.FinalExamination;
- finalExamination.ApprovalStatus = startStatusID;//(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- finalExamination.ResultTypeID = educationMission.ResultTypeID;
- finalExamination.CollegeID = educationMission.CollegeID;
- finalExamination.ClassmajorID = educationMission.ClassmajorID;
- finalExamination.IsGenerate = false;
- finalExamination.IsEntry = false;
- SetNewStatus(finalExamination);
- finalExamination.ER_FinalExaminationStudent = new HashSet<ER_FinalExaminationStudent>();
- foreach (var student in studentList)
- {
- //(schoolyear - startSchoolyear.Value - (specialtyCourse.SchoolcodeID == grademajor.SchoolcodeID ? 0 : 1)) / 2 + 1 = specialtyCourse.SchoolyearNumID
- var gradeSchoolyearValue = ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1));
- //需要检查生成的学生有否该教学任务的重修记录,如果有,需要将开课学年和开课学期替换成重修记录中的开课学年和开课学期
- var retakePlanStudent = student.ER_RetakePlanStudent.FirstOrDefault(x => x.EducationMissionID == educationMission.EducationMissionID);
- var newFinalExaminationStudent = new ER_FinalExaminationStudent
- {
- FinalExaminationStudentID = Guid.NewGuid(),
- FinalExaminationID = finalExamination.FinalExaminationID,
- SchoolyearNumID = (retakePlanStudent != null) ? retakePlanStudent.SchoolyearNumID :
- (schoolYear.Value - gradeSchoolyearValue - (schoolYear.SchoolcodeID == student.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1,
- StarttermID = (retakePlanStudent != null) ? retakePlanStudent.StarttermID :
- (schoolYear.Value - gradeSchoolyearValue + 1),
- UserID = student.UserID
- };
- this.SetNewStatus(newFinalExaminationStudent);
- finalExamination.ER_FinalExaminationStudent.Add(newFinalExaminationStudent);
- }
- list.Add(finalExamination);
- }
- UnitOfWork.BulkInsert(list);
- UnitOfWork.BulkInsert(list.SelectMany(x => x.ER_FinalExaminationStudent).ToList());
- }
- catch (Exception ex)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取期末设定学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<BaseStudentView> GetFinalExaminationStudent(Guid? finalExaminationID)
- {
- return finalExaminationDAL.GetFinalExaminationStudentList(finalExaminationID,null).OrderBy(x => x.LoginID).ToGridResultSet<BaseStudentView>();
- }
- /// <summary>
- /// 获取期末设定学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public BaseStudentView GetFinalExaminationStudentForStudentAdd(Guid? finalExaminationID,Guid? userID)
- {
- return finalExaminationDAL.GetFinalExaminationStudentList(finalExaminationID, userID).FirstOrDefault();
- }
- /// <summary>
- /// 添加期末设定学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <param name="userIDs"></param>
- public void FinalExaminationStudentAdd(Guid? finalExaminationID, List<BaseStudentView> listBaseStudentView)
- {
- try
- {
- var queryUserIDList = listBaseStudentView.Select(x => x.UserID).ToList();
- ER_FinalExamination finalExamination = GetFinalExamination(finalExaminationID);
- if (finalExamination != null)
- {
- var statusList = this.GetStatusViewList();
- //审核中的数据(节点的Description为[AP])和end的节点不能修改
- var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") && (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
- List<ER_FinalExaminationStudent> finalExaminationStudentList = new List<ER_FinalExaminationStudent>();
- if (status.Contains(finalExamination.ApprovalStatus))
- {
- throw new Exception("该数据已经提交或已审核,不能修改学生!");
- }
- UnitOfWork.Remove<ER_FinalExaminationStudent>(x => x.FinalExaminationID == finalExamination.FinalExaminationID);
- UnitOfWork.Remove<ER_Score>(x => !queryUserIDList.Contains((Guid)x.UserID) && x.FinalExaminationID == finalExamination.FinalExaminationID);
- //如果是补考或者毕业补考,需要读出添加学生的期末考试状况,注意还有补考设定编辑的那一边
- if (finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit || finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
- {
- finalExaminationStudentList = finalExaminationDAL
- .GetFinalExaminationByResitStudent(x => x.FinalExaminationID == finalExaminationID,
- queryUserIDList.Select(x => (Guid?)x).ToList()).ToList();
- }
- var listStudent = finalExaminationDAL.studentRepository.GetList(x => queryUserIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();
- foreach (var student in listStudent)
- {
- int? schoolyearNumID, startTermID;
- schoolyearNumID = (finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) - (finalExamination.CF_Schoolyear.SchoolcodeID == student.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1;
- startTermID = finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1;
- var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
- if (lastFinalExamination != null)
- {
- schoolyearNumID = lastFinalExamination.SchoolyearNumID;
- startTermID = lastFinalExamination.StarttermID;
- }
- finalExamination.ER_FinalExaminationStudent.Add(new ER_FinalExaminationStudent
- {
- FinalExaminationStudentID = Guid.NewGuid(),
- FinalExaminationID = finalExamination.FinalExaminationID,
- SchoolyearNumID = schoolyearNumID,
- StarttermID = startTermID,
- UserID = student.UserID,
- RecordStatus = (int)SYS_STATUS.USABLE,
- CreateUserID = CustomPrincipal.Current.UserID,
- CreateTime = DateTime.Now,
- ModifyUserID = CustomPrincipal.Current.UserID,
- ModifyTime = DateTime.Now
- });
- }
- UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 添加期末设定学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <param name="userIDs"></param>
- public void StudentAdd(FinalExaminationView finalExaminationView)
- {
- try
- {
- List<Guid?> sutdentIDList = new List<Guid?>();
- sutdentIDList.Add(finalExaminationView.UserID);
- var queryUserIDList = sutdentIDList;
- ER_FinalExamination finalExamination = GetFinalExamination(finalExaminationView.FinalExaminationID);
- if (finalExamination != null)
- {
- var addOrUpdate = finalExaminationDAL.FinalExaminationStudentRepository.Entities.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID && x.UserID == finalExaminationView.UserID).FirstOrDefault();
-
- var statusList = this.GetStatusViewList();
- //审核中的数据(节点的Description为[AP])和end的节点不能修改
- var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
- List<ER_FinalExaminationStudent> finalExaminationStudentList = new List<ER_FinalExaminationStudent>();
- if (status.Contains(finalExamination.ApprovalStatus))
- {
- throw new Exception("不是未开放状态或重录待审状态,不能更变该考试设定的学生!");
- }
- //学生在数据库中的考试科目
- var OtrerStudentList = finalExaminationDAL.FinalExaminationStudentRepository.GetList(x => queryUserIDList.Contains((Guid)x.UserID) && x.FinalExaminationID != finalExaminationView.FinalExaminationID).ToList();
- //学生在数据库中的期末设定ID
- var OtrerFinalExaminationIDList = finalExaminationDAL.FinalExaminationStudentRepository.GetList(x => queryUserIDList.Contains((Guid)x.UserID) && x.FinalExaminationID != finalExaminationView.FinalExaminationID).Select(x => x.FinalExaminationID).ToList();
- //学生在数据库中的期末设定
- var OtrerFinalExaminationList = finalExaminationDAL.finalExaminationRepository.GetList(x => OtrerFinalExaminationIDList.Contains(x.FinalExaminationID)).ToList();
- //foreach (var of in OtrerFinalExaminationList)
- //{
- // if (of.CoursematerialID == finalExamination.CoursematerialID
- // && of.ExamsCategoryID == finalExamination.ExamsCategoryID)
- // {
- // int? schoolyearNumID, startTermID;
- // double StarttermID = Convert.ToDouble(finalExaminationView.StarttermID);
- // double two = 2.0;
- // double Startterm = Convert.ToDouble(StarttermID / two);
- // schoolyearNumID = Convert.ToInt32(Math.Ceiling(Startterm));
- // startTermID = finalExaminationView.StarttermID;
- // foreach (var os in OtrerStudentList)
- // {
- // if (os.StarttermID == startTermID)
- // {
- // throw new Exception("该学生数据重复,重复的录入班名称为:" + of.ClassName + "请检查!");
- // }
- // }
- // }
- //}
- //如果是补考或者毕业补考,需要读出添加学生的期末考试状况,注意还有补考设定编辑的那一边
- if (finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit || finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
- {
- finalExaminationStudentList = finalExaminationDAL
- .GetFinalExaminationByResitStudent(x => x.FinalExaminationID == finalExaminationView.FinalExaminationID,
- queryUserIDList.Select(x => (Guid?)x).ToList()).ToList();
- }
- var listStudent = finalExaminationDAL.studentRepository.GetList(x => queryUserIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();
- if (addOrUpdate == null)
- {
- foreach (var student in listStudent)
- {
- int? schoolyearNumID, startTermID;
- double StarttermID = Convert.ToDouble(finalExaminationView.StarttermID);
- double two = 2.0;
- double Startterm = Convert.ToDouble(StarttermID / two);
- schoolyearNumID = Convert.ToInt32(Math.Ceiling(Startterm));
- startTermID = finalExaminationView.StarttermID;
- var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
- if (lastFinalExamination != null)
- {
- schoolyearNumID = lastFinalExamination.SchoolyearNumID;
- startTermID = lastFinalExamination.StarttermID;
- }
- finalExamination.ER_FinalExaminationStudent.Add(new ER_FinalExaminationStudent
- {
- FinalExaminationStudentID = Guid.NewGuid(),
- FinalExaminationID = finalExamination.FinalExaminationID,
- SchoolyearNumID = schoolyearNumID,
- StarttermID = startTermID,
- UserID = student.UserID,
- RecordStatus = (int)SYS_STATUS.USABLE,
- CreateUserID = CustomPrincipal.Current.UserID,
- CreateTime = DateTime.Now,
- ModifyUserID = CustomPrincipal.Current.UserID,
- ModifyTime = DateTime.Now
- });
- }
- }
- else
- {
- foreach (var student in listStudent)
- {
- int? schoolyearNumID, startTermID;
- double StarttermID = Convert.ToDouble(finalExaminationView.StarttermID);
- double two = 2.0;
- double Startterm = Convert.ToDouble(StarttermID / two);
- schoolyearNumID = Convert.ToInt32(Math.Ceiling(Startterm));
- startTermID = finalExaminationView.StarttermID;
- var lastFinalExamination = finalExaminationStudentList.FirstOrDefault(x => x.UserID == student.UserID);
- if (lastFinalExamination != null)
- {
- schoolyearNumID = lastFinalExamination.SchoolyearNumID;
- startTermID = lastFinalExamination.StarttermID;
- }
- addOrUpdate.FinalExaminationID = finalExamination.FinalExaminationID;
- addOrUpdate.SchoolyearNumID = schoolyearNumID;
- addOrUpdate.StarttermID = startTermID;
- addOrUpdate.UserID = student.UserID;
- addOrUpdate.RecordStatus = (int)SYS_STATUS.USABLE;
- addOrUpdate.CreateUserID = CustomPrincipal.Current.UserID;
- addOrUpdate.CreateTime = DateTime.Now;
- addOrUpdate.ModifyUserID = CustomPrincipal.Current.UserID;
- addOrUpdate.ModifyTime = DateTime.Now;
- }
-
- }
- UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 期末生成,按兵良要求,加上院系所、年级、专业下拉条件 增加班级条件,加上总学时
- /// </summary>
- public virtual 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 queryFinalExamination = studentList.GroupBy(x => new
- {
- 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,
- });
- //var queryFinal = SuspensionsutdentList.GroupBy(x => new
- //{
- // x.Year,
- // x.CollegeID,
- // x.GrademajorID,
- // x.GrademajorName,
- // x.CoursematerialID,
- // x.DepartmentID,
- // x.CourseName,
- // x.CourseTypeID,
- // x.ExaminationModeID,
- // x.StartTermID,
- // x.Credit,
- // x.ResultTypeID
- //});
- foreach (var finalExaminationView in queryFinalExamination)
- {
- ER_FinalExamination finalExamination = new ER_FinalExamination();
- if (finalExaminationView.Key.ExamsCategoryID == (int)CF_ExamsCategory.Resit)
- {
- string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + "-补考";
- finalExamination.FinalExaminationID = Guid.NewGuid();
- finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
- finalExamination.GradeYearID = finalExaminationView.Key.Year;
- finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
- finalExamination.ClassName = className;
- finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
- finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
- finalExamination.ExamsCategoryID = finalExaminationView.Key.ExamsCategoryID;
- //(int)EMIS.ViewModel.CF_ExamsCategory.Resit;
- finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
- finalExamination.Credit = finalExaminationView.Key.Credit;
- //总学时
- finalExamination.TotalHours = finalExaminationView.Key.TotalHours;
- finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
- finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
- finalExamination.IsEntry = false;
- finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
- SetNewStatus(finalExamination);
- }
- else
- {
- string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.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 = finalExaminationView.Key.Year;
- finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
- finalExamination.ClassName = className;
- finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
- finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
- finalExamination.ExamsCategoryID = finalExaminationView.Key.ExamsCategoryID;
- //(int)EMIS.ViewModel.CF_ExamsCategory.Resit;
- finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
- finalExamination.Credit = finalExaminationView.Key.Credit;
- //总学时
- finalExamination.TotalHours = finalExaminationView.Key.TotalHours;
- finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
- finalExamination.CollegeID = finalExaminationView.Key.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);
- }
- //foreach (var finalExaminationView in queryFinal)
- //{
- // string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + "-缓考补考";
- // ER_FinalExamination finalExamination = new ER_FinalExamination();
- // finalExamination.FinalExaminationID = Guid.NewGuid();
- // finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
- // finalExamination.GradeYearID = finalExaminationView.Key.Year;
- // finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
- // finalExamination.ClassName = className;
- // finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
- // finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
- // finalExamination.ExamsCategoryID = (int)CF_ExamsCategory.DelayExam;
- // finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
- // finalExamination.Credit = finalExaminationView.Key.Credit;
- // finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- // finalExamination.ApprovalStatus = this.GetStartStatus(); //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- // finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
- // finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
- // finalExamination.IsEntry = false;
- // 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());
- // SlistFinalExamination.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;
- }
- }
- /// <summary>
- /// 毕业生成 增加院系所、专业、班级条件,加上总学时
- /// </summary>
- public void GenerateGraduationExam(int? year, Guid? collegeID, int? standardID, Guid? classmajorID, decimal? learnSystem)
- {
- try
- {
- var startStatusID = this.GetStartStatus();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var curSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
- List<ER_FinalExamination> listFinalExamination = new List<ER_FinalExamination>();
- var query = this.GerenateResitDataRangeFunction(finalExaminationDAL.GetGraduationExamStudent(year));
- if (collegeID.HasValue) //院系所
- query = query.Where(x => x.CollegeID == collegeID);
- if (year.HasValue && year != -1) //年级
- query = query.Where(x => x.Year == year);
- if (standardID.HasValue) //专业
- query = query.Where(x => x.StandardID == standardID);
- if (classmajorID.HasValue)
- query = query.Where(x => x.ClassmajorID == classmajorID);
- if (learnSystem.HasValue && learnSystem != -1)
- query = query.Where(x => x.LearnSystem == learnSystem);
- var studentList = query.ToList();
- var queryFinalExamination = studentList.GroupBy(x => new
- {
- 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,
- });
- foreach (var finalExaminationView in queryFinalExamination)
- {
- string className = finalExaminationView.Key.CourseName + " - " + finalExaminationView.Key.GrademajorName + "-毕业补考";
- ER_FinalExamination finalExamination = new ER_FinalExamination();
- finalExamination.FinalExaminationID = Guid.NewGuid();
- finalExamination.SchoolyearID = curSchoolyear.SchoolYearID;
- finalExamination.GradeYearID = finalExaminationView.Key.Year;
- finalExamination.DepartmentID = finalExaminationView.Key.DepartmentID;
- finalExamination.ClassName = className;
- finalExamination.CoursematerialID = finalExaminationView.Key.CoursematerialID;
- finalExamination.CourseTypeID = finalExaminationView.Key.CourseTypeID;
- finalExamination.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.GraduationExam;
- finalExamination.ExaminationModeID = finalExaminationView.Key.ExaminationModeID;
- finalExamination.Credit = finalExaminationView.Key.Credit;
- //总学时
- finalExamination.TotalHours = finalExaminationView.Key.TotalHours;
- finalExamination.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- finalExamination.ApprovalStatus = startStatusID; //(int)EMIS.ViewModel.CF_ScoreState.NoCanInput;
- finalExamination.ResultTypeID = finalExaminationView.Key.ResultTypeID;
- finalExamination.CollegeID = finalExaminationView.Key.CollegeID;
- finalExamination.CreatorUserID = finalExaminationView.FirstOrDefault().CreatorUserID;
- finalExamination.IsEntry = false;
- 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.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 更新 是否可录入字段
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- public void GetFinal_ResitExaminationIsEntry(List<Guid> finalExaminationIDs)
- {
- try
- {
- var statusList = this.GetStatusViewList();
- var startStatus = this.GetStartStatus(); //
- //可录入节点的Description用[ENTRY]标识
- var status = statusList.Where(x => (x.Description ?? "").Contains("[ENTRY]")).Select(x => x.ID).FirstOrDefault();
- if (finalExaminationIDs.Count > 0)
- {
- var query = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID)).ToList();
- if (query.Where(x => x.ApprovalStatus != startStatus).FirstOrDefault() != null)
- throw new Exception("只能操作未开放的数据!");
- StartUp(finalExaminationIDs, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, null);
- query.ForEach(x => x.IsEntry = true);
- //query.ForEach(x => x.ApprovalStatus = status);
- UnitOfWork.Commit();
- }
-
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 撤销录入
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- public void GetFinal_ResitExaminationBack(List<Guid> finalExaminationIDs)
- {
- try
- {
- var statusList = this.GetStatusViewList();
- var startStatus = this.GetStartStatus(); //
- var actionList = WorkflowServices.Value.GetActionView("ER_FinalExamination", finalExaminationIDs[0], CustomPrincipal.Current.UserID).ToList();
- var actionID = actionList.Where(x => (x.Description ?? "").Contains("[Cancel]")).Select(w => w.ActionID).FirstOrDefault();
- //可录入节点的Description用[ENTRY]标识
- if (actionID == null || actionID==Guid.Empty)
- {
- throw new Exception("没有对应的流程,请添加!");
- }
- var status = statusList.Where(x => (x.Description ?? "").Contains("[ENTRY]")).FirstOrDefault();
- if (finalExaminationIDs.Count > 0)
- {
- var query = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID)).ToList();
- if (query.Where(x => x.ApprovalStatus != status.ID).FirstOrDefault() != null)
- throw new Exception("只能操作可录入状态的数据!");
- Approve(finalExaminationIDs, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionID, null);
- query.ForEach(x => x.IsEntry = true);
- UnitOfWork.Commit();
- }
- ScoreServices.Value.ScoreDelete(finalExaminationIDs);
- }
- catch (Exception)
- {
- throw;
- }
- }
- public List<FinalExaminationView> GetFinalExaminationViewList_Excel(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? examinationType, int? approvalStatus, int? gradeYearID, List<Guid?> FinalExaminationIDList)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (FinalExaminationIDList != null)
- exp = exp.And(x => FinalExaminationIDList.Contains(x.FinalExaminationID));
- if (collegeID.HasValue)
- exp = exp.And(this.CollegeExpression(collegeID));
- if (departmentID.HasValue)
- exp = exp.And(x => x.DepartmentID == departmentID);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- if (courseTypeID.HasValue)
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- if (examsCategoryID.HasValue)
- exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
- if (examinationType.HasValue)
- exp = exp.And(x => x.ExaminationType == examinationType);
- if (approvalStatus.HasValue)
- exp = exp.And(x => x.ApprovalStatus == approvalStatus);
- if (gradeYearID.HasValue)
- exp = exp.And(x => x.GradeYearID == gradeYearID);
- var query = finalExaminationDAL.GetFinalExaminationViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- public FinalExaminationView GetStarttermID(Guid? finalExaminationID, Guid? UserID)
- {
- FinalExaminationView f = new FinalExaminationView();
- var finalExamination = GetFinalExamination(finalExaminationID);
- var student = finalExaminationDAL.studentRepository.GetSingle(x => x.UserID == UserID, (x => x.CF_Classmajor.CF_Grademajor),(x=>x.Sys_User));
- var startTermID = finalExamination.CF_Schoolyear.Value - ((student.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (student.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1;
- f.StarttermID = startTermID;
- f.UserName = student.Sys_User.Name;
- return f;
- }
- //public string CanBatchEdit(List<Guid?> finalExaminationIDs)
- //{
- // var finalExaminationList = finalExaminationDAL.finalExaminationRepository.GetList(x => finalExaminationIDs.Contains(x.FinalExaminationID)).ToList();
- // var statusList = this.GetStatusViewList(); //获取工作流列表
- // var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]") || (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
- // foreach(var f in finalExaminationList){
- // if (status.Contains(f.ApprovalStatus))
- // {
- // return "不能修改";
- // }
- // }
- // return "可以修改";
- //}
- }
- }
|