123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.EvaluationManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EvaluationManage.EvaluationEnter;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using Bowin.Common.Utility;
- using Bowin.Common.Mapping;
- using EMIS.CommonLogic.SystemServices;
- using Bowin.Common.JSON;
- using EMIS.Utility;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.EvaluationManage
- {
- public class EvaluationEnterServices : BaseServices, IEvaluationEnterServices
- {
- public EvaluationTypeRepository EvaluationTypeRepository { get; set; }
- public DataRangeDAL DataRangeDAL { get; set; }
- public EvaluationEnterDAL EvaluationEnterDAL { get; set; }
- public Lazy<IEvaluationNormServices> EvaluationNormServices { get; set; }
- public Lazy<IEvaluationTargetServices> EvaluationTargetServices { get; set; }
- public Lazy<IEvaluationProjectServices> EvaluationProjectServices { get; set; }
- public IGridResultSet<EvaluationEnterView> GetEvaluationEnterViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? userID, Guid? roleID, bool isStudent, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationSetting, bool>> expEvaluationSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.OpenStatus == (int)CF_YesOrNoStatus.Yes);
- Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = x => x.IsEnabled == true;
- Expression<Func<CF_Student, bool>> expStudent = x => true;
- if (schoolYearID.HasValue)
- expEvaluationSetting = expEvaluationSetting.And(x => x.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.SchoolyearID == schoolYearID);
- if (isStudent)
- {
- expStudent = expStudent.And(x => x.UserID == userID);
- var studentEvaluationType = EvaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault();
- if (studentEvaluationType == null)
- {
- throw new Exception("未找到对应的参评类型数据!");
- }
- expEvaluationTable = expEvaluationTable.And(x => x.EvaluationTypeID == studentEvaluationType.EvaluationTypeID);
- }
- else
- {
- var staffEvaluationType = EvaluationTypeRepository.Entities.Where(w => w.IsStudent == false)
- .OrderByDescending(w => w.IsStudent).FirstOrDefault();
- if (staffEvaluationType == null)
- {
- throw new Exception("未找到对应的参评类型数据!");
- }
- expEvaluationTable = expEvaluationTable.And(x => x.EvaluationTypeID == staffEvaluationType.EvaluationTypeID);
- }
- Expression<Func<EM_EvaluationGradeControl, bool>> expEvaluationGradeControl = x => true;
- Expression<Func<EM_EvaluationEnter, bool>> expEvaluationEnter = x => true;// 如果是超级管理员、那么默认显示全部数据
- expEvaluationSetting = expEvaluationSetting.And(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes);
- var menuNo = HttpHelper.GetMenuNo();
- if (isStudent)//过滤属于自己的评价信息
- {
- expEvaluationEnter = expEvaluationEnter.And(x => x.StudentUserID == userID && x.EM_EvaluationEnter_EM_EvaluationProject.Count() > 0);
- expEvaluationSetting = expEvaluationSetting.And(x => x.CF_Student.Any(w => w.UserID == userID));
- expEvaluationGradeControl = expEvaluationGradeControl.And(x => x.CF_Schoolyear.SchoolyearID == schoolYearID);
- }
- else
- {
- SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(roleID, menuNo);
- if (!dataRange.Equals(SYS_DataRange.All) && !isStudent)//过滤属于自己的评价信息
- {
- expEvaluationEnter = expEvaluationEnter.And(x => x.StaffUserID == userID && x.EM_EvaluationEnter_EM_EvaluationProject.Count() > 0);
- expEvaluationSetting = expEvaluationSetting.And(x => x.CF_Staff.Any(w => w.UserID == userID));
- }
- }
- var query = EvaluationEnterDAL.GetEvaluationEnterQuery(expEvaluationSetting, expEvaluationEnter, expEvaluationTable);
- if (isStudent)
- {
- query = EvaluationEnterDAL.GetStudentEvaluationEnterQuery(expEvaluationSetting, expEvaluationEnter, expEvaluationTable, expEvaluationGradeControl, expStudent);
- }
- if (!isStudent)
- {
- //query = GetQueryByDataRangeByCollege(query);//以院系 区分
-
- }
- else
- {
- query = query.Where(x => x.IsStudentEvaluation == true && x.IsEvaluation == true);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = query.OrderByDescending(o => o.SchoolyearCode).ThenByDescending(o => o.EntityCreateTime);
- return query.ToGridResultSet<EvaluationEnterView>(pageIndex, pageSize);
- }
- public IList<EvaluationEnterView> GetEvaluationEnterViewList(ConfiguretView configuretView, Guid? schoolYearID, Guid? userID, Guid? roleID, bool isStudent)
- {
- Expression<Func<EM_EvaluationSetting, bool>> expEvaluationSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = x => x.IsEnabled == true;
- if (schoolYearID.HasValue)
- expEvaluationSetting = expEvaluationSetting.And(x => x.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.SchoolyearID == schoolYearID);
- if (isStudent)
- {
- var studentEvaluationType = EvaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault();
- if (studentEvaluationType == null)
- {
- throw new Exception("未找到对应的参评类型数据!");
- }
- expEvaluationTable = expEvaluationTable.And(x => x.EvaluationTypeID == studentEvaluationType.EvaluationTypeID);
- }
- else
- {
- var staffEvaluationType = EvaluationTypeRepository.Entities.Where(w => w.IsStudent == false)
- .OrderByDescending(w => w.IsStudent).FirstOrDefault();
- if (staffEvaluationType == null)
- {
- throw new Exception("未找到对应的参评类型数据!");
- }
- expEvaluationTable = expEvaluationTable.And(x => x.EvaluationTypeID == staffEvaluationType.EvaluationTypeID);
- }
- Expression<Func<EM_EvaluationEnter, bool>> expEvaluationEnter = x => true;// 如果是超级管理员、那么默认显示全部数据
- expEvaluationSetting = expEvaluationSetting.And(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes);
- var menuNo = HttpHelper.GetMenuNo();
- if (isStudent)//过滤属于自己的评价信息
- {
- expEvaluationEnter = expEvaluationEnter.And(x => x.StudentUserID == userID && x.EM_EvaluationEnter_EM_EvaluationProject.Count() > 0);
- expEvaluationSetting = expEvaluationSetting.And(x => x.CF_Student.Any(w => w.UserID == userID));
- }
- else
- {
- SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(roleID, menuNo);
- if (!dataRange.Equals(SYS_DataRange.All) && !isStudent)//过滤属于自己的评价信息
- {
- expEvaluationEnter = expEvaluationEnter.And(x => x.StaffUserID == userID && x.EM_EvaluationEnter_EM_EvaluationProject.Count() > 0);
- expEvaluationSetting = expEvaluationSetting.And(x => x.CF_Staff.Any(w => w.UserID == userID));
- }
- }
- var query = EvaluationEnterDAL.GetEvaluationEnterQuery(expEvaluationSetting, expEvaluationEnter, expEvaluationTable);
- query = GetQueryByDataRangeByCollege(query);//以院系 区分
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = query.OrderByDescending(o => o.EntityCreateTime);
- return query.ToList();
- }
- public void Save(EvaluationEnterView model, bool isStudent)
- {
- var ProjectStrList = model.jsonDataStr.ToString().JsonToObject<List<EvaluationEnterView>>();//将json转实体集合
- EM_EvaluationEnter evaluationEnter = EvaluationEnterDAL.EvaluationEnterRepository.Entities.Where(x => x.EvaluationEnterID == model.EvaluationEnterID).FirstOrDefault();
- if (evaluationEnter == null)
- {
- //新增进入评价信息
- evaluationEnter = new EM_EvaluationEnter();
- evaluationEnter.EvaluationEnterID = Guid.NewGuid();
- evaluationEnter.EducationMissionClassID = model.EducationMissionClassID;
- evaluationEnter.EvaluationTableID = model.EvaluationTableID;
- evaluationEnter.Remark = model.Remark;
- evaluationEnter.TotalScore = model.TotalScore;
- if (isStudent)
- {
- evaluationEnter.StudentUserID = model.UserID;
- }
- else
- {
- evaluationEnter.StaffUserID = model.UserID;
- }
- this.SetNewStatus(evaluationEnter);
- foreach (var ProjectEntity in ProjectStrList)
- {
- EM_EvaluationEnter_EM_EvaluationProject evaluationEnterOrProject = new EM_EvaluationEnter_EM_EvaluationProject();
- evaluationEnterOrProject.ID = Guid.NewGuid();
- evaluationEnterOrProject.CreateUserID = model.UserID;
- evaluationEnterOrProject.CreateTime = DateTime.Now;
- evaluationEnterOrProject.ModifyUserID = model.UserID;
- evaluationEnterOrProject.ModifyTime = evaluationEnter.ModifyTime;// Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
- evaluationEnterOrProject.ProjectID = (Guid)ProjectEntity.ProjectID;
- evaluationEnterOrProject.EvaluationScore = ProjectEntity.EvaluationScore;
- evaluationEnterOrProject.EvaluationEnterID = evaluationEnter.EvaluationEnterID;
- //SetNewStatus(evaluationEnterOrProject);
- //evaluationEnterOrProject.
- this.UnitOfWork.Add(evaluationEnterOrProject);
- }
- this.UnitOfWork.Add(evaluationEnter);
- }
- else
- {
- //更新进入评价信息
- this.SetModifyStatus(evaluationEnter);
- evaluationEnter.EducationMissionClassID = model.EducationMissionClassID;
- evaluationEnter.EvaluationTableID = model.EvaluationTableID;
- evaluationEnter.Remark = model.Remark;
- evaluationEnter.TotalScore = model.TotalScore;
- if (isStudent)
- {
- evaluationEnter.StudentUserID = model.UserID;
- }
- else
- {
- evaluationEnter.StaffUserID = model.UserID;
- }
- foreach (var ProjectEntity in ProjectStrList)
- {
- EM_EvaluationEnter_EM_EvaluationProject evaluationEnterOrProject = new EM_EvaluationEnter_EM_EvaluationProject();
- evaluationEnterOrProject.ID = Guid.NewGuid();
- evaluationEnterOrProject.CreateUserID = model.UserID;
- evaluationEnterOrProject.ModifyUserID = model.UserID;
- evaluationEnterOrProject.ModifyTime = evaluationEnter.ModifyTime;//Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
- evaluationEnterOrProject.ProjectID = (Guid)ProjectEntity.ProjectID;
- evaluationEnterOrProject.EvaluationScore = ProjectEntity.EvaluationScore;
- evaluationEnterOrProject.EvaluationEnterID = evaluationEnter.EvaluationEnterID;
- //SetModifyStatus(evaluationEnterOrProject);
- this.UnitOfWork.Add(evaluationEnterOrProject);
- }
- this.UnitOfWork.Update(evaluationEnter);
- }
- this.UnitOfWork.Commit();
- }
- /// <summary>
- /// 查询进入评价基本信息
- /// </summary>
- /// <param name="evaluationEnterID"></param>
- /// <returns></returns>
- public EM_EvaluationEnter GetEvaluationEnterView(Guid? evaluationEnterID)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- //查询条件
- Expression<Func<EM_EvaluationEnter, bool>> expression = (x => x.EvaluationEnterID == evaluationEnterID && x.CreateUserID == curUser.UserID);
- return EvaluationEnterDAL.EvaluationEnterRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取创建评价表集合
- /// </summary>
- /// <param name="evaluationTableID"></param>
- /// <returns></returns>
- public IList<CreateTable> GetCreateEvaluationEnterTable(Guid? evaluationTableID, ConfiguretView configuretView)
- {
- List<CreateTable> CreateTableList = new List<CreateTable>();
- //1.0 查询评价指标信息
- var dataTargetList = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, evaluationTableID, null).Select(x => new
- {
- x.TargetID,
- x.NormID,
- x.Name,
- x.Weight
- }).ToList();
- CreateTable tables = null;
- foreach (var dataTarget in dataTargetList)
- {
- //2.0 查询评分标准明细
- var NormNames = string.Join(" ", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select(s => s.Name + s.Weight));
- tables = new CreateTable();
- tables.OrderID = dataTarget.Name;
- tables.Weight = dataTarget.Weight + "";
- tables.NormNames = NormNames; //构建一级标题
- CreateTableList.Add(tables);
- //3.0 查询评分项目信息
- var dataProjectList = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, dataTarget.TargetID, evaluationTableID, null).Select(x => new
- {
- x.ProjectID,
- x.OrderID,
- x.Name,
- x.Weight,
- x.Code
- }).ToList();
- foreach (var dataProject in dataProjectList)
- {
- tables = new CreateTable();
- //4.0 查询评分评分标准信息
- //格式: 优,中,差
- var NormNames1 = string.Join(",", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name));
- //构建一级标题下、标题
- tables.OrderID = dataProject.OrderID + "";
- tables.ProjectName = dataProject.Name;
- tables.Weight = dataProject.Weight + "";
- tables.NormNames = NormNames;
- CreateTableList.Add(tables);
- }
- }
- return CreateTableList;
- }
- /// <summary>
- /// 查询进入评价教研室、课程名称、教师名称相关信息
- /// </summary>
- /// <param name="educationMissionClassID">教学任务班ID</param>
- /// <param name="evaluationTableID">评价表ID</param>
- /// <returns></returns>
- public EvaluationEnterView GetEvaluationEnterByMissionClass(Guid? educationMissionClassID, Guid? evaluationTableID)
- {
- var queryView = EvaluationEnterDAL.GetEvaluationEnterTitleView(educationMissionClassID, evaluationTableID);
- return queryView;
- }
- //评价项目明细
- public IList<EvaluationEnterView> GetEvaluationEnterByNormDetail(Guid? evaluationEnterID, Guid? evaluationTableID, Guid? normID)
- {
- var queryView = EvaluationEnterDAL.GetEvaluationEnterView(evaluationEnterID, evaluationTableID);
- //if (normID.HasValue)
- //{
- // queryView = queryView.Where(x => x.NormID == normID);
- //}
- return queryView.ToList();
- }
- public IList<EM_EvaluationEnter_EM_EvaluationProject> GetEvaluationEnter_EM_EvaluationProjectList(Guid? evaluationEnterID)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var queryView = EvaluationEnterDAL.EvaluationEnter_EM_EvaluationProjectRepository.GetList(x => x.EvaluationEnterID == evaluationEnterID && x.CreateUserID == curUser.UserID);
- return queryView.ToList();
- }
- public EvaluationEnterView GetEvaluationSettingOrEnterView(Guid? evaluationSettingID, Guid userID, Guid? roleID, bool isStudent)
- {
- EM_EvaluationSetting evaluationSetting = EvaluationEnterDAL.EvaluationSettingRepository.Entities.Where(x => x.EvaluationSettingID == evaluationSettingID).FirstOrDefault();
- Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = x => x.IsEnabled == true;
- if (isStudent)
- {
- var studentEvaluationType = EvaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault();
- if (studentEvaluationType == null)
- {
- throw new Exception("未找到对应的参评类型数据!");
- }
- expEvaluationTable = expEvaluationTable.And(x => x.EvaluationTypeID == studentEvaluationType.EvaluationTypeID);
- }
- else
- {
- var staffEvaluationType = EvaluationTypeRepository.Entities.Where(w => w.IsStudent == false)
- .OrderByDescending(w => w.IsStudent).FirstOrDefault();
- if (staffEvaluationType == null)
- {
- throw new Exception("未找到对应的参评类型数据!");
- }
- expEvaluationTable = expEvaluationTable.And(x => x.EvaluationTypeID == staffEvaluationType.EvaluationTypeID);
- }
- Expression<Func<EM_EvaluationEnter, bool>> expEvaluationEnter = x => true;// 如果是超级管理员、那么默认显示全部数据
- var menuNo = HttpHelper.GetMenuNo();
- if (isStudent)//过滤属于自己的评价信息
- {
- expEvaluationEnter = expEvaluationEnter.And(x => x.StudentUserID == userID && x.EM_EvaluationEnter_EM_EvaluationProject.Count() > 0);
- }
- else
- {
- SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(roleID, menuNo);
- if (!dataRange.Equals(SYS_DataRange.All) && !isStudent)//过滤属于自己的评价信息
- {
- expEvaluationEnter = expEvaluationEnter.And(x => x.StaffUserID == userID && x.EM_EvaluationEnter_EM_EvaluationProject.Count() > 0);
- }
- }
- var query = EvaluationEnterDAL.GetEvaluationEnterQuery(null, expEvaluationEnter, expEvaluationTable);
- if (isStudent)
- {
- Expression<Func<CF_Student, bool>> expStudent = x => true;
- Expression<Func<EM_EvaluationGradeControl, bool>> expEvaluationGradeControl = x => true;
- expStudent = expStudent.And(x => x.UserID == userID);
- //expEvaluationGradeControl = expEvaluationGradeControl.And(x => x.CF_Schoolyear.SchoolyearID == schoolYearID);
- query = EvaluationEnterDAL.GetStudentEvaluationEnterQuery(null, expEvaluationEnter, expEvaluationTable, expEvaluationGradeControl, expStudent);
- }
- //query = GetQueryByDataRangeByCollege(query);
- if (evaluationSettingID.HasValue && evaluationSettingID != Guid.Empty)
- {
- query = query.Where(w => w.EducationMissionClassID == evaluationSetting.EducationMissionClassID && w.EvaluationSettingID == evaluationSettingID);
- }
- return query.FirstOrDefault();
- }
- public bool GteDataRange(Guid? roleID)
- {
- bool IsView = true;
- var menuNo = HttpHelper.GetMenuNo();
- SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(roleID, menuNo);
- if (dataRange.Equals(SYS_DataRange.All))
- {
- IsView = false;
- }
- if (dataRange.Equals(SYS_DataRange.Campus))
- {
- IsView = true;
- }
- if (dataRange.Equals(SYS_DataRange.College))
- {
- IsView = true;
- }
- return IsView;
- }
- }
- }
|