123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.StudentSystem.MyGrade;
- using EMIS.ViewModel.Students;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using System.Dynamic;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.Students
- {
- public class CourseGradeServices : BaseServices, ICourseGradeServices
- {
- public CourseGradeDAL CourseGradeDAL { get; set; }
- public SubmitedScoreRepository SubmitedScoreRepository { get; set; }
- public FinallyScoreRepository FinallyScoreRepository { get; set; }
- public IList<CourseGradeView> GetStudentCourseGrade(Guid UserID)
- {
- return CourseGradeDAL.GetStudentCourseGrade(UserID);
- }
- /// <summary>
- /// 获取已提交成绩
- /// </summary>
- /// <param name="CoursematerialID"></param>
- /// <param name="SchoolyearID"></param>
- /// <param name="UserID"></param>
- public IGridResultSet<SubmitedScoreView> GetSubmitedScoreList(Guid? CoursematerialID, int? StartTermID, Guid? UserID)
- {
- var data = CourseGradeDAL.GetSubmitedScoreList(CoursematerialID, StartTermID, UserID);
- foreach (var Grade in data)
- {
- var ScoreDetail = CourseGradeDAL.GetScoreDetail(Grade.SubmitedScoreID);
- var pingshi = ScoreDetail.SingleOrDefault(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime);
- var jishu = ScoreDetail.SingleOrDefault(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique);
- var lilun = ScoreDetail.SingleOrDefault(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical);
- Grade.Pingshi = pingshi != null ? pingshi.Score : 0;
- Grade.Jishu = jishu != null ? jishu.Score : 0;
- Grade.Lilun = lilun != null ? lilun.Score : 0;
- }
- return data.AsQueryable().OrderBy(x=>x.LoginID.Length).ThenBy(x=>x.LoginID)
- .ThenBy(x=>x.CourseCode.Length).ThenBy(x=>x.CourseCode)
- .ThenByDescending(x=>x.CreateTime)
- .ToGridResultSet<SubmitedScoreView>();
- }
- /// <summary>
- /// 获取学生个人成绩预览信息
- /// </summary>
- /// <param name="StudentID"></param>
- /// <returns></returns>
- public StudentGradView GetStudentInfo(Guid StudentID)
- {
- var student = CourseGradeDAL.GetStudentInfo(StudentID);
- return student;
- }
- /// <summary>
- /// 获取学生个人成绩预览信息
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public StudentGradView GetStudentPersonalScore(Guid? userID)
- {
- var student = CourseGradeDAL.GetStudentPersonalScore(userID);
- return student;
- }
- /// <summary>
- /// 获取学生个人成绩预览信息(GT)
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public StudentGradView GetStudentPersonalScoreGT(Guid? userID)
- {
- var student = CourseGradeDAL.GetStudentPersonalScoreGT(userID);
- return student;
- }
- /// <summary>
- /// 已提交成绩详细
- /// </summary>
- /// <param name="submitedScoreID"></param>
- /// <returns></returns>
- public ViewModel.ScoreManage.SubmitedScoreDetailView GetSubmitedScoreDetailView(Guid? submitedScoreID)
- {
- var query = CourseGradeDAL.GetSubmitedScoreViewQueryable();
- if (submitedScoreID.HasValue)
- query = query.Where(x => x.SubmitedScoreID == submitedScoreID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 添加修改
- /// </summary>
- /// <param name="submitedScoreDetailView"></param>
- /// <param name="atype">1、新增 0、修改</param>
- public void SubmitedScoreAdd(ViewModel.ScoreManage.SubmitedScoreDetailView submitedScoreDetailView, int atype, List<ExpandoObject> listExpandoObject)
- {
- try
- {
- if (submitedScoreDetailView.Remark == "Add")
- {
- //复制型新增
- submitedScoreDetailView.SubmitedScoreID = null;
- }
- ER_SubmitedScore submitedScore = null;
- //新增
- if (atype == 1)
- {
- submitedScore = new ER_SubmitedScore();
- submitedScore.SubmitedScoreID = Guid.NewGuid();
- submitedScore.SchoolyearID = submitedScoreDetailView.SchoolyearID;
- submitedScore.SchoolyearNumID = submitedScoreDetailView.SchoolyearNumID;
- submitedScore.DepartmentID = submitedScoreDetailView.DepartmentID;
- submitedScore.ClassName = submitedScoreDetailView.ClassName;
- submitedScore.CoursematerialID = submitedScoreDetailView.CoursematerialID;
- submitedScore.CourseTypeID = submitedScoreDetailView.CourseTypeID;
- submitedScore.ExamsCategoryID = submitedScoreDetailView.ExamsCategoryID;
- submitedScore.ExaminationModeID = submitedScoreDetailView.ExaminationModeID;
- submitedScore.Credit = submitedScoreDetailView.Credit;
- submitedScore.ExamsDatetime = submitedScoreDetailView.ExamsDatetime;
- submitedScore.CreatorUserID = submitedScoreDetailView.CreatorUserID;
- submitedScore.EntryDeadlineTime = submitedScoreDetailView.EntryDeadlineTime;
- submitedScore.ExaminationType = submitedScoreDetailView.ExaminationTypeID;
- submitedScore.StarttermID = submitedScoreDetailView.StarttermID;
- submitedScore.UserID = submitedScoreDetailView.UserID;
- submitedScore.ExamsStateID = submitedScoreDetailView.ExamsStateID;
- submitedScore.TotalScore = submitedScoreDetailView.TotalScore;
- submitedScore.ScoreCredit = submitedScoreDetailView.ScoreCredit;
- submitedScore.GradePoint = submitedScoreDetailView.GradePoint;
- SetNewStatus(submitedScore);
- UnitOfWork.Add(submitedScore);
- foreach (dynamic expandoObject in listExpandoObject)
- {
- var dic = (IDictionary<string, object>)expandoObject;
- ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail();
- submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid();
- submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID;
- submitedScoreDetail.ScoreTypeID = expandoObject.ScoreTypeID;
- submitedScoreDetail.Score = expandoObject.Score;
- SetNewStatus(submitedScoreDetail);
- UnitOfWork.Add(submitedScoreDetail);
- }
- }
- else
- {
- submitedScore = CourseGradeDAL.SubmitedScoreRepository.GetSingle(x => x.SubmitedScoreID == submitedScoreDetailView.SubmitedScoreID, (x => x.ER_SubmitedScoreDetail));
- if (submitedScore == null)
- throw new Exception("未找到相对应的数据!");
- submitedScore.SchoolyearID = submitedScoreDetailView.SchoolyearID;
- submitedScore.SchoolyearNumID = submitedScoreDetailView.SchoolyearNumID;
- submitedScore.DepartmentID = submitedScoreDetailView.DepartmentID;
- submitedScore.ClassName = submitedScoreDetailView.ClassName;
- submitedScore.CoursematerialID = submitedScoreDetailView.CoursematerialID;
- submitedScore.CourseTypeID = submitedScoreDetailView.CourseTypeID;
- submitedScore.ExamsCategoryID = submitedScoreDetailView.ExamsCategoryID;
- submitedScore.ExaminationModeID = submitedScoreDetailView.ExaminationModeID;
- submitedScore.Credit = submitedScoreDetailView.Credit;
- submitedScore.ExamsDatetime = submitedScoreDetailView.ExamsDatetime;
- submitedScore.CreatorUserID = submitedScoreDetailView.CreatorUserID;
- submitedScore.EntryDeadlineTime = submitedScoreDetailView.EntryDeadlineTime;
- submitedScore.ExaminationType = submitedScoreDetailView.ExaminationTypeID;
- submitedScore.StarttermID = submitedScoreDetailView.StarttermID;
- submitedScore.UserID = submitedScoreDetailView.UserID;
- submitedScore.ExamsStateID = submitedScoreDetailView.ExamsStateID;
- submitedScore.TotalScore = submitedScoreDetailView.TotalScore;
- submitedScore.ScoreCredit = submitedScoreDetailView.ScoreCredit;
- submitedScore.GradePoint = submitedScoreDetailView.GradePoint;
- SetModifyStatus(submitedScore);
- foreach (dynamic expandoObject in listExpandoObject)
- {
- int scoreTypeID = expandoObject.ScoreTypeID;
- ER_SubmitedScoreDetail submitedScoreDetail = submitedScore.ER_SubmitedScoreDetail.Where(x => x.ScoreTypeID == scoreTypeID).FirstOrDefault();
- submitedScoreDetail.ScoreTypeID = expandoObject.ScoreTypeID;
- submitedScoreDetail.Score = expandoObject.Score;
- SetModifyStatus(submitedScoreDetail);
- }
- }
- UnitOfWork.Commit();
- //提取到该成绩对应的最大考试性质信息
- int? ExamsCategoryIDMax = SubmitedScoreRepository.GetList(x => x.SchoolyearID == submitedScoreDetailView.SchoolyearID
- && x.DepartmentID == submitedScoreDetailView.DepartmentID
- && x.CoursematerialID == submitedScoreDetailView.CoursematerialID
- && x.UserID == submitedScoreDetailView.UserID).Max(w => w.ExamsCategoryID).Value;
- //学生成绩操作完成以后、同步最终成绩表对应的信息
- if (ExamsCategoryIDMax != null)
- {
- ER_SubmitedScore entity = SubmitedScoreRepository.GetSingle(x => x.SchoolyearID == submitedScoreDetailView.SchoolyearID
- && x.DepartmentID == submitedScoreDetailView.DepartmentID
- && x.CoursematerialID == submitedScoreDetailView.CoursematerialID
- && x.UserID == submitedScoreDetailView.UserID && x.ExamsCategoryID == ExamsCategoryIDMax);
- //判断是否存在最终成绩
- ER_FinallyScore finallyScore = CourseGradeDAL.ScoreRepository.GetSingle(x => x.SchoolyearID == submitedScoreDetailView.SchoolyearID && x.CoursematerialID == submitedScoreDetailView.CoursematerialID && x.DepartmentID == submitedScoreDetailView.DepartmentID
- && x.StarttermID == submitedScoreDetailView.StarttermID && x.UserID == submitedScoreDetailView.UserID, (x => x.ER_FinallyScoreDetail));
- if (finallyScore == null)
- {
- finallyScore = new ER_FinallyScore();
- finallyScore.FinallyScoreID = Guid.NewGuid();
- finallyScore.SchoolyearID = submitedScoreDetailView.SchoolyearID;
- finallyScore.SchoolyearNumID = submitedScoreDetailView.SchoolyearNumID;
- finallyScore.DepartmentID = submitedScoreDetailView.DepartmentID;
- finallyScore.ClassName = submitedScoreDetailView.ClassName;
- finallyScore.CoursematerialID = submitedScoreDetailView.CoursematerialID;
- finallyScore.CourseTypeID = submitedScoreDetailView.CourseTypeID;
- finallyScore.ExamsCategoryID = submitedScoreDetailView.ExamsCategoryID;
- finallyScore.ExaminationModeID = submitedScoreDetailView.ExaminationModeID;
- finallyScore.Credit = submitedScoreDetailView.Credit;
- finallyScore.ExamsDatetime = submitedScoreDetailView.ExamsDatetime;
- finallyScore.CreatorUserID = submitedScoreDetailView.CreatorUserID;
- finallyScore.EntryDeadlineTime = submitedScoreDetailView.EntryDeadlineTime;
- finallyScore.ExaminationType = submitedScoreDetailView.ExaminationTypeID;
- finallyScore.StarttermID = submitedScoreDetailView.StarttermID;
- finallyScore.UserID = submitedScoreDetailView.UserID;
- finallyScore.ExamsStateID = submitedScoreDetailView.ExamsStateID;
- finallyScore.TotalScore = submitedScoreDetailView.TotalScore;
- finallyScore.ScoreCredit = submitedScoreDetailView.ScoreCredit;
- finallyScore.GradePoint = submitedScoreDetailView.GradePoint;
- SetNewStatus(finallyScore);
- UnitOfWork.Add(finallyScore);
- foreach (dynamic expandoObject in listExpandoObject)
- {
- var dic = (IDictionary<string, object>)expandoObject;
- ER_FinallyScoreDetail finallyScoreDetail = new ER_FinallyScoreDetail();
- finallyScoreDetail.FinallyScoreDetailID = Guid.NewGuid();
- finallyScoreDetail.FinallyScoreID = finallyScore.FinallyScoreID;
- finallyScoreDetail.ScoreTypeID = expandoObject.ScoreTypeID;
- finallyScoreDetail.Score = expandoObject.Score;
- SetNewStatus(finallyScoreDetail);
- UnitOfWork.Add(finallyScoreDetail);
- }
- }
- else
- {
- finallyScore.SchoolyearID = submitedScoreDetailView.SchoolyearID;
- finallyScore.SchoolyearNumID = submitedScoreDetailView.SchoolyearNumID;
- finallyScore.DepartmentID = submitedScoreDetailView.DepartmentID;
- finallyScore.ClassName = submitedScoreDetailView.ClassName;
- finallyScore.CoursematerialID = submitedScoreDetailView.CoursematerialID;
- finallyScore.CourseTypeID = submitedScoreDetailView.CourseTypeID;
- finallyScore.ExamsCategoryID = submitedScoreDetailView.ExamsCategoryID;
- finallyScore.ExaminationModeID = submitedScoreDetailView.ExaminationModeID;
- finallyScore.Credit = submitedScoreDetailView.Credit;
- finallyScore.ExamsDatetime = submitedScoreDetailView.ExamsDatetime;
- finallyScore.CreatorUserID = submitedScoreDetailView.CreatorUserID;
- finallyScore.EntryDeadlineTime = submitedScoreDetailView.EntryDeadlineTime;
- finallyScore.ExaminationType = submitedScoreDetailView.ExaminationTypeID;
- finallyScore.StarttermID = submitedScoreDetailView.StarttermID;
- finallyScore.UserID = submitedScoreDetailView.UserID;
- finallyScore.ExamsStateID = submitedScoreDetailView.ExamsStateID;
- finallyScore.TotalScore = submitedScoreDetailView.TotalScore;
- finallyScore.ScoreCredit = submitedScoreDetailView.ScoreCredit;
- finallyScore.GradePoint = submitedScoreDetailView.GradePoint;
- SetModifyStatus(finallyScore);
- foreach (dynamic expandoObject in listExpandoObject)
- {
- int scoreTypeID = expandoObject.ScoreTypeID;
- ER_FinallyScoreDetail finallyScoreDetail = finallyScore.ER_FinallyScoreDetail.Where(x => x.ScoreTypeID == scoreTypeID).FirstOrDefault();
- finallyScoreDetail.ScoreTypeID = expandoObject.ScoreTypeID;
- finallyScoreDetail.Score = expandoObject.Score;
- SetModifyStatus(finallyScoreDetail);
- }
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="submitedScoreIDs"></param>
- public void SubmitedScoreDelete(List<Guid> submitedScoreIDs, Guid? schoolyearID, Guid? coursematerialID, int? starttermID, Guid? userID)
- {
- try
- {
- if (submitedScoreIDs.Count > 0)
- {
- UnitOfWork.Delete<ER_SubmitedScoreDetail>(x => submitedScoreIDs.Contains(x.SubmitedScoreID.Value));
- UnitOfWork.Delete<ER_SubmitedScore>(x => submitedScoreIDs.Contains(x.SubmitedScoreID));
- var listSubmitedScore = CourseGradeDAL.SubmitedScoreRepository.GetList(x => x.SchoolyearID == schoolyearID && x.CoursematerialID == coursematerialID && x.StarttermID == starttermID && x.UserID == userID).ToList();
- if (listSubmitedScore.Count == 0)
- {
- UnitOfWork.Delete<ER_FinallyScore>(x => x.SchoolyearID == schoolyearID && x.CoursematerialID == coursematerialID && x.StarttermID == starttermID && x.UserID == userID);
- }
- else
- {
- ER_SubmitedScore submitedScore = CourseGradeDAL.SubmitedScoreRepository.GetList(x => x.SchoolyearID == schoolyearID && x.CoursematerialID == coursematerialID && x.StarttermID == starttermID && x.UserID == userID, (x => x.ER_SubmitedScoreDetail)).OrderByDescending(x => x.CreateTime).ToList().FirstOrDefault();
- if (submitedScore != null)
- {
- ER_FinallyScore finallyScore = CourseGradeDAL.ScoreRepository.GetSingle(x => x.SchoolyearID == schoolyearID && x.CoursematerialID == coursematerialID && x.StarttermID == starttermID && x.UserID == userID, (x => x.ER_FinallyScoreDetail));
- if (finallyScore != null)
- {
- var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
- finallyScore.SchoolyearID = submitedScore.SchoolyearID;
- finallyScore.SchoolyearNumID = submitedScore.SchoolyearNumID;
- finallyScore.DepartmentID = submitedScore.DepartmentID;
- finallyScore.ClassName = submitedScore.ClassName;
- finallyScore.CoursematerialID = submitedScore.CoursematerialID;
- finallyScore.CourseTypeID = submitedScore.CourseTypeID;
- finallyScore.ExamsCategoryID = submitedScore.ExamsCategoryID;
- finallyScore.ExaminationModeID = submitedScore.ExaminationModeID;
- finallyScore.Credit = submitedScore.Credit;
- finallyScore.ExamsDatetime = submitedScore.ExamsDatetime;
- finallyScore.CreatorUserID = submitedScore.CreatorUserID;
- finallyScore.EntryDeadlineTime = submitedScore.EntryDeadlineTime;
- finallyScore.ExaminationType = submitedScore.ExaminationType;
- finallyScore.StarttermID = submitedScore.StarttermID;
- finallyScore.UserID = submitedScore.UserID;
- finallyScore.ExamsStateID = submitedScore.ExamsStateID;
- finallyScore.TotalScore = submitedScore.TotalScore;
- finallyScore.ScoreCredit = submitedScore.ScoreCredit;
- finallyScore.GradePoint = submitedScore.GradePoint;
- finallyScore.Remark = submitedScore.Remark;
- SetModifyStatus(finallyScore);
- foreach (var scoreDynamicType in scoreDynamicTypes)
- {
- ER_SubmitedScoreDetail submitedScoreDetail = submitedScore.ER_SubmitedScoreDetail.Where(x => x.ScoreTypeID == scoreDynamicType.Value).FirstOrDefault();
- ER_FinallyScoreDetail finallyScoreDetail = finallyScore.ER_FinallyScoreDetail.Where(x => x.ScoreTypeID == scoreDynamicType.Value).FirstOrDefault();
- finallyScoreDetail.ScoreTypeID = submitedScoreDetail.ScoreTypeID;
- finallyScoreDetail.Score = submitedScoreDetail.Score;
- SetModifyStatus(finallyScoreDetail);
- }
- }
- UnitOfWork.Commit();
- }
- }
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取已提交成绩
- /// </summary>
- /// <param name="submitedScoreID"></param>
- /// <returns></returns>
- public ER_SubmitedScore GetSubmitedScore(Guid? submitedScoreID)
- {
- return CourseGradeDAL.SubmitedScoreRepository.GetSingle(x => x.SubmitedScoreID == submitedScoreID, (x => x.ER_SubmitedScoreDetail));
- }
- public List<SubmitedScoreView> GetStudentPersonalScoreViewList(ConfiguretView configuretView, Guid? coursematerialID, int? starttermID, Guid? userID)
- {
- if (!coursematerialID.HasValue)
- {
- coursematerialID = Guid.Empty;
- starttermID = null;
- userID = Guid.Empty;
- }
- var data = CourseGradeDAL.GetSubmitedScoreList((Guid)coursematerialID, starttermID, (Guid)userID);
- foreach (var Grade in data)
- {
- var ScoreDetail = CourseGradeDAL.GetScoreDetail(Grade.SubmitedScoreID);
- var pingshi = ScoreDetail.SingleOrDefault(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime);
- var jishu = ScoreDetail.SingleOrDefault(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique);
- var lilun = ScoreDetail.SingleOrDefault(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical);
- Grade.Pingshi = pingshi != null ? pingshi.Score : 0;
- Grade.Jishu = jishu != null ? jishu.Score : 0;
- Grade.Lilun = lilun != null ? lilun.Score : 0;
- }
- return data.ToList();
- }
- }
- }
|