123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.EvaluationManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EvaluationManage;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using Bowin.Common.Utility;
- using Bowin.Common.Mapping;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.EducationManagement;
- using EMIS.Utility;
- namespace EMIS.CommonLogic.EvaluationManage
- {
- public class EvaluationSettingServices : BaseServices, IEvaluationSettingServices
- {
- public EvaluationSettingDAL EvaluationSettingDAL { get; set; }
- public ISerialNumberServices SerialNumberServices { get; set; }
- public SchoolyearRepository SchoolyearRepository { get; set; }
- public EducationSchedulingClassRepository educationSchedulingClassRepository { get; set; }
- public InSchoolSettingRepository inSchoolSettingRepository { get; set; }
- #region 1.0 查询评价设定列表信息
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.EvaluationManage.EvaluationSettingView> GetEvaluationSettingViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? openStatus, Guid? CoursematerialID, Guid? departmentID, Guid? userId, int? standardID, int? schoolyearCodeID, Guid? classmajorID,int? learningformID, int? education,string LearnSystem, int pageIndex, int pageSize)
- {
- bool hasClassmajorFilter = false;
- Expression<Func<EM_EvaluationSetting, bool>> filter = x => true;
- Expression<Func<CF_Classmajor, bool>> classmajorFilter = x => true;
- if (openStatus.HasValue && openStatus >= 0)
- {
- filter = filter.And(w => w.OpenStatus == openStatus);
- }
- if (schoolYearID.HasValue && schoolYearID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolYearID);
- }
- if (campusID.HasValue && campusID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (classmajorID.HasValue && classmajorID != Guid.Empty)
- {
- hasClassmajorFilter = true;
- classmajorFilter = x => x.ClassmajorID == classmajorID;
- }
- if (schoolyearCodeID.HasValue && schoolyearCodeID > 0)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == schoolyearCodeID);
- }
- if (learningformID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- hasClassmajorFilter = true;
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- if (education.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
- }
- if (standardID.HasValue && standardID > 0)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (hasClassmajorFilter)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.CF_Classmajor.AsQueryable().Any(classmajorFilter));
- }
-
- if (collegeID.HasValue && collegeID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.CF_College.CollegeID == collegeID);
- }
- if (CoursematerialID.HasValue && CoursematerialID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.CoursematerialID == CoursematerialID);
- }
- if (departmentID.HasValue && departmentID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.CF_Department.DepartmentID == departmentID);
- }
- if (userId.HasValue && userId != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_MissionClassTeacher.Any(x => x.UserID == userId));
- }
- var query = EvaluationSettingDAL.GetEvaluationSettingQuery(filter);
- query = GetQueryByDataRangeByCollege(query);//以院系 区分
- if ((configuretView.Attribute != "UserNames" && !string.IsNullOrEmpty(configuretView.ConditionValue)) && (configuretView.Attribute != "UserCodes" && !string.IsNullOrEmpty(configuretView.ConditionValue)))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- var educationMissionClassIDList = query.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = EvaluationSettingDAL.GetMissionClassTeacherViewQueryable(x => educationMissionClassIDList.Contains(x.MissionClassID));
- var result = query.OrderBy(x => x.SchoolyearCode).OrderBy(x => x.CourseCode).OrderBy(x => x.EducationMissionClassName).
- ToGridResultSet<EvaluationSettingView>(pageIndex, pageSize);
- if (configuretView.Attribute == "UserCodes" && !string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- missionClassTeacherList = missionClassTeacherList.Where(x => x.LoginID == configuretView.ConditionValue).ToList();
- var missionClassTeacherIDList = missionClassTeacherList.Select(x => x.EducationMissionClassID).ToList();
- result = query.Where(x => missionClassTeacherIDList.Contains(x.EducationMissionClassID)).OrderBy(x => x.SchoolyearCode).OrderBy(x => x.CourseCode).OrderBy(x => x.EducationMissionClassName).
- ToGridResultSet<EvaluationSettingView>(pageIndex, pageSize);
-
- }
- if (configuretView.Attribute == "UserNames" && !string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- missionClassTeacherList = missionClassTeacherList.Where(x => x.Name == configuretView.ConditionValue).ToList();
- var missionClassTeacherIDList = missionClassTeacherList.Select(x => x.EducationMissionClassID).ToList();
- result = query.Where(x => missionClassTeacherIDList.Contains(x.EducationMissionClassID)).OrderBy(x => x.SchoolyearCode).OrderBy(x => x.CourseCode).OrderBy(x => x.EducationMissionClassName).
- ToGridResultSet<EvaluationSettingView>(pageIndex, pageSize);
- }
- result.rows.ForEach(x => x.EvaluationSettingMissionClassTeacherViewList =
- new HashSet<EvaluationSettingMissionClassTeacherView>(missionClassTeacherList.
- Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- #endregion
- #region 2.0 查询评价设定编辑信息
- public ViewModel.EvaluationManage.EvaluationSettingView GetEvaluationSettingView(Guid? id)
- {
- var result = new EvaluationSettingView();
- if (id.HasValue && id != Guid.Empty)
- result = EvaluationSettingDAL.GetEvaluationSettingQuery(x => x.EvaluationSettingID == id).FirstOrDefault();
- return result;
- }
- #endregion
- #region 3.0 保存评价设定数据信息
- public void AddOrUpdateEvaluationSetting(ViewModel.EvaluationManage.EvaluationSettingView model)
- {
- EM_EvaluationSetting entity;
- var courseQuery = EvaluationSettingDAL.EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == model.EducationMissionClassID && x.RecordStatus == (int)CF_ApprovalStatus.Submitted)
- .Select(s => new
- {
- s.EducationMissionClassID,
- s.EM_EducationMission.CF_Department,
- s.EM_Coursematerial
- });
- string YearCode = SchoolyearRepository.GetSingle(x => x.SchoolyearID == model.SchoolyearID).Code;
- string StrCode = courseQuery.FirstOrDefault().EM_Coursematerial.CourseCode + "(" + YearCode + ")";
- string settingCode = SerialNumberServices.GetSN(StrCode);//格式20160429
- #region 0.0 提取该教学任务班下对应的相关人员信息
- var evaluationTableEntity = EvaluationSettingDAL.EvaluationTableRepository.GetSingle(x => x.EvaluationTableID == model.EvaluationTableID, x => x.EM_EvaluationType);
- if (evaluationTableEntity == null)
- {
- throw new Exception("该评价表没指定参评类型!");
- }
- bool? IsApply = evaluationTableEntity.EM_EvaluationType.IsStudent;
- var evaluationByStudentUser = EvaluationSettingDAL.GetEvaluationByStudent(model.EducationMissionClassID);
- // var evaluationByStaffUser = EvaluationSettingDAL.GetEvaluationByStaff(model.EducationMissionClassID,null);
- #endregion
- if (model.EvaluationSettingID == Guid.Empty)
- {
- #region 1.0 评价设置基本信息 Add
- entity = new EM_EvaluationSetting();
- model.DynamicCloneTo(entity);
- //SetNewStatus方法去掉了设置ID的功能
- entity.EvaluationSettingID = Guid.NewGuid();
- //entity.ID = Function.NewPKGuid();
- SetNewStatus(entity);//EMIS.CommonLogic
- //是否适用于学生 否 默认同行
- //if ((bool)IsApply)
- //{
- foreach (var sysUser in evaluationByStudentUser)
- {
- entity.CF_Student.Add(sysUser);
- }
- //}
- //else
- //{
- //foreach (var sysUser in evaluationByStaffUser)
- //{
- // entity.CF_Staff.Add(sysUser);
- //}
- entity.EvaluationSettingCode = settingCode;//SerialNumberServices.SetSN(model.CourseCode + "(" + model.SchoolyearCode + ")");
- entity.CreateTime = DateTime.Now;
- entity.RecordStatus = evaluationTableEntity.EM_EvaluationType.IsStudent == true ? (int)CF_YesOrNoStatus.Yes : (int)CF_YesOrNoStatus.No;//是否适用学生
- entity.EvaluationTypeID = evaluationTableEntity.EvaluationTypeID;//参评类型
- UnitOfWork.Add(entity);
- #endregion
- }
- else
- {
- #region 2.0 评价设置基本信息 Update
- entity = EvaluationSettingDAL.EvaluationSettingRepository.GetSingle(x => x.EvaluationSettingID == model.EvaluationSettingID, (x => x.CF_Student), (x => x.CF_Staff));
- if (entity != null)
- {
- SetModifyStatus(entity);
- entity.CF_Student = new HashSet<CF_Student>();//该学生、对应的所有数据
- foreach (var sysUser in evaluationByStudentUser)
- {
- entity.CF_Student.Add(sysUser);
- }
- entity.CF_Staff = new HashSet<CF_Staff>();//该同行、对应的所有数据
- //foreach (var sysUser in evaluationByStaffUser)
- //{
- // entity.CF_Staff.Add(sysUser);
- //}
- entity.EvaluationSettingCode = settingCode;
- entity.EvaluationTypeID = evaluationTableEntity.EvaluationTypeID;//参评类型
- entity.OpenStatus = model.OpenStatus;
- entity.RecordStatus = evaluationTableEntity.EM_EvaluationType.IsStudent == true ? (int)CF_YesOrNoStatus.Yes : (int)CF_YesOrNoStatus.No;//是否适用学生
- UnitOfWork.Update(entity);
- }
- #endregion
- }
- UnitOfWork.Commit();//统一提交
- }
- #endregion
- #region 4.0 删除评价设定数据信息
- //4.0 删除评价设定信息
- public void DeleteEvaluationSetting(List<Guid> ids)
- {
- //var evaluationSettingList = EvaluationSettingDAL.EvaluationSettingRepository.GetList(w => ids.Contains(w.EvaluationSettingID)).ToList();
- //foreach (var evaluationSetting in evaluationSettingList)
- //{
- // if (evaluationSetting.OpenStatus == (int)CF_YesOrNoStatus.Yes)
- // {
- // throw new Exception("勾选信息包含开放状态为是,不能删除!");
- // }
- //}
- UnitOfWork.Delete<EM_EvaluationSetting>(w => ids.Contains(w.EvaluationSettingID));
- }
- //同时删除进入评价记录
- public void DeleteSettingWithRecord(List<Guid> ids)
- {
- var evaluationSettingList = EvaluationSettingDAL.EvaluationSettingRepository.GetList(w => ids.Contains(w.EvaluationSettingID)).ToList();
- foreach (var evaluationSetting in evaluationSettingList)
- {
- EM_EducationMissionClass edu = EvaluationSettingDAL.EducationMissionClassRepository.GetSingle(x => x.EducationMissionClassID == evaluationSetting.EducationMissionClassID);
- List<Guid> tablelist = EvaluationSettingDAL.EvaluationTableRepository.GetList(x => x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(edu.TeachingModeID ?? (int)CF_TeachingMode.Theory) && x.IsEnabled == true).Select(x => x.EvaluationTableID).ToList();
- List<EM_EvaluationEnter> lie = EvaluationSettingDAL.evaluationEnterRepository.GetList(x => x.EducationMissionClassID == evaluationSetting.EducationMissionClassID && tablelist.Contains((Guid)x.EvaluationTableID)).ToList();
- if (lie != null)
- {
- List<Guid> idlist = lie.Select(x => x.EvaluationEnterID).ToList();
- UnitOfWork.Delete<EM_EvaluationEnter_EM_EvaluationProject>(x => idlist.Contains(x.EvaluationEnterID));
- UnitOfWork.Delete<EM_EvaluationEnter>(x => idlist.Contains(x.EvaluationEnterID));
- }
- }
- UnitOfWork.Delete<EM_EvaluationSetting>(w => ids.Contains(w.EvaluationSettingID));
- }
-
- public bool DeleteValidate(List<Guid> ids)//删除前提醒
- {
- bool val = false;
- var evaluationSettingList = EvaluationSettingDAL.EvaluationSettingRepository.GetList(w => ids.Contains(w.EvaluationSettingID)).ToList();
- foreach (var evaluationSetting in evaluationSettingList)
- {
- if (evaluationSetting.OpenStatus == (int)CF_YesOrNoStatus.Yes)
- {
- throw new Exception("勾选信息包含开放状态为是,不能删除!");
- }
- EM_EducationMissionClass edu = EvaluationSettingDAL.EducationMissionClassRepository.GetSingle(x => x.EducationMissionClassID == evaluationSetting.EducationMissionClassID);
- List<Guid> tablelist = EvaluationSettingDAL.EvaluationTableRepository.GetList(x => x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(edu.TeachingModeID ?? (int)CF_TeachingMode.Theory) && x.IsEnabled == true).Select(x => x.EvaluationTableID).ToList();
- List<EM_EvaluationEnter> lie = EvaluationSettingDAL.evaluationEnterRepository.GetList(x => x.EducationMissionClassID == evaluationSetting.EducationMissionClassID && tablelist.Contains((Guid)x.EvaluationTableID)).ToList();
- if (lie != null && lie.Count != 0)
- {
- val = true;
- }
- }
- return val;
- }
- #endregion
- #region 5.0 导出评价设定数据信息
- //Excel导出
- public IList<EvaluationSettingView> GetEvaluationSettingViewList(ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? openStatus, Guid? CoursematerialID, Guid? departmentID, Guid? userId, int? standardID, int? schoolyearCodeID, Guid? classmajorID, int? learningformID, int? education, string LearnSystem)
- {
- bool hasClassmajorFilter = false;
- Expression<Func<EM_EvaluationSetting, bool>> filter = x => true;
- Expression<Func<CF_Classmajor, bool>> classmajorFilter = x => true;
- if (openStatus.HasValue&&openStatus >= 0)
- {
- filter= filter.And(w => w.OpenStatus == openStatus);
- }
- if (schoolYearID.HasValue && schoolYearID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolYearID);
- }
- if (campusID.HasValue && campusID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.CF_College.CampusID == campusID);
- }
-
- if (classmajorID.HasValue && classmajorID != Guid.Empty)
- {
- hasClassmajorFilter = true;
- classmajorFilter = x => x.ClassmajorID == classmajorID;
- }
- if (schoolyearCodeID.HasValue&&schoolyearCodeID>0)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == schoolyearCodeID);
- }
- if (learningformID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- hasClassmajorFilter = true;
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- if (education.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
- }
- if (standardID.HasValue && standardID > 0)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (hasClassmajorFilter)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.CF_Classmajor.AsQueryable().Any(classmajorFilter));
- }
- if (collegeID.HasValue && collegeID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.CF_College.CollegeID == collegeID);
- }
- if (CoursematerialID.HasValue && CoursematerialID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID == CoursematerialID);
- }
- if (departmentID.HasValue && departmentID != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_EducationMission.CF_Department.DepartmentID == departmentID);
- }
- if (userId.HasValue && userId != Guid.Empty)
- {
- filter = filter.And(w => w.EM_EducationMissionClass.EM_MissionClassTeacher.Any(x => x.UserID == userId));
- }
- var query = EvaluationSettingDAL.GetEvaluationSettingQuery(filter);
- query = GetQueryByDataRangeByCollege(query);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- var educationMissionClassIDList = query.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = EvaluationSettingDAL.GetMissionClassTeacherViewQueryable(x => educationMissionClassIDList.Contains(x.MissionClassID));
- var result = query.OrderBy(o => o.CourseCode).ToList();
- result.ForEach(x => x.EvaluationSettingMissionClassTeacherViewList = new HashSet<EvaluationSettingMissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- #endregion
- #region 6.0 查询评价设定明细信息
- //学生明细
- public IList<EvaluationSettingDetailView> EvaluationSettingStudentDetail(Guid? evaluationSettingID, int pageIndex, int pageSize)
- {
- var query = EvaluationSettingDAL.GetEvaluationSettingStudentDetailQuery(evaluationSettingID).OrderBy(x => x.LoginID);
- return query.ToList();
- // return query.ToGridResultSet(pageIndex, pageSize);
- }
- //教职工明细
- public IList<EvaluationSettingDetailView> EvaluationSettingStaffDetail(Guid? evaluationSettingID, int pageIndex, int pageSize)
- {
- var query = EvaluationSettingDAL.GetEvaluationSettingStaffDetailQuery(evaluationSettingID).OrderBy(x => x.StaffCode);
- return query.ToList();
- // return query.ToGridResultSet(pageIndex, pageSize);
- }
- //教职工明细
- public IList<EvaluationSettingDetailView> EvaluationSettingStaffList(ConfiguretView configuretView, Guid? evaluationSettingID)
- {
- var query = EvaluationSettingDAL.GetEvaluationSettingStaffDetailList(evaluationSettingID).OrderBy(x => x.StaffCode);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).ToList();
- }
- return query.ToList();
- }
- //学生明细
- public IList<EvaluationSettingDetailView> EvaluationSettingStudentList(ConfiguretView configuretView, Guid? evaluationSettingID)
- {
- var query = EvaluationSettingDAL.GetEvaluationSettingStudentDetailList(evaluationSettingID).OrderBy(x => x.LoginID);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).ToList();
- }
- return query.ToList();
- }
- #endregion
- #region 7.0 创建评价设定清单信息
- //以学年学期生成评价信息
- public void CreateEvaluationInventory(Guid schoolyearID)
- {
- var inschoolStatus = inSchoolSettingRepository.GetList(w => w.IsSelected == true).Select(s => s.InSchoolStatusID).ToList();
- #region 1.0 以学年学期缩小对应的教学任务班数据范围、统一构建学生、同行清单操作
- List<EM_EvaluationSetting> listEvaluationSetting = new List<EM_EvaluationSetting>();//评价设定数据集合
- var evaluationSetting = EvaluationSettingDAL.GetCreateInventoryQuery(schoolyearID);//提取对应的评价相关数据
- List<EducationMissionClassView> educationMissionClassIDLsit = this.GetQueryByDataRangeByCollege(evaluationSetting).ToList();
- //获取所有的教学任务
- var allEducationMissionClass = EvaluationSettingDAL.GetEducationMissionClassQuery(schoolyearID);
- var existEvaluationSettingList = this.EvaluationSettingDAL.EvaluationSettingRepository.GetList(x =>
- x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolyearID,
- (x => x.EM_EducationMissionClass),
- (x => x.EM_EducationMissionClass.EM_MissionClassTeacher)).ToList();
- var existCourseAndTeacher = (from es in existEvaluationSettingList
- from mct in es.EM_EducationMissionClass.EM_MissionClassTeacher
- select new { es.EM_EducationMissionClass.CoursematerialID, mct.UserID }).ToList();
- List<EducationMissionClassView> allEducationMissionClassList = this.GetQueryByDataRangeByCollege(allEducationMissionClass).ToList();
- if (educationMissionClassIDLsit.Count() < 0)
- {
- throw new Exception("没有相关的评价生成信息!");
- }
- string YearCode = SchoolyearRepository.GetSingle(x => x.SchoolyearID == schoolyearID).Code;
-
- List<CF_Staff> st = new List<CF_Staff>();
- //所有的老师
- var stall=EvaluationSettingDAL.StaffRepository.GetList(x=>x.RecordStatus==(int)SYS_STATUS.USABLE).ToList();
- //同教研室的老师
-
- #endregion
- #region 1.0 评价设置基本信息 Add
- EM_EvaluationSetting entity = null;
- foreach (var educationMissionEntity in educationMissionClassIDLsit)
- {
- if (educationMissionEntity.CF_Staff.FirstOrDefault() != null)//TODO:没有任课老师、将不做评价信息生成~
- {
- #region 1.1 主体数据构建
- string StrCode = educationMissionEntity.CourseCode + "(" + YearCode + ")";
- //string settingCode = SerialNumberServices.SetSN(StrCode, 3);//格式20160429 慢慢慢~~~
- entity = new EM_EvaluationSetting();
- entity.EvaluationTypeID = null;
- entity.CreateTime = DateTime.Now;
- entity.EvaluationSettingCode = StrCode;
- entity.OpenStatus = (int)CF_YesOrNoStatus.No;
- entity.EducationMissionClassID = educationMissionEntity.EducationMissionClassID;
- entity.EvaluationTableID = null;
- entity.EvaluationSettingID = Guid.NewGuid();
- SetNewStatus(entity);
- #endregion
- #region 1.2 学生清单写入
- if (educationMissionEntity.CF_Student.Count() > 0)
- {
- //过滤非在校状态学生
- educationMissionEntity.CF_Student = new HashSet<CF_Student>(educationMissionEntity.CF_Student.Where(x => inschoolStatus.Contains(x.InSchoolStatusID)));
- educationMissionEntity.CF_Student.ForEach(x => { entity.CF_Student.Add(x); });
- }
- #endregion
- #region 1.3 教师清单写入
- List<CF_Staff> StaffList = educationMissionEntity.CF_Staff.ToList();
- //去除已经生成过的课程
- StaffList.RemoveAll(x => existCourseAndTeacher.Any(w => w.CoursematerialID == educationMissionEntity.CoursematerialID
- && w.UserID == x.UserID));
- if (StaffList.Count > 0)//没有排课老师、直接不做同行查询
- {
- var staffid = StaffList.Select(x => x.UserID).ToList();
-
- //var staffDepartid=StaffList.Select(x=>x.DepartmentID).ToList();
- //同开课教研室的教师
- var stdepart = (from all in stall
- from staff in StaffList.Where(x => all.DepartmentID == x.DepartmentID && x.UserID != all.UserID)
- select all).ToList();
- //var stdepart = stall.Where(x => x.DepartmentID == educationMissionEntity.DepartmentID&&!staffid.Contains(x.UserID)).ToList();
- //var stdepartList = stall.Where(x => staffDepartid.Contains(x.DepartmentID)).ToList();
- //上同一门课的教师
- List<CF_Staff> stclass = new List<CF_Staff>();
- //上同一门课的教师,用教学任务是否控制配置来排除是只生成提交的还是全部都生成
- if (!Const.LOCAL_SETTING_MISSIONCLASS_CAN_SUBMIT_NOTEACHER)
- {
- foreach (var e in educationMissionClassIDLsit)
- {
- if (e.CoursematerialID == educationMissionEntity.CoursematerialID
- && e.EducationMissionID != educationMissionEntity.EducationMissionID)
- {
- List<CF_Staff> StaffLists = e.CF_Staff.ToList();
- foreach (var s in StaffLists)
- {
- if (!staffid.Contains(s.UserID))
- {
- stclass.Add(s);
- }
- }
- }
- }
- }
- else
- {
- foreach (var e in allEducationMissionClassList)
- {
- if (e.CoursematerialID == educationMissionEntity.CoursematerialID
- && e.EducationMissionClassID != educationMissionEntity.EducationMissionClassID)
- {
- List<CF_Staff> StaffLists = e.CF_Staff.ToList();
- foreach (var s in StaffLists)
- {
- if (!staffid.Contains(s.UserID))
- {
- stclass.Add(s);
- }
- }
- }
- }
- }
- List<CF_Staff> evaluationByStaffUser = new List<CF_Staff>();
- foreach (var sd in stdepart)
- {
- evaluationByStaffUser.Add(sd);
- }
- foreach (var sc in stclass)
- {
- evaluationByStaffUser.Add(sc);
- }
- //foreach(var sdd in stdepartList)
- //{
- // evaluationByStaffUser.Add(sdd);
- //}
- evaluationByStaffUser = evaluationByStaffUser.Distinct().ToList(); //EvaluationSettingDAL.GetEvaluationByStaff(educationMissionEntity.EducationMissionClassID, StaffList);
- if (evaluationByStaffUser.Count() > 0)
- {
- evaluationByStaffUser.ForEach(x => { entity.CF_Staff.Add(x); });
- }
- StaffList.ForEach(x => existCourseAndTeacher.Add(new { educationMissionEntity.CoursematerialID, UserID = (Guid?)x.UserID }));
- }
- #endregion
- #region 1.4 Add实体集合
- listEvaluationSetting.Add(entity);
- //UnitOfWork.Add(entity);
- #endregion
- }
- }
- if (listEvaluationSetting.Count > 0)
- {
- UnitOfWork.BulkInsert(listEvaluationSetting);
- UnitOfWork.BulkInsert(listEvaluationSetting, (x => x.CF_Student));//批量插入
- UnitOfWork.BulkInsert(listEvaluationSetting, (x => x.CF_Staff));
- }
- // UnitOfWork.Commit();//统一提交
- #endregion
- }
- #endregion
- #region 8.0 查询对应的评价表|评价类型信息
- //以教学任务班ID、查询对应的评价表、级评价类型信息
- public IGridResultSet<EvaluationTableView> GetEvaluationSettingByEducationMissionClassID(Guid? educationMissionClassID)
- {
- var query = EvaluationSettingDAL.GetTableByEducationMissionClassID(educationMissionClassID);
- return query.ToGridResultSet<EvaluationTableView>(0, 10);
- }
- #endregion
- public void Save(Guid? evaluationSettingID, IList<EvaluationSettingDetailView> list, string SaveType)
- {
- try
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- EM_EvaluationSetting entity = EvaluationSettingDAL.EvaluationSettingRepository
- .GetSingle(x => x.EvaluationSettingID == evaluationSettingID, x => x.CF_Student, x => x.CF_Staff);//有多对多关系、一定要指定属性
- var Userid = list.Select(x => x.UserID).ToList();
- if (entity != null && SaveType.Equals("Student"))
- {
- entity.CF_Student = new HashSet<CF_Student>();//该学生发放ID、对应的所有数据
- var queryStudent = EvaluationSettingDAL.StudentRepository.Entities.Where(x => Userid.Contains(x.UserID));
- foreach (var student in queryStudent)
- {
- entity.CF_Student.Add(student);
- }
- entity.ModifyUserID = curUser.UserID;
- UnitOfWork.Update(entity);
- }
- if (entity != null && SaveType.Equals("Staff"))
- {
- entity.CF_Staff = new HashSet<CF_Staff>();
- var queryStaff = EvaluationSettingDAL.StaffRepository.Entities.Where(x => Userid.Contains(x.UserID));
- foreach (var Staff in queryStaff)
- {
- entity.CF_Staff.Add(Staff);
- }
- entity.ModifyUserID = curUser.UserID;
- UnitOfWork.Update(entity);
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|