123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- 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.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.EvaluationManage.StudentEvaluation
- {
- public class EvaluationStudentServices : BaseServices, IEvaluationStudentServices
- {
- public EvaluationStudentDAL EvaluationStudentDAL { get; set; }
- public Lazy<IInSchoolSettingServices> InSchoolSettingServices { 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="teachingModeID"></param>
- /// <param name="staffID"></param>
- /// <param name="teachingMethodID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="isValidity"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationStudentView> GetEvaluationStudentViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID,
- Guid? coursematerialID, int? courseTypeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? isValidity, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationStudent, bool>> expEvaluationStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (isValidity.HasValue)
- {
- if (isValidity.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expEvaluationStudent = expEvaluationStudent.And(x => x.IsValidity == true);
- }
- if (isValidity.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expEvaluationStudent = expEvaluationStudent.And(x => x.IsValidity != true);
- }
- }
- Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID);
- }
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = EvaluationStudentDAL.GetEvaluationStudentViewQueryable(expEvaluationStudent, expEducationMission, expStudent);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (coursematerialID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- }
- if (teachingModeID.HasValue)
- {
- query = query.Where(x => x.TeachingModeID == teachingModeID);
- }
- if (staffID.HasValue)
- {
- query = query.Where(x => x.StaffUserID == staffID);
- }
- if (teachingMethodID.HasValue)
- {
- query = query.Where(x => x.TeachingMethodID == teachingMethodID);
- }
- if (evaluationTableID.HasValue)
- {
- query = query.Where(x => x.EvaluationTableID == evaluationTableID);
- }
- //查询条件
- 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).ThenBy(x => x.StudentNo).ToGridResultSet<EvaluationStudentView>(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="teachingModeID"></param>
- /// <param name="staffID"></param>
- /// <param name="teachingMethodID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="isValidity"></param>
- /// <param name="inSchoolStatus"></param>
- /// <returns></returns>
- public IList<EvaluationStudentView> GetEvaluationStudentViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID,
- Guid? coursematerialID, int? courseTypeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? isValidity, int? inSchoolStatus)
- {
- Expression<Func<EM_EvaluationStudent, bool>> expEvaluationStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (isValidity.HasValue)
- {
- if (isValidity.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expEvaluationStudent = expEvaluationStudent.And(x => x.IsValidity == true);
- }
- if (isValidity.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expEvaluationStudent = expEvaluationStudent.And(x => x.IsValidity != true);
- }
- }
- Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID);
- }
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = EvaluationStudentDAL.GetEvaluationStudentViewQueryable(expEvaluationStudent, expEducationMission, expStudent);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (coursematerialID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- }
- if (teachingModeID.HasValue)
- {
- query = query.Where(x => x.TeachingModeID == teachingModeID);
- }
- if (staffID.HasValue)
- {
- query = query.Where(x => x.StaffUserID == staffID);
- }
- if (teachingMethodID.HasValue)
- {
- query = query.Where(x => x.TeachingMethodID == teachingMethodID);
- }
- if (evaluationTableID.HasValue)
- {
- query = query.Where(x => x.EvaluationTableID == evaluationTableID);
- }
- //查询条件
- 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).ThenBy(x => x.StudentNo).ToList();
- }
- /// <summary>
- /// 查询对应的学评学生信息EvaluationStudentView
- /// </summary>
- /// <param name="evaluationStudentID"></param>
- /// <returns></returns>
- public EvaluationStudentView GetEvaluationStudentView(Guid? evaluationStudentID)
- {
- try
- {
- Expression<Func<EM_EvaluationStudent, bool>> exp = (x => x.EvaluationStudentID == evaluationStudentID);
- var query = EvaluationStudentDAL.GetEvaluationStudentViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="evaluationStudentView"></param>
- public void EvaluationStudentEdit(EvaluationStudentView evaluationStudentView)
- {
- try
- {
- if (!evaluationStudentView.EvaluationStudentSettingID.HasValue || evaluationStudentView.EvaluationStudentSettingID == Guid.Empty)
- {
- throw new Exception("对应的学评设定信息数据有误,请核查。");
- }
- var evaluationStudentVerify = EvaluationStudentDAL.EvaluationStudentRepository.GetList(x => x.EvaluationStudentID != evaluationStudentView.EvaluationStudentID && x.UserID == evaluationStudentView.UserID && x.EvaluationStudentSettingID == evaluationStudentView.EvaluationStudentSettingID).SingleOrDefault();
- if (evaluationStudentVerify == null)
- {
- var evaluationStudentInList = new List<EM_EvaluationStudent>();
- var evaluationStudentUpList = new List<EM_EvaluationStudent>();
- if (evaluationStudentView.EvaluationStudentID != Guid.Empty)
- {
- var evaluationStudent = EvaluationStudentDAL.EvaluationStudentRepository.GetList(x => x.EvaluationStudentID == evaluationStudentView.EvaluationStudentID).SingleOrDefault();
- if (evaluationStudent == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- evaluationStudent.Numbered = (evaluationStudent.Numbered ?? 0) + 1;
- evaluationStudent.IsValidity = evaluationStudentView.IsValidity;
- evaluationStudent.TotalScore = evaluationStudentView.TotalScore;
- evaluationStudent.Advice = evaluationStudentView.Advice;
- evaluationStudent.Remark = evaluationStudentView.Remark;
- SetModifyStatus(evaluationStudent);
- evaluationStudentUpList.Add(evaluationStudent);
- }
- }
- else
- {
- //表示新增
- var newEvaluationStudent = new EM_EvaluationStudent();
- newEvaluationStudent.EvaluationStudentID = Guid.NewGuid();
- newEvaluationStudent.UserID = evaluationStudentView.UserID;
- newEvaluationStudent.EvaluationStudentSettingID = evaluationStudentView.EvaluationStudentSettingID;
- newEvaluationStudent.Numbered = evaluationStudentView.Numbered;
- newEvaluationStudent.IsValidity = evaluationStudentView.IsValidity;
- newEvaluationStudent.TotalScore = evaluationStudentView.TotalScore;
- newEvaluationStudent.Advice = evaluationStudentView.Remark;
- newEvaluationStudent.Remark = evaluationStudentView.Remark;
- SetNewStatus(newEvaluationStudent);
- evaluationStudentInList.Add(newEvaluationStudent);
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.BulkInsert(evaluationStudentInList);
- if (evaluationStudentInList != null && evaluationStudentInList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(evaluationStudentInList);
- }
- ts.Complete();
- }
- }
- else
- {
- throw new Exception("已存在相同的学评明细信息(学生信息、学评设定信息唯一),请核查。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationStudentIDs"></param>
- /// <returns></returns>
- public bool EvaluationStudentDelete(List<Guid?> evaluationStudentIDs)
- {
- try
- {
- Expression<Func<EM_EvaluationStudent, bool>> expEvaluationStudent = (x => evaluationStudentIDs.Contains(x.EvaluationStudentID));
- var evaluationStudentList = EvaluationStudentDAL.EvaluationStudentRepository.GetList(expEvaluationStudent).ToList();
- var evaluationStudentSettingIDList = evaluationStudentList.Select(x => x.EvaluationStudentSettingID).Distinct().ToList();
- var evaluationStudentSettingScoreList = EvaluationStudentDAL.EvaluationStudentSettingScoreRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList();
- if (evaluationStudentSettingScoreList != null && evaluationStudentSettingScoreList.Count() > 0)
- {
- throw new Exception("选择删除的信息中存在对应的学评评分信息,无法删除,请核查。");
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<EM_EvaluationStudentDetail>(x => evaluationStudentIDs.Contains(x.EvaluationStudentID));
- UnitOfWork.Delete<EM_EvaluationStudent>(x => evaluationStudentIDs.Contains(x.EvaluationStudentID));
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|