123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EducationManage;
- using EMIS.ViewModel.EducationManagement;
- using EMIS.DataLogic.EducationManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.CommonLogic.EducationManage
- {
- public class EducationMissionClassCheckServices : BaseServices, IEducationMissionClassCheckServices
- {
- public EducationMissionClassCheckDAL educationMissionClassCheckDAL { get; set; }
- public IGridResultSet<EducationMissionClassCheckView> GetEducationMissionClassCheckViewGrid(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? times, Guid? classroomID, Guid? coursematerialID, Guid? staffID, int? opinionID, int? checkWayID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EducationMissionClassCheck, bool>> emccexp = (x => true);
- Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
- Expression<Func<ES_EducationScheduling, bool>> esexp = (x => true);
- Expression<Func<EM_MissionClassTeacher, bool>> mctexp = (x => true);
- Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
- Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = (x => true);
- if (schoolyearID.HasValue)
- {
- emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (weekNum.HasValue)
- {
- eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
- }
- if (weekDay.HasValue)
- {
- esexp = esexp.And(x => x.Weekday == weekDay);
- }
- if (times.HasValue)
- {
- esexp = esexp.And(x => x.CoursesTimeID == times);
- }
- if (classroomID.HasValue)
- {
- esexp = esexp.And(x => x.ClassroomID == classroomID);
- }
- if (coursematerialID.HasValue)
- {
- emcexp = emcexp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (staffID.HasValue)
- {
- emcexp = emcexp.And(x => x.EM_MissionClassTeacher.Any(y => y.UserID == staffID));
- }
- if (opinionID.HasValue)
- {
- emccexp = emccexp.And(x => x.OpinionID == opinionID);
- }
- if (checkWayID.HasValue)
- {
- emccexp = emccexp.And(x => x.CheckWayID == checkWayID);
- }
- var query = educationMissionClassCheckDAL.GetEducationMissionClassCheckViewQueryble(emccexp, emexp, esexp, mctexp, emcexp, eswnexp);
- 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.ClassroomCode).ToGridResultSet<EducationMissionClassCheckView>(pageIndex, pageSize);
- var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
- var educationSchedulingID = result.rows.Select(x => x.EducationSchedulingID).ToList();
- var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherByEducationSchedulingID(x => educationSchedulingID.Contains(x.EducationSchedulingID)).ToList();
- result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationSchedulingID == x.EducationSchedulingID)));
- return result;
- }
- /// <summary>
- /// 获取导出列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="weekNum"></param>
- /// <param name="weekDay"></param>
- /// <param name="times"></param>
- /// <param name="classroomID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="staffID"></param>
- /// <param name="opinionID"></param>
- /// <param name="checkWayID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public List<EducationMissionClassCheckView> GetEducationMissionClassCheckViewList(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? times, Guid? classroomID, Guid? coursematerialID, Guid? staffID, int? opinionID, int? checkWayID, List<Guid?> educationMissionClassCheckIDList)
- {
- Expression<Func<EM_EducationMissionClassCheck, bool>> emccexp = (x => true);
- Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
- Expression<Func<ES_EducationScheduling, bool>> esexp = (x => true);
- Expression<Func<EM_MissionClassTeacher, bool>> mctexp = (x => true);
- Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
- Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = (x => true);
- if (educationMissionClassCheckIDList != null)
- {
- emccexp = emccexp.And(x => educationMissionClassCheckIDList.Contains(x.EducationMissionClassCheckID));
- }
- if (schoolyearID.HasValue)
- {
- emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (weekNum.HasValue)
- {
- eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
- }
- if (weekDay.HasValue)
- {
- esexp = esexp.And(x => x.Weekday == weekDay);
- }
- if (times.HasValue)
- {
- esexp = esexp.And(x => x.CoursesTimeID == times);
- }
- if (classroomID.HasValue)
- {
- esexp = esexp.And(x => x.ClassroomID == classroomID);
- }
- if (coursematerialID.HasValue)
- {
- emcexp = emcexp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (staffID.HasValue)
- {
- mctexp = mctexp.And(x => x.UserID == staffID);
- }
- if (opinionID.HasValue)
- {
- emccexp = emccexp.And(x => x.OpinionID == opinionID);
- }
- if (checkWayID.HasValue)
- {
- emccexp = emccexp.And(x => x.CheckWayID == checkWayID);
- }
- var query = educationMissionClassCheckDAL.GetEducationMissionClassCheckViewQueryble(emccexp, emexp, esexp, mctexp, emcexp, eswnexp);
- 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.ClassroomCode).ToList();
- var educationMissionClassID = result.Select(x => x.EducationMissionClassID).ToList();
- var educationSchedulingID = result.Select(x => x.EducationSchedulingID).ToList();
- var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherByEducationSchedulingID(x => educationSchedulingID.Contains(x.EducationSchedulingID)).ToList();
- result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationSchedulingID == x.EducationSchedulingID)));
- return result;
- }
- public IGridResultSet<EducationMissionClassView> GetEducationMissionClassViewByCondition(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? CoursesTimeID, Guid? ClassroomID, int pageIndex, int pageSize)
- {
- Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = x => true;
- Expression<Func<ES_EducationScheduling, bool>> esexp = x => true;
- Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
- Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
- if (schoolyearID.HasValue)
- {
- emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (weekNum.HasValue)
- {
- eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
- }
- if (weekDay.HasValue)
- {
- esexp = esexp.And(x => x.Weekday == weekDay);
- }
- if (CoursesTimeID.HasValue)
- {
- esexp = esexp.And(x => x.CoursesTimeID == CoursesTimeID);
- }
- if (ClassroomID.HasValue)
- {
- esexp = esexp.And(x => x.ClassroomID == ClassroomID);
- }
- var query = educationMissionClassCheckDAL.GetEducationMissionClassViewByConditionQueryble(emcexp, emexp, eswnexp, esexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.Name).ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
- //var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
- //var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherNameQuery(esexp, eswnexp).ToList();
- //result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- public IGridResultSet<EducationMissionClassView> GetCoursematerialByCondition(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? CoursesTimeID, Guid? ClassroomID, Guid? educationID, int pageIndex, int pageSize)
- {
- Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = x => true;
- Expression<Func<ES_EducationScheduling, bool>> esexp = x => true;
- Expression<Func<EM_EducationMission, bool>> emexp = (x => true);
- Expression<Func<EM_EducationMissionClass, bool>> emcexp = (x => true);
- if (educationID.HasValue)
- {
- emcexp = emcexp.And(x => x.EducationMissionClassID == educationID);
- }
- if (schoolyearID.HasValue)
- {
- emexp = emexp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (weekNum.HasValue)
- {
- eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
- }
- if (weekDay.HasValue)
- {
- esexp = esexp.And(x => x.Weekday == weekDay);
- }
- if (CoursesTimeID.HasValue)
- {
- esexp = esexp.And(x => x.CoursesTimeID == CoursesTimeID);
- }
- if (ClassroomID.HasValue)
- {
- esexp = esexp.And(x => x.ClassroomID == ClassroomID);
- }
- var query = educationMissionClassCheckDAL.GetEducationMissionClassViewByConditionQueryble(emcexp, emexp, eswnexp, esexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.Name).ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
- //var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
- //var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherNameQuery(esexp, eswnexp).ToList();
- //result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- /// <summary>
- /// 获取单个信息
- /// </summary>
- /// <param name="graduationApplyID"></param>
- /// <returns></returns>
- public EducationMissionClassCheckView GetEducationMissionClassCheckView(Guid? educationMissionClassCheckID)
- {
- try
- {
- var graduationApplyView = educationMissionClassCheckDAL.GetEducationMissionClassCheckView(educationMissionClassCheckID);
- return graduationApplyView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public void EducationMissionClassCheckEdit(EducationMissionClassCheckView educationMissionClassCheckView, List<EducationMissionClassCheckTeacherView> teacherList)
- {
- try
- {
- //根据周次、星期、节次、场地、任务班去找对应的排课周次ID
- var educationSchedulingWeekNumID = educationMissionClassCheckDAL.GetEducationSchedulingWeekNumID(educationMissionClassCheckView.WeekNum, educationMissionClassCheckView.Weekday, educationMissionClassCheckView.CoursesTimeID, educationMissionClassCheckView.ClassroomID, (Guid)educationMissionClassCheckView.EducationMissionClassID);
- educationMissionClassCheckView.EducationSchedulingWeekNumID = educationSchedulingWeekNumID;
- //查询数据库进行验证
- var educationMissionClassCheckVerification = educationMissionClassCheckDAL.educationMissionClassCheckRepository
- .GetList(x => x.EducationMissionClassCheckID != educationMissionClassCheckView.EducationMissionClassCheckID &&
- x.EducationSchedulingWeekNumID == educationMissionClassCheckView.EducationSchedulingWeekNumID)
- .SingleOrDefault();
- if (educationMissionClassCheckVerification == null)
- {
- //数据有误验证
- if (educationMissionClassCheckView.EducationMissionClassCheckID != Guid.Empty)
- {
- var educationMissionClassCheck = educationMissionClassCheckDAL.educationMissionClassCheckRepository
- .GetList(x => x.EducationMissionClassCheckID == educationMissionClassCheckView.EducationMissionClassCheckID, x => x.Sys_User)
- .SingleOrDefault();
- if (educationMissionClassCheck == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- educationMissionClassCheck.EducationSchedulingWeekNumID = educationMissionClassCheckView.EducationSchedulingWeekNumID;
- educationMissionClassCheck.StudentComment = educationMissionClassCheckView.StudentComment;
- educationMissionClassCheck.TeacherComment = educationMissionClassCheckView.TeacherComment;
- educationMissionClassCheck.DeviceComment = educationMissionClassCheckView.DeviceComment;
- educationMissionClassCheck.CheckWayID = educationMissionClassCheckView.CheckWayID;
- educationMissionClassCheck.OpinionID = educationMissionClassCheckView.OpinionID;
- educationMissionClassCheck.Remark = educationMissionClassCheckView.Remark;
- educationMissionClassCheck.Sys_User = new HashSet<Sys_User>();
- teacherList.ForEach(x =>
- {
- Sys_User user = educationMissionClassCheckDAL.userRepository.GetSingle(y => y.UserID == x.UserID);
- //educationMissionClassCheck.Sys_User = new HashSet<Sys_User>();
- educationMissionClassCheck.Sys_User.Add(user);
- });
- SetModifyStatus(educationMissionClassCheck);
- UnitOfWork.Update(educationMissionClassCheck);
- }
- }
- else
- {
- //表示新增
- EM_EducationMissionClassCheck educationMissionClassCheck = new EM_EducationMissionClassCheck();
- educationMissionClassCheck.EducationMissionClassCheckID = Guid.NewGuid();
- educationMissionClassCheck.EducationSchedulingWeekNumID = educationMissionClassCheckView.EducationSchedulingWeekNumID;
- educationMissionClassCheck.StudentComment = educationMissionClassCheckView.StudentComment;
- educationMissionClassCheck.TeacherComment = educationMissionClassCheckView.TeacherComment;
- educationMissionClassCheck.DeviceComment = educationMissionClassCheckView.DeviceComment;
- educationMissionClassCheck.CheckWayID = educationMissionClassCheckView.CheckWayID;
- educationMissionClassCheck.OpinionID = educationMissionClassCheckView.OpinionID;
- educationMissionClassCheck.Remark = educationMissionClassCheckView.Remark;
- teacherList.ForEach(x =>
- {
- Sys_User user = educationMissionClassCheckDAL.userRepository.GetSingle(y => y.UserID == x.UserID);
- educationMissionClassCheck.Sys_User.Add(user);
- });
- SetNewStatus(educationMissionClassCheck);
- UnitOfWork.Add(educationMissionClassCheck);
- }
- }
- else
- {
- throw new Exception("已存在相同的教学检查,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
-
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="graduationApplyIDs"></param>
- /// <returns></returns>
- public bool EducationMissionClassCheckDelete(List<Guid?> educationMissionClassCheckIDs)
- {
- try
- {
- List<EM_EducationMissionClassCheck> emccList = educationMissionClassCheckDAL.educationMissionClassCheckRepository.GetList(x => educationMissionClassCheckIDs.Contains(x.EducationMissionClassCheckID), (x => x.Sys_User)).ToList();
- foreach (EM_EducationMissionClassCheck emcc in emccList)
- {
- emcc.Sys_User = new HashSet<Sys_User>();
- UnitOfWork.Remove(emcc);
- }
- //UnitOfWork.Delete<EM_EducationMissionClassCheck>(x => educationMissionClassCheckIDs.Contains(x.EducationMissionClassCheckID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 根据任务班ID获取授课老师姓名
- /// </summary>
- /// <param name="EducationMissionClassID"></param>
- /// <returns></returns>
- public string GetTeacherbyEducationMissionClass(Guid EducationMissionClassID)
- {
- try
- {
- var missionClassTeacherList = educationMissionClassCheckDAL.GetMissionClassTeacherQuery(x => x.EducationMissionClassID == EducationMissionClassID).ToList();
- string TeacherNames = "";
- foreach (MissionClassTeacherView mission in missionClassTeacherList)
- {
- TeacherNames = TeacherNames + mission.Name + ",";
- }
- TeacherNames = TeacherNames.Substring(0, TeacherNames.Length - 1);
- return TeacherNames;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 根据学年学期,周次,星期,节次,教室获取排课中的授课老师
- /// </summary>
- /// <param name="EducationMissionClassID"></param>
- /// <returns></returns>
- public string GetTeacherByAll(ConfiguretView configuretView, Guid? schoolyearID, int? weekNum, int? weekDay, Guid? coursesTimeID, Guid? classroomID, Guid? educationClassID)
- {
- try
- {
- Expression<Func<ES_EducationScheduling, bool>> exp = x => true;
- Expression<Func<ES_EducationSchedulingWeekNum, bool>> eswnexp = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (weekDay.HasValue)
- {
- exp = exp.And(x => x.Weekday == weekDay);
- }
- if (coursesTimeID.HasValue)
- {
- exp = exp.And(x => x.CoursesTimeID == coursesTimeID);
- }
- if (classroomID.HasValue)
- {
- exp = exp.And(x => x.ClassroomID == classroomID);
- }
- if (weekNum.HasValue)
- {
- eswnexp = eswnexp.And(x => x.WeekNum == weekNum);
- }
- var missionClassTeacherList = educationMissionClassCheckDAL.GetTeacherNameQuery(exp, eswnexp).ToList();
- string TeacherNames = "";
- foreach (MissionClassTeacherView mission in missionClassTeacherList)
- {
- TeacherNames = TeacherNames + mission.Name + ",";
- }
- TeacherNames = TeacherNames.Substring(0, TeacherNames.Length - 1);
- return TeacherNames;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public List<EducationMissionClassCheckTeacherView> GetCheckTeacherViewListByCheckID(Guid EducationMissionClassCheckID)
- {
- return educationMissionClassCheckDAL.GetEducationMissionClassCheckTeacherListViewQueryble(EducationMissionClassCheckID).ToList();
- }
- }
- }
|