123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Data;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.StudentEvaluation;
- using EMIS.DataLogic.EvaluationManage.StudentEvaluation;
- using EMIS.CommonLogic.EvaluationManage.EvaluationManage;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.EvaluationManage.StudentEvaluation
- {
- public class EvaluationStudentSettingScoreServices : BaseServices, IEvaluationStudentSettingScoreServices
- {
- public EvaluationStudentSettingScoreDAL EvaluationStudentSettingScoreDAL { get; set; }
- public EvaluationStudentSettingDAL EvaluationStudentSettingDAL { get; set; }
- public Lazy<IEvaluationStudentScoreServices> EvaluationStudentScoreServices { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- /// <summary>
- /// 查询对应的学评评分信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="staffID"></param>
- /// <param name="teachingMethodID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="openState"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationStudentSettingScoreView> GetEvaluationStudentSettingScoreViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID,
- Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? openState, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationStudentSettingScore, bool>> expEvaluationStudentSettingScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<EM_EvaluationStudentSetting, bool>> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (staffID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID);
- }
- if (teachingMethodID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.TeachingMethodID == teachingMethodID);
- }
- if (evaluationTableID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationTableID == evaluationTableID);
- }
- if (openState.HasValue)
- {
- if (openState.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState == true);
- }
- if (openState.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState != true);
- }
- }
- var query = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSettingScore, expEvaluationStudentSetting);
- if (schoolyearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == schoolyearID);
- }
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- query = query.Where(x => x.DepartmentID == departmentID);
- }
- if (coursematerialID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- }
- if (handleModeID.HasValue)
- {
- query = query.Where(x => x.HandleModeID == handleModeID);
- }
- if (teachingModeID.HasValue)
- {
- query = query.Where(x => x.TeachingModeID == teachingModeID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
- .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToGridResultSet<EvaluationStudentSettingScoreView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学评评分信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="staffID"></param>
- /// <param name="teachingMethodID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="openState"></param>
- /// <returns></returns>
- public IList<EvaluationStudentSettingScoreView> GetEvaluationStudentSettingScoreViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID,
- Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? openState)
- {
- Expression<Func<EM_EvaluationStudentSettingScore, bool>> expEvaluationStudentSettingScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<EM_EvaluationStudentSetting, bool>> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (staffID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID);
- }
- if (teachingMethodID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.TeachingMethodID == teachingMethodID);
- }
- if (evaluationTableID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationTableID == evaluationTableID);
- }
- if (openState.HasValue)
- {
- if (openState.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState == true);
- }
- if (openState.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState != true);
- }
- }
- var query = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSettingScore, expEvaluationStudentSetting);
- if (schoolyearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == schoolyearID);
- }
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- query = query.Where(x => x.DepartmentID == departmentID);
- }
- if (coursematerialID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- }
- if (handleModeID.HasValue)
- {
- query = query.Where(x => x.HandleModeID == handleModeID);
- }
- if (teachingModeID.HasValue)
- {
- query = query.Where(x => x.TeachingModeID == teachingModeID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
- .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToList();
- }
- /// <summary>
- /// 查询对应的学评评分信息EvaluationStudentSettingScoreView
- /// </summary>
- /// <param name="evaluationStudentSettingScoreID"></param>
- /// <returns></returns>
- public EvaluationStudentSettingScoreView GetEvaluationStudentSettingScoreView(Guid? evaluationStudentSettingScoreID)
- {
- try
- {
- Expression<Func<EM_EvaluationStudentSettingScore, bool>> exp = (x => x.EvaluationStudentSettingScoreID == evaluationStudentSettingScoreID);
- var query = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 评分生成
- /// </summary>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="staffID"></param>
- /// <param name="teachingMethodID"></param>
- /// <param name="schoolyearID"></param>
- /// <returns></returns>
- public string EvaluationStudentSettingScoreCreate(Guid? campusID, Guid? collegeID, Guid? departmentID, int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID,
- int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID)
- {
- try
- {
- var schoolyear = EvaluationStudentSettingScoreDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == schoolyearID).SingleOrDefault();
- if (schoolyear == null)
- {
- throw new Exception("选择的学年学期有误,请核查。");
- }
- var setParticipateCountScope = ParameterServices.Value.GetParameterValue(CF_ParameterType.ParticipateCountScope);
- if (setParticipateCountScope == null)
- {
- throw new Exception("未设置参评人数范围,请设置。");
- }
- var participateCountScope = Convert.ToInt32(setParticipateCountScope);
- decimal? evStudentSettingScore = 0;
- Expression<Func<EM_EvaluationStudentSetting, bool>> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (staffID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID);
- }
- if (teachingMethodID.HasValue)
- {
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.TeachingMethodID == teachingMethodID);
- }
- Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- bool classmajorHasValue = false;
- if (gradeID.HasValue)
- {
- expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID);
- classmajorHasValue = true;
- }
- if (standardID.HasValue)
- {
- expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- classmajorHasValue = true;
- }
- if (classmajorHasValue)
- {
- expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor));
- }
- if (coursematerialID.HasValue)
- {
- expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID);
- }
- if (handleModeID.HasValue)
- {
- expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID);
- }
- if (teachingModeID.HasValue)
- {
- expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID);
- }
- Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID);
- }
- if (schoolyearID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(expEvaluationStudentSetting, expEducationMissionClass, expEducationMission);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- var evaluationStudentSettingViewList = this.GetQueryByDataRangeByDepartment(query).ToList();
- var evaluationStudentSettingIDList = evaluationStudentSettingViewList.Select(x => x.EvaluationStudentSettingID).ToList();
- Expression<Func<EM_EvaluationStudent, bool>> expEvaluationStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEvaluationStudent = expEvaluationStudent.And(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID.Value));
- expEvaluationStudent = expEvaluationStudent.And(x => x.IsValidity == true);
- var evaluationStudentList = EvaluationStudentSettingScoreDAL.EvaluationStudentRepository.GetList(expEvaluationStudent).ToList();
- var evaluationStudentSettingScoreList = EvaluationStudentSettingScoreDAL.EvaluationStudentSettingScoreRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID.Value)).ToList();
- int inSuccess = 0;
- int upSuccess = 0;
- string tipMessage = null;
- var evaluationStudentSettingScoreInList = new List<EM_EvaluationStudentSettingScore>();
- var evaluationStudentSettingScoreUpList = new List<EM_EvaluationStudentSettingScore>();
- foreach (var evaluationStudentSettingView in evaluationStudentSettingViewList)
- {
- var evaluationStudentVerifyList = evaluationStudentList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingView.EvaluationStudentSettingID).OrderBy(x => x.TotalScore ?? 0).ToList();
- if (evaluationStudentVerifyList == null || evaluationStudentVerifyList.Count() <= 0)
- {
- evStudentSettingScore = 0;
- }
- else
- {
- if (evaluationStudentVerifyList.Count() < participateCountScope)
- {
- evStudentSettingScore = evaluationStudentVerifyList.Average(x => x.TotalScore ?? 0);
- }
- else
- {
- var differenceNumber = Convert.ToInt32(Math.Round(((decimal)evaluationStudentVerifyList.Count() * (decimal)0.05), 0, MidpointRounding.AwayFromZero));
- evaluationStudentVerifyList.RemoveRange(evaluationStudentVerifyList.Count() - differenceNumber, differenceNumber);
- evaluationStudentVerifyList.RemoveRange(0, differenceNumber);
- evStudentSettingScore = evaluationStudentVerifyList.Average(x => x.TotalScore ?? 0);
- }
- }
- var evaluationStudentSettingScoreVerify = evaluationStudentSettingScoreList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingView.EvaluationStudentSettingID).SingleOrDefault();
- if (evaluationStudentSettingScoreVerify == null)
- {
- var newEvaluationStudentSettingScore = new EM_EvaluationStudentSettingScore();
- newEvaluationStudentSettingScore.EvaluationStudentSettingScoreID = Guid.NewGuid();
- newEvaluationStudentSettingScore.EvaluationStudentSettingID = evaluationStudentSettingView.EvaluationStudentSettingID;
- newEvaluationStudentSettingScore.TotalScore = evStudentSettingScore;
- newEvaluationStudentSettingScore.Remark = null;
- SetNewStatus(newEvaluationStudentSettingScore);
- evaluationStudentSettingScoreInList.Add(newEvaluationStudentSettingScore);
- inSuccess++;
- }
- else
- {
- evaluationStudentSettingScoreVerify.TotalScore = evStudentSettingScore;
- SetModifyStatus(evaluationStudentSettingScoreVerify);
- evaluationStudentSettingScoreUpList.Add(evaluationStudentSettingScoreVerify);
- upSuccess++;
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.BulkInsert(evaluationStudentSettingScoreInList);
- if (evaluationStudentSettingScoreUpList != null && evaluationStudentSettingScoreUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(evaluationStudentSettingScoreUpList);
- }
- ts.Complete();
- }
- if (inSuccess > 0 && upSuccess <= 0)
- {
- tipMessage = inSuccess + "条";
- }
- else
- {
- tipMessage = inSuccess + "条,更新成功" + upSuccess + "条";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="evaluationStudentSettingScoreView"></param>
- public void EvaluationStudentSettingScoreEdit(EvaluationStudentSettingScoreView evaluationStudentSettingScoreView)
- {
- try
- {
- if (!evaluationStudentSettingScoreView.EvaluationStudentSettingID.HasValue || evaluationStudentSettingScoreView.EvaluationStudentSettingID == Guid.Empty)
- {
- throw new Exception("对应的学评设定数据有误,请核查。");
- }
- var evaluationStudentSettingScoreVerify = EvaluationStudentSettingScoreDAL.EvaluationStudentSettingScoreRepository.GetList(x => x.EvaluationStudentSettingScoreID != evaluationStudentSettingScoreView.EvaluationStudentSettingScoreID && x.EvaluationStudentSettingID == evaluationStudentSettingScoreView.EvaluationStudentSettingID).SingleOrDefault();
- if (evaluationStudentSettingScoreVerify == null)
- {
- var setPassParticipateRate = ParameterServices.Value.GetParameterValue(CF_ParameterType.PassParticipateRate);
- if (setPassParticipateRate == null)
- {
- throw new Exception("未设置达标参评率,请设置。");
- }
- var startStatusID = EvaluationStudentScoreServices.Value.GetStartStatus();
- if (startStatusID == null)
- {
- throw new Exception("工作流平台中,学生评分流程开始环节未配置,请核查。");
- }
- var passParticipateRate = Convert.ToDecimal(setPassParticipateRate);
- decimal? evStudentTotalScore = 0;
- Expression<Func<EM_EvaluationStudentSetting, bool>> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == evaluationStudentSettingScoreView.UserID);
- Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEducationMission = expEducationMission.And(x => x.SchoolyearID == evaluationStudentSettingScoreView.SchoolyearID);
- expEducationMission = expEducationMission.And(x => x.DepartmentID == evaluationStudentSettingScoreView.DepartmentID);
- Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == evaluationStudentSettingScoreView.CoursematerialID);
- var evaluationStudentSettingViewList = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(expEvaluationStudentSetting).ToList();
- var evaluationStudentSettingView = evaluationStudentSettingViewList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingScoreView.EvaluationStudentSettingID).SingleOrDefault();
- if (evaluationStudentSettingView == null)
- {
- throw new Exception("对应的学评设定数据有误,请核查。");
- }
- else
- {
- var evaluationStudentSettingScoreViewList = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSetting, expEducationMission, expEducationMissionClass).ToList();
- if (evaluationStudentSettingScoreViewList != null && evaluationStudentSettingScoreViewList.Count() > 0)
- {
- var evaStuSettingScoreView = evaluationStudentSettingScoreViewList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingScoreView.EvaluationStudentSettingID).SingleOrDefault();
- if (evaStuSettingScoreView == null)
- {
- var passEvaStuSettingScoreViewList = evaluationStudentSettingScoreViewList.Where(x => x.ValidityParticipateRate >= passParticipateRate).ToList();
- if (evaluationStudentSettingView.ValidityParticipateRate >= passParticipateRate)
- {
- evStudentTotalScore = Math.Round((decimal)((decimal?)((passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) + (evaluationStudentSettingScoreView.TotalScore ?? 0)) * (decimal?)1.00 / (decimal?)(evaluationStudentSettingScoreViewList.Count() + 1)), 1);
- }
- else
- {
- evStudentTotalScore = Math.Round((decimal)((decimal?)(passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) * (decimal?)1.00 / (decimal?)(evaluationStudentSettingScoreViewList.Count() + 1)), 1);
- }
- }
- else
- {
- var passEvaStuSettingScoreViewList = evaluationStudentSettingScoreViewList.Where(x => x.EvaluationStudentSettingID != evaluationStudentSettingScoreView.EvaluationStudentSettingID && x.ValidityParticipateRate >= passParticipateRate).ToList();
- if (evaStuSettingScoreView.ValidityParticipateRate >= passParticipateRate)
- {
- evStudentTotalScore = Math.Round((decimal)((decimal?)((passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) + (evaluationStudentSettingScoreView.TotalScore ?? 0)) * (decimal?)1.00 / (decimal?)evaluationStudentSettingScoreViewList.Count()), 1);
- }
- else
- {
- evStudentTotalScore = Math.Round((decimal)((decimal?)(passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) * (decimal?)1.00 / (decimal?)evaluationStudentSettingScoreViewList.Count()), 1);
- }
- }
- }
- else
- {
- if (evaluationStudentSettingView.ValidityParticipateRate >= passParticipateRate)
- {
- evStudentTotalScore = evaluationStudentSettingScoreView.TotalScore;
- }
- else
- {
- evStudentTotalScore = 0;
- }
- }
- }
- var evaluationStudentScoreInList = new List<EM_EvaluationStudentScore>();
- var evaluationStudentScoreUpList = new List<EM_EvaluationStudentScore>();
- Expression<Func<EM_EvaluationStudentScore, bool>> expEvaluationStudentScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.SchoolyearID == evaluationStudentSettingScoreView.SchoolyearID);
- expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.UserID == evaluationStudentSettingScoreView.UserID);
- expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.CoursematerialID == evaluationStudentSettingScoreView.CoursematerialID);
- expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.DepartmentID == evaluationStudentSettingScoreView.DepartmentID);
- var evaluationStudentScore = EvaluationStudentSettingScoreDAL.EvaluationStudentScoreRepository.GetList(expEvaluationStudentScore).SingleOrDefault();
- if (evaluationStudentScore == null)
- {
- var newEvaluationStudentScore = new EM_EvaluationStudentScore();
- newEvaluationStudentScore.EvaluationStudentScoreID = Guid.NewGuid();
- newEvaluationStudentScore.SchoolyearID = evaluationStudentSettingScoreView.SchoolyearID;
- newEvaluationStudentScore.UserID = evaluationStudentSettingScoreView.UserID;
- newEvaluationStudentScore.CoursematerialID = evaluationStudentSettingScoreView.CoursematerialID;
- newEvaluationStudentScore.DepartmentID = evaluationStudentSettingScoreView.DepartmentID;
- newEvaluationStudentScore.TotalScore = evStudentTotalScore;
- newEvaluationStudentScore.ApprovalStatus = startStatusID;
- SetNewStatus(newEvaluationStudentScore);
- evaluationStudentScoreInList.Add(newEvaluationStudentScore);
- }
- else
- {
- if (evaluationStudentScore.ApprovalStatus == startStatusID)
- {
- evaluationStudentScore.TotalScore = evStudentTotalScore;
- SetModifyStatus(evaluationStudentScore);
- evaluationStudentScoreUpList.Add(evaluationStudentScore);
- }
- else
- {
- throw new Exception("对应的学生评分信息已在工作流程中,请核查。");
- }
- }
- var evaluationStudentSettingScoreInList = new List<EM_EvaluationStudentSettingScore>();
- var evaluationStudentSettingScoreUpList = new List<EM_EvaluationStudentSettingScore>();
- if (evaluationStudentSettingScoreView.EvaluationStudentSettingScoreID != Guid.Empty)
- {
- var evaluationStudentSettingScore = EvaluationStudentSettingScoreDAL.EvaluationStudentSettingScoreRepository.GetList(x => x.EvaluationStudentSettingScoreID == evaluationStudentSettingScoreView.EvaluationStudentSettingScoreID).SingleOrDefault();
- if (evaluationStudentSettingScore == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- evaluationStudentSettingScore.TotalScore = evaluationStudentSettingScoreView.TotalScore;
- evaluationStudentSettingScore.Remark = evaluationStudentSettingScoreView.Remark;
- SetModifyStatus(evaluationStudentSettingScore);
- evaluationStudentSettingScoreUpList.Add(evaluationStudentSettingScore);
- }
- }
- else
- {
- //表示新增
- var newEvaluationStudentSettingScore = new EM_EvaluationStudentSettingScore();
- newEvaluationStudentSettingScore.EvaluationStudentSettingScoreID = Guid.NewGuid();
- newEvaluationStudentSettingScore.EvaluationStudentSettingID = evaluationStudentSettingScoreView.EvaluationStudentSettingID;
- newEvaluationStudentSettingScore.TotalScore = evaluationStudentSettingScoreView.TotalScore;
- newEvaluationStudentSettingScore.Remark = evaluationStudentSettingScoreView.Remark;
- SetNewStatus(newEvaluationStudentSettingScore);
- evaluationStudentSettingScoreInList.Add(newEvaluationStudentSettingScore);
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.BulkInsert(evaluationStudentScoreInList);
- if (evaluationStudentScoreUpList != null && evaluationStudentScoreUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(evaluationStudentScoreUpList);
- }
- UnitOfWork.BulkInsert(evaluationStudentSettingScoreInList);
- if (evaluationStudentSettingScoreUpList != null && evaluationStudentSettingScoreUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(evaluationStudentSettingScoreUpList);
- }
- ts.Complete();
- }
- }
- else
- {
- throw new Exception("已存在相同的学评评分信息(学评设定信息唯一),请核查。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationStudentSettingScoreIDs"></param>
- /// <returns></returns>
- public bool EvaluationStudentSettingScoreDelete(List<Guid?> evaluationStudentSettingScoreIDs)
- {
- try
- {
- Expression<Func<EM_EvaluationStudentSettingScore, bool>> expEvaluationStudentSetting = (x => evaluationStudentSettingScoreIDs.Contains(x.EvaluationStudentSettingScoreID));
- var evaluationStudentSettingScoreViewList = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSetting).ToList();
- var userIDList = evaluationStudentSettingScoreViewList.Select(x => x.UserID).Distinct().ToList();
- var evaluationStudentScoreList = EvaluationStudentSettingScoreDAL.EvaluationStudentScoreRepository.GetList(x => userIDList.Contains(x.UserID)).ToList();
- var evaluationStudentSettingIDList = evaluationStudentSettingScoreViewList.Select(x => x.EvaluationStudentSettingID).ToList();
- var evaluationStudentList = EvaluationStudentSettingScoreDAL.EvaluationStudentRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList();
- var evaluationStudentIDList = evaluationStudentList.Select(x => x.EvaluationStudentID).ToList();
- foreach (var evaluationStudentSettingScoreView in evaluationStudentSettingScoreViewList)
- {
- var evaluationStudentScore = evaluationStudentScoreList.Where(x => x.SchoolyearID == evaluationStudentSettingScoreView.SchoolyearID && x.UserID == evaluationStudentSettingScoreView.UserID
- && x.CoursematerialID == evaluationStudentSettingScoreView.CoursematerialID && x.DepartmentID == evaluationStudentSettingScoreView.DepartmentID).SingleOrDefault();
- if (evaluationStudentScore != null)
- {
- throw new Exception("选择删除的信息中存在对应的学生评分信息,无法删除,请核查。");
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<EM_EvaluationStudentSettingScore>(x => evaluationStudentSettingScoreIDs.Contains(x.EvaluationStudentSettingScoreID));
- UnitOfWork.Delete<EM_EvaluationStudentDetail>(x => evaluationStudentIDList.Contains(x.EvaluationStudentID.Value));
- UnitOfWork.Delete<EM_EvaluationStudent>(x => evaluationStudentIDList.Contains(x.EvaluationStudentID));
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
-
- }
- }
|