123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- 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;
- namespace EMIS.CommonLogic.Students
- {
- public class BatchRepeatServices : BaseWorkflowServices<CF_DifferentDynamic>, IBatchRepeatServices
- {
- public Lazy<IDifferentDynamicServices> DifferentDynamicServices { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public BatchRepeatDAL BatchRepeatDAL { get; set; }
- public IGridResultSet<DifferentDynamicView> GetDifferentDynamicViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID,
- Guid? collegeID, int? education, int? year, int? standard, int? learningform, int? differentDynamicStatus, int pageIndex, int pageSize)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter = (x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.BatchRepeat);
- 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 = BatchRepeatDAL.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? education, int? year, int? standard, int? learningform, int? differentDynamicStatus)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<CF_DifferentDynamic, bool>> filter = (x => x.ChangeApplyTypeID == (int)CF_ChangeApplyType.BatchRepeat);
- 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 = BatchRepeatDAL.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.Repeat,
- Reason = (int)CF_ChangeReason.PoorPerformance,
- InSchoolStatusID = student.InSchoolStatusID,
- StudentStatus = student.StudentStatus,
- StandardID = student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
- ClassmajorID = student.ClassmajorID,
- ApplyTypeID = (int)CF_ChangeApplyType.BatchRepeat,
- ApplyRemark = "成绩太差,超过4门成绩不及格",
- Remark = "成绩太差,超过4门成绩不及格"
- };
- DifferentDynamicServices.Value.AddOrUpdateDifferentDynamic(differentDynamicView);
- });
- }
- public void Process(IList<Guid> idList)
- {
- var startStatus = this.GetStartStatus();
- var endStatusList = this.GetBackpointStatus();
- var correctEndStatus = this.GetCorrectEndStatus();
- var differentDynamicList = this.BatchRepeatDAL
- .GetBatchRepeatProcessView(x => idList.Contains(x.StudentChangeID)
- && x.AfterClassmajorID == null).ToList();
- ActionView actionView = null;
- if (differentDynamicList.Any(x => x.EntityApprovalStatus == startStatus || x.EntityApprovalStatus == correctEndStatus || endStatusList.Contains(x.EntityApprovalStatus))
- || idList.Any(x => !differentDynamicList.Any(w => w.EntityID == x)))
- {
- throw new Exception("只能审核已提交的数据,所选的记录中有其他状态的数据,无法审核。");
- }
- if (differentDynamicList.Any(x => x.AfterClassmajorID == null))
- {
- throw new Exception("学生" + string.Join("、", differentDynamicList.Where(x => x.AfterClassmajorID == null).Select(x => x.Name)) + "找不到可留级的班,请检查班级设置。");
- }
- if (differentDynamicList.Count > 0)
- {
- actionView = this.GetActionView(differentDynamicList.First().EntityID, CustomPrincipal.Current.UserID)
- .OrderBy(x => x.Sort).FirstOrDefault();
- }
- else
- {
- return;
- }
- foreach (var differentDynamic in differentDynamicList)
- {
- this.DifferentDynamicServices.Value.AddOrUpdateDifferentDynamic(differentDynamic);
- }
- var approveIDList = differentDynamicList.Select(x => x.EntityID).Distinct().ToList();
- this.Approve(approveIDList, CustomPrincipal.Current.UserID, actionView.ActionID);
- }
- public void Approve(IList<Guid> idList)
- {
- var startStatus = this.GetStartStatus();
- var endStatusList = this.GetBackpointStatus();
- var correctEndStatus = this.GetCorrectEndStatus();
- var differentDynamicList = this.BatchRepeatDAL
- .GetBatchRepeatProcessView(x => idList.Contains(x.StudentChangeID)
- && x.AfterClassmajorID != null).ToList();
- ActionView actionView = null;
- if (differentDynamicList.Any(x => x.EntityApprovalStatus == startStatus || x.EntityApprovalStatus == correctEndStatus || endStatusList.Contains(x.EntityApprovalStatus))
- || idList.Any(x => !differentDynamicList.Any(w => w.EntityID == x)))
- {
- throw new Exception("只能审核已处理的数据,所选的记录中有其他状态的数据,无法审核。");
- }
- if (differentDynamicList.Count > 0)
- {
- actionView = this.GetActionView(differentDynamicList.First().EntityID, CustomPrincipal.Current.UserID)
- .OrderBy(x => x.Sort).FirstOrDefault();
- }
- else
- {
- return;
- }
- var approveIDList = differentDynamicList.Select(x => x.EntityID).Distinct().ToList();
- this.Approve(approveIDList, CustomPrincipal.Current.UserID, actionView.ActionID);
- }
- }
- }
|