InventoryServices.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.TeachingMaterial;
  6. using EMIS.ViewModel.TeachingMaterial;
  7. using Bowin.Common.Linq.Entity;
  8. using Bowin.Common.Linq;
  9. using EMIS.ViewModel;
  10. using System.Linq.Expressions;
  11. using EMIS.Entities;
  12. using EMIS.ViewModel.Cultureplan;
  13. namespace EMIS.CommonLogic.TeachingMaterial
  14. {
  15. public class InventoryServices : BaseServices, IInventoryServices
  16. {
  17. public InventoryDAL InventoryDAL { get; set; }
  18. public IGridResultSet<InventoryView> GetTeachingMateriaInventoryViewGrid(ConfiguretView configuretView, Guid? teachingMateriaCodeID, Guid? teachingMateriaNameID, Guid? publishID, bool? isLate, int? teachingMaterialTypeID, int pageIndex, int pageSize)
  19. {
  20. Expression<Func<ET_TeachingMateriaInventory, bool>> exp = x => true;
  21. Expression<Func<CF_TeachingMaterialPool, bool>> poolexp = x => true;
  22. if (isLate != null)
  23. {
  24. //exp = exp.And(x => x.CF_TeachingMaterialPool.IsLate == isLate);
  25. poolexp = poolexp.And(x => x.IsLate == isLate);
  26. }
  27. if (teachingMateriaNameID.HasValue)
  28. {
  29. //exp = exp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
  30. poolexp = poolexp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
  31. }
  32. if (publishID.HasValue)
  33. {
  34. //exp = exp.And(x => x.CF_TeachingMaterialPool.CF_Publish.PublishID == publishID);
  35. poolexp = poolexp.And(x => x.CF_Publish.PublishID == publishID);
  36. }
  37. if (teachingMaterialTypeID.HasValue)
  38. {
  39. //exp = exp.And(x => x.CF_TeachingMaterialPool.TeachingMaterialTypeID == teachingMaterialTypeID);
  40. poolexp = poolexp.And(x => x.TeachingMaterialTypeID == teachingMaterialTypeID);
  41. }
  42. var query = InventoryDAL.GetTeachingMaterialInventoryGridView(exp, poolexp);
  43. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  44. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
  45. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
  46. }
  47. public IList<InventoryView> GetTeachingMateriaInventoryViewList(ConfiguretView configuretView, Guid? teachingMateriaCodeID, Guid? teachingMateriaNameID, Guid? publishID, bool? isLate, int? teachingMaterialTypeID)
  48. {
  49. Expression<Func<ET_TeachingMateriaInventory, bool>> exp = x => true;
  50. Expression<Func<CF_TeachingMaterialPool, bool>> poolexp = x => true;
  51. if (isLate != null)
  52. {
  53. //exp = exp.And(x => x.CF_TeachingMaterialPool.IsLate == isLate);
  54. poolexp = poolexp.And(x => x.IsLate == isLate);
  55. }
  56. if (teachingMateriaNameID.HasValue)
  57. {
  58. //exp = exp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
  59. poolexp = poolexp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID);
  60. }
  61. if (publishID.HasValue)
  62. {
  63. //exp = exp.And(x => x.CF_TeachingMaterialPool.CF_Publish.PublishID == publishID);
  64. poolexp = poolexp.And(x => x.CF_Publish.PublishID == publishID);
  65. }
  66. if (teachingMaterialTypeID.HasValue)
  67. {
  68. //exp = exp.And(x => x.CF_TeachingMaterialPool.TeachingMaterialTypeID == teachingMaterialTypeID);
  69. poolexp = poolexp.And(x => x.TeachingMaterialTypeID == teachingMaterialTypeID);
  70. }
  71. var query = InventoryDAL.GetTeachingMaterialInventoryGridView(exp, poolexp);
  72. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  73. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  74. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  75. }
  76. //获取库存统计信息
  77. public IGridResultSet<InventoryView> GetInventoryManagementViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMateriaID, int? teachingMateriaType, Guid? publishID, int pageIndex, int pageSize)
  78. {
  79. var query = InventoryDAL.GetInventoryManagementGridOnlyNumView(schoolyearID);
  80. //if (schoolyearID.HasValue)
  81. // query = query.Where(x => x.SchoolYearID == schoolyearID);
  82. if (teachingMateriaID.HasValue)
  83. query = query.Where(x => x.TeachingMaterialPoolID == teachingMateriaID);
  84. if (teachingMateriaType.HasValue)
  85. query = query.Where(x => x.TeachingMaterialTypeID == teachingMateriaType);
  86. if (publishID.HasValue)
  87. query = query.Where(x => x.PublishID == publishID);
  88. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  89. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
  90. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(pageIndex, pageSize);
  91. }
  92. public IList<InventoryView> GetInventoryManagementViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMateriaID, int? teachingMateriaType, Guid? publishID)
  93. {
  94. var query = InventoryDAL.GetInventoryManagementGridOnlyNumView(schoolyearID);
  95. if (teachingMateriaID.HasValue)
  96. query = query.Where(x => x.TeachingMaterialPoolID == teachingMateriaID);
  97. if (teachingMateriaType > 1)
  98. query = query.Where(x => x.TeachingMaterialTypeID == teachingMateriaType);
  99. if (publishID.HasValue)
  100. query = query.Where(x => x.PublishID == publishID);
  101. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  102. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  103. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  104. }
  105. /*----------------------------加载入库、库存、出库明细各项数据------------------------------*/
  106. public IGridResultSet<StockOutView> GetStockOutDetailViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID)
  107. {
  108. //var query = InventoryDAL.GetStockOutDetailGridView(x => true);
  109. var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
  110. if (schoolyearID.HasValue)
  111. query = query.Where(x => x.SchoolyearID == schoolyearID);
  112. if (teachingMaterialPoolID.HasValue)
  113. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  114. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockOutView>(0, 20);
  115. }
  116. public IGridResultSet<StockInView> GetStockInDetailViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID)
  117. {
  118. Expression<Func<ET_StockIn, bool>> exp = x => true;
  119. if (schoolyearID.HasValue)
  120. {
  121. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  122. }
  123. var query = InventoryDAL.GetStockInDetailGridView(exp);
  124. if (teachingMaterialPoolID.HasValue)
  125. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  126. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockInView>(0, 20);
  127. }
  128. #region 2.0 库存出入库教材信息数据加载
  129. public IGridResultSet<StockOutView> GetStockOutDetailByValueViewGrid(Guid? teachingMaterialPoolID, int? Value, Guid? schoolyearID, decimal? discountPrice, int pageIndex, int pageSize)
  130. {
  131. var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= Value).Select(x => x.SchoolyearID);
  132. var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
  133. if (teachingMaterialPoolID.HasValue)
  134. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  135. if (discountPrice.HasValue)
  136. query = query.Where(x => x.DiscountPrice == discountPrice);
  137. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockOutView>(pageIndex, pageSize);
  138. }
  139. public IGridResultSet<StockInView> GetStockInDetailByValueViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID, decimal? discountPrice, int pageIndex, int pageSize)
  140. {
  141. var query = InventoryDAL.GetStockInDetailGridView(x => x.SchoolyearID == schoolyearID && x.RecordStatus == (int)CF_YesOrNoStatus.Yes);
  142. if (teachingMaterialPoolID.HasValue)
  143. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  144. if (discountPrice.HasValue)
  145. query = query.Where(x => x.DiscountPrice == discountPrice);
  146. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<StockInView>(pageIndex, pageSize);
  147. }
  148. #endregion
  149. public IGridResultSet<InventoryView> GetTeachingMateriaInventoryViewGrid(Guid? teachingMaterialPoolID)
  150. {
  151. var query = InventoryDAL.GetTeachingMaterialInventoryGridView(x => x.TeachingMaterialPoolID == teachingMaterialPoolID, x => true);
  152. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<InventoryView>(0, 20);
  153. }
  154. /*----------------------------Excel导出入库、库存、出库明细各项数据------------------------------*/
  155. public IList<StockOutView> GetStockOutDetailViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID)
  156. {
  157. var SchoolYearEntity = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.SchoolyearID == schoolyearID);
  158. var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= SchoolYearEntity.FirstOrDefault().Value).Select(x => x.SchoolyearID);
  159. var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
  160. if (query.Count() <= 0)
  161. {
  162. query = InventoryDAL.GetStudentDistributeDetailGridView(x => schoolyearIDList.Contains(x.EM_SpecialtyPlan.CF_Schoolyear.SchoolyearID) && x.RecordStatus == (int)CF_YesOrNoStatus.Yes);
  163. }
  164. if (schoolyearID.HasValue)
  165. query = query.Where(x => x.SchoolyearID == schoolyearID);
  166. if (teachingMaterialPoolID.HasValue)
  167. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  168. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  169. }
  170. public IList<StockInView> GetStockInDetailViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID)
  171. {
  172. Expression<Func<ET_StockIn, bool>> exp = x => true;
  173. if (schoolyearID.HasValue)
  174. {
  175. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  176. }
  177. var query = InventoryDAL.GetStockInDetailGridView(exp);
  178. if (teachingMaterialPoolID.HasValue)
  179. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  180. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  181. }
  182. #region 2.0 库存汇总出入库明细查看
  183. public IList<StockOutView> GetStockOutDetailByValueViewList(Guid? teachingMaterialPoolID, int? Value, Guid? schoolyearID)
  184. {
  185. var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= Value).Select(x => x.SchoolyearID);
  186. var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID);
  187. if (teachingMaterialPoolID.HasValue)
  188. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  189. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  190. }
  191. public IList<StockInView> GetStockInDetailByValueViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID)
  192. {
  193. Expression<Func<ET_StockIn, bool>> exp = x => x.SchoolyearID == schoolyearID && x.RecordStatus == (int)CF_YesOrNoStatus.Yes;
  194. var query = InventoryDAL.GetStockInDetailGridView(exp);
  195. if (teachingMaterialPoolID.HasValue)
  196. query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  197. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  198. }
  199. #endregion
  200. public IList<InventoryView> GetTeachingMateriaInventoryViewList(Guid? teachingMaterialPoolID)
  201. {
  202. var query = InventoryDAL.GetTeachingMaterialInventoryGridView(x => x.TeachingMaterialPoolID == teachingMaterialPoolID, x => true);
  203. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
  204. }
  205. }
  206. }