123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.RetakeManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.RetakeManage;
- using EMIS.Utility;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.EducationManage;
- using EMIS.DataLogic.EducationManage;
- using EMIS.CommonLogic.EducationSchedule;
- using EMIS.DataLogic.SystemSetting;
- using EMIS.CommonLogic.RetakeManage.General;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.RetakeManage.General
- {
- public class RetakePlanListServices : BaseServices, IRetakePlanListServices
- {
- public RetakePlanTaskDAL RetakePlanTaskDAL { get; set; }
- public IInSchoolSettingServices InSchoolSettingServices { get; set; }
- /// <summary>
- /// 查询重修任务名单View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="retakePlanStatusID"></param>
- /// <param name="generalPurposeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeStudentListView> GetRetakePlanStudentView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? coursematerialID,
- int? inSchoolStatus, int? retakePlanStatusID, int? generalPurposeID, int pageIndex, int pageSize)
- {
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (schoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
- }
- if (retakePlanStatusID.HasValue)
- {
- //重修任务状态
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus == retakePlanStatusID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- //在校状态
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(expRetakePlan, x => true, expStudent);
- if (collegeID.HasValue)
- {
- //院系所
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- //年级
- query = query.Where(x => x.Gradeyear == yearID);
- }
- if (standardID.HasValue)
- {
- //专业名称
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- //培养层次
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- //学习形式
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (generalPurposeID.HasValue)
- {
- //报名状态
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.ApplyStatus == true);
- }
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.ApplyStatus == false);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCredit)
- .ThenBy(x => x.DepartmentCode.Length).ThenBy(x => x.DepartmentCode)
- .ThenBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .ToGridResultSet<RetakeStudentListView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询重修任务名单List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="retakePlanStatusID"></param>
- /// <param name="generalPurposeID"></param>
- /// <returns></returns>
- public List<RetakeStudentListView> GetRetakePlanStudentViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID,
- int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? coursematerialID,
- int? inSchoolStatus, int? retakePlanStatusID, int? generalPurposeID)
- {
- //重修计划
- Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- //课程信息
- expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (schoolyearID.HasValue)
- {
- //重修学年学期
- expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
- }
- if (retakePlanStatusID.HasValue)
- {
- //重修任务状态
- expRetakePlan = expRetakePlan.And(x => x.RecordStatus == retakePlanStatusID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- //班级信息
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- //在校状态
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(expRetakePlan, x => true, expStudent);
- if (collegeID.HasValue)
- {
- //院系所
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- //年级
- query = query.Where(x => x.Gradeyear == yearID);
- }
- if (standardID.HasValue)
- {
- //专业名称
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- //培养层次
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- //学习形式
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (generalPurposeID.HasValue)
- {
- //报名状态
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.ApplyStatus == true);
- }
- if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.ApplyStatus == false);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCredit)
- .ThenBy(x => x.DepartmentCode.Length).ThenBy(x => x.DepartmentCode)
- .ThenBy(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .ToList();
- }
- /// <summary>
- /// 删除重修任务名单
- /// </summary>
- /// <param name="retakePlanStudentIDsList"></param>
- public void DeleteRetakePlanStudent(IList<Guid?> retakePlanStudentIDsList)
- {
- try
- {
- //查询对应的重修计划名单信息
- var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository
- .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID),
- (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)).ToList();
- if (retakePlanStudentViewList.Any(x => x.ER_RetakePlan.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated))
- {
- throw new Exception("不能删除已开班状态的重修任务名单。");
- }
- //查询对应的重修报名信息List
- var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository
- .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID),
- (x => x.ER_RetakePlan),
- (x => x.ER_RetakePlan.CF_Student))
- .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID))
- .ToList();
- if (retakePlanStudentApplyList.Count() > 0)
- {
- //查询对应的重修计划信息
- var retakePlanViewList = retakePlanStudentApplyList
- .Select(x => x.ER_RetakePlan).Distinct().ToList();
- //重修报名表
- foreach (var retakePlan in retakePlanViewList)
- {
- //查询存在报名名单的重修计划名单对应的userIDList
- var userIDList = retakePlanStudentApplyList
- .Where(x => x.RetakePlanID == retakePlan.RetakePlanID)
- .Select(x => x.UserID).ToList();
- retakePlan.CF_Student.RemoveWhere(x => userIDList.Contains(x.UserID));
- }
- //throw new Exception("要删除的重修计划名单已进行重修报名。");
- }
- //重修计划名单表
- //UnitOfWork.RemoveRange(new HashSet<ER_RetakePlanStudent>(retakePlanStudentViewList));
- UnitOfWork.Remove<ER_RetakePlanStudent>(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID));
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|