123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorManage.MinorApply;
- using EMIS.ViewModel;
- using EMIS.DataLogic.MinorManage.MinorApply;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.MinorManage.MinorClass;
- namespace EMIS.CommonLogic.MinorManage.MinorApply
- {
- public class MinorApplyServices : BaseWorkflowServices<EM_StudentMinorRegist>, IMinorApplyServices
- {
- public MinorApplyDAL minorApplyDAL { get; set; }
- public MinorClassDAL minorClassDAL { get; set; }
- /// <summary>
- /// 辅修报名审核
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="classmajorID"></param>
- /// <param name="minorStandardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorApplyView> MinorApplyViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, int? minorStandardID, int? approvalStatus, int pageIndex, int pageSize)
- {
- //结束流程环节ID
- var endStatusID = this.GetCorrectEndStatus();
- //审核流程状态IDList
- var approveStatusIDList = this.GetApproveStatusViewList()
- .Select(x => x.ID).ToList();
- var applyStatusList = this.GetStatusViewList();
- var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
- .Select(x => x.ID).ToList();
- Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
- Expression<Func<CF_Classmajor, bool>> expcla = x => true;
- Expression<Func<CF_College, bool>> expcol = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- expcol = expcol.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- expcla = expcla.And(x => x.CF_Grademajor.GradeID == yearID);
- }
- if (standardID.HasValue)
- {
- expcla = expcla.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- expcla = expcla.And(x => x.ClassmajorID == classmajorID);
- }
- if (minorStandardID.HasValue)
- {
- exp = exp.And(x => x.CF_Grademinor.StandardID == minorStandardID);
- }
- if (approvalStatus.HasValue && approvalStatus > (int)SYS_STATUS.UNUSABLE)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- var query = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.GrademajorCode).ThenBy(x => x.GrademinorCode).ThenBy(x => x.LoginID).ToGridResultSet<MinorApplyView>(pageIndex, pageSize);
- result.rows.ForEach(x => x.RecordStatusStr = applyStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
- return result;
- }
- /// <summary>
- /// 辅修报名(Excel)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="classmajorID"></param>
- /// <param name="minorStandardID"></param>
- /// <param name="idList"></param>
- /// <returns></returns>
- public List<MinorApplyView> GetMinorApplyViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, int? minorStandardID, int? approvalStatus, List<Guid?> idList)
- {
- //结束流程环节ID
- var endStatusID = this.GetCorrectEndStatus();
- //审核流程状态IDList
- var approveStatusIDList = this.GetApproveStatusViewList()
- .Select(x => x.ID).ToList();
- var applyStatusList = this.GetStatusViewList();
- var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
- .Select(x => x.ID).ToList();
- Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
- Expression<Func<CF_Classmajor, bool>> expcla = x => true;
- Expression<Func<CF_College, bool>> expcol = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- expcol = expcol.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- expcla = expcla.And(x => x.CF_Grademajor.GradeID == yearID);
- }
- if (standardID.HasValue)
- {
- expcla = expcla.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- expcla = expcla.And(x => x.ClassmajorID == classmajorID);
- }
- if (minorStandardID.HasValue)
- {
- exp = exp.And(x => x.CF_Grademinor.StandardID == minorStandardID);
- }
- if (approvalStatus.HasValue && approvalStatus > (int)SYS_STATUS.UNUSABLE)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (idList.Count > 0 && idList != null)
- {
- exp = exp.And(x => idList.Contains(x.StudentMinorRegistID));
- }
- var query = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.GrademajorCode).ThenBy(x => x.GrademinorCode).ThenBy(x => x.LoginID).ToList();
- result.ForEach(x => x.RecordStatusStr = applyStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
- return result;
- }
- public void MinorApplyEdit(MinorApplyView minorApplyView)
- {
- try
- {
- EM_StudentMinorRegist studentMinorRegist = new EM_StudentMinorRegist();
- if (minorApplyView.StudentMinorRegistID == null || minorApplyView.StudentMinorRegistID == Guid.Empty)
- {
- //新增、复制新增
- studentMinorRegist = minorApplyDAL.studentMinorRegistRepository
- .GetSingle(x => x.SchoolyearID == minorApplyView.SchoolyearID && x.UserID == minorApplyView.CollegeID && x.GrademinorID == minorApplyView.GrademinorID);
- if (studentMinorRegist != null)
- {
- throw new Exception("该学生已存在相同学年学期的辅修报名信息。");
- }
- studentMinorRegist = new EM_StudentMinorRegist();
- studentMinorRegist.StudentMinorRegistID = Guid.NewGuid();
- studentMinorRegist.GrademinorID = minorApplyView.GrademinorID;
- studentMinorRegist.SchoolyearID = minorApplyView.SchoolyearID;
- studentMinorRegist.UserID = minorApplyView.UserID;
- studentMinorRegist.CreateTime = DateTime.Now;
- studentMinorRegist.CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- studentMinorRegist.ModifyTime = DateTime.Now;
- studentMinorRegist.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- UnitOfWork.Add(studentMinorRegist);
- }
- else
- {
- //修改
- studentMinorRegist = minorApplyDAL.studentMinorRegistRepository
- .GetSingle(x => x.StudentMinorRegistID != minorApplyView.StudentMinorRegistID
- && x.SchoolyearID == minorApplyView.SchoolyearID && x.UserID == minorApplyView.CollegeID && x.GrademinorID == minorApplyView.GrademinorID);
- if (studentMinorRegist != null)
- {
- throw new Exception("该学生已存在相同学年学期的辅修报名信息。");
- }
- studentMinorRegist = minorApplyDAL.studentMinorRegistRepository
- .GetSingle(x => x.StudentMinorRegistID == minorApplyView.StudentMinorRegistID);
- if (studentMinorRegist == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- studentMinorRegist = new EM_StudentMinorRegist();
- studentMinorRegist.StudentMinorRegistID = Guid.NewGuid();
- studentMinorRegist.GrademinorID = minorApplyView.GrademinorID;
- studentMinorRegist.SchoolyearID = minorApplyView.SchoolyearID;
- studentMinorRegist.UserID = minorApplyView.UserID;
- studentMinorRegist.ModifyTime = DateTime.Now;
- studentMinorRegist.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="minorApplyIDList"></param>
- public void MinorApplyDelete(IList<Guid?> minorApplyIDList)
- {
- try
- {
- if (minorApplyIDList.Count > 0)
- {
- UnitOfWork.Delete<EM_StudentMinorRegist>(x => minorApplyIDList.Contains(x.StudentMinorRegistID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public MinorApplyView GetMinorApplyView(Guid? minorApplyID)
- {
- try
- {
- var minorApplyView = minorApplyDAL.GetMinorApplyViewQueryable(x => x.StudentMinorRegistID == minorApplyID, x => true, x => true)
- .SingleOrDefault();
- return minorApplyView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public void MinorApproveConfirm(List<Guid?> minorApplyIDs, Guid userID, Guid actionID, string comment)
- {
- try
- {
- //查询对应的审核信息List
- var minorApplyList = minorApplyDAL.studentMinorRegistRepository
- .GetList(x => minorApplyIDs.Contains(x.StudentMinorRegistID)).ToList();
- var endStatusID = this.GetCorrectEndStatus();
- foreach (var minorApplyID in minorApplyIDs)
- {
- //查询对应的审核信息
- var minorApply = minorApplyList.Where(x => x.StudentMinorRegistID == minorApplyID).SingleOrDefault();
- if (minorApply == null)
- {
- throw new Exception("数据有误,请核查");
- }
- }
- //审核
- this.Approve(minorApplyIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询辅修专业,下拉框用
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public IGridResultSet<MinorApplyView> GetGrademinorGrid(ConfiguretView configuretView)
- {
- return null;
- }
- public void OnApproveEnd(IList<Guid> studentMinorRegistIDList, Guid? userID)
- {
- try
- {
- Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
- Expression<Func<CF_Classmajor, bool>> expcla = x => true;
- Expression<Func<CF_College, bool>> expcol = x => true;
- if (studentMinorRegistIDList.Count > 0)
- {
- exp = exp.And(x => studentMinorRegistIDList.Contains(x.StudentMinorRegistID));
- }
- var query = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol).ToList();
- foreach (var studentMinor in query)
- {
- var classMinor = minorClassDAL.classminorRepository.GetSingle(x => x.GrademinorID == studentMinor.GrademinorID && x.RecordStatus == (int)SYS_STATUS.USABLE, (x => x.CF_ClassminorStudent));
- if (classMinor == null)
- {
- return;
- }
- var classmionrStudent = new CF_ClassminorStudent();
- classmionrStudent.ClassminorStudentID = Guid.NewGuid();
- classmionrStudent.ClassminorID = classMinor.ClassminorID;
- classmionrStudent.UserID = studentMinor.UserID.Value;
- SetNewStatus(classmionrStudent);
- classMinor.CF_ClassminorStudent.Add(classmionrStudent);
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|