using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.StudentManage.StudentChange; using EMIS.DataLogic.StudentManage.StudentChange; using EMIS.CommonLogic.SystemServices; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.StudentManage.StudentChange { public class ChangeResultServices : BaseWorkflowServices, IChangeResultServices { public Lazy StudentChangeDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } /// /// 数据范围 /// public ChangeResultServices() { DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege(x, y, (w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID))); } /// /// 查询学籍异动结果信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetChangeResultViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? schoolyearID, int? changeTypeID, int? inSchoolStatus, int pageIndex, int pageSize) { var approveStatusList = this.GetStatusViewList(); var endApproveStatusID = this.GetCorrectEndStatus(); Expression> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endApproveStatusID); if (schoolyearID.HasValue) { expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID); } if (changeTypeID.HasValue) { expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID); } Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (classmajorID.HasValue) { expStudent = expStudent.And(x => x.ClassmajorID == classmajorID); } if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange, expStudent); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { query = query.Where(x => x.GradeID == gradeID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)) .OrderBy(x => x.SchoolyearValue).ThenBy(x => x.ChangeTypeID).ThenBy(x => x.GradeID).ThenBy(x => x.StandardID) .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.StudentNo) .OrderByDescending(x => x.ChangeDate).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询学籍异动结果信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetChangeResultViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? schoolyearID, int? changeTypeID, int? inSchoolStatus) { var approveStatusList = this.GetStatusViewList(); var endApproveStatusID = this.GetCorrectEndStatus(); Expression> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endApproveStatusID); if (schoolyearID.HasValue) { expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID); } if (changeTypeID.HasValue) { expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID); } Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (classmajorID.HasValue) { expStudent = expStudent.And(x => x.ClassmajorID == classmajorID); } if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange, expStudent); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { query = query.Where(x => x.GradeID == gradeID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)) .OrderBy(x => x.SchoolyearValue).ThenBy(x => x.ChangeTypeID).ThenBy(x => x.GradeID).ThenBy(x => x.StandardID) .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.StudentNo) .OrderByDescending(x => x.ChangeDate).ToList(); result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的学籍异动信息View /// /// /// public StudentChangeView GetStudentChangeView(Guid? studentChangeID) { try { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.StudentChangeID == studentChangeID); var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(exp).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool ChangeResultDelete(List studentChangeIDs) { try { var workflowStatusViewList = this.GetStatusViewList(); if (workflowStatusViewList == null || workflowStatusViewList.Count() <= 0) { throw new Exception("工作流平台中,学籍异动流程未配置,请核查。"); } var endStatusID = this.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,学籍异动流程结束环节未配置,请核查。"); } var studentChangeList = StudentChangeDAL.Value.StudentChangeRepository.GetList(x => studentChangeIDs.Contains(x.StudentChangeID)).ToList(); foreach (var studentChange in studentChangeList) { if (studentChange.ApprovalStatus != endStatusID) { throw new Exception("只能删除审核通过状态的信息,请刷新页面再次尝试。"); } } UnitOfWork.Delete(x => studentChangeIDs.Contains(x.StudentChangeID)); return true; } catch (Exception) { throw; } } /// /// 学籍异动Excel导入 /// /// /// /// /// /// /// public void StudentChangeImport(Dictionary cellheader, out int? inCount, out int? upCount, out List errdataList, out int? errCount, string sourcePhysicalPath) { throw new NotImplementedException(); } /// /// 流程结束跳转函数(工作流平台中配置) /// /// /// public void OnApproveEnd(List studentChangeIDList, Guid? userID) { throw new NotImplementedException(); } } }