1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366 |
- 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.CultureplanManage;
- using EMIS.ViewModel.CultureplanManage.PlanManagement;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.CultureplanManage.PlanManagement;
- namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
- {
- public class PlanApplicationServices : BaseWorkflowServices<EM_PlanApplication>, IPlanApplicationServices
- {
- public PlanApplicationDAL PlanApplicationDAL { get; set; }
- /// <summary>
- /// 查询对应的计划申请信息PlanApplicationView
- /// 注:普教版本(年级专业)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="grademajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<PlanApplicationView> GetPlanApplicationViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID,
- Guid? coursematerialID, int? handleModeID, 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<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expPlanApplication = expPlanApplication.And(x => applyStatusIDList.Contains(x.RecordStatus));
- if (schoolyearID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID);
- }
- if (grademajorID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
- }
- if (coursematerialID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
- }
- if (handleModeID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID);
- }
- if (approvalStatus.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus);
- }
- var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication);
- 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.GradeID == 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.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
- .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenByDescending(x => x.CreateTime).ToGridResultSet<PlanApplicationView>(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的计划申请信息List
- /// 注:普教版本(年级专业)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="grademajorID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="approvalStatus"></param>
- /// <returns></returns>
- public IList<PlanApplicationView> GetPlanApplicationViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID,
- Guid? coursematerialID, int? handleModeID, 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<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expPlanApplication = expPlanApplication.And(x => applyStatusIDList.Contains(x.RecordStatus));
- if (schoolyearID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID);
- }
- if (grademajorID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
- }
- if (coursematerialID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
- }
- if (handleModeID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID);
- }
- if (approvalStatus.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus);
- }
- var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication);
- 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.GradeID == 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.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
- .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenByDescending(x => x.CreateTime).ToList();
- result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的计划申请信息PlanApplicationView(根据计划申请ID)
- /// </summary>
- /// <param name="planApplicationID"></param>
- /// <returns></returns>
- public PlanApplicationView GetPlanApplicationView(Guid? planApplicationID)
- {
- try
- {
- var planApplicationView = PlanApplicationDAL.GetPlanApplicationViewQueryable(x => x.PlanApplicationID == planApplicationID).SingleOrDefault();
- return planApplicationView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
- /// </summary>
- /// <param name="planApplicationView"></param>
- public void PlanApplicationEdit(PlanApplicationView planApplicationView)
- {
- try
- {
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
- }
- //查询工作流程开始环节状态
- var startStatusID = this.GetStartStatus();
- if (startStatusID == 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();
- //查询数据库进行验证
- var planApplicationVerify = PlanApplicationDAL.PlanApplicationRepository
- .GetList(x => x.PlanApplicationID != planApplicationView.PlanApplicationID
- && x.SchoolyearID == planApplicationView.SchoolyearID
- && x.GrademajorID == planApplicationView.GrademajorID
- && x.CoursematerialID == planApplicationView.CoursematerialID).SingleOrDefault();
- if (planApplicationVerify == null)
- {
- //查询对应的年级专业信息
- var grademajor = PlanApplicationDAL.GrademajorRepository
- .GetList(x => x.GrademajorID == planApplicationView.GrademajorID).SingleOrDefault();
- if (grademajor == null)
- {
- throw new Exception("年级专业信息不存在,请检查。");
- }
- //查询年级专业对应的入学学年学期信息
- var startSchoolyear = PlanApplicationDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID
- && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault();
- if (startSchoolyear == null)
- {
- throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。");
- }
- //查询年级专业对应的毕业学年学期信息
- var graduatingSemester = PlanApplicationDAL.SchoolyearRepository
- .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduatingSemester == null)
- {
- throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。");
- }
- //查询对应的学年学期信息
- var schoolyear = PlanApplicationDAL.SchoolyearRepository
- .GetList(x => x.SchoolyearID == planApplicationView.SchoolyearID).SingleOrDefault();
- if (schoolyear == null)
- {
- throw new Exception("学年学期信息不存在,请检查。");
- }
- if (schoolyear.Value < startSchoolyear.Value)
- {
- throw new Exception("学年学期小于入学学年学期,请检查。");
- }
- if (schoolyear.Value > graduatingSemester.Value)
- {
- throw new Exception("学年学期大于毕业学年学期,请检查。");
- }
- List<EM_PlanApplication> newPlanApplicationInList = new List<EM_PlanApplication>();
- List<EM_PlanApplication> newPlanApplicationUpList = new List<EM_PlanApplication>();
- List<EM_PlanApplicationTeachingSetting> newTeachingSettingInList = new List<EM_PlanApplicationTeachingSetting>();
- List<EM_PlanApplicationTeachingSetting> newTeachingSettingUpList = new List<EM_PlanApplicationTeachingSetting>();
- List<EM_PlanApplicationTeachingModeType> newTeachingModeTypeInList = new List<EM_PlanApplicationTeachingModeType>();
- List<EM_PlanApplicationTeachingPlace> newTeachingPlaceInList = new List<EM_PlanApplicationTeachingPlace>();
- List<Guid?> planApplicationTMDelList = new List<Guid?>();
- List<Guid?> planApplicationTPDelList = new List<Guid?>();
- //数据有误验证
- if (planApplicationView.PlanApplicationID != Guid.Empty)
- {
- var planApplication = PlanApplicationDAL.PlanApplicationRepository
- .GetList(x => x.PlanApplicationID == planApplicationView.PlanApplicationID,
- (x => x.EM_PlanApplicationTeachingSetting)).SingleOrDefault();
- if (planApplication == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- if (applyStatusIDList.Any(x => x == planApplication.RecordStatus))
- {
- planApplication.SchoolyearID = planApplicationView.SchoolyearID;
- planApplication.GrademajorID = planApplicationView.GrademajorID;
- planApplication.CoursematerialID = planApplicationView.CoursematerialID;
- planApplication.CourseStructureID = planApplicationView.CourseStructureID;
- planApplication.CourseCategoryID = planApplicationView.CourseCategoryID;
- planApplication.CourseTypeID = planApplicationView.CourseTypeID;
- planApplication.CourseQualityID = planApplicationView.CourseQualityID;
- planApplication.DepartmentID = planApplicationView.DepartmentID;
- planApplication.IsSpecialtycore = planApplicationView.IsSpecialtycore;
- planApplication.IsCooperation = planApplicationView.IsCooperation;
- planApplication.IsRequired = planApplicationView.IsRequired;
- planApplication.IsElective = planApplicationView.IsElective;
- planApplication.IsNetworkCourse = planApplicationView.IsNetworkCourse;
- planApplication.IsMainCourse = planApplicationView.IsMainCourse;
- planApplication.IsNeedMaterial = planApplicationView.IsNeedMaterial;
- planApplication.CourseFineID = planApplicationView.CourseFineID;
- planApplication.PracticeTypeID = planApplicationView.PracticeTypeID;
- planApplication.TeachinglanguageID = planApplicationView.TeachinglanguageID;
- planApplication.ExaminationModeID = planApplicationView.ExaminationModeID;
- planApplication.ResultTypeID = planApplicationView.ResultTypeID;
- planApplication.HandleModeID = planApplicationView.HandleModeID;
- planApplication.Remark = planApplicationView.Remark;
- SetModifyStatus(planApplication);
- newPlanApplicationUpList.Add(planApplication);
- if (planApplication.EM_PlanApplicationTeachingSetting == null)
- {
- var newTeachingSetting = new EM_PlanApplicationTeachingSetting();
- newTeachingSetting.PlanApplicationID = planApplication.PlanApplicationID;
- newTeachingSetting.Credit = planApplicationView.Credit;
- newTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse;
- newTeachingSetting.Practicehours = planApplicationView.Practicehours;
- newTeachingSetting.Trialhours = planApplicationView.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours;
- newTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum;
- newTeachingSettingInList.Add(newTeachingSetting);
- }
- else
- {
- planApplication.EM_PlanApplicationTeachingSetting.Credit = planApplicationView.Credit;
- planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse;
- planApplication.EM_PlanApplicationTeachingSetting.Practicehours = planApplicationView.Practicehours;
- planApplication.EM_PlanApplicationTeachingSetting.Trialhours = planApplicationView.Trialhours;
- planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum;
- planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum;
- planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum;
- planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours;
- planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum;
- planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum;
- planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum;
- newTeachingSettingUpList.Add(planApplication.EM_PlanApplicationTeachingSetting);
- }
- if (planApplicationView.TeachingModeIDList != null && planApplicationView.TeachingModeIDList.Count() > 0)
- {
- planApplicationTMDelList.Add(planApplication.PlanApplicationID);
- foreach (var teachingModeID in planApplicationView.TeachingModeIDList)
- {
- var newTeachingMode = new EM_PlanApplicationTeachingModeType();
- newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.PlanApplicationID = planApplication.PlanApplicationID;
- newTeachingMode.TeachingModeID = teachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- else
- {
- planApplicationTMDelList.Add(planApplication.PlanApplicationID);
- }
- if (planApplicationView.TeachingPlaceIDList != null && planApplicationView.TeachingPlaceIDList.Count() > 0)
- {
- planApplicationTPDelList.Add(planApplication.PlanApplicationID);
- foreach (var teachingPlaceID in planApplicationView.TeachingPlaceIDList)
- {
- var newTeachingPlace = new EM_PlanApplicationTeachingPlace();
- newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.PlanApplicationID = planApplication.PlanApplicationID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- else
- {
- planApplicationTPDelList.Add(planApplication.PlanApplicationID);
- }
- }
- else
- {
- throw new Exception("数据有误,请核查(只能修改未提交、已退回状态的信息)。");
- }
- }
- }
- else
- {
- //表示新增
- var newPlanApplication = new EM_PlanApplication();
- newPlanApplication.PlanApplicationID = Guid.NewGuid();
- newPlanApplication.SchoolyearID = planApplicationView.SchoolyearID;
- newPlanApplication.GrademajorID = planApplicationView.GrademajorID;
- newPlanApplication.CoursematerialID = planApplicationView.CoursematerialID;
- newPlanApplication.CourseStructureID = planApplicationView.CourseStructureID;
- newPlanApplication.CourseCategoryID = planApplicationView.CourseCategoryID;
- newPlanApplication.CourseTypeID = planApplicationView.CourseTypeID;
- newPlanApplication.CourseQualityID = planApplicationView.CourseQualityID;
- newPlanApplication.DepartmentID = planApplicationView.DepartmentID;
- newPlanApplication.IsSpecialtycore = planApplicationView.IsSpecialtycore;
- newPlanApplication.IsCooperation = planApplicationView.IsCooperation;
- newPlanApplication.IsRequired = planApplicationView.IsRequired;
- newPlanApplication.IsElective = planApplicationView.IsElective;
- newPlanApplication.IsNetworkCourse = planApplicationView.IsNetworkCourse;
- newPlanApplication.IsMainCourse = planApplicationView.IsMainCourse;
- newPlanApplication.IsNeedMaterial = planApplicationView.IsNeedMaterial;
- newPlanApplication.CourseFineID = planApplicationView.CourseFineID;
- newPlanApplication.PracticeTypeID = planApplicationView.PracticeTypeID;
- newPlanApplication.TeachinglanguageID = planApplicationView.TeachinglanguageID;
- newPlanApplication.ExaminationModeID = planApplicationView.ExaminationModeID;
- newPlanApplication.ResultTypeID = planApplicationView.ResultTypeID;
- newPlanApplication.HandleModeID = planApplicationView.HandleModeID;
- newPlanApplication.Remark = planApplicationView.Remark;
- SetNewStatus(newPlanApplication, startStatusID.Value);
- newPlanApplicationInList.Add(newPlanApplication);
- var newTeachingSetting = new EM_PlanApplicationTeachingSetting();
- newTeachingSetting.PlanApplicationID = newPlanApplication.PlanApplicationID;
- newTeachingSetting.Credit = planApplicationView.Credit;
- newTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse;
- newTeachingSetting.Practicehours = planApplicationView.Practicehours;
- newTeachingSetting.Trialhours = planApplicationView.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours;
- newTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum;
- newTeachingSettingInList.Add(newTeachingSetting);
- if (planApplicationView.TeachingModeIDList != null && planApplicationView.TeachingModeIDList.Count() > 0)
- {
- foreach (var teachingModeID in planApplicationView.TeachingModeIDList)
- {
- var newTeachingMode = new EM_PlanApplicationTeachingModeType();
- newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.PlanApplicationID = newPlanApplication.PlanApplicationID;
- newTeachingMode.TeachingModeID = teachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- if (planApplicationView.TeachingPlaceIDList != null && planApplicationView.TeachingPlaceIDList.Count() > 0)
- {
- foreach (var teachingPlaceID in planApplicationView.TeachingPlaceIDList)
- {
- var newTeachingPlace = new EM_PlanApplicationTeachingPlace();
- newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.PlanApplicationID = newPlanApplication.PlanApplicationID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- }
- //事务提交
- //UnitOfWork.Commit();
- using (TransactionScope ts = new TransactionScope())
- {
- //删除
- UnitOfWork.Delete<EM_PlanApplicationTeachingPlace>(x => planApplicationTPDelList.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplicationTeachingModeType>(x => planApplicationTMDelList.Contains(x.PlanApplicationID));
- //批量插入
- UnitOfWork.BulkInsert(newPlanApplicationInList);
- UnitOfWork.BulkInsert(newTeachingSettingInList);
- UnitOfWork.BulkInsert(newTeachingModeTypeInList);
- UnitOfWork.BulkInsert(newTeachingPlaceInList);
- //批量统一提交更新
- if (newPlanApplicationUpList != null && newPlanApplicationUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newPlanApplicationUpList);
- }
- //批量统一提交更新
- if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newTeachingSettingUpList);
- }
- ts.Complete();
- }
- }
- else
- {
- throw new Exception("已存在相同的计划申请信息(学年学期、年级专业、课程信息唯一),请核查。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 专业课程模版批量新增
- /// </summary>
- /// <param name="specialtyCourseViewList"></param>
- /// <param name="planApplicationView"></param>
- /// <returns></returns>
- public string PlanApplicationBatchAdd(List<SpecialtyCourseView> specialtyCourseViewList, PlanApplicationView planApplicationView)
- {
- try
- {
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
- }
- //查询工作流程开始环节状态
- var startStatusID = this.GetStartStatus();
- if (startStatusID == null)
- {
- throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。");
- }
- //查询对应的年级专业信息
- var grademajor = PlanApplicationDAL.GrademajorRepository.GetList(x => x.GrademajorID == planApplicationView.GrademajorID).SingleOrDefault();
- if (grademajor == null)
- {
- throw new Exception("选择申请的年级专业不存在,请检查。");
- }
- //查询学年学期信息schoolyearList
- var schoolyearList = PlanApplicationDAL.SchoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //查询年级专业对应的入学学年学期信息
- var startSchoolyear = schoolyearList.Where(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault();
- if (startSchoolyear == null)
- {
- throw new Exception("选择申请的年级专业对应的入学学年学期不存在,请检查。");
- }
- //查询年级专业对应的毕业学年学期信息
- var graduatingSemester = schoolyearList.Where(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduatingSemester == null)
- {
- throw new Exception("选择申请的年级专业对应的毕业学年学期信息不存在,请检查。");
- }
- //查询计划申请信息planApplicationList
- var planApplicationList = PlanApplicationDAL.PlanApplicationRepository.GetList(x => x.GrademajorID == grademajor.GrademajorID, (x => x.EM_PlanApplicationTeachingSetting)).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<EM_PlanApplication> newPlanApplicationInList = new List<EM_PlanApplication>();
- List<EM_PlanApplicationTeachingSetting> newTeachingSettingInList = new List<EM_PlanApplicationTeachingSetting>();
- List<EM_PlanApplicationTeachingModeType> newTeachingModeTypeInList = new List<EM_PlanApplicationTeachingModeType>();
- List<EM_PlanApplicationTeachingPlace> newTeachingPlaceInList = new List<EM_PlanApplicationTeachingPlace>();
- foreach (var specialtyCourseView in specialtyCourseViewList)
- {
- //判断对应的学年学期信息
- var value = startSchoolyear.Value + specialtyCourseView.StarttermID - 1;
- if (value < startSchoolyear.Value)
- {
- //表示学年学期小于入学学年学期
- fail++;
- }
- else
- {
- if (value > graduatingSemester.Value)
- {
- //表示学年学期大于毕业学年学期
- fail++;
- }
- else
- {
- var schoolyear = schoolyearList.Where(x => x.Value == value).SingleOrDefault();
- if (schoolyear == null)
- {
- //表示对应的学年学期信息不存在
- fail++;
- }
- else
- {
- //查询对应的计划申请信息(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
- var planApplication = planApplicationList.Where(x => x.SchoolyearID == schoolyear.SchoolyearID
- && x.GrademajorID == grademajor.GrademajorID
- && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault();
- if (planApplication == null)
- {
- //表示新增
- var newPlanApplication = new EM_PlanApplication();
- newPlanApplication.PlanApplicationID = Guid.NewGuid();
- newPlanApplication.SchoolyearID = schoolyear.SchoolyearID;
- newPlanApplication.GrademajorID = grademajor.GrademajorID;
- newPlanApplication.CoursematerialID = specialtyCourseView.CoursematerialID;
- newPlanApplication.CourseStructureID = specialtyCourseView.CourseStructureID;
- newPlanApplication.CourseCategoryID = specialtyCourseView.CourseCategoryID;
- newPlanApplication.CourseTypeID = specialtyCourseView.CourseTypeID;
- newPlanApplication.CourseQualityID = specialtyCourseView.CourseQualityID;
- newPlanApplication.DepartmentID = specialtyCourseView.DepartmentID;
- newPlanApplication.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
- newPlanApplication.IsCooperation = specialtyCourseView.IsCooperation;
- newPlanApplication.IsRequired = specialtyCourseView.IsRequired;
- newPlanApplication.IsElective = specialtyCourseView.IsElective;
- newPlanApplication.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
- newPlanApplication.IsMainCourse = specialtyCourseView.IsMainCourse;
- newPlanApplication.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
- newPlanApplication.CourseFineID = specialtyCourseView.CourseFineID;
- newPlanApplication.PracticeTypeID = specialtyCourseView.PracticeTypeID;
- newPlanApplication.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
- newPlanApplication.ExaminationModeID = specialtyCourseView.ExaminationModeID;
- newPlanApplication.ResultTypeID = specialtyCourseView.ResultTypeID;
- newPlanApplication.HandleModeID = specialtyCourseView.HandleModeID;
- newPlanApplication.Remark = planApplicationView.Remark;
- SetNewStatus(newPlanApplication, startStatusID.Value);
- newPlanApplicationInList.Add(newPlanApplication);
- var newTeachingSetting = new EM_PlanApplicationTeachingSetting();
- newTeachingSetting.PlanApplicationID = newPlanApplication.PlanApplicationID;
- newTeachingSetting.Credit = specialtyCourseView.Credit;
- newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
- newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
- newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
- newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
- newTeachingSettingInList.Add(newTeachingSetting);
- if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
- {
- foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
- {
- var newTeachingMode = new EM_PlanApplicationTeachingModeType();
- newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.PlanApplicationID = newPlanApplication.PlanApplicationID;
- newTeachingMode.TeachingModeID = teachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
- {
- foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
- {
- var newTeachingPlace = new EM_PlanApplicationTeachingPlace();
- newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.PlanApplicationID = newPlanApplication.PlanApplicationID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- success++;
- }
- else
- {
- //表示已存在相同的计划申请信息
- fail++;
- }
- }
- }
- }
- }
- //事务提交
- using (TransactionScope ts = new TransactionScope())
- {
- //批量插入
- UnitOfWork.BulkInsert(newPlanApplicationInList);
- UnitOfWork.BulkInsert(newTeachingSettingInList);
- UnitOfWork.BulkInsert(newTeachingModeTypeInList);
- UnitOfWork.BulkInsert(newTeachingPlaceInList);
- ts.Complete();
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条,失败" + fail + "条,原因:学年学期小于入学学年学期、学年学期大于毕业学年学期、对应的学年学期不存在或已存在相同的计划申请信息,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的未申请专业课程信息SpecialtyCourseView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="departmentID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="starttermID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="yearID"></param>
- /// <param name="grademajorID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyCourseView> GetSpecialtyCourseViewNoApplyGrid(ConfiguretView configuretView, Guid? departmentID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID,
- int? starttermID, int? handleModeID, int? yearID, Guid? grademajorID, int pageIndex, int pageSize)
- {
- //结束流程环节ID
- var endStatusID = this.GetCorrectEndStatus();
- //专业课程
- Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true);
- if (departmentID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID);
- }
- if (coursematerialID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID);
- }
- if (starttermID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID);
- }
- if (handleModeID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID);
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (yearID.HasValue)
- {
- expGrademajor = expGrademajor.And(x => x.GradeID == yearID);
- }
- expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //注:需排除审核通过状态的计划申请信息
- expPlanApplication = expPlanApplication.And(x => x.RecordStatus != endStatusID);
- if (coursematerialID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
- }
- if (grademajorID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
- }
- //专业计划
- Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (grademajorID.HasValue)
- {
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.GrademajorID == grademajorID);
- }
- var query = PlanApplicationDAL.GetSpecialtyCourseViewNoApplyQueryable(expSpecialtyCourse, expGrademajor, expPlanApplication, expSpecialtyPlan);
-
- 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());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ToGridResultSet<SpecialtyCourseView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的未申请专业课程信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="departmentID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="starttermID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="yearID"></param>
- /// <param name="grademajorID"></param>
- /// <returns></returns>
- public IList<SpecialtyCourseView> GetSpecialtyCourseViewNoApplyList(ConfiguretView configuretView, Guid? departmentID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID,
- int? starttermID, int? handleModeID, int? yearID, Guid? grademajorID)
- {
- //结束流程环节ID
- var endStatusID = this.GetCorrectEndStatus();
- //专业课程
- Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true);
- if (departmentID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID);
- }
- if (coursematerialID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID);
- }
- if (starttermID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID);
- }
- if (handleModeID.HasValue)
- {
- expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID);
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (yearID.HasValue)
- {
- expGrademajor = expGrademajor.And(x => x.GradeID == yearID);
- }
- expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //注:需排除审核通过状态的计划申请信息
- expPlanApplication = expPlanApplication.And(x => x.RecordStatus != endStatusID);
- if (coursematerialID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
- }
- if (grademajorID.HasValue)
- {
- expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
- }
- //专业计划
- Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (grademajorID.HasValue)
- {
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.GrademajorID == grademajorID);
- }
- var query = PlanApplicationDAL.GetSpecialtyCourseViewNoApplyQueryable(expSpecialtyCourse, expGrademajor, expPlanApplication, expSpecialtyPlan);
-
- 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());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="planApplicationIDs"></param>
- /// <returns></returns>
- public bool PlanApplicationDelete(List<Guid?> planApplicationIDs)
- {
- try
- {
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<EM_PlanApplicationTeachingPlace>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplicationTeachingModeType>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplicationTeachingSetting>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- UnitOfWork.Delete<EM_PlanApplication>(x => planApplicationIDs.Contains(x.PlanApplicationID));
- ts.Complete();
- return true;
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 提交
- /// </summary>
- /// <param name="planApplicationIDs"></param>
- /// <param name="userID"></param>
- /// <param name="comment"></param>
- /// <returns></returns>
- public string PlanApplicationSubmit(List<Guid> planApplicationIDs, Guid userID, string comment = "")
- {
- try
- {
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
- }
- //查询工作流程开始环节状态
- var startStatusID = this.GetStartStatus();
- if (startStatusID == null)
- {
- throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。");
- }
- //查询对应的计划申请信息List
- var planApplicationList = PlanApplicationDAL.PlanApplicationRepository
- .GetList(x => planApplicationIDs.Contains(x.PlanApplicationID), (x => x.EM_PlanApplicationTeachingSetting)).ToList();
- //计划申请信息对应的grademajorIDList
- var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString()))
- .Select(x => x.GrademajorID).ToList();
- //查询对应的专业计划信息
- var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository
- .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- var submitIDList = new List<Guid>();
- var approveIDList = new List<Guid>();
- foreach (var planApplication in planApplicationList)
- {
- //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
- var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID
- && x.GrademajorID == planApplication.GrademajorID
- && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault();
- if (specialtyPlan == null)
- {
- if (planApplication.RecordStatus == startStatusID)
- {
- submitIDList.Add(planApplication.PlanApplicationID);
- }
- else
- {
- approveIDList.Add(planApplication.PlanApplicationID);
- }
- success++;
- }
- else
- {
- fail++;
- }
- }
- if (submitIDList.Count > 0)
- {
- this.StartUp(submitIDList, userID, comment);
- }
- if (approveIDList.Count > 0)
- {
- this.Approve(approveIDList, userID, Guid.Empty, comment);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的专业计划信息,请检查。";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询计划申请对应的授课方式List
- /// </summary>
- /// <param name="planApplicationID"></param>
- /// <returns></returns>
- public List<string> GetTeachingModeTypeList(Guid? planApplicationID)
- {
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.PlanApplicationID == planApplicationID);
- var query = PlanApplicationDAL.GetTeachingModeTypeQueryble(exp);
- return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
- }
- /// <summary>
- /// 查询计划申请对应的授课地点List
- /// </summary>
- /// <param name="planApplicationID"></param>
- /// <returns></returns>
- public List<string> GetTeachingPlaceList(Guid? planApplicationID)
- {
- //计划申请
- Expression<Func<EM_PlanApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.PlanApplicationID == planApplicationID);
- var query = PlanApplicationDAL.GetTeachingPlaceQueryble(exp);
- return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
- }
- /// <summary>
- /// 流程结束跳转函数(工作流平台中配置)
- /// 注:此为普教版本(年级专业)
- /// 注:根据不同的版本配置(区分普教、成教版本-工作流跳转函数)
- /// </summary>
- /// <param name="planApplicationIDList"></param>
- /// <param name="userID"></param>
- public void OnApproveEnd(List<Guid> planApplicationIDList, Guid? userID)
- {
- try
- {
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
- }
- //查询工作流程结束环节状态
- var endStatusID = this.GetCorrectEndStatus();
- if (endStatusID == null)
- {
- throw new Exception("工作流平台中,专业计划流程结束环节未配置,请核查。");
- }
- //查询对应的计划申请信息List
- var planApplicationList = PlanApplicationDAL.PlanApplicationRepository
- .GetList(x => planApplicationIDList.Contains(x.PlanApplicationID),
- (x => x.EM_PlanApplicationTeachingSetting), (x => x.EM_PlanApplicationTeachingModeType),
- (x => x.EM_PlanApplicationTeachingPlace)).ToList();
- //计划申请信息对应的grademajorIDList
- var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
- //查询对应的专业计划信息
- var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository
- .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
- List<EM_SpecialtyPlan> newSpecialtyPlanInList = new List<EM_SpecialtyPlan>();
- List<EM_SpecialtyPlan> newSpecialtyPlanUpList = new List<EM_SpecialtyPlan>();
- List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyPlanTeachingSetting>();
- List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyPlanTeachingSetting>();
- List<EM_SpecialtyPlanTeachingModeType> newTeachingModeTypeInList = new List<EM_SpecialtyPlanTeachingModeType>();
- List<EM_SpecialtyPlanTeachingPlace> newTeachingPlaceInList = new List<EM_SpecialtyPlanTeachingPlace>();
- List<Guid?> specialtyPlanTMDelList = new List<Guid?>();
- List<Guid?> specialtyPlanTPDelList = new List<Guid?>();
- foreach (var planApplication in planApplicationList)
- {
- //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
- var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID
- && x.GrademajorID == planApplication.GrademajorID
- && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault();
- if (specialtyPlan == null)
- {
- //新增
- var newSpecialtyPlan = new EM_SpecialtyPlan();
- newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid();
- newSpecialtyPlan.PlanApplicationID = planApplication.PlanApplicationID;
- newSpecialtyPlan.SchoolyearID = planApplication.SchoolyearID;
- newSpecialtyPlan.GrademajorID = planApplication.GrademajorID;
- newSpecialtyPlan.CoursematerialID = planApplication.CoursematerialID;
- newSpecialtyPlan.CourseStructureID = planApplication.CourseStructureID;
- newSpecialtyPlan.CourseCategoryID = planApplication.CourseCategoryID;
- newSpecialtyPlan.CourseTypeID = planApplication.CourseTypeID;
- newSpecialtyPlan.CourseQualityID = planApplication.CourseQualityID;
- newSpecialtyPlan.DepartmentID = planApplication.DepartmentID;
- newSpecialtyPlan.IsSpecialtycore = planApplication.IsSpecialtycore;
- newSpecialtyPlan.IsCooperation = planApplication.IsCooperation;
- newSpecialtyPlan.IsRequired = planApplication.IsRequired;
- newSpecialtyPlan.IsElective = planApplication.IsElective;
- newSpecialtyPlan.IsNetworkCourse = planApplication.IsNetworkCourse;
- newSpecialtyPlan.IsMainCourse = planApplication.IsMainCourse;
- newSpecialtyPlan.IsNeedMaterial = planApplication.IsNeedMaterial;
- newSpecialtyPlan.CourseFineID = planApplication.CourseFineID;
- newSpecialtyPlan.PracticeTypeID = planApplication.PracticeTypeID;
- newSpecialtyPlan.TeachinglanguageID = planApplication.TeachinglanguageID;
- newSpecialtyPlan.ExaminationModeID = planApplication.ExaminationModeID;
- newSpecialtyPlan.ResultTypeID = planApplication.ResultTypeID;
- newSpecialtyPlan.HandleModeID = planApplication.HandleModeID;
- newSpecialtyPlan.Remark = planApplication.Remark;
- SetNewStatus(newSpecialtyPlan);
- newSpecialtyPlanInList.Add(newSpecialtyPlan);
- var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
- newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
- if (planApplication.EM_PlanApplicationTeachingSetting != null)
- {
- newTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit;
- newTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse;
- newTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours;
- newTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours;
- newTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum;
- }
- else
- {
- newTeachingSetting.Credit = 0;
- newTeachingSetting.TheoryCourse = 0;
- newTeachingSetting.Practicehours = 0;
- newTeachingSetting.Trialhours = 0;
- newTeachingSetting.TheoryWeeklyNum = 0;
- newTeachingSetting.PracticeWeeklyNum = 0;
- newTeachingSetting.TrialWeeklyNum = 0;
- newTeachingSetting.WeeklyHours = 0;
- newTeachingSetting.WeeklyNum = 0;
- newTeachingSetting.StartWeeklyNum = 1;
- newTeachingSetting.EndWeeklyNum = 16;
- }
- newTeachingSettingInList.Add(newTeachingSetting);
- if (planApplication.EM_PlanApplicationTeachingModeType != null && planApplication.EM_PlanApplicationTeachingModeType.Count() > 0)
- {
- foreach (var teachingMode in planApplication.EM_PlanApplicationTeachingModeType.ToList())
- {
- var newTeachingMode = new EM_SpecialtyPlanTeachingModeType();
- newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
- newTeachingMode.TeachingModeID = teachingMode.TeachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- else
- {
- var newTeachingMode = new EM_SpecialtyPlanTeachingModeType();
- newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
- newTeachingMode.TeachingModeID = (int)CF_TeachingMode.Theory;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- if (planApplication.EM_PlanApplicationTeachingPlace != null && planApplication.EM_PlanApplicationTeachingPlace.Count() > 0)
- {
- foreach (var teachingPlace in planApplication.EM_PlanApplicationTeachingPlace.ToList())
- {
- var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
- newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
- newTeachingPlace.TeachingPlace = teachingPlace.TeachingPlace;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- }
- else
- {
- //修改
- specialtyPlan.CourseStructureID = planApplication.CourseStructureID;
- specialtyPlan.CourseCategoryID = planApplication.CourseCategoryID;
- specialtyPlan.CourseTypeID = planApplication.CourseTypeID;
- specialtyPlan.CourseQualityID = planApplication.CourseQualityID;
- specialtyPlan.DepartmentID = planApplication.DepartmentID;
- specialtyPlan.IsSpecialtycore = planApplication.IsSpecialtycore;
- specialtyPlan.IsCooperation = planApplication.IsCooperation;
- specialtyPlan.IsRequired = planApplication.IsRequired;
- specialtyPlan.IsElective = planApplication.IsElective;
- specialtyPlan.IsNetworkCourse = planApplication.IsNetworkCourse;
- specialtyPlan.IsMainCourse = planApplication.IsMainCourse;
- specialtyPlan.IsNeedMaterial = planApplication.IsNeedMaterial;
- specialtyPlan.CourseFineID = planApplication.CourseFineID;
- specialtyPlan.PracticeTypeID = planApplication.PracticeTypeID;
- specialtyPlan.TeachinglanguageID = planApplication.TeachinglanguageID;
- specialtyPlan.ExaminationModeID = planApplication.ExaminationModeID;
- specialtyPlan.ResultTypeID = planApplication.ResultTypeID;
- specialtyPlan.HandleModeID = planApplication.HandleModeID;
- specialtyPlan.Remark = planApplication.Remark;
- SetModifyStatus(specialtyPlan);
- newSpecialtyPlanUpList.Add(specialtyPlan);
- if (specialtyPlan.EM_SpecialtyPlanTeachingSetting == null)
- {
- var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
- newTeachingSetting.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
- if (planApplication.EM_PlanApplicationTeachingSetting == null)
- {
- newTeachingSetting.Credit = 0;
- newTeachingSetting.TheoryCourse = 0;
- newTeachingSetting.Practicehours = 0;
- newTeachingSetting.Trialhours = 0;
- newTeachingSetting.TheoryWeeklyNum = 0;
- newTeachingSetting.PracticeWeeklyNum = 0;
- newTeachingSetting.TrialWeeklyNum = 0;
- newTeachingSetting.WeeklyHours = 0;
- newTeachingSetting.WeeklyNum = 0;
- newTeachingSetting.StartWeeklyNum = 1;
- newTeachingSetting.EndWeeklyNum = 16;
- }
- else
- {
- newTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit;
- newTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse;
- newTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours;
- newTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours;
- newTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum;
- }
- newTeachingSettingInList.Add(newTeachingSetting);
- }
- else
- {
- if (planApplication.EM_PlanApplicationTeachingSetting != null)
- {
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum;
- specialtyPlan.EM_SpecialtyPlanTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum;
- }
- newTeachingSettingUpList.Add(specialtyPlan.EM_SpecialtyPlanTeachingSetting);
- }
- if (planApplication.EM_PlanApplicationTeachingModeType != null && planApplication.EM_PlanApplicationTeachingModeType.Count() > 0)
- {
- specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
- foreach (var newModeType in planApplication.EM_PlanApplicationTeachingModeType.ToList())
- {
- var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType();
- newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
- newTeachingModeType.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
- newTeachingModeType.TeachingModeID = newModeType.TeachingModeID;
- this.SetNewStatus(newTeachingModeType);
- newTeachingModeTypeInList.Add(newTeachingModeType);
- }
- }
- else
- {
- specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
- }
- if (planApplication.EM_PlanApplicationTeachingPlace != null && planApplication.EM_PlanApplicationTeachingPlace.Count() > 0)
- {
- specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
- foreach (var newPlace in planApplication.EM_PlanApplicationTeachingPlace.ToList())
- {
- var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
- newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
- newTeachingPlace.TeachingPlace = newPlace.TeachingPlace;
- this.SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- else
- {
- specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- //删除
- UnitOfWork.Delete<EM_SpecialtyPlanTeachingPlace>(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID));
- UnitOfWork.Delete<EM_SpecialtyPlanTeachingModeType>(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID));
- //批量插入
- UnitOfWork.BulkInsert(newSpecialtyPlanInList);
- UnitOfWork.BulkInsert(newTeachingSettingInList);
- UnitOfWork.BulkInsert(newTeachingModeTypeInList);
- UnitOfWork.BulkInsert(newTeachingPlaceInList);
- //批量统一提交更新
- if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newSpecialtyPlanUpList);
- }
- //批量统一提交更新
- if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newTeachingSettingUpList);
- }
- ts.Complete();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|