TeachersConfirmOrderServices.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 System.Configuration;
  8. using EMIS.ViewModel;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.ViewModel.SystemView;
  11. using EMIS.DataLogic.Common.TeachingMaterial;
  12. using EMIS.ViewModel.TeachingMaterial;
  13. using EMIS.CommonLogic;
  14. using EMIS.DataLogic.Repositories;
  15. using Bowin.Common.Linq;
  16. using System.Linq.Expressions;
  17. namespace EMIS.CommonLogic.TeachingMaterial
  18. {
  19. public class TeachersConfirmOrderServices : BaseServices, ITeachersConfirmOrderServices
  20. {
  21. #region 0.0 --定义--
  22. public TeachersOrderRepository TeachersOrderRepository { get; set; }
  23. public TeachersConfirmOrderRepository TeachersConfirmOrderRepository { get; set; }
  24. public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
  25. public TeachersPreOrderRepository TeachersPreOrderRepository { get; set; }
  26. public UserRepository UserRepository { get; set; }
  27. public CoursematerialRepository CoursematerialRepository { get; set; }
  28. public PublishRepository PublishRepository { get; set; }
  29. public SchoolyearRepository SchoolyearRepository { get; set; }
  30. public CollegeRepository CollegeRepository { get; set; }
  31. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  32. public TeachersConfirmOrderDAL TeachersConfirmOrderDAL { get; set; }
  33. public Lazy<ITeachersOrderServices> TeachersOrderServices { get; set; }
  34. #endregion
  35. #region 1.0 查询教师征订清单信息
  36. /// <summary>
  37. /// 查询教师征订清单记录绑定页面
  38. /// </summary>
  39. /// <param name="configuretView"></param>
  40. /// <param name="campusID"></param>
  41. /// <param name="collegeID"></param>
  42. /// <param name="schoolyearID"></param>
  43. /// <param name="educationID"></param>
  44. /// <param name="learningformID"></param>
  45. /// <param name="approvalStatus"></param>
  46. /// <param name="pageIndex"></param>
  47. /// <param name="pageSize"></param>
  48. /// <returns></returns>
  49. public IGridResultSet<TeachersConfirmOrderView> GetTeachersOrderViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID,
  50. Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus, int pageIndex, int pageSize)
  51. {
  52. ApprovalStatus = TeachersOrderServices.Value.GetCorrectEndStatus();//提取已通过
  53. Expression<Func<ET_TeachersOrder, bool>> exp = (x => x.ApprovalStatus == ApprovalStatus);
  54. if (schoolyearID.HasValue)
  55. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  56. if (teachingMaterialPoolID.HasValue)
  57. exp = exp.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  58. if (coursematerialID.HasValue)
  59. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  60. if (publishID.HasValue)
  61. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  62. var query = TeachersConfirmOrderDAL.GetTeachersConfirmOrderGridView(exp);
  63. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  64. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToGridResultSet<TeachersConfirmOrderView>(pageIndex, pageSize);
  65. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToGridResultSet<TeachersConfirmOrderView>(pageIndex, pageSize);
  66. }
  67. #endregion
  68. #region 2.0 查询教师征订清单明细信息
  69. /// <summary>
  70. /// 查询教师征订清单征订明细页面
  71. /// </summary>
  72. /// <param name="configuretView"></param>
  73. /// <param name="campusID"></param>
  74. /// <param name="collegeID"></param>
  75. /// <param name="schoolyearID"></param>
  76. /// <param name="educationID"></param>
  77. /// <param name="learningformID"></param>
  78. /// <param name="approvalStatus"></param>
  79. /// <param name="pageIndex"></param>
  80. /// <param name="pageSize"></param>
  81. /// <returns></returns>
  82. public IGridResultSet<TeachersConfirmOrderView> GetTeachersOrderDetailViewGrid(Guid? schoolyearID,
  83. Guid? collegeID, Guid? teachingMaterialPoolID, int pageIndex, int pageSize)
  84. {
  85. var endStatus = TeachersOrderServices.Value.GetCorrectEndStatus();
  86. var query = TeachersConfirmOrderDAL.GetTeachingOrderDetail(x => x.ApprovalStatus == endStatus);
  87. if (schoolyearID.HasValue)
  88. query = query.Where(x => x.SchoolyearID == schoolyearID);
  89. //if (collegeID.HasValue)
  90. // query = query.Where(x => x.CollegeID == collegeID);
  91. if (teachingMaterialPoolID.HasValue)
  92. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  93. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.PublishTime).ToGridResultSet<TeachersConfirmOrderView>(pageIndex, pageSize);
  94. }
  95. #endregion
  96. #region 3.0 查询教师征订清单Excel导出
  97. /// <summary>
  98. /// 获取征订清单列表导出
  99. /// </summary>
  100. /// <param name="exp"></param>
  101. /// <returns></returns>
  102. public IList<TeachersConfirmOrderView> GetTeachersConfirmOrderViewExcel(ConfiguretView configuretView, Guid? schoolyearID,
  103. Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID)
  104. {
  105. int? ApprovalStatus = TeachersOrderServices.Value.GetCorrectEndStatus();//提取已通过
  106. Expression<Func<ET_TeachersOrder, bool>> exp = (x => x.ApprovalStatus == ApprovalStatus);
  107. if (schoolyearID.HasValue)
  108. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  109. if (teachingMaterialPoolID.HasValue)
  110. exp = exp.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  111. if (coursematerialID.HasValue)
  112. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  113. if (publishID.HasValue)
  114. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  115. var query = TeachersConfirmOrderDAL.GetTeachersConfirmOrderGridView(exp);
  116. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  117. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToList();
  118. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ThenBy(x => x.SchoolyearName).ToList();
  119. }
  120. #endregion
  121. #region 4.0 批量更新预加值
  122. /// <summary>
  123. /// 批量更新预加值
  124. /// </summary>
  125. /// <param name="teachersOrderIDs"></param>
  126. /// <param name="preAddedValue"></param>
  127. public void BatchUpdatePreAddedValue(List<TeachersOrderView> teachersOrderList, int preAddedValue, Guid userId)
  128. {
  129. try
  130. {
  131. if (teachersOrderList.Count > 0)
  132. {
  133. //int? ApprovalStatus = (int)CF_TeachersOrderStatus.Completed;//提取已通过
  134. foreach (var teachersOrder in teachersOrderList)
  135. {
  136. var teachersPreOrderEnt = TeachersPreOrderRepository.Entities.Where(x => x.TeachingMaterialPoolID == teachersOrder.TeachingMaterialPoolID && x.SchoolyearID == teachersOrder.SchoolyearID).FirstOrDefault();//&& x.ApprovalStatus == ApprovalStatus 所有教材征订附加表的信息ApprovalStatus的值为空
  137. if (teachersPreOrderEnt == null)//如果该记录存在、就更新数据
  138. {
  139. ET_TeachersPreOrder teachersPreOrder = new ET_TeachersPreOrder();
  140. teachersPreOrder.TeachersPreOrderID = Guid.NewGuid();
  141. teachersPreOrder.TeachingMaterialPoolID = teachersOrder.TeachingMaterialPoolID;
  142. teachersPreOrder.SchoolyearID = (Guid)teachersOrder.SchoolyearID;
  143. teachersPreOrder.CreateTime = DateTime.Now;
  144. teachersPreOrder.CreateUserID = userId;
  145. teachersPreOrder.ModifyTime = DateTime.Now;
  146. teachersPreOrder.ModifyUserID = userId;
  147. teachersPreOrder.Desc = "预加值";
  148. teachersPreOrder.PreQty = preAddedValue;//设置预加值;
  149. TeachersPreOrderRepository.UnitOfWork.Add(teachersPreOrder);
  150. }
  151. else
  152. {
  153. ET_TeachersPreOrder teachersPreOrder = teachersPreOrderEnt;
  154. teachersPreOrder.ModifyTime = DateTime.Now;
  155. teachersPreOrder.ModifyUserID = userId;
  156. teachersPreOrder.Desc = "预加值";
  157. teachersPreOrder.PreQty = preAddedValue;//设置预加值;
  158. TeachersPreOrderRepository.UnitOfWork.Update(teachersPreOrder);
  159. }
  160. }
  161. UnitOfWork.Commit();
  162. }
  163. }
  164. catch (Exception ex)
  165. {
  166. throw ex;
  167. }
  168. }
  169. #endregion
  170. #region 5.0 导出Excel明细信息
  171. /// <summary>
  172. /// 导出清单明细数据
  173. /// </summary>
  174. /// <param name="schoolyearID"></param>
  175. /// <param name="teachingMaterialPoolID"></param>
  176. /// <returns></returns>
  177. public IList<TeachersConfirmOrderView> GetTeachersConfirmOrderViewDetailExcel(Guid? schoolyearID, Guid? teachingMaterialPoolID)
  178. {
  179. int? ApprovalStatus = TeachersOrderServices.Value.GetCorrectEndStatus();//提取已通过
  180. var query = TeachersConfirmOrderDAL.GetTeachingOrderDetail(x => x.ApprovalStatus == ApprovalStatus);
  181. if (schoolyearID.HasValue)
  182. query = query.Where(x => x.SchoolyearID == schoolyearID);
  183. if (teachingMaterialPoolID.HasValue)
  184. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  185. return query.OrderBy(x => x.PublishTime).ToList();
  186. }
  187. #endregion
  188. }
  189. }