123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.GraduationManage.GraduationRequirement;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using System.Linq.Expressions;
- using EMIS.DataLogic.GraduationManage.GraduationRequirement;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.GraduationManage.GraduationRequirement
- {
- public class GraduationCourseServices : BaseServices, IGraduationCourseServices
- {
- public GraduationCourseDAL GraduationCourseDAL { get; set; }
- /// <summary>
- /// 查询毕业课程信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradSchoolyearID"></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="courseTypeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GraduationCourseView> GetGraduationCourseViewGird(ConfiguretView configuretView, Guid? gradSchoolyearID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- int? courseTypeID, int pageIndex, int pageSize)
- {
- //毕业课程
- Expression<Func<ER_GraduationCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (courseTypeID.HasValue)
- {
- //课程类型
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- }
- var query = GraduationCourseDAL.GetGraduationCourseQueryable(exp);
- if (gradSchoolyearID.HasValue)
- {
- query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
- }
- 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());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID)
- .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
- .ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ToGridResultSet<GraduationCourseView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询毕业课程信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradSchoolyearID"></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="courseTypeID"></param>
- /// <returns></returns>
- public IList<GraduationCourseView> GetGraduationCourseViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? courseTypeID)
- {
- //毕业课程
- Expression<Func<ER_GraduationCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (courseTypeID.HasValue)
- {
- //课程类型
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- }
- var query = GraduationCourseDAL.GetGraduationCourseQueryable(exp);
- if (gradSchoolyearID.HasValue)
- {
- query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
- }
- 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());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID)
- .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
- .ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ToList();
- }
- /// <summary>
- /// 根据毕业课程ID查询对应的毕业课程信息GraduationCourseView
- /// </summary>
- /// <param name="GraduationCourseID"></param>
- /// <returns></returns>
- public GraduationCourseView GetGraduationCourseView(Guid? GraduationCourseID)
- {
- try
- {
- var query = GraduationCourseDAL.GetGraduationCourseQueryable(x => x.GraduationCourseID == GraduationCourseID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的专业计划信息View(需与毕业课程信息进行对比)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradSchoolyearID"></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="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GradSpecialtyPlanView> GetGradSpecialtyPlanViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- Guid? coursematerialID, int? courseTypeID, int pageIndex, int pageSize)
- {
- //专业计划
- Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- //课程信息
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- //课程类型
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID);
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (gradSchoolyearID.HasValue)
- {
- //毕业学期
- expGrademajor = expGrademajor.And(x => x.GraduateSchoolyearID == gradSchoolyearID);
- }
- var query = GraduationCourseDAL.GetGradSpecialtyPlanQueryable(expSpecialtyPlan, expGrademajor);
- 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());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderByDescending(x => x.GradeID).ThenBy(x => x.GrademajorCode.Length)
- .ThenBy(x => x.GrademajorCode).ThenBy(x => x.StarttermID)
- .ToGridResultSet<GradSpecialtyPlanView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的专业计划信息List(需与毕业课程信息进行对比)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradSchoolyearID"></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="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <returns></returns>
- public IList<GradSpecialtyPlanView> GetGradSpecialtyPlanViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
- Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
- Guid? coursematerialID, int? courseTypeID)
- {
- //专业计划
- Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- //课程信息
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- //课程类型
- expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID);
- }
- //年级专业
- Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (gradSchoolyearID.HasValue)
- {
- //毕业学期
- expGrademajor = expGrademajor.And(x => x.GraduateSchoolyearID == gradSchoolyearID);
- }
- var query = GraduationCourseDAL.GetGradSpecialtyPlanQueryable(expSpecialtyPlan, expGrademajor);
- 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());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderByDescending(x => x.GradeID).ThenBy(x => x.GrademajorCode.Length)
- .ThenBy(x => x.GrademajorCode).ThenBy(x => x.StarttermID)
- .ToList();
- }
- /// <summary>
- /// 计划生成(专业计划)
- /// </summary>
- /// <param name="graduationCourseView"></param>
- /// <param name="gradSpecialtyPlanViewList"></param>
- /// <returns></returns>
- public string GraduationCourseBatchAdd(GraduationCourseView graduationCourseView, List<GradSpecialtyPlanView> gradSpecialtyPlanViewList)
- {
- try
- {
- //毕业课程信息List
- var chargeStandardList = GraduationCourseDAL.GraduationCourseRepository
- .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<ER_GraduationCourse> graduationCourseInList = new List<ER_GraduationCourse>();
- //注:毕业课程业务主键(年级专业ID、课程信息ID、课程类型ID、课程学分)
- foreach (var gradSpecialtyPlanView in gradSpecialtyPlanViewList)
- {
- //查询数据库进行验证
- var graduationCourseVerification = chargeStandardList
- .Where(x => x.GrademajorID == gradSpecialtyPlanView.GrademajorID
- && x.CoursematerialID == gradSpecialtyPlanView.CoursematerialID
- && x.CourseTypeID == gradSpecialtyPlanView.CourseTypeID
- && x.CourseCredit == gradSpecialtyPlanView.Credit)
- .SingleOrDefault();
-
- if (graduationCourseVerification == null)
- {
- //表示不存在对应的毕业课程(新增)
- ER_GraduationCourse graduationCourse = new ER_GraduationCourse();
- graduationCourse.GraduationCourseID = Guid.NewGuid();
- graduationCourse.GrademajorID = gradSpecialtyPlanView.GrademajorID;
- graduationCourse.CoursematerialID = gradSpecialtyPlanView.CoursematerialID;
- graduationCourse.CourseTypeID = gradSpecialtyPlanView.CourseTypeID;
- graduationCourse.CourseCredit = gradSpecialtyPlanView.Credit;
- SetNewStatus(graduationCourse);
- graduationCourseInList.Add(graduationCourse);
- success++;
- }
- else
- {
- //表示已存在相同的毕业课程
- fail++;
- }
- }
- //批量插入
- UnitOfWork.BulkInsert<ER_GraduationCourse>(graduationCourseInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的毕业课程,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:年级专业、课程信息、课程类型、课程学分)
- /// </summary>
- /// <param name="graduationCourseView"></param>
- public void GraduationCourseEdit(GraduationCourseView graduationCourseView)
- {
- try
- {
- //查询数据库进行验证
- var graduationCourseVerification = GraduationCourseDAL.GraduationCourseRepository
- .GetList(x => x.GraduationCourseID != graduationCourseView.GraduationCourseID
- && x.GrademajorID == graduationCourseView.GrademajorID
- && x.CoursematerialID == graduationCourseView.CoursematerialID
- && x.CourseTypeID == graduationCourseView.CourseTypeID
- && x.CourseCredit == graduationCourseView.CourseCredit)
- .SingleOrDefault();
- if (graduationCourseVerification == null)
- {
- //数据有误验证
- if (graduationCourseView.GraduationCourseID != Guid.Empty)
- {
- var graduationCourse = GraduationCourseDAL.GraduationCourseRepository
- .GetList(x => x.GraduationCourseID == graduationCourseView.GraduationCourseID)
- .SingleOrDefault();
- if (graduationCourse == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- graduationCourse.GrademajorID = graduationCourseView.GrademajorID;
- graduationCourse.CoursematerialID = graduationCourseView.CoursematerialID;
- graduationCourse.CourseTypeID = graduationCourseView.CourseTypeID;
- graduationCourse.CourseCredit = graduationCourseView.CourseCredit;
- SetModifyStatus(graduationCourse);
- }
- }
- else
- {
- //表示新增
- ER_GraduationCourse graduationCourse = new ER_GraduationCourse();
- graduationCourse.GraduationCourseID = Guid.NewGuid();
- graduationCourse.GrademajorID = graduationCourseView.GrademajorID;
- graduationCourse.CoursematerialID = graduationCourseView.CoursematerialID;
- graduationCourse.CourseTypeID = graduationCourseView.CourseTypeID;
- graduationCourse.CourseCredit = graduationCourseView.CourseCredit;
- SetNewStatus(graduationCourse);
- UnitOfWork.Add(graduationCourse);
- }
- }
- else
- {
- throw new Exception("已存在相同的毕业课程,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="graduationCourseIDList"></param>
- /// <returns></returns>
- public bool GraduationCourseDelete(IList<Guid?> graduationCourseIDList)
- {
- try
- {
- UnitOfWork.Delete<ER_GraduationCourse>(x => graduationCourseIDList.Contains(x.GraduationCourseID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|