/// <summary> /// 获得产品的缓存数据 /// </summary> /// <returns></returns> public List <ProductEntity> GetList() { string Key = string.Format(CacheKey.JOOSHOW_PRODUCT_CACHE, this.CompanyID); List <ProductEntity> list = CacheHelper.Get(Key) as List <ProductEntity>; if (!list.IsNullOrEmpty()) { return(list); } ProductEntity entity = new ProductEntity(); entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete) .And(a => a.CompanyID == this.CompanyID); entity.OrderBy(a => a.ID, EOrderBy.DESC); list = this.Product.GetList(entity); if (!list.IsNullOrEmpty()) { StorageProvider storageProvider = new StorageProvider(this.CompanyID); List <StorageEntity> listStorage = storageProvider.GetList(); listStorage = listStorage.IsNull() ? new List <StorageEntity>() : listStorage; LocationProvider locationProvider = new LocationProvider(this.CompanyID); List <LocationEntity> listLocation = locationProvider.GetList(); listLocation = listLocation.IsNull() ? new List <LocationEntity>() : listLocation; foreach (ProductEntity item in list) { if (!item.StorageNum.IsEmpty()) { StorageEntity storage = listStorage.FirstOrDefault(a => a.SnNum == item.StorageNum); item.StorageName = storage.IsNull() ? string.Empty : storage.StorageName; } if (!item.DefaultLocal.IsEmpty()) { LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.DefaultLocal); item.LocalName = location.IsNull() ? string.Empty : location.LocalName; } } } if (!list.IsNullOrEmpty()) { CacheHelper.Insert(Key, list); } return(list); }
/// <summary> /// 查询产品列表 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <ProductEntity> GetList(ProductEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.OrderBy(a => a.ID, EOrderBy.DESC); int rowCount = 0; List <ProductEntity> list = this.Product.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); if (!list.IsNullOrEmpty()) { List <ProductCategoryEntity> listCate = new ProductCategoryProvider().GetList(); listCate = listCate.IsNull() ? new List <ProductCategoryEntity>() : listCate; foreach (ProductEntity item in list) { if (listCate.Exists(a => a.CateNum == item.CateNum)) { item.CateName = listCate.First(a => a.CateNum == item.CateNum).CateName; } } } pageInfo.RowCount = rowCount; return(list); }
/// <summary> /// 存储过程查询在线产品库存 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <param name="ProductName"></param> /// <param name="begin"></param> /// <param name="end"></param> /// <returns></returns> public List <ProductEntity> GetList(ProductEntity entity, ref PageInfo pageInfo, string searchKey, string begin, string end) { entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.OrderBy(a => a.ID, EOrderBy.DESC); int rowCount = 0; List <ProductEntity> list = this.Product.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); List <ProductEntity> listResult = new List <ProductEntity>(); pageInfo.RowCount = rowCount; DateTime beginTime = ConvertHelper.ToType <DateTime>(begin, DateTime.Now.AddDays(-1)); DateTime endTime = ConvertHelper.ToType <DateTime>(end, DateTime.Now); Proc_ProductReportEntity prEntity = new Proc_ProductReportEntity(); prEntity.SearchKey = searchKey; prEntity.BeginTime = beginTime; prEntity.EndTime = endTime; if (!begin.IsEmpty() && !end.IsEmpty()) { prEntity.IsTime = 1;//加上时间条件 } else { prEntity.IsTime = 0; } if (!list.IsNullOrEmpty()) { List <ProductCategoryEntity> listCates = new ProductCategoryProvider().GetList(); listCates = listCates.IsNull() ? new List <ProductCategoryEntity>() : listCates; foreach (ProductEntity item in list) { if (item.CateName.IsEmpty()) { ProductCategoryEntity cate = listCates.FirstOrDefault(a => a.CateNum == item.CateNum); item.CateName = cate == null ? "" : cate.CateName; } prEntity.ProductNum = item.SnNum; prEntity.IsDelete = (int)EIsDelete.NotDelete; prEntity.Status = (int)EAudite.Pass; int line = this.Proc_ProductReport.ExecuteNonQuery(prEntity); item.LocalProductNum = prEntity.LocalProductNum; item.InStorageNum = prEntity.InStorageNum; item.OutStorageNum = prEntity.OutStorageNum; item.BadReportNum = prEntity.BadReportNum; item.TotalLocalProductNum = prEntity.TotalLocalProductNum; item.TotalInStorageNum = prEntity.TotalInStorageNum; item.TotalOutStorageNum = prEntity.TotalOutStorageNum; item.TotalBadReportNum = prEntity.TotalBadReportNum; if (item.InStorageNum > 0 && item.TotalInStorageNum > 0) { item.InStorageNumPCT = (item.InStorageNum * 100.00f) / item.TotalInStorageNum; } if (item.OutStorageNum > 0 && item.TotalOutStorageNum > 0) { item.OutStorageNumPCT = (item.OutStorageNum * 100.00f) / item.TotalOutStorageNum; } listResult.Add(item); } } return(listResult); }