123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.ViewModel;
- using EMIS.DataLogic.ScoreManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.EducationManage;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Utility;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class ScoreConvertByLevelServices : BaseServices,IScoreConvertByLevelServices
- {
- public ScoreConvertByApplyDAL scoreConvertByApplyDAL { get; set; }
- public ScoreConvertByLevelDAL ScoreConvertByLevelDAL { get; set; }
- public ExecutablePlanDAL ExecutablePlanDAL { get; set; }
- public LevelScoreDAL levelScoreDAL { get; set; }
- public StudentScoreDAL studentScoreDAL { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- public LevelSettingDAL levelSettingDAL { get; set; }
- public Lazy<IStudentScoreServices> StudentScoreServices { get; set; }
- public IGridResultSet<ScoreConvertByLevelView> GetUniteMaintainViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, Guid? coursematerialID, int pageIndex, int pageSize)
- {
- Expression<Func<ER_ScoreConvertByLevelScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (collegeID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- if (yearID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == yearID);
- if (standardID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- if (classmajorID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.ClassmajorID == classmajorID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- var query = ScoreConvertByLevelDAL.GetScoreConvertByLevelViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)).OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeName).ThenBy(x => x.StandardID).ThenBy(x => x.ClassmajorName).ToGridResultSet<ScoreConvertByLevelView>(pageIndex, pageSize);
- }
- public List<ScoreConvertByLevelView> GetScoreConvertByLevelView_Excel(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, Guid? coursematerialID, List<Guid?> ScoreConvertByLevelScoreIDList)
- {
- Expression<Func<ER_ScoreConvertByLevelScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- if (collegeID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- if (yearID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == yearID);
- if (standardID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- if (classmajorID.HasValue)
- exp = exp.And(x => x.ER_LevelScore.CF_Student.ClassmajorID == classmajorID);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- if(ScoreConvertByLevelScoreIDList!=null)
- exp = exp.And(x => ScoreConvertByLevelScoreIDList.Contains(x.ScoreConvertByLevelScoreID));
- var query = ScoreConvertByLevelDAL.GetScoreConvertByLevelViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)).OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeName).ThenBy(x => x.StandardID).ThenBy(x => x.ClassmajorName).ToList();
- }
- public string Save(ScoreConvertByLevelView scoreConvertByLevelView)
- {
- //获取默认绩点公式
- var gradePointFormula = scoreConvertByApplyDAL.GetDefaultGradePointFormula().FirstOrDefault();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- //获取当前学年学期
- var SchoolyearID=ScoreConvertByLevelDAL.SchoolyearRepository.Entities.Where(x=>x.IsCurrent==true).FirstOrDefault();
- //获取过级成绩
- Expression<Func<ER_LevelScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (scoreConvertByLevelView.SchoolyearID.HasValue)
- exp = exp.And(x => x.SchoolyearID == scoreConvertByLevelView.SchoolyearID);
- if(scoreConvertByLevelView.CollegeID.HasValue)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CollegeID == scoreConvertByLevelView.CollegeID);
- if (scoreConvertByLevelView.Year.HasValue && scoreConvertByLevelView.Year!=-1)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == scoreConvertByLevelView.Year);
- if (scoreConvertByLevelView.StandardID.HasValue && scoreConvertByLevelView.StandardID!=-1)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == scoreConvertByLevelView.StandardID);
- if(scoreConvertByLevelView.ClassmajorID.HasValue)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.ClassmajorID == scoreConvertByLevelView.ClassmajorID);
- if (scoreConvertByLevelView.ExaminationFormID.HasValue && scoreConvertByLevelView.ExaminationFormID!=-1)
- exp = exp.And(x => x.EX_ExaminationSubject.ExaminationFormID == scoreConvertByLevelView.ExaminationFormID);
- if (scoreConvertByLevelView.ExaminationTypeID.HasValue)
- exp = exp.And(x => x.EX_ExaminationSubject.ExaminationTypeID == scoreConvertByLevelView.ExaminationTypeID);
- if (scoreConvertByLevelView.LevelScoreID.HasValue)
- exp = exp.And(x => x.ExaminationSubjectID == scoreConvertByLevelView.LevelScoreID);
- var LevelScoreList = levelScoreDAL.GetLevelScoreViewQueryable(exp).ToList();
- var queryLevelName = levelSettingDAL.GetLevelSettingViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //获取课程
- int? retakeExamsCategoryID = ParameterServices.Value.GetParameterValue<int>(CF_ParameterType.RetakeExamsCatagoryID);
- var selectKeyList = LevelScoreList.Select(x => new { x.UserID, CoursematerialID = scoreConvertByLevelView.CoursematerialID }).ToList();
- var lastCourseStarttermViewList = ExecutablePlanDAL.GetLastCourseStarttermViewQueryable().SelectByKeys(selectKeyList);
- //获取现有数据
- var nowScoreConvertByLevelScore = ScoreConvertByLevelDAL.ScoreConvertByLevelScoreRepository.GetList(x => true).ToList();
- //处理数据
- List<ER_ScoreConvertByLevelScore> insertList = new List<ER_ScoreConvertByLevelScore>();
- List<ER_SubmitedScore> insertSubList = new List<ER_SubmitedScore>();
- List<ER_SubmitedScoreDetail> insertSubDetailList = new List<ER_SubmitedScoreDetail>();
- var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
- foreach (var level in LevelScoreList)
- {
- var UserLevelScore = LevelScoreList.Where(x => x.UserID == level.UserID).OrderByDescending(x => x.TotalScore).FirstOrDefault();
- var LevelPassScore=queryLevelName.Where(x=>x.ExaminationSubjectName==UserLevelScore.ExaminationSubjectName&&x.MinScore<=UserLevelScore.TotalScore&&x.MaxScore>=UserLevelScore.TotalScore).FirstOrDefault();
- var UserInCoursematerial = lastCourseStarttermViewList.Where(x => x.UserID == level.UserID).FirstOrDefault();
- var isExist = insertList.Where(x => x.LevelScoreID == UserLevelScore.LevelScoreID).FirstOrDefault();
- var isExists = nowScoreConvertByLevelScore.Where(x => x.LevelScoreID == UserLevelScore.LevelScoreID && x.CoursematerialID == scoreConvertByLevelView.CoursematerialID).FirstOrDefault();
- if (isExists==null)
- {
- if (isExist == null && UserLevelScore != null && UserInCoursematerial != null)
- {
-
- //插入已提交成绩表
- ER_SubmitedScore submitedScore = new ER_SubmitedScore();
- submitedScore.SubmitedScoreID = Guid.NewGuid();
- submitedScore.SchoolyearID = SchoolyearID.SchoolyearID;
- submitedScore.SchoolyearNumID = UserInCoursematerial.SchoolyearNumID;
- submitedScore.DepartmentID = UserInCoursematerial.DepartmentID;
- submitedScore.ClassName = UserInCoursematerial.ClassName;
- submitedScore.CoursematerialID = UserInCoursematerial.CoursematerialID;
- submitedScore.CourseTypeID = UserInCoursematerial.CourseTypeID;
- submitedScore.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam;
- submitedScore.ExaminationModeID = UserInCoursematerial.ExaminationModeID;
- submitedScore.HandleModeID = UserInCoursematerial.HandleModeID;
- submitedScore.Credit = UserInCoursematerial.Credit;
- submitedScore.TotalHours = UserInCoursematerial.TotalHours;
- submitedScore.ResultTypeID = UserInCoursematerial.ResultTypeID;
- submitedScore.CreatorUserID = curUser.UserID;
- submitedScore.IsEntry = true;
- submitedScore.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.FinalExamination;
- submitedScore.StarttermID = UserInCoursematerial.StarttermID;
- submitedScore.UserID = UserInCoursematerial.UserID;
- submitedScore.ExamsStateID = (int)CF_ExamsState.NormalExams;
- submitedScore.TotalScore = UserLevelScore.TotalScore;
- if(LevelPassScore!=null){
- if(LevelPassScore.LevelName=="不合格"){
- submitedScore.ScoreCredit = 0;
- submitedScore.GradePoint = 0;
- }
- else
- {
- submitedScore.ScoreCredit = UserInCoursematerial.Credit;
- submitedScore.GradePoint = gradePointFormula == null ? 0 : (UserLevelScore.TotalScore >= gradePointFormula.GradePointlimit ? (1 + gradePointFormula.GradePointFloor * (UserLevelScore.TotalScore - gradePointFormula.GradePointlimit)) : 0);
- }
- }
- submitedScore.Remark = Const.ER_SCORECONVERT_BYREPLACE_SCOREREMARK;
- submitedScore.RecordStatus = (int)SYS_STATUS.USABLE;
- submitedScore.CreateUserID = curUser.UserID;
- submitedScore.CreateTime = DateTime.Now;
- submitedScore.ModifyUserID = curUser.UserID;
- submitedScore.ModifyTime = DateTime.Now;
- insertSubList.Add(submitedScore);
- foreach (var scoreDynamicType in scoreDynamicTypes)
- {
- ER_SubmitedScoreDetail SubmitedScoreDetail = new ER_SubmitedScoreDetail();
- SubmitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid();
- SubmitedScoreDetail.ScoreTypeID = scoreDynamicType.Value;
- SubmitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID;
- SubmitedScoreDetail.Score = null;
- SetNewStatus(SubmitedScoreDetail);
- insertSubDetailList.Add(SubmitedScoreDetail);
- }
- //插入统一认定表
- ER_ScoreConvertByLevelScore ScoreConvertByLevelScore = new ER_ScoreConvertByLevelScore();
- ScoreConvertByLevelScore.ScoreConvertByLevelScoreID = Guid.NewGuid();
- ScoreConvertByLevelScore.SchoolyearID = SchoolyearID.SchoolyearID;
- ScoreConvertByLevelScore.LevelScoreID = UserLevelScore.LevelScoreID;
- ScoreConvertByLevelScore.CoursematerialID = scoreConvertByLevelView.CoursematerialID;
- ScoreConvertByLevelScore.TotalScore = UserLevelScore.TotalScore;
- SetNewStatus(ScoreConvertByLevelScore);
- ScoreConvertByLevelScore.ER_SubmitedScore.Add(submitedScore);
- insertList.Add(ScoreConvertByLevelScore);
- }
- }
- }
- UnitOfWork.BulkInsert(insertList);
- UnitOfWork.BulkInsert(insertSubList);
- UnitOfWork.BulkInsert(insertList,x=>x.ER_SubmitedScore);
- UnitOfWork.BulkInsert(insertSubDetailList);
- UnitOfWork.Commit();
- var insertSubIDList = insertSubList.Select(x => x.SubmitedScoreID).ToList();
- StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(insertSubIDList);
- var success = "保存成功:一共替换了" + insertList.Count()+"条";
- return success;
- }
- public void Delete(List<Guid?> ScoreConvertByLevelScoreIDList)
- {
- try
- {
- var ScoreConvertByLevelScoreList = ScoreConvertByLevelDAL.ScoreConvertByLevelScoreRepository.GetList(x => ScoreConvertByLevelScoreIDList.Contains(x.ScoreConvertByLevelScoreID),(x=>x.ER_SubmitedScore)).ToList();
- List<Guid?> submitedScoerIDList = new List<Guid?>();
- foreach (var ScoreConvertByLevelScore in ScoreConvertByLevelScoreList)
- {
- var submitedScoerID = ScoreConvertByLevelScore.ER_SubmitedScore.Select(x => x.SubmitedScoreID).FirstOrDefault();
- //ScoreConvertByLevelScore.ER_SubmitedScore = new HashSet<ER_SubmitedScore>();
- submitedScoerIDList.Add(submitedScoerID);
-
- }
- StudentScoreServices.Value.RefreshFinallyScoreBeforeDelete(x => submitedScoerIDList.Contains(x.SubmitedScoreID));
- UnitOfWork.Delete(ScoreConvertByLevelScoreList,(x=>x.ER_SubmitedScore));
- UnitOfWork.Delete(ScoreConvertByLevelScoreList);
- UnitOfWork.Delete<ER_SubmitedScoreDetail>(x => submitedScoerIDList.Contains(x.SubmitedScoreID));
- UnitOfWork.Delete<ER_SubmitedScore>(x => submitedScoerIDList.Contains(x.SubmitedScoreID));
- UnitOfWork.Commit();
-
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|