123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.Common.Students;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.DifferentDynamic;
- using EMIS.ViewModel;
- using EMIS.Utility.FormValidate;
- using EMIS.ViewModel.WorkflowManage;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.Utility;
- namespace EMIS.CommonLogic.Students
- {
- public class BatchQuitServices : BaseWorkflowServices<CF_DifferentDynamic>, IBatchQuitServices
- {
- public Lazy<IDifferentDynamicServices> DifferentDynamicServices { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public DifferentDynamicDAL DifferentDynamicDAL { get; set; }
- public IGridResultSet<DifferentDynamicView> GetDifferentDynamicViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID,
- Guid? collegeID, int? year, int? standard, int? education, int? learningform, int? differentDynamicStatus, int pageIndex, int pageSize)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter = (x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.BatchQuit);
- Expression<Func<CF_College, bool>> collegeFilter = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultyFilter = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeFilter = (x => true);
- if (schoolyearID.HasValue)
- {
- filter = filter.And(x => x.SchoolyearID == schoolyearID);
- }
- if (campusID.HasValue)
- {
- collegeFilter = collegeFilter.And(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- collegeFilter = collegeFilter.And(x => x.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- gradeFilter = gradeFilter.And(x => x.GradeID == year);
- }
- if (standard.HasValue)
- {
- facultyFilter = facultyFilter.And(x => x.StandardID == standard);
- }
- if (education.HasValue)
- {
- facultyFilter = facultyFilter.And(x => x.EducationID == education);
- }
- if (learningform.HasValue)
- {
- facultyFilter = facultyFilter.And(x => x.LearningformID == learningform);
- }
- if (differentDynamicStatus.HasValue)
- {
- filter = filter.And(x => x.ApprovalStatus == differentDynamicStatus);
- }
- var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter, gradeFilter, facultyFilter, collegeFilter);
- query = GetQueryByDataRangeByCollege(query);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- 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 List<DifferentDynamicView> GetDifferentDynamicViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? year, int? standard, int? education, int? learningform, int? differentDynamicStatus)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter = (x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.BatchQuit);
- Expression<Func<CF_College, bool>> collegeFilter = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultyFilter = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeFilter = (x => true);
- if (schoolyearID.HasValue)
- {
- filter = filter.And(x => x.SchoolyearID == schoolyearID);
- }
- if (campusID.HasValue)
- {
- collegeFilter = collegeFilter.And(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- collegeFilter = collegeFilter.And(x => x.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- gradeFilter = gradeFilter.And(x => x.GradeID == year);
- }
- if (standard.HasValue)
- {
- facultyFilter = facultyFilter.And(x => x.StandardID == standard);
- }
- if (education.HasValue)
- {
- facultyFilter = facultyFilter.And(x => x.EducationID == education);
- }
- if (learningform.HasValue)
- {
- facultyFilter = facultyFilter.And(x => x.LearningformID == learningform);
- }
- if (differentDynamicStatus.HasValue)
- {
- filter = filter.And(x => x.ApprovalStatus == differentDynamicStatus);
- }
- var query = DifferentDynamicDAL.GetDifferentDynamicQueryable(filter, gradeFilter, facultyFilter, collegeFilter);
- query = GetQueryByDataRangeByCollege(query);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = query.OrderByDescending(w => w.SchoolyearCode).ThenByDescending(w => w.EntityCreateTime).ThenBy(w => w.LoginID);
- var result = query.ToList();
- result.ForEach(x => x.ApprovalStatusName = statusList.Where(w => w.ID == x.EntityApprovalStatus).Select(w => w.Name).FirstOrDefault());
- return result;
- }
- public void BatchAddStudents(IList<Guid> studentIDList)
- {
- var studentList = StudentDAL.StudentRepository.GetList(x => studentIDList.Contains(x.UserID), (x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor)).ToList();
- var schoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
- studentList.ForEach(student => {
- var differentDynamicView = new DifferentDynamicView()
- {
- EntityID = Guid.Empty,
- SchoolyearID = schoolyear.SchoolYearID,
- UserID = student.UserID,
- DifferentDynamicType = (int)CF_ChangeType.Quit,
- Reason = (int)CF_ChangeReason.AutoQuit,
- InSchoolStatusID = student.InSchoolStatusID,
- StudentStatus = student.StudentStatus,
- StandardID = student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
- ClassmajorID = student.ClassmajorID,
- AfterInSchoolStatusID = (int)CF_InschoolStatus.Quited,
- AfterStudentStatus = (int)CF_StudentStatus.Cancel,
- ApplyTypeID = (int)CF_ChangeApplyType.BatchQuit,
- ApplyRemark = "自动退学",
- Remark = "自动退学"
- };
- DifferentDynamicServices.Value.AddOrUpdateDifferentDynamic(differentDynamicView);
- });
- }
- public void Approve(IList<Guid> idList)
- {
- var collegeApproveStatusList = this.GetStatusViewList()
- .Where(x => x.Description.Contains(Const.CF_STUDENTCHANGE_COLLEGEAPPROVE_FLAG)).ToList();
- var collegeApproveStatusIDList = collegeApproveStatusList.Select(x => x.ID).ToList();
- var differentDynamicList = this.DifferentDynamicDAL.DifferentDynamicRepository.GetList(x => idList.Contains(x.StudentChangeID)).ToList();
- ActionView actionView = null;
- Guid actionID;
- if (differentDynamicList.Any(x => !collegeApproveStatusIDList.Contains(x.ApprovalStatus)))
- {
- throw new Exception(string.Format("只能审核{0}状态的数据,所选的记录中有其他状态的数据,无法审核。",
- string.Join("、", collegeApproveStatusList.Select(x => x.Name))));
- }
- if (differentDynamicList.Count > 0)
- {
- actionView = this.GetActionView(differentDynamicList.First().StudentChangeID, CustomPrincipal.Current.UserID)
- .OrderBy(x => x.Sort).FirstOrDefault();
- actionID = actionView.ActionID;
- }
- else
- {
- return;
- }
- var differentDynamicIDList = differentDynamicList.Select(x => x.StudentChangeID).Distinct().ToList();
- this.Approve(differentDynamicIDList, CustomPrincipal.Current.UserID, actionID);
- }
- }
- }
|