123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.ScoreManage;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class ScoreParameterSettingServices : BaseServices, IScoreParameterSettingServices
- {
- public FinalExaminationDAL FinalExaminationDAL { get; set; }
- public ScoreParameterSettingDAL scoreParameterSettingDAL { get; set; }
- public ScoreParameterCollegeSettingDAL ScoreParameterCollegeSettingDAL { get; set; }
- public ScoreDAL scoreDAL { get; set; }
- public List<ViewModel.ScoreManage.ScoreParameterSettingView> GetScoreParameterSettingViewGrid()
- {
- return scoreParameterSettingDAL.GetScoreParameterSettingViewQueryable().ToList();
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="listScoreParameterSetting"></param>
- public void ScoreParameterSettingServicesAdd(List<ScoreParameterSettingView> listScoreParameterSetting)
- {
- try
- {
- UnitOfWork.Delete<ER_ScoreParameterSetting>(x=>true);
- listScoreParameterSetting.ToList().ForEach(x =>
- {
- var detail = new ER_ScoreParameterSetting();
- detail.ScoreParameterSettingID = Guid.NewGuid();
- detail.ExamsTypeID = x.ExamsTypeID;
- detail.CourseTypeID = x.CourseTypeID;
- detail.ScoreFormulaID = x.ScoreFormulaID;
- detail.IsTotalFormula = x.IsTotalFormula;
- detail.CreditFormulaID = x.CreditFormulaID;
- detail.IsCreditFormula = x.IsCreditFormula;
- detail.GradePointFormulaID = x.GradePointFormulaID;
- detail.IsGradePointFormula = x.IsGradePointFormula;
- this.SetNewStatus(detail);
- UnitOfWork.Add(detail);
- });
- this.UnitOfWork.Commit();
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- /// <summary>
- /// 获取优先设置
- /// </summary>
- /// <param name="examsTypeID">考试类型</param>
- /// <param name="courseTypeID">课程类型</param>
- /// <returns></returns>
- public ScoreParameterSettingView GetScoreParameterSettingList(Guid? finalExaminationID)
- {
- var finalExaminationView = FinalExaminationDAL.GetFinalExaminationViewQueryable(x => x.FinalExaminationID == finalExaminationID).FirstOrDefault();
- if (finalExaminationView == null)
- {
- throw new Exception("获取公式设置失败,找不到对应的期末设定。");
- }
- var studentScoreList = scoreDAL.ScoreRepository.GetList(x => x.FinalExaminationID == finalExaminationID).ToList();
- var ScoreParameterSettingList=GetScoreParameterSettingList(finalExaminationView.CollegeID, finalExaminationView.GradeYearID, finalExaminationView.ExamsCategoryID, finalExaminationView.CourseTypeID);
- if (studentScoreList.Count>0)
- {
- foreach (var studentScore in studentScoreList)
- {
- if (studentScore.RecordStatus== (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE)
- {
- ScoreParameterSettingList.IsTotalFormula = false;
- ScoreParameterSettingList.IsCreditFormula = false;
- ScoreParameterSettingList.IsGradePointFormula = false;
- break;
- }
- }
- }
- return ScoreParameterSettingList;
- }
- public ScoreParameterSettingView GetScoreParameterSettingList(Guid? collegeID, int? year, int? examsCategoryID, int? courseTypeID)
- {
- ScoreParameterSettingView scoreParameterSetting = new ScoreParameterSettingView();
- List<ScoreParameterSettingView> commonScoreParameterSettingList = this.GetScoreParameterSettingViewGrid().ToList(); ;
- List<ScoreParameterSettingView> collegeScoreParameterSettingList = commonScoreParameterSettingList;
- //获取各院系的个性化设置,优先获取指定了自己院系的设置
- var collegeScoreParameterSetting = this.ScoreParameterCollegeSettingDAL
- .GetScoreParameterCollegeSettingViewQueryable(x => x.Years == year
- && x.CollegeID == collegeID).FirstOrDefault();
- //找不到再找该年级的通用设置
- if (collegeScoreParameterSetting == null)
- {
- collegeScoreParameterSetting = this.ScoreParameterCollegeSettingDAL
- .GetScoreParameterCollegeSettingViewQueryable(x => x.Years == year
- && x.CollegeID == null).FirstOrDefault();
- }
- //有可能以上两种都没有,所以要判断一下
- if (collegeScoreParameterSetting != null)
- {
- collegeScoreParameterSettingList = this.ScoreParameterCollegeSettingDAL
- .GetScoreParameterSettingViewQueryable(x => x.ScoreParameterCollegeSettingID == collegeScoreParameterSetting.ScoreParameterCollegeSettingID)
- .ToList();
- }
- //总分公式、学分公式和绩点公式是分开读取的,未必来源于同一条设置
- #region 先找总分公式
- #region 按个性化设置先找
- var totalScoreParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == examsCategoryID && x.ScoreFormulaID != null);
- if (totalScoreParameterSetting == null)
- {
- totalScoreParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == null && x.ScoreFormulaID != null);
- }
- if (totalScoreParameterSetting == null)
- {
- totalScoreParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null
- && x.ExamsTypeID == examsCategoryID && x.ScoreFormulaID != null);
- }
- if (totalScoreParameterSetting == null)
- {
- totalScoreParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null && x.ExamsTypeID == null);
- }
- scoreParameterSetting.ScoreFormulaID = totalScoreParameterSetting.ScoreFormulaID;
- scoreParameterSetting.IsTotalFormula = totalScoreParameterSetting.IsTotalFormula;
- #endregion
- #region 再按通用设置找
- if (scoreParameterSetting.ScoreFormulaID == null)
- {
- totalScoreParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == examsCategoryID && x.ScoreFormulaID != null);
- if (totalScoreParameterSetting == null)
- {
- totalScoreParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == null && x.ScoreFormulaID != null);
- }
- if (totalScoreParameterSetting == null)
- {
- totalScoreParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null
- && x.ExamsTypeID == examsCategoryID && x.ScoreFormulaID != null);
- }
- if (totalScoreParameterSetting == null)
- {
- totalScoreParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null && x.ExamsTypeID == null);
- }
- scoreParameterSetting.ScoreFormulaID = totalScoreParameterSetting.ScoreFormulaID;
- scoreParameterSetting.IsTotalFormula = totalScoreParameterSetting.IsTotalFormula;
- }
- #endregion
- #endregion
- #region 再找学分公式
- #region 按个性化设置先找
- var creditParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == examsCategoryID && x.CreditFormulaID != null);
- if (creditParameterSetting == null)
- {
- creditParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == null && x.CreditFormulaID != null);
- }
- if (creditParameterSetting == null)
- {
- creditParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null
- && x.ExamsTypeID == examsCategoryID && x.CreditFormulaID != null);
- }
- if (creditParameterSetting == null)
- {
- creditParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null && x.ExamsTypeID == null);
- }
- scoreParameterSetting.CreditFormulaID = creditParameterSetting.CreditFormulaID;
- scoreParameterSetting.IsCreditFormula = creditParameterSetting.IsCreditFormula;
- #endregion
- #region 再按通用设置找
- if (scoreParameterSetting.CreditFormulaID == null)
- {
- creditParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == examsCategoryID && x.CreditFormulaID != null);
- if (creditParameterSetting == null)
- {
- creditParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == null && x.CreditFormulaID != null);
- }
- if (creditParameterSetting == null)
- {
- creditParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null
- && x.ExamsTypeID == examsCategoryID && x.CreditFormulaID != null);
- }
- if (creditParameterSetting == null)
- {
- creditParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null && x.ExamsTypeID == null);
- }
- scoreParameterSetting.CreditFormulaID = creditParameterSetting.CreditFormulaID;
- scoreParameterSetting.IsCreditFormula = creditParameterSetting.IsCreditFormula;
- }
- #endregion
- #endregion
- #region 再找绩点公式
- #region 按个性化设置先找
- var gradePointParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == examsCategoryID && x.GradePointFormulaID != null);
- if (gradePointParameterSetting == null)
- {
- gradePointParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == null && x.GradePointFormulaID != null);
- }
- if (gradePointParameterSetting == null)
- {
- gradePointParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null
- && x.ExamsTypeID == examsCategoryID && x.GradePointFormulaID != null);
- }
- if (gradePointParameterSetting == null)
- {
- gradePointParameterSetting = collegeScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null && x.ExamsTypeID == null);
- }
- scoreParameterSetting.GradePointFormulaID = gradePointParameterSetting.GradePointFormulaID;
- scoreParameterSetting.IsGradePointFormula = gradePointParameterSetting.IsGradePointFormula;
- #endregion
- #region 再按通用设置找
- if (scoreParameterSetting.GradePointFormulaID == null)
- {
- gradePointParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == examsCategoryID && x.GradePointFormulaID != null);
- if (gradePointParameterSetting == null)
- {
- gradePointParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == courseTypeID
- && x.ExamsTypeID == null && x.GradePointFormulaID != null);
- }
- if (gradePointParameterSetting == null)
- {
- gradePointParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null
- && x.ExamsTypeID == examsCategoryID && x.GradePointFormulaID != null);
- }
- if (gradePointParameterSetting == null)
- {
- gradePointParameterSetting = commonScoreParameterSettingList.FirstOrDefault(x => x.CourseTypeID == null && x.ExamsTypeID == null);
- }
- scoreParameterSetting.GradePointFormulaID = gradePointParameterSetting.GradePointFormulaID;
- scoreParameterSetting.IsGradePointFormula = gradePointParameterSetting.IsGradePointFormula;
- }
- #endregion
- #endregion
- return scoreParameterSetting;
- }
- }
- }
|