ChangeResultServices.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.StudentManage.StudentChange;
  11. using EMIS.DataLogic.StudentManage.StudentChange;
  12. using EMIS.CommonLogic.SystemServices;
  13. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  14. namespace EMIS.CommonLogic.StudentManage.StudentChange
  15. {
  16. public class ChangeResultServices : BaseWorkflowServices<CF_DifferentDynamic>, IChangeResultServices
  17. {
  18. public Lazy<StudentChangeDAL> StudentChangeDAL { get; set; }
  19. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  20. /// <summary>
  21. /// 数据范围
  22. /// </summary>
  23. public ChangeResultServices()
  24. {
  25. DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege<CF_DifferentDynamic>(x, y, (w => w.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID)));
  26. }
  27. /// <summary>
  28. /// 查询学籍异动结果信息View
  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="classmajorID"></param>
  39. /// <param name="schoolyearID"></param>
  40. /// <param name="changeTypeID"></param>
  41. /// <param name="inSchoolStatus"></param>
  42. /// <param name="pageIndex"></param>
  43. /// <param name="pageSize"></param>
  44. /// <returns></returns>
  45. public IGridResultSet<StudentChangeView> GetChangeResultViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
  46. int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? schoolyearID, int? changeTypeID, int? inSchoolStatus, int pageIndex, int pageSize)
  47. {
  48. var approveStatusList = this.GetStatusViewList();
  49. var endApproveStatusID = this.GetCorrectEndStatus();
  50. Expression<Func<CF_DifferentDynamic, bool>> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  51. expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endApproveStatusID);
  52. if (schoolyearID.HasValue)
  53. {
  54. expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID);
  55. }
  56. if (changeTypeID.HasValue)
  57. {
  58. expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID);
  59. }
  60. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  61. if (classmajorID.HasValue)
  62. {
  63. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  64. }
  65. if (inSchoolStatus != null && inSchoolStatus > -1)
  66. {
  67. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  68. if (inSchoolStatus == 1)
  69. {
  70. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  71. }
  72. if (inSchoolStatus == 0)
  73. {
  74. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  75. }
  76. }
  77. var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange, expStudent);
  78. if (campusID.HasValue)
  79. {
  80. query = query.Where(x => x.CampusID == campusID);
  81. }
  82. if (collegeID.HasValue)
  83. {
  84. query = query.Where(x => x.CollegeID == collegeID);
  85. }
  86. if (gradeID.HasValue)
  87. {
  88. query = query.Where(x => x.GradeID == gradeID);
  89. }
  90. if (standardID.HasValue)
  91. {
  92. query = query.Where(x => x.StandardID == standardID);
  93. }
  94. if (educationID.HasValue)
  95. {
  96. query = query.Where(x => x.EducationID == educationID);
  97. }
  98. if (learningformID.HasValue)
  99. {
  100. query = query.Where(x => x.LearningformID == learningformID);
  101. }
  102. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  103. {
  104. var LearnSystems = Convert.ToDecimal(learnSystem);
  105. query = query.Where(x => x.LearnSystem == LearnSystems);
  106. }
  107. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  108. {
  109. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  110. }
  111. var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  112. .OrderBy(x => x.SchoolyearValue).ThenBy(x => x.ChangeTypeID).ThenBy(x => x.GradeID).ThenBy(x => x.StandardID)
  113. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.StudentNo)
  114. .OrderByDescending(x => x.ChangeDate).ToGridResultSet<StudentChangeView>(pageIndex, pageSize);
  115. result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  116. return result;
  117. }
  118. /// <summary>
  119. /// 查询学籍异动结果信息List
  120. /// </summary>
  121. /// <param name="configuretView"></param>
  122. /// <param name="campusID"></param>
  123. /// <param name="collegeID"></param>
  124. /// <param name="gradeID"></param>
  125. /// <param name="standardID"></param>
  126. /// <param name="educationID"></param>
  127. /// <param name="learningformID"></param>
  128. /// <param name="learnSystem"></param>
  129. /// <param name="classmajorID"></param>
  130. /// <param name="schoolyearID"></param>
  131. /// <param name="changeTypeID"></param>
  132. /// <param name="inSchoolStatus"></param>
  133. /// <returns></returns>
  134. public IList<StudentChangeView> GetChangeResultViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID,
  135. int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, Guid? schoolyearID, int? changeTypeID, int? inSchoolStatus)
  136. {
  137. var approveStatusList = this.GetStatusViewList();
  138. var endApproveStatusID = this.GetCorrectEndStatus();
  139. Expression<Func<CF_DifferentDynamic, bool>> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  140. expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endApproveStatusID);
  141. if (schoolyearID.HasValue)
  142. {
  143. expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID);
  144. }
  145. if (changeTypeID.HasValue)
  146. {
  147. expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID);
  148. }
  149. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  150. if (classmajorID.HasValue)
  151. {
  152. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  153. }
  154. if (inSchoolStatus != null && inSchoolStatus > -1)
  155. {
  156. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  157. if (inSchoolStatus == 1)
  158. {
  159. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  160. }
  161. if (inSchoolStatus == 0)
  162. {
  163. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  164. }
  165. }
  166. var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange, expStudent);
  167. if (campusID.HasValue)
  168. {
  169. query = query.Where(x => x.CampusID == campusID);
  170. }
  171. if (collegeID.HasValue)
  172. {
  173. query = query.Where(x => x.CollegeID == collegeID);
  174. }
  175. if (gradeID.HasValue)
  176. {
  177. query = query.Where(x => x.GradeID == gradeID);
  178. }
  179. if (standardID.HasValue)
  180. {
  181. query = query.Where(x => x.StandardID == standardID);
  182. }
  183. if (educationID.HasValue)
  184. {
  185. query = query.Where(x => x.EducationID == educationID);
  186. }
  187. if (learningformID.HasValue)
  188. {
  189. query = query.Where(x => x.LearningformID == learningformID);
  190. }
  191. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  192. {
  193. var LearnSystems = Convert.ToDecimal(learnSystem);
  194. query = query.Where(x => x.LearnSystem == LearnSystems);
  195. }
  196. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  197. {
  198. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  199. }
  200. var result = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  201. .OrderBy(x => x.SchoolyearValue).ThenBy(x => x.ChangeTypeID).ThenBy(x => x.GradeID).ThenBy(x => x.StandardID)
  202. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.StudentNo)
  203. .OrderByDescending(x => x.ChangeDate).ToList();
  204. result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  205. return result;
  206. }
  207. /// <summary>
  208. /// 查询对应的学籍异动信息View
  209. /// </summary>
  210. /// <param name="studentChangeID"></param>
  211. /// <returns></returns>
  212. public StudentChangeView GetStudentChangeView(Guid? studentChangeID)
  213. {
  214. try
  215. {
  216. Expression<Func<CF_DifferentDynamic, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  217. exp = exp.And(x => x.StudentChangeID == studentChangeID);
  218. var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(exp).SingleOrDefault();
  219. return query;
  220. }
  221. catch (Exception ex)
  222. {
  223. throw new Exception(ex.Message);
  224. }
  225. }
  226. /// <summary>
  227. /// 删除
  228. /// </summary>
  229. /// <param name="studentChangeIDs"></param>
  230. /// <returns></returns>
  231. public bool ChangeResultDelete(List<Guid?> studentChangeIDs)
  232. {
  233. try
  234. {
  235. var workflowStatusViewList = this.GetStatusViewList();
  236. if (workflowStatusViewList == null || workflowStatusViewList.Count() <= 0)
  237. {
  238. throw new Exception("工作流平台中,学籍异动流程未配置,请核查。");
  239. }
  240. var endStatusID = this.GetCorrectEndStatus();
  241. if (endStatusID == null)
  242. {
  243. throw new Exception("工作流平台中,学籍异动流程结束环节未配置,请核查。");
  244. }
  245. var studentChangeList = StudentChangeDAL.Value.StudentChangeRepository.GetList(x => studentChangeIDs.Contains(x.StudentChangeID)).ToList();
  246. foreach (var studentChange in studentChangeList)
  247. {
  248. if (studentChange.ApprovalStatus != endStatusID)
  249. {
  250. throw new Exception("只能删除审核通过状态的信息,请刷新页面再次尝试。");
  251. }
  252. }
  253. UnitOfWork.Delete<CF_DifferentDynamic>(x => studentChangeIDs.Contains(x.StudentChangeID));
  254. return true;
  255. }
  256. catch (Exception)
  257. {
  258. throw;
  259. }
  260. }
  261. /// <summary>
  262. /// 学籍异动Excel导入
  263. /// </summary>
  264. /// <param name="cellheader"></param>
  265. /// <param name="inCount"></param>
  266. /// <param name="upCount"></param>
  267. /// <param name="errdataList"></param>
  268. /// <param name="errCount"></param>
  269. /// <param name="sourcePhysicalPath"></param>
  270. public void StudentChangeImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StudentChangeView> errdataList, out int? errCount, string sourcePhysicalPath)
  271. {
  272. throw new NotImplementedException();
  273. }
  274. /// <summary>
  275. /// 流程结束跳转函数(工作流平台中配置)
  276. /// </summary>
  277. /// <param name="studentChangeIDList"></param>
  278. /// <param name="userID"></param>
  279. public void OnApproveEnd(List<Guid> studentChangeIDList, Guid? userID)
  280. {
  281. throw new NotImplementedException();
  282. }
  283. }
  284. }