123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.MinorManage.MinorPlanManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorManage.MinorPlanManage;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.CommonLogic.MinorManage.MinorApply;
- using EMIS.DataLogic.MinorManage.MinorApply;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.Students;
- namespace EMIS.CommonLogic.MinorManage.MinorPlanManage
- {
- public class MinorSpecialtyServices : BaseServices, IMinorSpecialtyServices
- {
- public MinorSpecialtyDAL MinorSpecialtyDAL { get; set; }
- public IMinorApplyServices minorApplyServices { get; set; }
- public MinorApplyDAL minorApplyDAL { get; set; }
- public IGridResultSet<MinorSpecialtyView> GetMinorSpecialtyViewGrid(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? grademinorStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Grademinor, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (yearID.HasValue)
- exp = exp.And(x => x.YearID == yearID);
- if (standardID.HasValue)
- exp = exp.And(x => x.StandardID == standardID);
- if (collegeID.HasValue)
- exp = exp.And(x => x.CollegeID == collegeID);
- if (grademinorStatus.HasValue)
- exp = exp.And(x => x.RecordStatus == grademinorStatus);
- var query = MinorSpecialtyDAL.GetMinorSpecialtyViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToGridResultSet<MinorSpecialtyView>(pageIndex, pageSize);
- return result;
- }
- public List<MinorSpecialtyView> GetMinorSpecialtyViewList(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? grademinorStatus, List<Guid?> GrademinorIDList)
- {
- Expression<Func<CF_Grademinor, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (GrademinorIDList != null)
- exp = exp.And(x => GrademinorIDList.Contains(x.GrademinorID));
- if (yearID.HasValue)
- exp = exp.And(x => x.YearID == yearID);
- if (standardID.HasValue)
- exp = exp.And(x => x.StandardID == standardID);
- if (collegeID.HasValue)
- exp = exp.And(x => x.CollegeID == collegeID);
- if (grademinorStatus.HasValue)
- exp = exp.And(x => x.RecordStatus == grademinorStatus);
- var query = MinorSpecialtyDAL.GetMinorSpecialtyViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToList();
- }
- public MinorSpecialtyView GetMinorSpecialtyView(Guid? GrademinorID)
- {
- Expression<Func<CF_Grademinor, bool>> exp = (x => x.GrademinorID == GrademinorID);
- var query = MinorSpecialtyDAL.GetMinorSpecialtyViewQueryable(exp).FirstOrDefault();
- return query;
- }
- public bool MinorSpecialtyOpen(List<Guid?> IDList)
- {
- try
- {
- if (IDList.Count > 0)
- {
- var MinorSpecialtyList = MinorSpecialtyDAL.GrademinorRepository.GetList(x => IDList.Contains(x.GrademinorID)).ToList();
- foreach (var MinorSpecialty in MinorSpecialtyList)
- {
- CF_Grademinor Grademinor = MinorSpecialty;
- Grademinor.RecordStatus = (int)CF_GrademinorStatus.Opened;
- SetModifyStatus(Grademinor);
- UnitOfWork.Commit();
- }
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public bool MinorSpecialtyCancel(List<Guid?> IDList)
- {
- try
- {
- if (IDList.Count > 0)
- {
- var MinorSpecialtyList = MinorSpecialtyDAL.GrademinorRepository.GetList(x => IDList.Contains(x.GrademinorID)).ToList();
- foreach (var MinorSpecialty in MinorSpecialtyList)
- {
- CF_Grademinor Grademinor = MinorSpecialty;
- Grademinor.RecordStatus = (int)CF_GrademinorStatus.NotOpened;
- SetModifyStatus(Grademinor);
- UnitOfWork.Commit();
- }
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 开班
- /// </summary>
- /// <param name="iDList"></param>
- public void OpenClass(List<Guid?> iDList)
- {
- try
- {
- if (iDList.Count > 0)
- {
- Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
- Expression<Func<CF_Classmajor, bool>> expcla = x => true;
- Expression<Func<CF_College, bool>> expcol = x => true;
- var endStatusID = minorApplyServices.GetCorrectEndStatus();
- var inputStatus = minorApplyServices.GetStartApproveStatusList();
- //获取所有的辅修报名信息
- var minorStudentList = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol);
- var minorApplyViewList = this.GetQueryByDataRangeByCollege(minorStudentList).ToList();
- //var query = minorApplyViewList.GroupBy(x => new
- //{
- // x.GrademinorID,
- //}).ToList();
- List<CF_Classminor> classminorList = new List<CF_Classminor>();
- var minorSpecialtyList = MinorSpecialtyDAL.GrademinorRepository.GetList(x => iDList.Contains(x.GrademinorID)).ToList();
- foreach (var minorSpecialty in minorSpecialtyList)
- {
- if (minorSpecialty.RecordStatus != (int)CF_GrademinorStatus.Opened)
- {
- throw new Exception("只能对 已开放 状态的辅修专业进行开班");
- }
- //还有没有处理完的学生报名信息不让开班
- if (minorStudentList.Any(x => x.GrademinorID == minorSpecialty.GrademinorID && x.GradeYearID == minorSpecialty.YearID && inputStatus.Contains(x.RecordStatus)))
- {
- throw new Exception("所选辅修专业对应的学生报名信息存在未处理完的,请处理完再开班");
- }
- CF_Grademinor Grademinor = minorSpecialty;
- Grademinor.RecordStatus = (int)CF_GrademinorStatus.Confirmed;
- SetModifyStatus(Grademinor);
- UnitOfWork.Commit();
- //生成辅修班级
- var standardName = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard.ToString()).Where(x => x.Value == minorSpecialty.StandardID).Select(x => x.Name).FirstOrDefault();
- CF_Classminor classminor = new CF_Classminor();
- classminor.ClassminorID = Guid.NewGuid();
- classminor.GrademinorID = minorSpecialty.GrademinorID;
- classminor.Name = minorSpecialty.YearID.ToString() + standardName + "辅修班";
- classminor.Abbreviation = classminor.Name;
- classminor.ClassNum = 1;
- SetNewStatus(classminor);
- if (minorApplyViewList.Where(x => x.GrademinorID == minorSpecialty.GrademinorID && x.GradeYearID == minorSpecialty.YearID).Count() <= 0)
- {
- throw new Exception("所选的辅修专业没有学生报名,不能开班");
- }
- if (minorApplyViewList.Where(x => x.GrademinorID == minorSpecialty.GrademinorID && x.GradeYearID == minorSpecialty.YearID && x.RecordStatus == endStatusID).Count() > 0)
- {
- var Student = minorApplyViewList.Where(x => x.GrademinorID == minorSpecialty.GrademinorID && x.GradeYearID == minorSpecialty.YearID && x.RecordStatus == endStatusID).Select(x => new CF_ClassminorStudent
- {
- ClassminorStudentID = Guid.NewGuid(),
- ClassminorID = classminor.ClassminorID,
- UserID = x.UserID.Value,
- RecordStatus = (int)SYS_STATUS.USABLE,
- CreateTime = DateTime.Now,
- CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID,
- ModifyTime = DateTime.Now,
- ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID,
- });
- classminor.CF_ClassminorStudent = new HashSet<CF_ClassminorStudent>(Student.ToList());
- }
- else
- {
- classminor.CF_ClassminorStudent = new HashSet<CF_ClassminorStudent>();
- }
- classminorList.Add(classminor);
- }
- UnitOfWork.BulkInsert(classminorList);
- UnitOfWork.BulkInsert(classminorList.SelectMany(x => x.CF_ClassminorStudent).ToList());
-
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 取消开班
- /// </summary>
- /// <param name="idList"></param>
- public void CancelClass(List<Guid?> idList)
- {
- try
- {
- if (idList.Count > 0)
- {
- var minorSpecialtyList = MinorSpecialtyDAL.GrademinorRepository.GetList(x => idList.Contains(x.GrademinorID)).ToList();
- foreach (var minorSpecialty in minorSpecialtyList)
- {
- if (minorSpecialty.RecordStatus != (int)CF_GrademinorStatus.Opened)
- {
- throw new Exception("只能对 已开放 状态的辅修专业取消开班");
- }
- CF_Grademinor grademinor = minorSpecialty;
- grademinor.RecordStatus = (int)CF_GrademinorStatus.Cancelled;
- SetModifyStatus(grademinor);
- UnitOfWork.Commit();
- }
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- public IGridResultSet<StudentsView> GetStudentsByGrademinorID(Guid grademinorID)
- {
- Expression<Func<EM_StudentMinorRegist, bool>> exp = x => x.GrademinorID == grademinorID;
- var query = MinorSpecialtyDAL.GetStudentsQueryable(exp);
- return query.OrderBy(x => x.LoginID).ToGridResultSet<StudentsView>();
- }
- }
- }
|