using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Transactions; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.GraduationManage.GraduateCardManage; using EMIS.ViewModel.ScoreManage; using EMIS.DataLogic.GraduationManage.GraduateCardManage; using EMIS.CommonLogic.SystemServices; using EMIS.CommonLogic.CalendarManage; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.GraduationManage.GraduateCardManage { public class GraduateCardApplyServices : BaseWorkflowServices, IGraduateCardApplyServices, IFileUploadServices { public GraduateCardApplyDAL GraduateCardApplyDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } public Lazy ParameterServices { get; set; } public Lazy SchoolYearServices { get; set; } /// /// 查询去向申请信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetGraduateCardApplyViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? graduationTypeID, int? inSchoolStatus, int? approvalStatus, int pageIndex, int pageSize) { //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); //审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusList = this.GetStatusViewList(); var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //去向申请 Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGraduateCardApply = expGraduateCardApply.And(x => applyStatusIDList.Contains(x.ApprovalStatus)); if (gradSchoolyearID.HasValue) { //毕业学期(实际的毕业学期) expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID); } if (graduationTypeID.HasValue) { //毕业类型 expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID); } if (approvalStatus.HasValue) { //审批状态 expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == approvalStatus); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); 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 = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(expGraduateCardApply, expStudent); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { query = query.Where(x => x.SchoolyearID == yearID); } 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.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo) .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo) .ThenBy(x => x.GraduatingSemesterValue) .ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询去向申请信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetGraduateCardApplyViewList(ConfiguretView configuretView, Guid? gradSchoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? graduationTypeID, int? inSchoolStatus, int? approvalStatus) { //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); //审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusList = this.GetStatusViewList(); var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //去向申请 Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGraduateCardApply = expGraduateCardApply.And(x => applyStatusIDList.Contains(x.ApprovalStatus)); if (gradSchoolyearID.HasValue) { //毕业学期(实际的毕业学期) expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID); } if (graduationTypeID.HasValue) { //毕业类型 expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID); } if (approvalStatus.HasValue) { //审批状态 expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == approvalStatus); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); 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 = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(expGraduateCardApply, expStudent); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { query = query.Where(x => x.SchoolyearID == yearID); } 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.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo) .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo) .ThenBy(x => x.GraduatingSemesterValue) .ToList(); result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的去向申请信息GraduateCardApplyView /// /// /// public GraduateCardApplyView GetGraduateCardApplyView(Guid? graduateCardApplyID) { try { var graduateCardApplyView = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(x => x.GraduateCardApplyID == graduateCardApplyID) .SingleOrDefault(); return graduateCardApplyView; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 名单生成(新增、修改) /// 新增包括:毕业学期小于等于当前启用的毕业学期、学籍信息为在校(排除在校状态为结业、毕业的信息)、在毕业申请允许最大年限(年)范围内 /// 修改:未提交 /// 业务主键:学生信息ID、毕业学期ID(实际的毕业学期) /// /// public string GraduateCardApplyEdit() { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,毕业去向流程未配置,请核查。"); } //查询工作流程开始环节状态 var approveStartStatusID = this.GetStartStatus(); if (approveStartStatusID == null) { throw new Exception("工作流平台中,毕业去向流程开始环节未配置,请核查。"); } //查询工作流程结束环节状态 var approveEndStatusID = this.GetCorrectEndStatus(); if (approveEndStatusID == null) { throw new Exception("工作流平台中,毕业去向流程结束环节未配置,请核查。"); } //查询工作流程审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusIDList = approveStatusList.Where(x => x.ID != approveEndStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //查询培养类型设置信息List var educationTypeSettingList = GraduateCardApplyDAL.EducationTypeSettingRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0) { throw new Exception("培养类型设置未设置,请设置。"); } //查询设置的毕业学期信息 var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear); if (!string.IsNullOrEmpty(graduatingSemesterID)) { var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID)); if (graSchoolYearView == null) { throw new Exception("毕业学期设置有误,请重新设置。"); } //查询设置的毕业申请允许最大年限(年) var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit); if (setGraduationApplyMaxAgeLimit == null) { throw new Exception("未设置毕业申请允许最大年限(年),请设置。"); } var graduationApplyMaxAgeLimit = Convert.ToDecimal(setGraduationApplyMaxAgeLimit); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //在校状态 var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); //排除在校状态为毕业的信息 expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Graduation); //排除在校状态为结业的信息 expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Complete); //毕业学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //应届、往届毕业(小于等于当前启用的毕业学期) expSchoolyear = expSchoolyear.And(x => x.Value <= graSchoolYearView.Value); //去向申请(需排除的信息) Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //去向申请中待审核、已通过状态 expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus) || x.ApprovalStatus == approveEndStatusID); //查询对应的毕业学生信息ViewList(注:数据范围) var query = GraduateCardApplyDAL.GetGraduationStudentViewQueryable(expStudent, expSchoolyear, expGraduateCardApply, graSchoolYearView.SchoolYearID); //在毕业申请允许最大年限(年)范围内 query = query.Where(x => x.GraduationAgeLimitValue <= graduationApplyMaxAgeLimit); //匹配对应的数据范围 var graduationStudentViewList = this.GetQueryByDataRangeByCollege(query).ToList(); //对应的学生信息IDList var userIDList = graduationStudentViewList.Select(x => x.UserID).ToList(); //查询去向申请信息graduateCardApplyList var graduateCardApplyList = GraduateCardApplyDAL.GraduateCardApplyRepository.GetList(x => true).ToList(); //匹配对应的条件查询 graduateCardApplyList = graduateCardApplyList.Where(x => userIDList.Contains(x.UserID)).ToList(); int insert = 0; int update = 0; string tipMessage = null; List graduateCardApplyInList = new List(); List graduateCardApplyUpList = new List(); foreach (var graduationStudentView in graduationStudentViewList) { //根据对应的信息查询去向申请信息 var graduateCardApply = graduateCardApplyList.Where(x => x.UserID == graduationStudentView.UserID && x.GraduatingSemesterID == graSchoolYearView.SchoolYearID) .SingleOrDefault(); if (graduateCardApply == null) { //新增 ER_GraduateCardApply newGraduateCardApply = new ER_GraduateCardApply(); newGraduateCardApply.GraduateCardApplyID = Guid.NewGuid(); newGraduateCardApply.UserID = graduationStudentView.UserID; if (graduationStudentView.GraduatingSemesterValue == graSchoolYearView.Value) { //应届 newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Fresh; } else if (graduationStudentView.GraduatingSemesterValue < graSchoolYearView.Value) { //往届 newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Former; } else { //提前 newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Advance; } newGraduateCardApply.GraduatingSemesterID = graSchoolYearView.SchoolYearID; newGraduateCardApply.NeedCardResult = null; newGraduateCardApply.ApprovalStatus = approveStartStatusID; newGraduateCardApply.Remark = null; SetNewStatus(newGraduateCardApply); graduateCardApplyInList.Add(newGraduateCardApply); insert++; } else { //表示修改(只处理未提交状态)if (applyStatusIDList.Any(x => x == graduateCardApply.ApprovalStatus)) if (graduateCardApply.ApprovalStatus == approveStartStatusID) { if (graduationStudentView.GraduatingSemesterValue == graSchoolYearView.Value) { //应届 graduateCardApply.GraduationTypeID = (int)ER_GraduationType.Fresh; } else if (graduationStudentView.GraduatingSemesterValue < graSchoolYearView.Value) { //往届 graduateCardApply.GraduationTypeID = (int)ER_GraduationType.Former; } else { //提前 graduateCardApply.GraduationTypeID = (int)ER_GraduationType.Advance; } graduateCardApply.NeedCardResult = null; SetModifyStatus(graduateCardApply); graduateCardApplyUpList.Add(graduateCardApply); update++; } } } //批量插入 UnitOfWork.BulkInsert(graduateCardApplyInList); if (graduateCardApplyUpList != null && graduateCardApplyUpList.Count() > 0) { //批量更新 UnitOfWork.BatchUpdate(graduateCardApplyUpList); } if (insert > 0 && update <= 0) { tipMessage = insert + "条"; } else { tipMessage = insert + "条,更新成功" + update + "条"; } return tipMessage; } else { throw new Exception("未设置毕业学期,请设置。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的附件文件(根据外键表ID) /// /// /// public List GetFileList(Guid? formID) { var query = GraduateCardApplyDAL.GetGraduateCardApplyAttachmentQueryable(x => x.GraduateCardApplyID == formID).ToList(); return query; } /// /// 编辑(新增、修改,业务主键:学生信息ID、毕业学期ID(实际的毕业学期)) /// /// /// public void GraduateCardApplyEdit(GraduateCardApplyView graduateCardApplyView, List fileList) { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,毕业去向流程未配置,请核查。"); } //查询工作流程开始环节状态 var approveStartStatus = this.GetStartStatus(); if (approveStartStatus == null) { throw new Exception("工作流平台中,毕业去向流程开始环节未配置,请核查。"); } //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,毕业去向流程结束环节未配置,请核查。"); } //审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusIDList = approveStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //查询培养类型设置信息List var educationTypeSettingList = GraduateCardApplyDAL.EducationTypeSettingRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0) { throw new Exception("培养类型设置未设置,请设置。"); } //查询数据库进行验证 var graduateCardApplyVerification = GraduateCardApplyDAL.GraduateCardApplyRepository .GetList(x => x.GraduateCardApplyID != graduateCardApplyView.GraduateCardApplyID && x.UserID == graduateCardApplyView.UserID && x.GraduatingSemesterID == graduateCardApplyView.GraduatingSemesterID) .SingleOrDefault(); if (graduateCardApplyVerification == null) { //数据有误验证 if (graduateCardApplyView.GraduateCardApplyID != Guid.Empty) { var graduateCardApply = GraduateCardApplyDAL.GraduateCardApplyRepository .GetList(x => x.GraduateCardApplyID == graduateCardApplyView.GraduateCardApplyID, (x => x.ER_GraduateCardApplyAttachment)).SingleOrDefault(); if (graduateCardApply == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 if (applyStatusIDList.Any(x => x == graduateCardApply.ApprovalStatus)) { graduateCardApply.GraduationTypeID = graduateCardApplyView.GraduationTypeID; graduateCardApply.Remark = graduateCardApplyView.Remark; SetModifyStatus(graduateCardApply); } else { throw new Exception("数据有误,请核查(只能修改未提交、已退回状态的信息)。"); } } } else { //表示新增 ER_GraduateCardApply newGraduateCardApply = new ER_GraduateCardApply(); newGraduateCardApply.GraduateCardApplyID = Guid.NewGuid(); newGraduateCardApply.UserID = graduateCardApplyView.UserID; newGraduateCardApply.GraduationTypeID = graduateCardApplyView.GraduationTypeID; newGraduateCardApply.GraduatingSemesterID = graduateCardApplyView.GraduatingSemesterID; newGraduateCardApply.NeedCardResult = null; newGraduateCardApply.ApprovalStatus = approveStartStatus; newGraduateCardApply.Remark = graduateCardApplyView.Remark; SetNewStatus(newGraduateCardApply); UnitOfWork.Add(newGraduateCardApply); } } else { throw new Exception("已存在相同的去向申请信息,请核查。"); } //事务提交 UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 去向申请批量新增(业务主键:学生信息ID、毕业学期ID(实际的毕业学期)) /// /// /// /// public string GraduateCardApplyBatchAdd(List graduationStudentViewList, GraduateCardApplyView graduateCardApplyView) { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,毕业去向流程未配置,请核查。"); } //查询工作流程开始环节状态 var approveStartStatusID = this.GetStartStatus(); if (approveStartStatusID == null) { throw new Exception("工作流平台中,毕业去向流程开始环节未配置,请核查。"); } //查询工作流程结束环节状态 var approveEndStatusID = this.GetCorrectEndStatus(); if (approveEndStatusID == null) { throw new Exception("工作流平台中,毕业去向流程结束环节未配置,请核查。"); } //查询培养类型设置信息List var educationTypeSettingList = GraduateCardApplyDAL.EducationTypeSettingRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0) { throw new Exception("培养类型设置未设置,请设置。"); } //查询设置的毕业学期信息 var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear); if (!string.IsNullOrEmpty(graduatingSemesterID)) { var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID)); if (graSchoolYearView == null) { throw new Exception("毕业学期设置有误,请重新设置。"); } //查询设置的毕业申请允许最大年限(年) var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit); if (setGraduationApplyMaxAgeLimit == null) { throw new Exception("未设置毕业申请允许最大年限(年),请设置。"); } //查询去向申请信息graduationApplyList var graduateCardApplyList = GraduateCardApplyDAL.GraduateCardApplyRepository.GetList(x => true).ToList(); //查询对应的学生信息userIDList var userIDList = graduationStudentViewList.Where(x => !string.IsNullOrEmpty(x.UserID.ToString())) .Select(x => x.UserID).ToList(); //匹配对应的条件查询 graduateCardApplyList = graduateCardApplyList.Where(x => userIDList.Contains(x.UserID)).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List graduateCardApplyInList = new List(); foreach (var graduationStudentView in graduationStudentViewList) { //根据对应的信息查询去向申请信息(业务主键:学生信息ID、毕业学期ID(实际的毕业学期)) var graduateCardApply = graduateCardApplyList.Where(x => x.UserID == graduationStudentView.UserID && x.GraduatingSemesterID == graSchoolYearView.SchoolYearID) .SingleOrDefault(); if (graduateCardApply == null) { //新增 ER_GraduateCardApply newGraduateCardApply = new ER_GraduateCardApply(); newGraduateCardApply.GraduateCardApplyID = Guid.NewGuid(); newGraduateCardApply.UserID = graduationStudentView.UserID; if (graduationStudentView.GraduatingSemesterValue == graSchoolYearView.Value) { //应届 newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Fresh; } else if (graduationStudentView.GraduatingSemesterValue < graSchoolYearView.Value) { //往届 newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Former; } else { //提前 newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Advance; } newGraduateCardApply.GraduatingSemesterID = graSchoolYearView.SchoolYearID; newGraduateCardApply.NeedCardResult = null; newGraduateCardApply.ApprovalStatus = approveStartStatusID; newGraduateCardApply.Remark = null; SetNewStatus(newGraduateCardApply); graduateCardApplyInList.Add(newGraduateCardApply); success++; } else { //表示已存在相同的去向申请信息 fail++; } } //批量插入 UnitOfWork.BulkInsert(graduateCardApplyInList); if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条,失败" + fail + "条,原因:已存在相同的去向申请信息,请检查"; } return tipMessage; } else { throw new Exception("未设置毕业学期,请设置。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询未新增毕业学生信息GraduateCardApplyView /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetGraduationStudentNoAddViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? inSchoolStatus, Guid? gradSchoolyearID, int pageIndex, int pageSize) { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); //查询工作流程结束环节状态 var approveEndStatusID = this.GetCorrectEndStatus(); //查询工作流程审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusIDList = approveStatusList.Where(x => x.ID != approveEndStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //查询设置的毕业学期信息 var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear); //查询毕业学期对应的学年学期信息graSchoolYearView var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID)); //查询设置的毕业申请允许最大年限(年) var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit); var graduationApplyMaxAgeLimit = Convert.ToDecimal(setGraduationApplyMaxAgeLimit); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); 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)); } } //排除在校状态为毕业的信息 expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Graduation); //排除在校状态为结业的信息 expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Complete); //毕业学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //应届、往届毕业(小于等于当前启用的毕业学期) expSchoolyear = expSchoolyear.And(x => x.Value <= graSchoolYearView.Value); //去向申请(需排除的信息) Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //去向申请中待审核、已通过状态 expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus) || x.ApprovalStatus == approveEndStatusID); //查询对应的毕业学生信息ViewList(注:数据范围) var query = GraduateCardApplyDAL.GetGraduationStudentNoAddViewQueryable(expStudent, expSchoolyear, expGraduateCardApply, graSchoolYearView.SchoolYearID); //在毕业申请允许最大年限(年)范围内 query = query.Where(x => x.GraduationAgeLimitValue <= graduationApplyMaxAgeLimit); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } 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 (gradSchoolyearID.HasValue) { //预毕业学期 query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID); } 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()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.ClassNo.Length) .ThenBy(x => x.ClassNo).ThenBy(x => x.StudentNo.Length) .ThenBy(x => x.StudentNo).ThenBy(x => x.GraduatingSemesterValue) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询未新增毕业学生信息List /// /// /// /// /// /// /// /// /// /// /// /// public IList GetGraduationStudentNoAddViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? inSchoolStatus, Guid? gradSchoolyearID) { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); //查询工作流程结束环节状态 var approveEndStatusID = this.GetCorrectEndStatus(); //查询工作流程审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusIDList = approveStatusList.Where(x => x.ID != approveEndStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //查询设置的毕业学期信息 var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear); //查询毕业学期对应的学年学期信息graSchoolYearView var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID)); //查询设置的毕业申请允许最大年限(年) var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit); var graduationApplyMaxAgeLimit = Convert.ToDecimal(setGraduationApplyMaxAgeLimit); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); 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)); } } //排除在校状态为毕业的信息 expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Graduation); //排除在校状态为结业的信息 expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Complete); //毕业学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //应届、往届毕业(小于等于当前启用的毕业学期) expSchoolyear = expSchoolyear.And(x => x.Value <= graSchoolYearView.Value); //去向申请(需排除的信息) Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //去向申请中待审核、已通过状态 expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus) || x.ApprovalStatus == approveEndStatusID); //查询对应的毕业学生信息ViewList(注:数据范围) var query = GraduateCardApplyDAL.GetGraduationStudentNoAddViewQueryable(expStudent, expSchoolyear, expGraduateCardApply, graSchoolYearView.SchoolYearID); //在毕业申请允许最大年限(年)范围内 query = query.Where(x => x.GraduationAgeLimitValue <= graduationApplyMaxAgeLimit); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } 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 (gradSchoolyearID.HasValue) { //预毕业学期 query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID); } 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()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.ClassNo.Length) .ThenBy(x => x.ClassNo).ThenBy(x => x.StudentNo.Length) .ThenBy(x => x.StudentNo).ThenBy(x => x.GraduatingSemesterValue) .ToList(); } /// /// 删除 /// /// /// public bool GraduateCardApplyDelete(List graduateCardApplyIDs) { try { using (TransactionScope ts = new TransactionScope()) { UnitOfWork.Delete(x => graduateCardApplyIDs.Contains(x.GraduateCardApplyID)); UnitOfWork.Delete(x => graduateCardApplyIDs.Contains(x.GraduateCardApplyID)); ts.Complete(); return true; } } catch (Exception) { throw; } } /// /// 查询去向申请对应的学生最终成绩信息FinallyScoreView /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetFinallyScoreViewGrid(ConfiguretView configuretView, Guid? graduateCardApplyID, Guid? schoolyearID, int? courseTypeID, int? courseSelectTypeID, int? examsCategoryID, int? starttermID, int? isMainCourse, int? handleModeID, int? isExecutablePlan, int? executablePlanStatus, int pageIndex, int pageSize) { //去向申请 Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGraduateCardApply = expGraduateCardApply.And(x => x.GraduateCardApplyID == graduateCardApplyID); var query = GraduateCardApplyDAL.GetFinallyScoreViewQueryable(expGraduateCardApply); if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } if (courseTypeID.HasValue) { query = query.Where(x => x.CourseTypeID == courseTypeID); } if (courseSelectTypeID.HasValue) { query = query.Where(x => x.CourseSelectTypeID == courseSelectTypeID); } if (examsCategoryID.HasValue) { query = query.Where(x => x.ExamsCategoryID == examsCategoryID); } if (starttermID.HasValue) { query = query.Where(x => x.StarttermID == starttermID); } if (isMainCourse.HasValue) { //可否学位课程 if (isMainCourse.Value == (int)CF_GeneralPurpose.IsYes) { query = query.Where(x => x.IsMainCourse == true); } if (isMainCourse.Value == (int)CF_GeneralPurpose.IsNo) { query = query.Where(x => x.IsMainCourse != true); } } if (handleModeID.HasValue) { query = query.Where(x => x.HandleModeID == handleModeID); } if (isExecutablePlan.HasValue) { //是否计划(执行计划) if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsYes) { query = query.Where(x => x.IsExecutablePlan == true); } if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsNo) { query = query.Where(x => x.IsExecutablePlan != true); } } if (executablePlanStatus.HasValue) { //执行计划状态 query = query.Where(x => x.ExecutablePlanStatus == executablePlanStatus); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询去向申请对应的学生最终成绩信息List /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetFinallyScoreViewList(ConfiguretView configuretView, Guid? graduateCardApplyID, Guid? schoolyearID, int? courseTypeID, int? courseSelectTypeID, int? examsCategoryID, int? starttermID, int? isMainCourse, int? handleModeID, int? isExecutablePlan, int? executablePlanStatus) { //去向申请 Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGraduateCardApply = expGraduateCardApply.And(x => x.GraduateCardApplyID == graduateCardApplyID); var query = GraduateCardApplyDAL.GetFinallyScoreViewQueryable(expGraduateCardApply); if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } if (courseTypeID.HasValue) { query = query.Where(x => x.CourseTypeID == courseTypeID); } if (courseSelectTypeID.HasValue) { query = query.Where(x => x.CourseSelectTypeID == courseSelectTypeID); } if (examsCategoryID.HasValue) { query = query.Where(x => x.ExamsCategoryID == examsCategoryID); } if (starttermID.HasValue) { query = query.Where(x => x.StarttermID == starttermID); } if (isMainCourse.HasValue) { //可否学位课程 if (isMainCourse.Value == (int)CF_GeneralPurpose.IsYes) { query = query.Where(x => x.IsMainCourse == true); } if (isMainCourse.Value == (int)CF_GeneralPurpose.IsNo) { query = query.Where(x => x.IsMainCourse != true); } } if (handleModeID.HasValue) { query = query.Where(x => x.HandleModeID == handleModeID); } if (isExecutablePlan.HasValue) { //是否计划(执行计划) if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsYes) { query = query.Where(x => x.IsExecutablePlan == true); } if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsNo) { query = query.Where(x => x.IsExecutablePlan != true); } } if (executablePlanStatus.HasValue) { //执行计划状态 query = query.Where(x => x.ExecutablePlanStatus == executablePlanStatus); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ToList(); } /// /// 流程已退回跳转函数(工作流平台中配置) /// /// /// public void OnApproveReturn(List graduateCardApplyIDList, Guid? userID) { //查询对应的去向申请信息List var graduateCardApplyList = GraduateCardApplyDAL.GraduateCardApplyRepository .GetList(x => graduateCardApplyIDList.Contains(x.GraduateCardApplyID)).ToList(); //更新对应的去向申请信息 List graduateCardApplyUpList = new List(); foreach (var graduateCardApply in graduateCardApplyList) { graduateCardApply.NeedCardResult = null; this.SetModifyStatus(graduateCardApply); graduateCardApplyUpList.Add(graduateCardApply); } this.UnitOfWork.BatchUpdate(graduateCardApplyUpList); } } }