using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.StudentManage.OnlineChecking; using EMIS.DataLogic.StudentManage.OnlineChecking; using EMIS.CommonLogic.SystemServices; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.StudentManage.OnlineChecking { public class CheckingCollectServices : BaseWorkflowServices, ICheckingCollectServices { public Lazy CheckingCollectDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } /// /// 数据范围 /// public CheckingCollectServices() { DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege(x, y, (w => w.Sys_User.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID))); } /// /// 查询对应的校对汇总信息CheckingHistoryView /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetCheckingCollectViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? checkingTypeID, int? inSchoolStatus, int? approvalStatus, int pageIndex, int pageSize) { var approveStatusList = this.GetStatusViewList(); var approveEndStatusID = this.GetEndStatus(); Expression> expStudentRecordChangeHistory = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (checkingTypeID.HasValue) { expStudentRecordChangeHistory = expStudentRecordChangeHistory.And(x => x.CheckingTypeID == checkingTypeID); } Expression> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expStudentContrast = expStudentContrast.And(x => approveEndStatusID.Contains(x.ApprovalStatus)); if (approvalStatus.HasValue) { expStudentContrast = expStudentContrast.And(x => x.ApprovalStatus == approvalStatus); } 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 = CheckingCollectDAL.Value.GetCheckingHistoryViewQueryable(expStudentRecordChangeHistory, expStudentContrast, 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 (grademajorID.HasValue) { query = query.Where(x => x.GrademajorID == grademajorID); } 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.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID) .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ColumnName) .OrderByDescending(x => x.ApprovalTime).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的校对汇总信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetCheckingCollectViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? checkingTypeID, int? inSchoolStatus, int? approvalStatus) { var approveStatusList = this.GetStatusViewList(); var approveEndStatusID = this.GetEndStatus(); Expression> expStudentRecordChangeHistory = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (checkingTypeID.HasValue) { expStudentRecordChangeHistory = expStudentRecordChangeHistory.And(x => x.CheckingTypeID == checkingTypeID); } Expression> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expStudentContrast = expStudentContrast.And(x => approveEndStatusID.Contains(x.ApprovalStatus)); if (approvalStatus.HasValue) { expStudentContrast = expStudentContrast.And(x => x.ApprovalStatus == approvalStatus); } 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 = CheckingCollectDAL.Value.GetCheckingHistoryViewQueryable(expStudentRecordChangeHistory, expStudentContrast, 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 (grademajorID.HasValue) { query = query.Where(x => x.GrademajorID == grademajorID); } 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.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID) .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ColumnName) .OrderByDescending(x => x.ApprovalTime).ToList(); result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的校对信息CheckingHistoryView /// /// /// public CheckingHistoryView GetStudentRecordChangeHistoryView(Guid? studentRecordChangeHistoryID) { try { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.StudentRecordChangeHistoryID == studentRecordChangeHistoryID); var query = CheckingCollectDAL.Value.GetCheckingHistoryViewQueryable(exp).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool StudentRecordChangeHistoryDelete(List studentRecordChangeHistoryIDs) { try { UnitOfWork.Delete(x => studentRecordChangeHistoryIDs.Contains(x.StudentRecordChangeHistoryID)); return true; } catch (Exception) { throw; } } } }