EvaluationOpenControlServices.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.ViewModel.EvaluationManage;
  7. using EMIS.ViewModel;
  8. using EMIS.DataLogic.Common.EvaluationManage;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using Bowin.Common.Linq;
  12. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  13. namespace EMIS.CommonLogic.EvaluationManage
  14. {
  15. public class EvaluationOpenControlServices : BaseServices,IEvaluationOpenControlServices
  16. {
  17. public EvaluationOpenControlDAL evaluationOpenControlDAL { get; set; }
  18. /// <summary>
  19. /// 查询评价控制信息
  20. /// </summary>
  21. /// <param name="configuretView">查询条件实体</param>
  22. /// <param name="pageIndex">页码</param>
  23. /// <param name="pageSize">显示页数</param>
  24. /// <returns></returns>
  25. public IGridResultSet<EvaluationOpenControlView> GetEvaluationOpenControlViewGrid(ConfiguretView configuretView, Guid? SchoolYearID, Guid? CollegeID, int? Year, int? Standard, int? education, int? Learningform, string LearnSystem, int pageIndex, int pageSize)
  26. {
  27. Expression<Func<EM_EvaluationGradeControl, bool>> exp = (x =>true);
  28. if (SchoolYearID.HasValue)
  29. exp=exp.And(x => x.SchoolyearID == SchoolYearID);
  30. if (CollegeID.HasValue)
  31. exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.CF_College.CollegeID == CollegeID);
  32. if(Year.HasValue)
  33. exp = exp.And(x => x.CF_Grademajor.GradeID == Year);
  34. if (Standard.HasValue)
  35. exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == Standard);
  36. if(education.HasValue)
  37. exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.EducationID == education);
  38. if(Learningform.HasValue)
  39. exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.LearningformID == Learningform);
  40. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  41. {
  42. var LearnSystems = Convert.ToDecimal(LearnSystem);
  43. exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  44. }
  45. var query = evaluationOpenControlDAL.GetEvaluationControlQueryable(exp);
  46. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  47. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.SchoolyearID).ToGridResultSet<EvaluationOpenControlView>(pageIndex, pageSize);
  48. return query.OrderByDescending(x => x.SchoolyearID).ToGridResultSet<EvaluationOpenControlView>(pageIndex, pageSize);
  49. }
  50. /// <summary>
  51. /// 通过ID查询开放控制
  52. /// </summary>
  53. /// <param name="evaluationGradeControlID"></param>
  54. /// <returns></returns>
  55. public EvaluationOpenControlView GetEvaluationOpenControlView(Guid? evaluationGradeControlID)
  56. {
  57. var query = evaluationOpenControlDAL.GetEvaluationControlQueryable(x => x.EvaluationGradeControlID == evaluationGradeControlID).FirstOrDefault();
  58. return query;
  59. }
  60. /// <summary>
  61. /// 查询开放控制信息
  62. /// </summary>
  63. /// <param name="configuretView">查询条件实体</param>
  64. /// <param name="pageIndex">页码</param>
  65. /// <param name="pageSize">显示页数</param>
  66. /// <returns></returns>
  67. public IGridResultSet<GrademajorView> GrademajorViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? standardID, int? educationID, int? learningformID, int? schoolyear, string LearnSystem,Guid? SchoolYearID, int pageIndex, int pageSize)
  68. {
  69. Expression<Func<CF_Grademajor, bool>> exp = (x => true);
  70. Expression<Func<EM_EvaluationGradeControl, bool>> exps=(x=>true);
  71. if (campusID.HasValue)
  72. exp = exp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID);
  73. if (collegeID.HasValue)
  74. exp = exp.And(x => x.CF_Facultymajor.CF_College.CollegeID == collegeID);
  75. if(standardID.HasValue)
  76. exp = exp.And(x => x.CF_Facultymajor.StandardID == standardID);
  77. if(educationID.HasValue)
  78. exp = exp.And(x => x.CF_Facultymajor.EducationID == educationID);
  79. if (learningformID.HasValue)
  80. exp = exp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
  81. if (schoolyear.HasValue)
  82. exp = exp.And(x => x.GradeID == schoolyear);
  83. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  84. {
  85. var LearnSystems = Convert.ToDecimal(LearnSystem);
  86. exp = exp.And(x => x.CF_Facultymajor.LearnSystem == LearnSystems);
  87. }
  88. if (SchoolYearID.HasValue)
  89. exps= exps.And(x => x.SchoolyearID == SchoolYearID);
  90. var query = evaluationOpenControlDAL.GrademajorViewGridQueryable(exp, exps);
  91. return query.OrderByDescending(x => x.CollegeID).OrderBy(x => x.FacultymajorID).ToGridResultSet<GrademajorView>(pageIndex, pageSize);
  92. }
  93. /// <summary>
  94. /// 新增修改开放控制
  95. /// </summary>
  96. /// <param name="evaluationOpenControlView"></param>
  97. /// <returns></returns>
  98. public bool EvaluationOpenControlEdit(EvaluationOpenControlView evaluationOpenControlView, List<GrademajorView> GrademajorList)
  99. {
  100. if (evaluationOpenControlView.EvaluationGradeControlID == null || evaluationOpenControlView.EvaluationGradeControlID==Guid.Empty)
  101. {
  102. EvaluationOpenControlAdd(evaluationOpenControlView, GrademajorList);
  103. }
  104. else
  105. {
  106. EvaluationOpenControlUpdate(evaluationOpenControlView);
  107. }
  108. UnitOfWork.Commit();
  109. return true;
  110. }
  111. public void EvaluationOpenControlAdd(EvaluationOpenControlView evaluationOpenControlView, List<GrademajorView> GrademajorList)
  112. {
  113. List<EM_EvaluationGradeControl> EM_EvaluationGradeControlList = new List<EM_EvaluationGradeControl>();
  114. foreach (var g in GrademajorList){
  115. EM_EvaluationGradeControl EvaluationGradeControl = new EM_EvaluationGradeControl();
  116. EvaluationGradeControl.EvaluationGradeControlID = Guid.NewGuid();
  117. EvaluationGradeControl.GrademajorID = g.GrademajorID;
  118. EvaluationGradeControl.SchoolyearID = evaluationOpenControlView.SchoolyearID;
  119. EvaluationGradeControl.StartTime = evaluationOpenControlView.StartTime;
  120. var endTime = evaluationOpenControlView.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59);
  121. EvaluationGradeControl.EndTime = endTime;
  122. EvaluationGradeControl.Number = evaluationOpenControlView.EvaluationCount;
  123. SetNewStatus(EvaluationGradeControl);
  124. EM_EvaluationGradeControlList.Add(EvaluationGradeControl);
  125. }
  126. UnitOfWork.BulkInsert(EM_EvaluationGradeControlList);
  127. UnitOfWork.Commit();
  128. }
  129. public void EvaluationOpenControlUpdate(EvaluationOpenControlView evaluationOpenControlView)
  130. {
  131. EM_EvaluationGradeControl EvaluationGradeControl = new EM_EvaluationGradeControl();
  132. EvaluationGradeControl = evaluationOpenControlDAL.EvaluationGradeControlRepository.Entities.Where(x => x.EvaluationGradeControlID == evaluationOpenControlView.EvaluationGradeControlID).FirstOrDefault();
  133. EvaluationGradeControl.GrademajorID = evaluationOpenControlView.GrademajorID;
  134. EvaluationGradeControl.SchoolyearID = evaluationOpenControlView.SchoolyearID;
  135. EvaluationGradeControl.StartTime = evaluationOpenControlView.StartTime;
  136. EvaluationGradeControl.EndTime = evaluationOpenControlView.EndTime;
  137. EvaluationGradeControl.Number = evaluationOpenControlView.EvaluationCount;
  138. SetModifyStatus(EvaluationGradeControl);
  139. }
  140. public string Verification(Guid? SchoolYearID, List<Guid?> list, string StartTime, string EndTime)
  141. {
  142. //获取所有的开放控制
  143. var EvaluationGradeControlList = evaluationOpenControlDAL.EvaluationGradeControlRepository.GetList(x => true).ToList();
  144. //获取存在的开放控制
  145. var existList = EvaluationGradeControlList.Where(x => x.SchoolyearID == SchoolYearID && list.Contains(x.GrademajorID)).Select(x => x.GrademajorID).ToList();
  146. //获取存在的开放控制的年级专业
  147. var GrademajorList = evaluationOpenControlDAL.GrademajorRepository.GetList(x => existList.Contains(x.GrademajorID));
  148. //获取参评类型
  149. var EvaluationType = evaluationOpenControlDAL.EvaluationTypeRepository.GetList(x => x.IsStudent == true).FirstOrDefault();
  150. StringBuilder sb = new StringBuilder();
  151. if (EvaluationType != null)
  152. {
  153. if (EvaluationType.StartTime.Value.Date.CompareTo(Convert.ToDateTime(StartTime)) > 0)
  154. {
  155. sb.Append("开始时间早于参评类型设置的开始时间、");
  156. }
  157. if (EvaluationType.EndTime.Value.Date.CompareTo(Convert.ToDateTime(StartTime)) < 0)
  158. {
  159. sb.Append("开始时间晚于参评类型设置的结束时间、");
  160. }
  161. if (EvaluationType.StartTime.Value.Date.CompareTo(Convert.ToDateTime(EndTime)) > 0)
  162. {
  163. sb.Append("结束时间早于参评类型设置的开始时间、");
  164. }
  165. if (EvaluationType.EndTime.Value.Date.CompareTo(Convert.ToDateTime(EndTime)) < 0)
  166. {
  167. sb.Append("结束时间晚于参评类型设置的结束时间、");
  168. }
  169. if (Convert.ToDateTime(EndTime).CompareTo(Convert.ToDateTime(StartTime)) < 0)
  170. {
  171. sb.Append("结束时间早于开始时间、");
  172. }
  173. if (existList.Count > 0)
  174. {
  175. if (sb.ToString() == "")
  176. {
  177. foreach (var g in GrademajorList)
  178. {
  179. sb.Append(g.Name + "、");
  180. }
  181. sb.Remove(sb.ToString().LastIndexOf('、'), 1);
  182. sb.Append("等专业已存在,请检查!");
  183. return sb.ToString();
  184. }
  185. else
  186. {
  187. sb.Remove(sb.ToString().LastIndexOf('、'), 1);
  188. return sb.ToString();
  189. }
  190. }
  191. else
  192. {
  193. if (sb.ToString() != "")
  194. {
  195. sb.Remove(sb.ToString().LastIndexOf('、'), 1);
  196. return sb.ToString();
  197. }
  198. return "成功";
  199. }
  200. }
  201. else
  202. {
  203. sb.Append("请设置适用于学生参评类型。");
  204. return sb.ToString();
  205. }
  206. }
  207. public void Delete(List<Guid?> list)
  208. {
  209. UnitOfWork.Remove<EM_EvaluationGradeControl>(x => list.Contains(x.EvaluationGradeControlID));
  210. UnitOfWork.Commit();
  211. }
  212. }
  213. }