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.DataLogic.GraduationManage.GraduateCardManage; using EMIS.CommonLogic.SystemServices; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.GraduationManage.GraduateCardManage { public class GraduateCardListServices : BaseWorkflowServices, IGraduateCardListServices, IFileUploadServices { public GraduateCardApplyDAL GraduateCardApplyDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } /// /// 查询去向名单信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetGraduateCardListViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? graduationTypeID, int? inSchoolStatus, int? needCardResult, int pageIndex, int pageSize) { var approveStatusList = this.GetStatusViewList(); var endApproveStatusID = this.GetCorrectEndStatus(); //去向申请 Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == endApproveStatusID); if (gradSchoolyearID.HasValue) { //毕业学期(实际的毕业学期) expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID); } if (graduationTypeID.HasValue) { //毕业类型 expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID); } if (needCardResult.HasValue) { //去向结论 expGraduateCardApply = expGraduateCardApply.And(x => x.NeedCardResult == needCardResult); } //学生信息 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 = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询去向名单信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetGraduateCardListViewList(ConfiguretView configuretView, Guid? gradSchoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? graduationTypeID, int? inSchoolStatus, int? needCardResult) { var approveStatusList = this.GetStatusViewList(); var endApproveStatusID = this.GetCorrectEndStatus(); //去向申请 Expression> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == endApproveStatusID); if (gradSchoolyearID.HasValue) { //毕业学期(实际的毕业学期) expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID); } if (graduationTypeID.HasValue) { //毕业类型 expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID); } if (needCardResult.HasValue) { //去向结论 expGraduateCardApply = expGraduateCardApply.And(x => x.NeedCardResult == needCardResult); } //学生信息 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 = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的去向名单信息GraduateCardApplyView /// /// /// public GraduateCardApplyView GetGraduateCardListView(Guid? graduateCardApplyID) { try { var graduateCardApplyView = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(x => x.GraduateCardApplyID == graduateCardApplyID) .SingleOrDefault(); return graduateCardApplyView; } 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 GraduateCardListEdit(GraduateCardApplyView graduateCardApplyView, List fileList) { throw new NotImplementedException(); } /// /// 删除 /// /// /// public bool GraduateCardListDelete(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; } } /// /// 流程结束跳转函数(工作流平台中配置) /// /// /// public void OnApproveEnd(List graduateCardApplyIDList, Guid? userID) { throw new NotImplementedException(); } } }