CheckingCollectServices.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.StudentManage.OnlineChecking;
  11. using EMIS.DataLogic.StudentManage.OnlineChecking;
  12. using EMIS.CommonLogic.SystemServices;
  13. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  14. namespace EMIS.CommonLogic.StudentManage.OnlineChecking
  15. {
  16. public class CheckingCollectServices : BaseWorkflowServices<CF_StudentContrast>, ICheckingCollectServices
  17. {
  18. public Lazy<CheckingCollectDAL> CheckingCollectDAL { get; set; }
  19. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  20. /// <summary>
  21. /// 数据范围
  22. /// </summary>
  23. public CheckingCollectServices()
  24. {
  25. DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege<CF_StudentContrast>(x, y, (w => w.Sys_User.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID)));
  26. }
  27. /// <summary>
  28. /// 查询对应的校对汇总信息CheckingHistoryView
  29. /// </summary>
  30. /// <param name="configuretView"></param>
  31. /// <param name="campusID"></param>
  32. /// <param name="collegeID"></param>
  33. /// <param name="gradeID"></param>
  34. /// <param name="standardID"></param>
  35. /// <param name="educationID"></param>
  36. /// <param name="learningformID"></param>
  37. /// <param name="learnSystem"></param>
  38. /// <param name="grademajorID"></param>
  39. /// <param name="classmajorID"></param>
  40. /// <param name="checkingTypeID"></param>
  41. /// <param name="inSchoolStatus"></param>
  42. /// <param name="approvalStatus"></param>
  43. /// <param name="pageIndex"></param>
  44. /// <param name="pageSize"></param>
  45. /// <returns></returns>
  46. public IGridResultSet<CheckingHistoryView> GetCheckingCollectViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
  47. int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? checkingTypeID, int? inSchoolStatus, int? approvalStatus, int pageIndex, int pageSize)
  48. {
  49. var approveStatusList = this.GetStatusViewList();
  50. var approveEndStatusID = this.GetEndStatus();
  51. Expression<Func<CF_StudentRecordChangeHistory, bool>> expStudentRecordChangeHistory = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  52. if (checkingTypeID.HasValue)
  53. {
  54. expStudentRecordChangeHistory = expStudentRecordChangeHistory.And(x => x.CheckingTypeID == checkingTypeID);
  55. }
  56. Expression<Func<CF_StudentContrast, bool>> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  57. expStudentContrast = expStudentContrast.And(x => approveEndStatusID.Contains(x.ApprovalStatus));
  58. if (approvalStatus.HasValue)
  59. {
  60. expStudentContrast = expStudentContrast.And(x => x.ApprovalStatus == approvalStatus);
  61. }
  62. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  63. if (classmajorID.HasValue)
  64. {
  65. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  66. }
  67. if (inSchoolStatus != null && inSchoolStatus > -1)
  68. {
  69. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  70. if (inSchoolStatus == 1)
  71. {
  72. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  73. }
  74. if (inSchoolStatus == 0)
  75. {
  76. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  77. }
  78. }
  79. var query = CheckingCollectDAL.Value.GetCheckingHistoryViewQueryable(expStudentRecordChangeHistory, expStudentContrast, expStudent);
  80. if (campusID.HasValue)
  81. {
  82. query = query.Where(x => x.CampusID == campusID);
  83. }
  84. if (collegeID.HasValue)
  85. {
  86. query = query.Where(x => x.CollegeID == collegeID);
  87. }
  88. if (gradeID.HasValue)
  89. {
  90. query = query.Where(x => x.GradeID == gradeID);
  91. }
  92. if (standardID.HasValue)
  93. {
  94. query = query.Where(x => x.StandardID == standardID);
  95. }
  96. if (educationID.HasValue)
  97. {
  98. query = query.Where(x => x.EducationID == educationID);
  99. }
  100. if (learningformID.HasValue)
  101. {
  102. query = query.Where(x => x.LearningformID == learningformID);
  103. }
  104. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  105. {
  106. var LearnSystems = Convert.ToDecimal(learnSystem);
  107. query = query.Where(x => x.LearnSystem == LearnSystems);
  108. }
  109. if (grademajorID.HasValue)
  110. {
  111. query = query.Where(x => x.GrademajorID == grademajorID);
  112. }
  113. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  114. {
  115. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  116. }
  117. var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  118. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
  119. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ColumnName)
  120. .OrderByDescending(x => x.ApprovalTime).ToGridResultSet<CheckingHistoryView>(pageIndex, pageSize);
  121. result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  122. return result;
  123. }
  124. /// <summary>
  125. /// 查询对应的校对汇总信息List
  126. /// </summary>
  127. /// <param name="configuretView"></param>
  128. /// <param name="campusID"></param>
  129. /// <param name="collegeID"></param>
  130. /// <param name="gradeID"></param>
  131. /// <param name="standardID"></param>
  132. /// <param name="educationID"></param>
  133. /// <param name="learningformID"></param>
  134. /// <param name="learnSystem"></param>
  135. /// <param name="grademajorID"></param>
  136. /// <param name="classmajorID"></param>
  137. /// <param name="checkingTypeID"></param>
  138. /// <param name="inSchoolStatus"></param>
  139. /// <param name="approvalStatus"></param>
  140. /// <returns></returns>
  141. public IList<CheckingHistoryView> GetCheckingCollectViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
  142. int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? checkingTypeID, int? inSchoolStatus, int? approvalStatus)
  143. {
  144. var approveStatusList = this.GetStatusViewList();
  145. var approveEndStatusID = this.GetEndStatus();
  146. Expression<Func<CF_StudentRecordChangeHistory, bool>> expStudentRecordChangeHistory = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  147. if (checkingTypeID.HasValue)
  148. {
  149. expStudentRecordChangeHistory = expStudentRecordChangeHistory.And(x => x.CheckingTypeID == checkingTypeID);
  150. }
  151. Expression<Func<CF_StudentContrast, bool>> expStudentContrast = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  152. expStudentContrast = expStudentContrast.And(x => approveEndStatusID.Contains(x.ApprovalStatus));
  153. if (approvalStatus.HasValue)
  154. {
  155. expStudentContrast = expStudentContrast.And(x => x.ApprovalStatus == approvalStatus);
  156. }
  157. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  158. if (classmajorID.HasValue)
  159. {
  160. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  161. }
  162. if (inSchoolStatus != null && inSchoolStatus > -1)
  163. {
  164. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  165. if (inSchoolStatus == 1)
  166. {
  167. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  168. }
  169. if (inSchoolStatus == 0)
  170. {
  171. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  172. }
  173. }
  174. var query = CheckingCollectDAL.Value.GetCheckingHistoryViewQueryable(expStudentRecordChangeHistory, expStudentContrast, expStudent);
  175. if (campusID.HasValue)
  176. {
  177. query = query.Where(x => x.CampusID == campusID);
  178. }
  179. if (collegeID.HasValue)
  180. {
  181. query = query.Where(x => x.CollegeID == collegeID);
  182. }
  183. if (gradeID.HasValue)
  184. {
  185. query = query.Where(x => x.GradeID == gradeID);
  186. }
  187. if (standardID.HasValue)
  188. {
  189. query = query.Where(x => x.StandardID == standardID);
  190. }
  191. if (educationID.HasValue)
  192. {
  193. query = query.Where(x => x.EducationID == educationID);
  194. }
  195. if (learningformID.HasValue)
  196. {
  197. query = query.Where(x => x.LearningformID == learningformID);
  198. }
  199. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  200. {
  201. var LearnSystems = Convert.ToDecimal(learnSystem);
  202. query = query.Where(x => x.LearnSystem == LearnSystems);
  203. }
  204. if (grademajorID.HasValue)
  205. {
  206. query = query.Where(x => x.GrademajorID == grademajorID);
  207. }
  208. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  209. {
  210. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  211. }
  212. var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  213. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
  214. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ColumnName)
  215. .OrderByDescending(x => x.ApprovalTime).ToList();
  216. result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  217. return result;
  218. }
  219. /// <summary>
  220. /// 查询对应的校对信息CheckingHistoryView
  221. /// </summary>
  222. /// <param name="studentRecordChangeHistoryID"></param>
  223. /// <returns></returns>
  224. public CheckingHistoryView GetStudentRecordChangeHistoryView(Guid? studentRecordChangeHistoryID)
  225. {
  226. try
  227. {
  228. Expression<Func<CF_StudentRecordChangeHistory, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  229. exp = exp.And(x => x.StudentRecordChangeHistoryID == studentRecordChangeHistoryID);
  230. var query = CheckingCollectDAL.Value.GetCheckingHistoryViewQueryable(exp).SingleOrDefault();
  231. return query;
  232. }
  233. catch (Exception ex)
  234. {
  235. throw new Exception(ex.Message);
  236. }
  237. }
  238. /// <summary>
  239. /// 删除
  240. /// </summary>
  241. /// <param name="studentRecordChangeHistoryIDs"></param>
  242. /// <returns></returns>
  243. public bool StudentRecordChangeHistoryDelete(List<Guid?> studentRecordChangeHistoryIDs)
  244. {
  245. try
  246. {
  247. UnitOfWork.Delete<CF_StudentRecordChangeHistory>(x => studentRecordChangeHistoryIDs.Contains(x.StudentRecordChangeHistoryID));
  248. return true;
  249. }
  250. catch (Exception)
  251. {
  252. throw;
  253. }
  254. }
  255. }
  256. }