123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.RetakeManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.RetakeManage
- {
- public class RetakeConditionDAL
- {
- public RetakeConditionRepository RetakConditionRepository { get; set; }
- public RetakeConditionParameterRepository RetakeConditionParameterRepository { get; set; }
- public StudentRepository StudentRepository { get; set; }
- public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
- public ParameterRepository ParameterRepository { get; set; }
- public RetakePlanStudentRepository RetakePlanStudentRepository { get; set; }
- public RetakeExamsCatagoryRepository RetakeExamsCatagoryRepository { get; set; }
- public CoursematerialRepository CoursematerialRepository { get; set; }
- public FinallyScoreRepository FinallyScoreRepository { get; set; }
- /// <summary>
- /// 查询重修条件限定信息View
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<RetakeConditionView> GetRetakeConditionView(Expression<Func<ER_RetakeCondition, bool>> exp)
- {
- var q = (from condition in RetakConditionRepository.GetList(exp)
- select new RetakeConditionView
- {
- RetakeConditionID = condition.RetakeConditionID,
- RetakeConditionTypeID = condition.RetakeConditionTypeID,
- Title = condition.Title,
- MethodFullName = condition.MethodFullName,
- RecordStatus = condition.RecordStatus
- });
- return q;
- }
- /// <summary>
- /// 查询对应的重修条件参数
- /// </summary>
- /// <param name="parameterType"></param>
- /// <returns></returns>
- private string GetParameterValue(ER_RetakeParameterType parameterType)
- {
- return RetakeConditionParameterRepository.GetList(x => x.RetakeParameterTypeID == (int)parameterType
- && x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
- .Select(x => x.Value).FirstOrDefault();
- }
- /// <summary>
- /// 重修条件限定查询(大于等于最小不及格门数且小于等于最大不及格门数)
- /// </summary>
- /// <param name="sourceView"></param>
- /// <returns></returns>
- public IQueryable<RetakeStudentListView> NoPassCondition(IQueryable<RetakeStudentListView> sourceView)
- {
- var minNoPassCount = Convert.ToInt32(GetParameterValue(ER_RetakeParameterType.MinNoPassCount) ?? "1");
- var maxNoPassCount = Convert.ToInt32(GetParameterValue(ER_RetakeParameterType.MaxNoPassCount) ?? "100");
- var query = (from retake in sourceView
- group retake by retake.UserID
- into g
- where g.Count() >= minNoPassCount && g.Count() <= maxNoPassCount
- select g).SelectMany(x => x.Select(w => w));
- return query;
- }
- public IQueryable<RetakeStudentView> GetRetakeStudentView()
- {
- var schoolyearIDStr = ParameterRepository.GetList(x => x.ParameterTypeID == (int)CF_ParameterType.RetakeSchoolyearID)
- .Select(x => x.Value).FirstOrDefault();
- Guid? schoolyearID = null;
- if (schoolyearIDStr != null)
- {
- schoolyearID = new Guid(schoolyearIDStr);
- }
- else
- {
- throw new Exception("未设置重修学年学期,请设置。");
- }
- var query = (from score in FinallyScoreRepository.GetList(x => x.TotalScore < 60 && x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
- join type in RetakeExamsCatagoryRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
- on score.ExamsCategoryID equals type.ExamsCategoryID
- join student in StudentRepository.Entities
- on score.UserID equals student.UserID
- join inschool in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
- on student.InSchoolStatusID equals inschool.InSchoolStatusID
- join course in CoursematerialRepository.Entities
- on score.CoursematerialID equals course.CoursematerialID
- join retake in RetakePlanStudentRepository.GetList(x => x.ER_RetakePlan.SchoolyearID == schoolyearID)
- on
- new { score.CoursematerialID, score.CourseTypeID, score.Credit, score.UserID }
- equals
- new { retake.ER_RetakePlan.CoursematerialID, retake.ER_RetakePlan.CourseTypeID, retake.ER_RetakePlan.Credit, UserID = (Guid?)retake.UserID }
- into dretake
- from eretake in dretake.DefaultIfEmpty()
- where eretake.RetakePlanStudentID == null
- select new RetakeStudentView
- {
- CoursematerialID = score.CoursematerialID,
- Abbreviation = course.Abbreviation,
- CourseCode = course.CourseCode,
- CourseName = course.CourseName,
- CourseTypeID = score.CourseTypeID,
- UserID = score.UserID,
- Credit = score.Credit,
- SchoolyearNumID = score.SchoolyearNumID,
- StarttermID = score.StarttermID
- });
- return query;
- }
- }
- }
|