123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.EducationManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EducationManagement;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.ViewModel.EducationManage;
- using EMIS.ViewModel.CacheManage;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.Common.CalendarManage;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.EducationSchedule;
- using EMIS.CommonLogic.Students;
- using EMIS.DataLogic.Common.Students;
- using EMIS.DataLogic.UniversityManage.TeacherManage;
- using EMIS.ViewModel.UniversityManage.TeacherManage;
- using EMIS.DataLogic;
- namespace EMIS.CommonLogic.EducationManage
- {
- public partial class AdultEducationMissionClassServices : BaseServices, IAdultEducationMissionClassServices
- {
- public AdultEducationMissionClassDAL educationMissionClassDAL { get; set; }
- public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; }
- public SchoolYearDAL schoolYearDAL { get; set; }
- public IStudentsServices studentServices { get; set; }
- public Lazy<StudentsDAL> StudentsDAL { get; set; }
- public Lazy<StaffDAL> staffDAL { get; set; }
- public CoursesTimeDAL coursesTimeDAL { get; set; }
- #region 查询任务班
- /// <summary>
- /// 查询教学任务班
- /// </summary>
- /// <param name="configuretView">查询条件</param>
- /// <param name="schoolyearID">学年学期ID</param>
- /// <param name="courseCode">课程代码</param>
- /// <param name="courseName">课程名称</param>
- /// <param name="name">排课班级</param>
- /// <param name="pageIndex">页数</param>
- /// <param name="pageSize">显示数</param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<EducationMissionClassView> GetEducationMissionClassViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, int? standardID, Guid? coursematerialID,
- int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, Guid? CoursesTimeID, int? learningformID, int? education, string LearnSystem, int pageIndex, int pageSize)
- {
- bool hasClassmajorFilter = false;
- Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorFilter = x => true;
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
- }
- if (CoursesTimeID.HasValue)
- {
- exp = exp.And(x => x.EM_CoursesTime.Any(c => c.CoursesTimeID == CoursesTimeID));
- }
- if (standardID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- 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 (gradeYearID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- }
- if (classmajorID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.ClassmajorID == classmajorID);
- }
- //if (hasClassmajorFilter)
- //{
- // exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorFilter));
- //}
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (approvalStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp, classmajorFilter).Distinct();
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var resultQuery = this.GetQueryByDataRangeByCollege(query, (x => x.ClassmajorCollegeID)).OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
- .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name);
- var result = resultQuery.ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
- var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).Distinct().ToList();
- result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- public List<EducationMissionImportClassView> GetEducationMissionClassViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, int? standardID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, int? learningformID, int? education, string LearnSystem)
- {
- bool hasClassmajorFilter = false;
- Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorFilter = x => true;
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == collegeID);
- }
- if (standardID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- 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 (gradeYearID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- }
- if (classmajorID.HasValue)
- {
- hasClassmajorFilter = true;
- classmajorFilter = classmajorFilter.And(x => x.ClassmajorID == classmajorID);
- }
- //if (hasClassmajorFilter)
- //{
- // exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorFilter));
- //}
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (approvalStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp, classmajorFilter);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
- .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name)
- .ToList();
- var educationMissionClassID = result.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
- result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- #endregion
-
- /// <summary>
- /// 获取任务班信息
- /// </summary>
- /// <param name="educationMissionClassID"></param>
- /// <returns></returns>
- public EducationMissionImportClassView GetEducationMissionClassView(Guid? educationMissionClassID)
- {
- return educationMissionClassDAL.GetEducationMissionClassViewQueryble(x => x.EducationMissionClassID == educationMissionClassID,w=>true).FirstOrDefault();
- }
- /// <summary>
- /// 获取任务班信息
- /// </summary>
- /// <param name="educationMissionClassID"></param>
- /// <returns></returns>
- public Entities.EM_EducationMissionClass GetEducationMissionClass(Guid? educationMissionClassID)
- {
- return educationMissionClassDAL.educationMissionClassRepository.GetSingle(x => x.EducationMissionClassID == educationMissionClassID,
- (x => x.EM_EducationMission),
- (x => x.CF_Classmajor),
- (x => x.EM_CoursesTime),
- (x => x.EM_MissionClassTeacher),
- (x => x.EM_EducationMissionClassSettings),
- (x => x.EM_CourseProcess),
- (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher)),
- (x => x.EM_EducationSchedulingClass),
- (x => x.EM_EducationMissionClassTeachingSetting), (x => x.CF_Classroom));
- }
-
- public void BatchModifyCoursesTime(List<Guid?> educationMissionClassIDs, Guid? CourseTimeID, int? ClassroomTypeID)
- {
- try
- {
- foreach (var id in educationMissionClassIDs)
- {
- EM_EducationMissionClass educationMissionClass = GetEducationMissionClass(id);
- educationMissionClass.ClassroomTypeID = ClassroomTypeID;
- List<EM_CoursesTime> coursesTime = coursesTimeDAL.coursesTimeRepository.Entities.Where(x => x.CoursesTimeID == CourseTimeID).ToList();
- educationMissionClass.EM_CoursesTime = new HashSet<EM_CoursesTime>();
- //educationMissionClass.EM_CoursesTime = new HashSet<EM_CoursesTime>();
- foreach (var time in coursesTime)
- {
- EM_CoursesTime c = time;
- educationMissionClass.EM_CoursesTime.Add(c);
- }
- SetModifyStatus(educationMissionClass);
- }
- UnitOfWork.Commit();
- }
- catch
- {
- }
- }
- /// <summary>
- /// 更新教学任务班表 处理状态
- /// </summary>
- /// <param name="educationMissionClassIDs"></param>
- public void EducationMissionClassUpdate(List<Guid?> educationMissionClassIDs)
- {
- try
- {
- string massge = string.Empty;
- var educationMissionClassList = educationMissionClassDAL.educationMissionClassRepository
- .GetList(x => educationMissionClassIDs.Contains(x.EducationMissionClassID),
- (x => x.CF_Classmajor),
- (x => x.EM_EducationMission),
- (x => x.EM_EducationMissionClassTeachingSetting),
- (x => x.EM_EducationMissionClassSettings),
- (x => x.EM_EducationSchedulingClass),
- (x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student)),
- (x => x.EM_MissionClassTeacher),
- (x => x.EM_CourseProcess),
- (x => x.EM_CoursesTime),
- (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher))).ToList();
- var educationMissionIDList = educationMissionClassList.Select(x => x.EducationMissionID).Distinct();
- foreach (var educationMissionClass in educationMissionClassList)
- {
- if (educationMissionClass.RecordStatus != (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted)
- massge += educationMissionClass.Name + "任务班,已提交,不能重复提交。";
- if (educationMissionClass.EM_CoursesTime.Count == 0)
- massge += educationMissionClass.Name + "任务班,未设置课时类别。";
- //if (educationMissionClass.EM_EducationMissionClassSettings.Count == 0)
- // massge += educationMissionClass.Name + "任务班,未设置授课周次。";
- if (educationMissionClass.ClassroomTypeID == null)
- massge += educationMissionClass.Name + "任务班,未设置教室类型。";
- var courseProcessList = educationMissionClassDAL.GetRelatedCourseProcess(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID)
- .ToList();
- var hours = courseProcessList.Select(x => x.Times).Sum();
- //总学时
- int? totalHours = (educationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryCourse ?? 0)
- + (educationMissionClass.EM_EducationMissionClassTeachingSetting.Practicehours ?? 0);
- //TODO:兵良说:排课学时要小于等于总学时 2016年10月17日18:48:49
- if (hours > totalHours)
- {
- massge += educationMissionClass.Name + "任务班,课程进度设置错误,请检查并重新设置后提交。";
- }
- if (!string.IsNullOrEmpty(massge))
- massge += ",";
- }
- //20161110 MM姐提的要求, 先提交数据检测是否问题,有问题把所有问题反馈回页面让客户进行修改,再重新提交
- if (!string.IsNullOrEmpty(massge))
- throw new Exception(massge.TrimEnd(','));
- foreach (var educationMissionClass in educationMissionClassList)
- {
- educationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Submitted;
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|