TeachersOrderExamineServices.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.CommonLogic.SystemServices;
  6. using EMIS.Entities;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.ViewModel.SystemView;
  9. using EMIS.ViewModel.TeachingMaterial;
  10. using EMIS.DataLogic.Common.TeachingMaterial;
  11. using EMIS.ViewModel;
  12. using Bowin.Common.Linq;
  13. using System.Linq.Expressions;
  14. using EMIS.ViewModel.WorkflowManage;
  15. namespace EMIS.CommonLogic.TeachingMaterial
  16. {
  17. public class TeachersOrderExamineServices : BaseWorkflowServices<ET_TeachersOrder>, ITeachersOrderExamineServices
  18. {
  19. public TeachersOrderDAL TeachersOrderDAL { get; set; }
  20. public IGridResultSet<ViewModel.TeachingMaterial.TeachersOrderView> GetTeachersOrderViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus, int pageIndex, int pageSize)
  21. {
  22. var statusList = this.GetStatusViewList();
  23. var approveStatusList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  24. Expression<Func<ET_TeachersOrder, bool>> exp = (x => approveStatusList.Contains(x.ApprovalStatus));
  25. if (schoolyearID.HasValue)
  26. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  27. if (collegeID.HasValue)
  28. exp = exp.And(x => x.CollegeID == collegeID);
  29. if (coursematerialID.HasValue)
  30. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  31. if (publishID.HasValue)
  32. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  33. if (ApprovalStatus.HasValue)
  34. exp = exp.And(x => x.ApprovalStatus == ApprovalStatus);
  35. var query = TeachersOrderDAL.GetTeachingOrderGridView(exp);
  36. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  37. //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachersOrderView>(pageIndex, pageSize);
  38. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime);
  39. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachersOrderView>(pageIndex, pageSize);
  40. result.rows.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  41. return result;
  42. }
  43. public List<ViewModel.TeachingMaterial.TeachersOrderView> GetTeachersOrderViewList(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus)
  44. {
  45. throw new NotImplementedException();
  46. }
  47. /// <summary>
  48. /// 提交审核
  49. /// </summary>
  50. /// <param name="planApplicationIDs"></param>
  51. /// <param name="userID"></param>
  52. /// <param name="comment"></param>
  53. public void SubmitTeachersOrderExamine(List<Guid> planApplicationIDs, Guid userID, string comment = "")
  54. {
  55. try
  56. {
  57. StartUp(planApplicationIDs, userID, comment);
  58. }
  59. catch (Exception)
  60. {
  61. throw;
  62. }
  63. }
  64. public List<ActionView> GetAuditingActionView(Guid formID, Guid userID)
  65. {
  66. return GetActionView(formID, userID);
  67. }
  68. public IGridResultSet<ViewModel.SystemView.WorkflowApproveHistoryView> GetWorkflowApproveHistoryView(Guid? planApplicationID)
  69. {
  70. var query = GetApproveHistoryViewList((Guid)planApplicationID).ToList().OrderBy(x => x.PID);
  71. return query.AsQueryable<WorkflowApproveHistoryView>().ToGridResultSet<WorkflowApproveHistoryView>(0, 100);
  72. }
  73. /// <summary>
  74. /// 获取征订详细
  75. /// </summary>
  76. /// <param name="teachersOrderID"></param>
  77. /// <returns></returns>
  78. public TeachersOrderView GetTeachersOrderExamineView(Guid? teachersOrderID)
  79. {
  80. var statusList = this.GetStatusViewList();
  81. var result = TeachersOrderDAL.GetTeachingOrderGridView(x => x.TeachersOrderID == teachersOrderID).FirstOrDefault();
  82. result.ApproveStatusName = statusList.Where(x => x.ID == result.ApproveStatus).Select(x => x.Name).FirstOrDefault();
  83. return result;
  84. }
  85. /// <summary>
  86. /// 审核
  87. /// </summary>
  88. /// <param name="planApplicationIDs"></param>
  89. /// <param name="userID"></param>
  90. /// <param name="actionView"></param>
  91. /// <param name="comment"></param>
  92. public void ApproveTeachersOrderExamine(List<Guid> teachersOrderIDs, Guid userID, ActionView actionView, string comment)
  93. {
  94. try
  95. {
  96. if (teachersOrderIDs.Count > 1 && string.IsNullOrEmpty(comment))
  97. comment = "同意";
  98. Approve(teachersOrderIDs, userID, actionView.ActionID, comment);//审核
  99. }
  100. catch (Exception ex)
  101. {
  102. throw ex;
  103. }
  104. }
  105. /// <summary>
  106. /// 查询计划申请详细
  107. /// </summary>
  108. /// <param name="planApplicationID">主键ID</param>
  109. /// <returns></returns>
  110. public Entities.ET_TeachersOrder GetTeachersOrder(Guid? teachersOrderID)
  111. {
  112. //查询条件
  113. System.Linq.Expressions.Expression<Func<ET_TeachersOrder, bool>> expression = (x => x.ApprovalStatus > (int)SYS_STATUS.UNUSABLE);
  114. expression = (x => x.TeachersOrderID == teachersOrderID);
  115. return TeachersOrderDAL.TeachersOrderRepository.GetSingle(expression);
  116. }
  117. public IList<TeachersOrderView> GetTeachersOrderExamineViewExcel(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus)
  118. {
  119. var statusList = this.GetStatusViewList();
  120. var approveStatusList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  121. Expression<Func<ET_TeachersOrder, bool>> exp = (x => approveStatusList.Contains(x.ApprovalStatus));
  122. if (schoolyearID.HasValue)
  123. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  124. if (collegeID.HasValue)
  125. exp = exp.And(x => x.CollegeID == collegeID);
  126. if (coursematerialID.HasValue)
  127. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  128. if (publishID.HasValue)
  129. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  130. if (ApprovalStatus.HasValue)
  131. exp = exp.And(x => x.ApprovalStatus == ApprovalStatus);
  132. var query = TeachersOrderDAL.GetTeachingOrderGridView(exp);
  133. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  134. //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime).ToList();
  135. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime);
  136. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CreateTime).ToList();
  137. result.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  138. return result;
  139. }
  140. }
  141. }