using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using EMIS.DataLogic.MinorManage.MinorPlanManage; using EMIS.DataLogic.Common.CalendarManage; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.MinorManage.MinorPlanManage; using EMIS.ViewModel; using System.Linq.Expressions; using Bowin.Common.Linq; namespace EMIS.CommonLogic.MinorManage.MinorPlanManage { public class MinorPlanApproveServices : BaseWorkflowServices, IMinorPlanApproveServices { public MinorPlanApplyDAL MinorPlanApplyDAL { get; set; } public SchoolYearDAL schoolYearDAL { get; set; } public IGridResultSet GetMinorPlanApplyViewGrid(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, int pageIndex, int pageSize) { var statusList = this.GetStatusViewList(); Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) exp = exp.And(x => x.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.StandardID == standardID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); if (approvalStatus.HasValue) exp = exp.And(x => x.RecordStatus == approvalStatus); var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp); query = query.Where(x => x.ApprovalStatus == 3); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } public List GetMinorPlanApplyViewList(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, List GradeMinorApplicationIDList) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (GradeMinorApplicationIDList != null) exp = exp.And(x => GradeMinorApplicationIDList.Contains(x.GradeMinorApplicationID)); if (yearID.HasValue) exp = exp.And(x => x.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.StandardID == standardID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); if (approvalStatus.HasValue) exp = exp.And(x => x.RecordStatus == approvalStatus); var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp); query = query.Where(x => x.ApprovalStatus == 3); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToList(); } /// /// 审核完成事件,由工作流自动触发 /// /// /// public void OnApproveEnd(IList GradeMinorApplicationIDList, Guid? userID) { var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID; if (graduatingSemester == null) { throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查"); } var SchoolcodeID = Convert.ToInt32(graduatingSemester); var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); var GradeMinorApplicationList = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(x => GradeMinorApplicationIDList.Contains(x.GradeMinorApplicationID)).ToList(); var GradeMinorApplicationIDsList = GradeMinorApplicationList.Select(x => x.GradeMinorApplicationID).ToList(); var minorSpecialCourseList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x=>GradeMinorApplicationIDsList.Contains(x.GrademinorApplicationID)).ToList(); var minorSpecialCourseIDList = minorSpecialCourseList.Select(x => x.MinorPlanApplicationID).ToList(); var minorSpecialCourseTeachingSettingList = MinorPlanApplyDAL.MinorPlanApplicationTeachingSettingRepository.GetList(x => minorSpecialCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList(); var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorPlanApplicationTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList(); var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorPlanApplicationTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList(); #region 插入数据 List GrademinorList = new List(); List MinorPlanList = new List(); List MinorPlanTeachingModeTypeList = new List(); List MinorPlanTeachingPlaceList = new List(); List MinorPlanTeachingSettingList = new List(); //添加辅修专业 foreach (var GrademinorPlan in GradeMinorApplicationList) { CF_Grademinor Grademinor = new CF_Grademinor(); Grademinor.GrademinorID = Guid.NewGuid(); Grademinor.GrademinorApplicationID = GrademinorPlan.GradeMinorApplicationID; Grademinor.SchoolyearID = GrademinorPlan.SchoolyearID; Grademinor.CollegeID=GrademinorPlan.CollegeID; Grademinor.YearID=GrademinorPlan.YearID; Grademinor.StandardID=GrademinorPlan.StandardID; Grademinor.StudentLimit = GrademinorPlan.StudentLimit; SetNewStatus(Grademinor); GrademinorList.Add(Grademinor); //添加辅修计划 foreach (var minorSpecialCourse in minorSpecialCourseList) { if (minorSpecialCourse.GrademinorApplicationID == GrademinorPlan.GradeMinorApplicationID) { var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == GrademinorPlan.YearID && x.SchoolcodeID == SchoolcodeID); var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + minorSpecialCourse.StarttermID - 1)); EM_MinorPlan MinorPlan = new EM_MinorPlan(); MinorPlan.MinorPlanID = Guid.NewGuid(); MinorPlan.MinorPlanApplicationID = minorSpecialCourse.MinorPlanApplicationID; MinorPlan.CoursematerialID = minorSpecialCourse.CoursematerialID; MinorPlan.DepartmentID = minorSpecialCourse.DepartmentID; MinorPlan.GrademinorID = Grademinor.GrademinorID; MinorPlan.SchoolyearID = courseSchoolyear.SchoolyearID; MinorPlan.CourseStructureID=minorSpecialCourse.CourseStructureID; MinorPlan.CourseCategoryID=minorSpecialCourse.CourseCategoryID; MinorPlan.CourseTypeID=minorSpecialCourse.CourseTypeID; MinorPlan.CourseQualityID=minorSpecialCourse.CourseQualityID; MinorPlan.PracticeTypeID=minorSpecialCourse.PracticeTypeID; MinorPlan.ExaminationModeID=minorSpecialCourse.ExaminationModeID; MinorPlan.CourseFineID=minorSpecialCourse.CourseFineID; MinorPlan.IsSpecialtycore=minorSpecialCourse.IsSpecialtycore; MinorPlan.IsCooperation=minorSpecialCourse.IsCooperation; MinorPlan.IsRequired=minorSpecialCourse.IsRequired; MinorPlan.IsElective=minorSpecialCourse.IsElective; MinorPlan.IsNetworkCourse=minorSpecialCourse.IsNetworkCourse; MinorPlan.IsMainCourse=minorSpecialCourse.IsMainCourse; MinorPlan.TeachinglanguageID=minorSpecialCourse.TeachinglanguageID; MinorPlan.HandleModeID=minorSpecialCourse.HandleModeID; MinorPlan.IsNeedMaterial=minorSpecialCourse.IsNeedMaterial; MinorPlan.ResultTypeID = minorSpecialCourse.ResultTypeID; MinorPlan.Remarks = minorSpecialCourse.Remarks; SetNewStatus(MinorPlan); MinorPlanList.Add(MinorPlan); var minorSpecialCourseTeachingSetting = minorSpecialCourseTeachingSettingList.Where(x => x.MinorPlanApplicationID == minorSpecialCourse.MinorPlanApplicationID).FirstOrDefault(); EM_MinorPlanTeachingSetting MinorPlanTeachingSetting = new EM_MinorPlanTeachingSetting(); MinorPlanTeachingSetting.MinorPlanID = MinorPlan.MinorPlanID; MinorPlanTeachingSetting.Credit = minorSpecialCourseTeachingSetting.Credit; MinorPlanTeachingSetting.TheoryCourse = minorSpecialCourseTeachingSetting.TheoryCourse; MinorPlanTeachingSetting.Practicehours = minorSpecialCourseTeachingSetting.Practicehours; MinorPlanTeachingSetting.Trialhours = minorSpecialCourseTeachingSetting.Trialhours; MinorPlanTeachingSetting.WeeklyNum = minorSpecialCourseTeachingSetting.WeeklyNum; MinorPlanTeachingSetting.TheoryWeeklyNum = minorSpecialCourseTeachingSetting.TheoryWeeklyNum; MinorPlanTeachingSetting.PracticeWeeklyNum = minorSpecialCourseTeachingSetting.PracticeWeeklyNum; MinorPlanTeachingSetting.TrialWeeklyNum = minorSpecialCourseTeachingSetting.TrialWeeklyNum; MinorPlanTeachingSetting.StartWeeklyNum = minorSpecialCourseTeachingSetting.StartWeeklyNum; MinorPlanTeachingSetting.EndWeeklyNum = minorSpecialCourseTeachingSetting.EndWeeklyNum; MinorPlanTeachingSetting.WeeklyHours = minorSpecialCourseTeachingSetting.WeeklyHours; MinorPlanTeachingSettingList.Add(MinorPlanTeachingSetting); minorSpecialCourseTeachModeTypeList.Where(x => x.MinorPlanApplicationID == minorSpecialCourse.MinorPlanApplicationID).ToList().ForEach(x => { EM_MinorPlanTeachingModeType MinorPlanTeachingModeType = new EM_MinorPlanTeachingModeType(); MinorPlanTeachingModeType.MinorPlanTeachingModeTypeID = Guid.NewGuid(); MinorPlanTeachingModeType.MinorPlanID = MinorPlan.MinorPlanID; MinorPlanTeachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(MinorPlanTeachingModeType); MinorPlanTeachingModeTypeList.Add(MinorPlanTeachingModeType); }); minorSpecialCourseTeachPlaceList.Where(x => x.MinorPlanApplicationID == minorSpecialCourse.MinorPlanApplicationID).ToList().ForEach(x => { EM_MinorPlanTeachingPlace MinorPlanTeachingPlace = new EM_MinorPlanTeachingPlace(); MinorPlanTeachingPlace.MinorPlanTeachingPlaceID = Guid.NewGuid(); MinorPlanTeachingPlace.MinorPlanID = MinorPlan.MinorPlanID; MinorPlanTeachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(MinorPlanTeachingPlace); MinorPlanTeachingPlaceList.Add(MinorPlanTeachingPlace); }); } } } UnitOfWork.BulkInsert(GrademinorList); UnitOfWork.BulkInsert(MinorPlanList); UnitOfWork.BulkInsert(MinorPlanTeachingModeTypeList); UnitOfWork.BulkInsert(MinorPlanTeachingPlaceList); UnitOfWork.BulkInsert(MinorPlanTeachingSettingList); UnitOfWork.Commit(); #endregion } } }