using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Common.TeachingMaterial; using EMIS.ViewModel.TeachingMaterial; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel.Cultureplan; namespace EMIS.CommonLogic.TeachingMaterial { public class InventoryServices : BaseServices, IInventoryServices { public InventoryDAL InventoryDAL { get; set; } public IGridResultSet GetTeachingMateriaInventoryViewGrid(ConfiguretView configuretView, Guid? teachingMateriaCodeID, Guid? teachingMateriaNameID, Guid? publishID, bool? isLate, int? teachingMaterialTypeID, int pageIndex, int pageSize) { Expression> exp = x => true; Expression> poolexp = x => true; if (isLate != null) { //exp = exp.And(x => x.CF_TeachingMaterialPool.IsLate == isLate); poolexp = poolexp.And(x => x.IsLate == isLate); } if (teachingMateriaNameID.HasValue) { //exp = exp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID); poolexp = poolexp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID); } if (publishID.HasValue) { //exp = exp.And(x => x.CF_TeachingMaterialPool.CF_Publish.PublishID == publishID); poolexp = poolexp.And(x => x.CF_Publish.PublishID == publishID); } if (teachingMaterialTypeID.HasValue) { //exp = exp.And(x => x.CF_TeachingMaterialPool.TeachingMaterialTypeID == teachingMaterialTypeID); poolexp = poolexp.And(x => x.TeachingMaterialTypeID == teachingMaterialTypeID); } var query = InventoryDAL.GetTeachingMaterialInventoryGridView(exp, poolexp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); } public IList GetTeachingMateriaInventoryViewList(ConfiguretView configuretView, Guid? teachingMateriaCodeID, Guid? teachingMateriaNameID, Guid? publishID, bool? isLate, int? teachingMaterialTypeID) { Expression> exp = x => true; Expression> poolexp = x => true; if (isLate != null) { //exp = exp.And(x => x.CF_TeachingMaterialPool.IsLate == isLate); poolexp = poolexp.And(x => x.IsLate == isLate); } if (teachingMateriaNameID.HasValue) { //exp = exp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID); poolexp = poolexp.And(x => x.TeachingMaterialPoolID == teachingMateriaNameID); } if (publishID.HasValue) { //exp = exp.And(x => x.CF_TeachingMaterialPool.CF_Publish.PublishID == publishID); poolexp = poolexp.And(x => x.CF_Publish.PublishID == publishID); } if (teachingMaterialTypeID.HasValue) { //exp = exp.And(x => x.CF_TeachingMaterialPool.TeachingMaterialTypeID == teachingMaterialTypeID); poolexp = poolexp.And(x => x.TeachingMaterialTypeID == teachingMaterialTypeID); } var query = InventoryDAL.GetTeachingMaterialInventoryGridView(exp, poolexp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } //获取库存统计信息 public IGridResultSet GetInventoryManagementViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMateriaID, int? teachingMateriaType, Guid? publishID, int pageIndex, int pageSize) { var query = InventoryDAL.GetInventoryManagementGridOnlyNumView(schoolyearID); //if (schoolyearID.HasValue) // query = query.Where(x => x.SchoolYearID == schoolyearID); if (teachingMateriaID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMateriaID); if (teachingMateriaType.HasValue) query = query.Where(x => x.TeachingMaterialTypeID == teachingMateriaType); if (publishID.HasValue) query = query.Where(x => x.PublishID == publishID); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); } public IList GetInventoryManagementViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMateriaID, int? teachingMateriaType, Guid? publishID) { var query = InventoryDAL.GetInventoryManagementGridOnlyNumView(schoolyearID); if (teachingMateriaID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMateriaID); if (teachingMateriaType > 1) query = query.Where(x => x.TeachingMaterialTypeID == teachingMateriaType); if (publishID.HasValue) query = query.Where(x => x.PublishID == publishID); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } /*----------------------------加载入库、库存、出库明细各项数据------------------------------*/ public IGridResultSet GetStockOutDetailViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID) { //var query = InventoryDAL.GetStockOutDetailGridView(x => true); var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID); if (schoolyearID.HasValue) query = query.Where(x => x.SchoolyearID == schoolyearID); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(0, 20); } public IGridResultSet GetStockInDetailViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID) { Expression> exp = x => true; if (schoolyearID.HasValue) { exp = exp.And(x => x.SchoolyearID == schoolyearID); } var query = InventoryDAL.GetStockInDetailGridView(exp); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(0, 20); } #region 2.0 库存出入库教材信息数据加载 public IGridResultSet GetStockOutDetailByValueViewGrid(Guid? teachingMaterialPoolID, int? Value, Guid? schoolyearID, decimal? discountPrice, int pageIndex, int pageSize) { var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= Value).Select(x => x.SchoolyearID); var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); if (discountPrice.HasValue) query = query.Where(x => x.DiscountPrice == discountPrice); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetStockInDetailByValueViewGrid(Guid? teachingMaterialPoolID, Guid? schoolyearID, decimal? discountPrice, int pageIndex, int pageSize) { var query = InventoryDAL.GetStockInDetailGridView(x => x.SchoolyearID == schoolyearID && x.RecordStatus == (int)CF_YesOrNoStatus.Yes); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); if (discountPrice.HasValue) query = query.Where(x => x.DiscountPrice == discountPrice); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); } #endregion public IGridResultSet GetTeachingMateriaInventoryViewGrid(Guid? teachingMaterialPoolID) { var query = InventoryDAL.GetTeachingMaterialInventoryGridView(x => x.TeachingMaterialPoolID == teachingMaterialPoolID, x => true); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(0, 20); } /*----------------------------Excel导出入库、库存、出库明细各项数据------------------------------*/ public IList GetStockOutDetailViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID) { var SchoolYearEntity = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.SchoolyearID == schoolyearID); var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= SchoolYearEntity.FirstOrDefault().Value).Select(x => x.SchoolyearID); var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID); if (query.Count() <= 0) { query = InventoryDAL.GetStudentDistributeDetailGridView(x => schoolyearIDList.Contains(x.EM_SpecialtyPlan.CF_Schoolyear.SchoolyearID) && x.RecordStatus == (int)CF_YesOrNoStatus.Yes); } if (schoolyearID.HasValue) query = query.Where(x => x.SchoolyearID == schoolyearID); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } public IList GetStockInDetailViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID) { Expression> exp = x => true; if (schoolyearID.HasValue) { exp = exp.And(x => x.SchoolyearID == schoolyearID); } var query = InventoryDAL.GetStockInDetailGridView(exp); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } #region 2.0 库存汇总出入库明细查看 public IList GetStockOutDetailByValueViewList(Guid? teachingMaterialPoolID, int? Value, Guid? schoolyearID) { var schoolyearIDList = InventoryDAL.SchoolyearRepository.Entities.Where(x => x.Value >= Value).Select(x => x.SchoolyearID); var query = InventoryDAL.GetStockOutDetailGridView(schoolyearID, teachingMaterialPoolID); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } public IList GetStockInDetailByValueViewList(Guid? teachingMaterialPoolID, Guid? schoolyearID) { Expression> exp = x => x.SchoolyearID == schoolyearID && x.RecordStatus == (int)CF_YesOrNoStatus.Yes; var query = InventoryDAL.GetStockInDetailGridView(exp); if (teachingMaterialPoolID.HasValue) query = query.Where(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } #endregion public IList GetTeachingMateriaInventoryViewList(Guid? teachingMaterialPoolID) { var query = InventoryDAL.GetTeachingMaterialInventoryGridView(x => x.TeachingMaterialPoolID == teachingMaterialPoolID, x => true); return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList(); } } }