123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Entities;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.DifferentDynamic;
- using Bowin.Common.Mapping;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using EMIS.Utility;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.EvaluationManage;
- using EMIS.Utility.FormValidate;
- using EMIS.ViewModel.Students;
- using EMIS.DataLogic.Common.Students;
- using EMIS.ViewModel.WorkflowManage;
- namespace EMIS.CommonLogic.Students
- {
- public class DifferentDynamicServices : BaseWorkflowServices<CF_DifferentDynamic>, IDifferentDynamicServices
- {
- public DifferentDynamicDAL DifferentDynamicDAL { get; set; }
- public Lazy<IStudentsServices> StudentsServices { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public Lazy<StudentsDAL> StudentsDAL { get; set; }
- public void AddOrUpdateDifferentDynamic(DifferentDynamicView model)
- {
- //TODO;调整验证逻辑、当前用户存在系统待办没有处理完、不能新增相同数据 2016年10月25日12:06:19
- var startStatusID = this.GetStartStatus();
- var status = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
- status.Add(startStatusID);
- bool IsNext = false;
- var hasApprovalEntity = DifferentDynamicDAL.DifferentDynamicRepository
- .GetList(w => w.UserID == (Guid)model.UserID
- && status.Contains(w.ApprovalStatus)
- && model.EntityID != w.StudentChangeID).Any();
- if (model.EntityID == Guid.Empty)
- {
- if (hasApprovalEntity)
- {
- IsNext = true;
- }
- }
- else
- {
- CF_DifferentDynamic differentDynamicEntity = DifferentDynamicDAL.DifferentDynamicRepository.Entities.Where(x => x.StudentChangeID == model.EntityID).FirstOrDefault();
- //if (hasApprovalEntity && differentDynamicEntity.ApprovalStatus == startStatusID)//防止在一条情况下误判断
- //{
- // IsNext = true;
- //}
- //if (model.Action == "update")//防止编辑是误操作
- //{
- // if (DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => x.UserID == model.UserID
- // && status.Contains(x.ApprovalStatus) && x.ID != model.EntityID).Count() > 0)
- // {
- // IsNext = true;
- // }
- // else
- // {
- // IsNext = false;
- // }
- //}
- }
- if (IsNext)
- {
- //throw new Exception("提交申请的学生中已有异动申请在审核中,请不要多次提交异动申请!");
- throw new Exception("该学生有未处理的申请记录,请不要重复申请!");
- }
- CF_DifferentDynamic entity;
- if (model.EntityID == Guid.Empty)
- {
- entity = new CF_DifferentDynamic();
- model.DynamicCloneTo(entity);
- entity.StudentChangeID = Function.NewPKGuid();
- SetNewStatus(entity);
- entity.ApprovalStatus = startStatusID.Value;
- UnitOfWork.Add(entity);
- }
- else
- {
- entity = DifferentDynamicDAL.DifferentDynamicRepository.GetSingle(w => w.StudentChangeID == model.EntityID);
- model.DynamicCloneTo(entity);
- SetModifyStatus(entity);
- //UnitOfWork.Update(entity);
- }
- UnitOfWork.Commit();
- }
- public void DeleteDifferentDynamic(List<Guid> ids)
- {
- var startStatusID = this.GetStartStatus();
- var statusList = this.GetStatusViewList();
- var status = statusList.Where(x => x.Description.Contains("[CanDelete]")).Select(x => x.ID).ToList();
- status.Add(startStatusID);
- var DifferentDynamicList = DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => ids.Contains(x.StudentChangeID) && !(status.Contains(x.ApprovalStatus))).ToList();
- if (DifferentDynamicList.Count > 0)
- {
- throw new Exception("只能删除未提交的记录,所选的部分记录已提交,无法删除。");
- }
- UnitOfWork.Delete<CF_DifferentDynamic>(w => ids.Contains(w.StudentChangeID));
- }
- public void Submit(List<Guid> ids, Guid userID, string comment = "")
- {
- StartUp(ids, userID, comment);
- }
- public void Submit(Guid id, Guid userId, string comment = "")
- {
- var userIds = DifferentDynamicDAL.DifferentDynamicRepository.GetList(w => w.StudentChangeID == id).Select(s => s.UserID);
- var status = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
- var hasApprovalEntity = DifferentDynamicDAL.DifferentDynamicRepository.GetList(w => userIds.Contains(w.UserID) && status.Contains(w.ApprovalStatus)).Any();
- if (hasApprovalEntity)
- {
- throw new Exception("该学生已有异动申请在审核中,请不要多次提交异动申请!");
- }
- StartUp(new List<Guid>{ id }, userId, comment);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID">校区</param>
- /// <param name="collegeID">院系所</param>
- /// <param name="year">年级</param>
- /// <param name="standard">专业名称</param>
- /// <param name="education">培养层次</param>
- /// <param name="learningform">学习形式</param>
- /// <param name="classmajorID">班级名称</param>
- /// <param name="schoolYearID">异动学期</param>
- /// <param name="differentDynamicType">异动类型</param>
- /// <param name="differentDynamicStatus">审批状态</param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<DifferentDynamicView> GetDifferentDynamicViewGrid(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
- int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID,
- int? differentDynamicType, int? differentDynamicStatus, string LearnSystem, int pageIndex, int pageSize, int atype)
- {
- var endStatusID = this.GetCorrectEndStatus();
- var statusList = this.GetStatusViewList();
- var filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem);
- //atype=1 代表是申请列表
- if (atype == 1)
- {
- filter = filter.And(x => x.ApprovalStatus != endStatusID); //根据老师要求,流程通过的数据不要显示在申请列表 20161011 czf
- filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
- }
- var query = GetDifferentDynamicViewGrid(configuretView, filter);
- query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);//.OrderBy(w => w.EntityApprovalStatus).ThenByDescending(w => w.SchoolyearCode);
- var result = query.ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public IGridResultSet<DifferentDynamicView> GetApplyDifferentDynamicViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType, int? differentDynamicStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, null,null);
- var statusList = this.GetStatusViewList();
- if (differentDynamicStatus.HasValue)
- {
- filter = filter.And(w => w.ApprovalStatus == differentDynamicStatus);
- }
- else
- {
- var approvalStatus = this.GetBackpointStatus();
- approvalStatus.Add(this.GetStartStatus());
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- }
- var result = GetDifferentDynamicViewGrid(configuretView, filter).ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public IGridResultSet<DifferentDynamicView> GetApprovalDifferentDynamicViewGrid(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
- Guid? schoolYearID, int? differentDynamicType,string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
- null, LearnSystem);
- filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
- var statusList = this.GetStatusViewList();
- var approvalStatus = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- var query = GetDifferentDynamicViewGrid(configuretView, filter);
- query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
- var result = query.ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = statusList
- .Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public IGridResultSet<DifferentDynamicView> GetCollegeApprovalDifferentDynamicViewGrid(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
- Guid? schoolYearID, int? differentDynamicType, string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
- null, LearnSystem);
- filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
- var statusList = this.GetStatusViewList();
- var approvalStatus = this.GetApproveStatusViewList()
- .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_COLLEGEAPPROVE_FLAG))
- .Select(x => x.ID).ToList();
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- var query = GetDifferentDynamicViewGrid(configuretView, filter);
- query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
- var result = query.ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = statusList
- .Where(w => w.ID == x.EntityApprovalStatus)
- .Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public IGridResultSet<DifferentDynamicView> GetAdminApprovalDifferentDynamicViewGrid(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
- Guid? schoolYearID, int? differentDynamicType, string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
- null, LearnSystem);
- var statusList = this.GetStatusViewList();
- var approvalStatus = this.GetApproveStatusViewList()
- .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_ADMINAPPROVE_FLAG))
- .Select(x => x.ID).ToList();
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- var query = GetDifferentDynamicViewGrid(configuretView, filter);
- query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
- var result = query.ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = statusList
- .Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- private static Expression<Func<CF_DifferentDynamic, bool>> GetFilter(Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType, int? differentDynamicStatus, string LearnSystem)
- {
- Expression<Func<CF_DifferentDynamic, bool>> filter = w => true;
- if (campusID.HasValue && campusID != Guid.Empty)
- {
- filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue && collegeID != Guid.Empty)
- {
- filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (education.HasValue)
- {
- filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education);
- }
- if (year.HasValue)
- {
- filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
- }
- if (learningform.HasValue)
- {
- filter = filter.And(w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningform);
- }
- if (standard.HasValue)
- {
- //filter = filter.And(w => w.StandardID == standard);
- }
- if (classmajorID.HasValue && classmajorID != Guid.Empty)
- {
- filter = filter.And(w => w.BeforeClassmajorID == classmajorID);
- }
- if (schoolYearID.HasValue && schoolYearID != Guid.Empty)
- {
- filter = filter.And(w => w.SchoolyearID == schoolYearID);
- }
- if (differentDynamicType.HasValue)
- {
- filter = filter.And(w => w.ChangeTypeID == differentDynamicType);
- }
- if (differentDynamicStatus.HasValue)
- {
- filter = filter.And(w => w.ApprovalStatus == differentDynamicStatus);
- }
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (user != null && user.IsStudent)
- {
- filter = filter.And(w => w.UserID == user.UserID);
- }
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- filter = filter.And(x => x.BeforeClassmajorID_Nav.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- return filter;
- }
- public ICollection<DifferentDynamicStatisticsView> GetDifferentDynamicStatistics(ViewModel.ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, Guid? schoolYearID)
- {
- var filter = GetFilter(campusID, collegeID, null, null, null, null, null, schoolYearID, null, this.GetCorrectEndStatus(),null);
- var query = DifferentDynamicDAL.GetDifferentDynamicStatisticsQueryable(filter);
- query = GetQueryByDataRangeByCollege(query);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = query.OrderBy(o => o.CampusID).ThenBy(o => o.CollegeID);
- return query.ToList();
- }
- public ICollection<DifferentDynamicView> GetDifferentDynamicViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
- int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID,
- int? differentDynamicType, int? differentDynamicStatus, string LearnSystem, int atype, List<Guid?> UserIDList = null)
- {
- var endStatusID = this.GetCorrectEndStatus();
- var statusList = this.GetStatusViewList();
- var filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem);
- //filter = filter.And(x => x.ApplyTypeID == (int)CF_DifferentDynamicApplyType.Normal);
- if (atype == 1)
- filter = filter.And(x => x.ApprovalStatus != endStatusID);
- if (UserIDList != null && UserIDList.Count() > 0)
- {
- filter = filter.And(x => UserIDList.Contains(x.UserID));
- }
- var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public ICollection<DifferentDynamicView> GetDifferentDynamicViewListNotDataRange(ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
- int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID,
- int? differentDynamicType, int? differentDynamicStatus, string LearnSystem, int atype, List<Guid?> UserIDList = null)
- {
- var endStatusID = this.GetCorrectEndStatus();
- var statusList = this.GetStatusViewList();
- var filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem);
- //filter = filter.And(x => x.ApplyTypeID == (int)CF_DifferentDynamicApplyType.Normal);
- if (atype == 1)
- filter = filter.And(x => x.ApprovalStatus != endStatusID);
- if (UserIDList != null && UserIDList.Count() > 0)
- {
- filter = filter.And(x => UserIDList.Contains(x.UserID));
- }
- var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = query.OrderByDescending(o => o.EntityCreateTime).ThenByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public ICollection<DifferentDynamicView> GetApprovalDifferentDynamicViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType,string LearnSystem)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, null, LearnSystem);
- filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
- var approvalStatus = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public ICollection<DifferentDynamicView> GetCollegeApprovalDifferentDynamicViewList(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
- Guid? schoolYearID, int? differentDynamicType, string LearnSystem)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
- null, LearnSystem);
- filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
- var approvalStatus = this.GetApproveStatusViewList()
- .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_COLLEGEAPPROVE_FLAG))
- .Select(x => x.ID).ToList();
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public ICollection<DifferentDynamicView> GetAdminApprovalDifferentDynamicViewList(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID,
- Guid? schoolYearID, int? differentDynamicType, string LearnSystem)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType,
- null, LearnSystem);
- filter = filter.And(x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.Normal);
- var approvalStatus = this.GetApproveStatusViewList()
- .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_ADMINAPPROVE_FLAG))
- .Select(x => x.ID).ToList();
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- var result = GetDifferentDynamicViewGrid(configuretView, filter).OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public ICollection<DifferentDynamicView> GetApplyDifferentDynamicViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, Guid? classmajorID, Guid? schoolYearID, int? differentDynamicType, int? differentDynamicStatus)
- {
- Expression<Func<CF_DifferentDynamic, bool>> filter =
- GetFilter(campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, null,null);
- var statusList = this.GetStatusViewList();
- if (differentDynamicStatus.HasValue)
- {
- filter = filter.And(w => w.ApprovalStatus == differentDynamicStatus);
- }
- else
- {
- var approvalStatus = this.GetBackpointStatus();
- approvalStatus.Add(this.GetStartStatus());
- filter = filter.And(w => approvalStatus.Contains(w.ApprovalStatus));
- }
- var result = GetDifferentDynamicViewGrid(configuretView, filter).ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public DifferentDynamicView GetDifferentDynamicView(Guid? id)
- {
- var result = new DifferentDynamicView();
- if (id.HasValue && id != Guid.Empty)
- result = DifferentDynamicDAL.GetDifferentDynamicQueryable(w => w.StudentChangeID == id).FirstOrDefault();
- result.ApprovalStatusName = this.GetStatusViewList().Where(x => x.ID == result.EntityApprovalStatus).Select(x => x.Name).FirstOrDefault();
- return result;
- }
- public void Approve(DifferentDynamicView model, Guid userID, ActionView actionView, string comment = "")
- {
- AddOrUpdateDifferentDynamic(model); //保存审核过程中的修改操作。
- Approve(new List<Guid>{ model.EntityID }, userID, actionView.ActionID, comment);
- }
-
- private IQueryable<DifferentDynamicView> GetDifferentDynamicViewGrid(ConfiguretView configuretView, Expression<Func<CF_DifferentDynamic, bool>> filter)
- {
- var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter);
- query = GetQueryByDataRangeByCollege(query);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = query.OrderByDescending(o => o.EntityCreateTime);
- return query;
- }
- /// <summary>
- /// 查询学生异动信息
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public IGridResultSet<DifferentDynamicView> GetStudentDifferentInfoViewGrid(Guid? userID)
- {
- var endStatusID = this.GetCorrectEndStatus();
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter = w => true;
- filter = filter.And(x => x.ApprovalStatus == endStatusID); //根据老师要求,流程通过的数据不要显示在申请列表 20161011 czf
- filter = filter.And(x => x.UserID == userID);
- var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter);
- query = GetQueryByDataRangeByCollege(query);
- query = query.OrderByDescending(w => w.EntityCreateTime);//.OrderBy(w => w.EntityApprovalStatus).ThenByDescending(w => w.SchoolyearCode);
- var result = query.ToGridResultSet<DifferentDynamicView>();
- result.rows.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- /// <summary>
- /// 查询异动报表下拉(已弃用)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- //public IGridResultSet<DifferentDynamicView> GetDifferentDynamicViewGrid(ConfiguretView configuretView)
- //{
- // var query = DifferentDynamicDAL.GetSelectReport();
- // return query.OrderBy(x=>x.ReportUrl).ToGridResultSet<DifferentDynamicView>();
- //}
- public void OnApproveEnd(List<Guid> differentDynamicIDList, Guid? userID)
- {
- var differentDynamicList = this.DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => differentDynamicIDList.Contains(x.StudentChangeID)).ToList();
- this.DifferentDynamicEnd(differentDynamicList);
- }
- private void DifferentDynamicEnd(List<CF_DifferentDynamic> entityViewList)
- {
- var schoolYear = SchoolYearServices.Value.GetCurrentSchoolYear();
- int? schoolYearValue = schoolYear.Value;//获取当前学年学期Value值
- var differentDynamicIDList = entityViewList.Select(x => x.StudentChangeID).ToList();
- Expression<Func<CF_DifferentDynamic, bool>> exp = x => differentDynamicIDList.Contains(x.StudentChangeID);
- var studentIDList = entityViewList.Select(x => x.UserID).Distinct().ToList();
- var studentEntityList = StudentsDAL.Value.StudentRepository.GetList(x => studentIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor)).ToList();//要转班的学生
- var afterClassmajorIDList = entityViewList.Where(x => x.AfterClassmajorID.HasValue).Select(x => x.AfterClassmajorID).ToList();
- var afterClassMajorList = DifferentDynamicDAL.ClassmajorRepository.GetList(w => afterClassmajorIDList.Contains(w.ClassmajorID), i => i.CF_Grademajor.CF_Schoolyear).ToList();
-
- #region 1.0 教学任务删除异动学生代码段......
- var educationSchedulingClassStudent = DifferentDynamicDAL.GetEducationSchedulingClassStudent(exp).ToList();
- var educationSchedulingIDList = educationSchedulingClassStudent.Select(u => u.TepTableID).ToList();
- var edustudentList = DifferentDynamicDAL.EducationSchedulingClassRepository.GetList(x => educationSchedulingIDList.Contains(x.EducationSchedulingClassID), (x => x.CF_Student));
- educationSchedulingClassStudent.ForEach(e =>
- {
- var educationScheduleClass = edustudentList.FirstOrDefault(x => x.EducationSchedulingClassID == e.TepTableID);
- var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == e.UserID);
- educationScheduleClass.CF_Student.Remove(studentEntity);
- });
- #endregion
- #region 2.0 考场安排删除异动学生代码段......
- var examinationRoomStudent = DifferentDynamicDAL.GetExaminationRoomStudent(exp).ToList();
- var examinationPlanStudent = DifferentDynamicDAL.GetExaminationPlanStudent(exp).ToList();
- var examinationPlanIDList = examinationPlanStudent.Select(u => u.TepTableID).ToList();
- var examinationPlanList = DifferentDynamicDAL.ExaminationPlanRepository.GetList(x => examinationPlanIDList.Contains(x.ExaminationPlanID), (x => x.CF_Student)).ToList();
- var examinationRoomStudentIDList = examinationRoomStudent.Select(u => u.TepTableID).ToList();
- //EX_ExaminationPlan_CF_Student考试计划相关学生表原先没删除成功掉,又往EX_ExaminationPlan_CF_Student插数据,一直没发现这个问题,但如果是同一个ExaminationPlanID时就会报重复错误
- UnitOfWork.Remove<EX_ExaminationRoomStudent>(x => examinationRoomStudentIDList.Contains(x.ExaminationRoomStudentID));
- examinationPlanStudent.ForEach(e =>
- {
- var examinationPlan = examinationPlanList.FirstOrDefault(x => x.ExaminationPlanID == e.TepTableID);
- var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == e.UserID);
- examinationPlan.CF_Student.Remove(studentEntity);
- });
- #endregion
- #region 3.0 成绩管理删除异动学生代码段......
- var scoreStudent = DifferentDynamicDAL.GetScoreStudent(exp).ToList();
- var finalExaminationIDList = scoreStudent.Select(u => u.TepTableID).ToList();
- var finalExaminationList = DifferentDynamicDAL.FinalExaminationRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID), (x => x.ER_FinalExaminationStudent), (x => x.ER_Score)).ToList();
- var finalExaminationStudentIDList = (
- from ss in scoreStudent
- join fe in finalExaminationList on ss.TepTableID equals fe.FinalExaminationID
- from fes in fe.ER_FinalExaminationStudent
- where ss.UserID == fes.UserID
- select fes.FinalExaminationStudentID
- ).ToList();
- var scoreIDList = (
- from ss in scoreStudent
- join fe in finalExaminationList on ss.TepTableID equals fe.FinalExaminationID
- from s in fe.ER_Score
- where ss.UserID == s.UserID
- select s.ScoreID
- ).ToList();
- UnitOfWork.Remove<ER_ScoreDetail>(x => scoreIDList.Contains(x.ScoreID.Value));
- UnitOfWork.Remove<ER_Score>(x => scoreIDList.Contains(x.ScoreID));
- UnitOfWork.Remove<ER_FinalExaminationStudent>(x => finalExaminationStudentIDList.Contains(x.FinalExaminationStudentID));
- #endregion
- #region 4.0 教学评价删除异动学生代码段......
- var evaluationSettingStudent = DifferentDynamicDAL.GetEvaluationSettingStudent(exp).ToList();
- var evaluationSettingIDList = evaluationSettingStudent.Select(u => u.TepTableID).ToList();
- var evaluationSettingStudentList = DifferentDynamicDAL.EvaluationSettingRepository.GetList(x => evaluationSettingIDList.Contains(x.EvaluationSettingID), (x => x.CF_Student));
- evaluationSettingStudent.ForEach(e =>
- {
- var evaluationSetting = evaluationSettingStudentList.FirstOrDefault(x => x.EvaluationSettingID == e.TepTableID);
- var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == e.UserID);
- evaluationSetting.CF_Student.Remove(studentEntity);
- });
- #endregion
- //这堆查询太慢了,不涉及班级转换的异动就不要跑了
- if (entityViewList.Where(x => x.AfterClassmajorID != null).Count() > 0)
- {
- #region 5.0 教学任务插入异动学生代码段......
- var studentSchedulingClassList = DifferentDynamicDAL.GetStudentRelateCourseViewQueryable(exp).ToList();
- List<StudentsView> educationSchedulingClassStudentInsert = new List<StudentsView>();
- foreach (var studentSchedulingClass in studentSchedulingClassList)
- {
- //情况1:找到同班同学,并且自己学号最小,塞同班同学的第一个班
- var classmateSchdulingList = studentSchedulingClass
- .StudentRelateSchedulingClassViewList
- .Where(x => x.ClassmajorIDList.Contains(studentSchedulingClass.ClassmajorID))
- .OrderBy(x => x.EducationMissionClassName)
- .ToList();
- if (classmateSchdulingList.Count > 0 && studentSchedulingClass.LoginID.CompareTo(classmateSchdulingList.Max(x => x.MinLoginID)) < 0)
- {
- var minMissionClassName = classmateSchdulingList.Min(x => x.EducationMissionClassName);
- var minSchedulingClassID = classmateSchdulingList.Where(x => x.EducationMissionClassName == minMissionClassName).Select(x => x.EducationSchedulingClassID).FirstOrDefault();
- if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID))
- {
- educationSchedulingClassStudentInsert.Add(new StudentsView
- {
- UserID = studentSchedulingClass.UserID ?? Guid.Empty,
- TepTableID = minSchedulingClassID
- });
- }
- }
- //情况2:找到同班同学,并且自己学号不是最小,塞第一个自己不是最大的班,如果没有,塞最后一个班
- else if (classmateSchdulingList.Count > 0 && studentSchedulingClass.LoginID.CompareTo(classmateSchdulingList.Max(x => x.MinLoginID)) >= 0)
- {
- foreach (var classmateScheduling in classmateSchdulingList)
- {
- if (studentSchedulingClass.LoginID.CompareTo(classmateScheduling.MaxLoginID) <= 0)
- {
- if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == classmateScheduling.EducationSchedulingClassID))
- {
- educationSchedulingClassStudentInsert.Add(new StudentsView
- {
- UserID = studentSchedulingClass.UserID ?? Guid.Empty,
- TepTableID = classmateScheduling.EducationSchedulingClassID
- });
- break;
- }
- }
- if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == classmateScheduling.EducationSchedulingClassID))
- {
- educationSchedulingClassStudentInsert.Add(new StudentsView
- {
- UserID = studentSchedulingClass.UserID ?? Guid.Empty,
- TepTableID = classmateScheduling.EducationSchedulingClassID
- });
- }
- }
- }
- //情况3:找不到同班同学,但排课班已经有人,塞顺序下来人最少的班
- else if (classmateSchdulingList.Count == 0 && studentSchedulingClass.StudentRelateSchedulingClassViewList.Any(x => x.StudentCount > 0))
- {
- var minStudentCount = studentSchedulingClass.StudentRelateSchedulingClassViewList.Min(x => x.StudentCount);
- var minSchedulingClassID = studentSchedulingClass.StudentRelateSchedulingClassViewList.Where(x => x.StudentCount == minStudentCount)
- .OrderBy(x => x.EducationMissionClassName)
- .Select(x => x.EducationSchedulingClassID).FirstOrDefault();
- if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID))
- {
- educationSchedulingClassStudentInsert.Add(new StudentsView
- {
- UserID = studentSchedulingClass.UserID ?? Guid.Empty,
- TepTableID = minSchedulingClassID
- });
- }
- }
- //情况4:找不到同班同学,而且排课班没人,塞第一个班
- else if (classmateSchdulingList.Count == 0 && !studentSchedulingClass.StudentRelateSchedulingClassViewList.Any(x => x.StudentCount > 0))
- {
- var minSchedulingClassID = studentSchedulingClass.StudentRelateSchedulingClassViewList
- .OrderBy(x => x.EducationMissionClassName)
- .Select(x => x.EducationSchedulingClassID).FirstOrDefault();
- if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID))
- {
- educationSchedulingClassStudentInsert.Add(new StudentsView
- {
- UserID = studentSchedulingClass.UserID ?? Guid.Empty,
- TepTableID = minSchedulingClassID
- });
- }
- }
- }
- var educationSchedulingClassIDInsertList = educationSchedulingClassStudentInsert.Select(x => x.TepTableID).Distinct().ToList();
- var educationSchedulingClassInsertList = DifferentDynamicDAL.EducationSchedulingClassRepository.GetList(x => educationSchedulingClassIDInsertList.Contains(x.EducationSchedulingClassID), x => x.CF_Student).ToList();
- foreach (var educationScheduling in educationSchedulingClassStudentInsert)
- {
- Guid? educationSchedulingClassID = educationScheduling.TepTableID;
- EM_EducationSchedulingClass educationSchedulingClassEntity = educationSchedulingClassInsertList.FirstOrDefault(x => x.EducationSchedulingClassID == educationSchedulingClassID);
- if (educationSchedulingClassEntity != null && educationScheduling.UserID != null)
- {
- if (!educationSchedulingClassEntity.CF_Student.Where(x => x.UserID == educationScheduling.UserID).Any())
- {
- var studentEntity = studentEntityList.FirstOrDefault(x => x.UserID == educationScheduling.UserID);
- educationSchedulingClassEntity.CF_Student.Add(studentEntity);
- UnitOfWork.Update(educationSchedulingClassEntity);
- }
- }
- }
- #endregion
- #region 6.0 考场安排插入异动学生代码段......
- var educationPlanInsertList = DifferentDynamicDAL.GetExaminationPlanStudentInsert(exp,
- (x => x.EM_EducationSchedulingClass
- .Any(w => educationSchedulingClassIDInsertList.Contains(w.EducationSchedulingClassID)))).ToList();
- var educationPlanIDList = educationPlanInsertList.Select(x => x.TepTableID).ToList();
- var educationPlanList = DifferentDynamicDAL.ExaminationPlanRepository.GetList(x => educationPlanIDList.Contains(x.ExaminationPlanID), (x => x.CF_Student)).ToList();
- educationPlanInsertList.ForEach(x =>
- {
- var educationPlan = educationPlanList.FirstOrDefault(w => w.ExaminationPlanID == x.TepTableID);
- var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == x.UserID);
- educationPlan.CF_Student.Add(studentEntity);
- });
- //2016年11月8日11:32:50 zhanghl
- //TODO: 由于考场安排涉及座位安排、暂时不做插入数据处理......
- #endregion
- #region 7.0 成绩管理插入异动学生代码段......
- var scoreStudentInsert = DifferentDynamicDAL.GetScoreStudentInsert(exp,
- (x => x.EM_EducationSchedulingClass
- .Any(w => educationSchedulingClassIDInsertList.Contains(w.EducationSchedulingClassID)))
- ).Distinct().ToList();
- var finalExaminationInsertIDList = scoreStudentInsert.Select(x => x.TepTableID).ToList();
- var finalExaminationEntityList = DifferentDynamicDAL.FinalExaminationRepository.GetList(x => finalExaminationInsertIDList.Contains(x.FinalExaminationID), (x => x.CF_Schoolyear)).ToList();
- foreach (var score in scoreStudentInsert)
- {
- Guid? finalExaminationID = score.TepTableID;
- var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == score.UserID);
- var finalExaminationEntity = finalExaminationEntityList.FirstOrDefault(x => x.FinalExaminationID == score.TepTableID);
- var afterClassMajor = (from c in afterClassMajorList
- join dd in entityViewList on c.ClassmajorID equals dd.AfterClassmajorID
- where dd.UserID == score.UserID
- select c
- ).LastOrDefault();
- if (finalExaminationEntity != null && afterClassMajor != null)
- {
- if (!finalExaminationEntity.ER_FinalExaminationStudent.Where(x => x.UserID == score.UserID).Any())
- {
- finalExaminationEntity.ER_FinalExaminationStudent.Add(new ER_FinalExaminationStudent
- {
- FinalExaminationStudentID = Guid.NewGuid(),
- FinalExaminationID = finalExaminationEntity.FinalExaminationID,
- SchoolyearNumID = (finalExaminationEntity.CF_Schoolyear.Value - ((afterClassMajor.CF_Grademajor.GradeID * 2) - 1 + (afterClassMajor.CF_Grademajor.SemesterID - 1)) - (finalExaminationEntity.CF_Schoolyear.SchoolcodeID == afterClassMajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1,
- StarttermID = finalExaminationEntity.CF_Schoolyear.Value - ((afterClassMajor.CF_Grademajor.GradeID * 2) - 1 + (afterClassMajor.CF_Grademajor.SemesterID - 1)) + 1,
- UserID = studentEntity.UserID,
- RecordStatus = (int)SYS_STATUS.USABLE,
- CreateUserID = CustomPrincipal.Current.UserID,
- CreateTime = DateTime.Now,
- ModifyUserID = CustomPrincipal.Current.UserID,
- ModifyTime = DateTime.Now
- });
- }
- }
- }
- #endregion
- #region 8.0 教学评价插入异动学生代码段......
- var evaluationSettingStudentInsert = DifferentDynamicDAL.GetEvaluationSettingStudentInsert(exp).Distinct().ToList();
- var evaluationSettingStudentInsertIDList = evaluationSettingStudentInsert.Select(x => x.TepTableID).ToList();
- var evaluationSettingStudentInsertList = DifferentDynamicDAL.EvaluationSettingRepository.GetList(x => evaluationSettingStudentInsertIDList.Contains(x.EvaluationSettingID) && x.OpenStatus == (int)CF_YesOrNoStatus.No, (x => x.CF_Student)).ToList();
- foreach (var evaluationSetting in evaluationSettingStudentInsert)
- {
- Guid? evaluationSettingID = evaluationSetting.TepTableID;
- EM_EvaluationSetting evaluationSettingEntity = evaluationSettingStudentInsertList.FirstOrDefault(x => x.EvaluationSettingID == evaluationSettingID);
- if (evaluationSettingEntity != null)
- {
- if (!evaluationSettingEntity.CF_Student.Where(x => x.UserID == evaluationSetting.UserID).Any())
- {
- var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == evaluationSetting.UserID);
- evaluationSettingEntity.CF_Student.Add(studentEntity);
- UnitOfWork.Update(evaluationSettingEntity);
- }
- }
- }
- #endregion
- }
- #region 9.0学生征订
- var studentOrderAddList = DifferentDynamicDAL.GetAddStudentsOrder(exp).ToList();
- studentOrderAddList.ForEach(x => x.OrderQty++);
- var studentOrderDecreaseList = DifferentDynamicDAL.GetDecreaseStudentsOrder(exp).ToList();
- studentOrderDecreaseList.ForEach(x => x.OrderQty--);
- #endregion
- #region 10.0学生发放
- var studentDistributeAddList = DifferentDynamicDAL.GetAddStudentDistribute(exp).ToList();
- studentDistributeAddList.ForEach(x => x.DistributeQty++);
- var studentDistributeDecreaseList = DifferentDynamicDAL.GetDecreaseStudentDistribute(exp).ToList();
- studentDistributeDecreaseList.ForEach(x => x.DistributeQty--);
- #endregion
- foreach (var entityView in entityViewList)
- {
- var studentEntity = studentEntityList.FirstOrDefault(w => w.UserID == entityView.UserID);
- var afterClassMajor = afterClassMajorList.FirstOrDefault(w => w.ClassmajorID == entityView.AfterClassmajorID);
- if (entityView.AfterClassmajorID.HasValue && entityView.AfterClassmajorID != Guid.Empty) //班级
- {
- studentEntity.ClassmajorID = entityView.AfterClassmajorID;
- // student.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(classMajor.CF_Grademajor.CF_Schoolyear);
- var PlanningGraduateDate = StudentsServices.Value.GetPlanningGraduate((Guid)afterClassMajor.GrademajorID);
- if (PlanningGraduateDate != "")
- {
- studentEntity.PlanningGraduateDate = Convert.ToDateTime(PlanningGraduateDate);
- }
- }
- if (entityView.AfterInSchoolStatusID.HasValue && entityView.AfterInSchoolStatusID != -1) //在校状态
- {
- studentEntity.InSchoolStatusID = entityView.AfterInSchoolStatusID;
- }
- if (entityView.AfterStudentStatus.HasValue && entityView.AfterStudentStatus != -1) //学籍状态
- {
- studentEntity.StudentStatus = entityView.AfterStudentStatus;
- }
- //异动后修改异动时间
- entityView.ChangeDate = DateTime.Now;
- }
- UnitOfWork.Commit();
- }
- }
- }
|