public static Product_CE ToCE(ProductEntity item) { Product_CE target = new Product_CE(); target.ID = item.ID; target.SnNum = item.SnNum; target.BarCode = item.BarCode; target.ProductName = item.ProductName; target.Num = item.Num; target.MinNum = item.MinNum; target.MaxNum = item.MaxNum; target.UnitNum = item.UnitNum; target.UnitName = item.UnitName; target.CateNum = item.CateNum; target.CateName = item.CateName; target.Size = item.Size; target.Color = item.Color; target.InPrice = item.InPrice; target.OutPrice = item.OutPrice; target.AvgPrice = item.AvgPrice; target.NetWeight = item.NetWeight; target.GrossWeight = item.GrossWeight; target.Description = item.Description; target.PicUrl = item.PicUrl; target.IsDelete = item.IsDelete; target.CreateTime = item.CreateTime; target.CreateUser = item.CreateUser; target.StorageNum = item.StorageNum; target.DefaultLocal = item.DefaultLocal; target.CusNum = item.CusNum; target.CusName = item.CusName; target.Display = item.Display; target.Remark = item.Remark; return target; }
/// <summary> /// 根据订单详细唯一编码号获取该订单详细信息以及产品信息 /// </summary> /// <param name="sn"></param> /// <returns></returns> public OrderDetailEntity GetOrderDetailBySnNum(string snNum) { OrderDetailEntity entity = new OrderDetailEntity(); entity.IncludeAll(); ProductEntity ProEntity = new ProductEntity(); ProEntity.Include(a => new { Size = a.Size}); entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" }); entity.Where("SnNum", ECondition.Eth, snNum); entity = this.OrderDetail.GetSingle(entity); return entity; }
/// <summary> /// 添加产品 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Add(ProductEntity entity) { entity.IncludeAll(); entity.InPrice = entity.AvgPrice; entity.OutPrice = entity.AvgPrice; int line = this.Product.Add(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE); } return line; }
public ActionResult GoodsDetail(string snNum) { ProductEntity entity = new ProductEntity(); ProductProvider provider = new ProductProvider(); entity = provider.GetProductBySn(snNum); ViewBag.Category = BaseHelper.GetProductCategory(entity.CateNum); ViewBag.Storage = LocalHelper.GetStorageNumList(entity.StorageNum); ViewBag.Local = LocalHelper.GetLocalNumList(entity.StorageNum, entity.DefaultLocal); ViewBag.Customer = BaseHelper.GetCustomerList(entity.CusNum); ViewBag.Goods = entity; //ViewBag.Unit = EnumHelper.GetOptions<EUnit>(entity.Unit, "请选择单位"); ViewBag.Unit = BaseHelper.GetMeasureNameList(entity.UnitNum); return View(); }
/// <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="barCode"></param> /// <returns></returns> public int GetCountByBarCode(string barCode) { ProductEntity entity = new ProductEntity(); entity.Where(a => a.BarCode == barCode); int count = this.Product.GetCount(entity); return count; }
public ActionResult ProductReportList() { string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty); string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty); string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty); int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue<int>("pageSize", 0); string storageNum = this.DefaultStore; ProductProvider provider = new ProductProvider(); ProductEntity entity = new ProductEntity(); entity.StorageNum = storageNum; if (!searchKey.IsEmpty()) { entity.Begin<ProductEntity>() .Where<ProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%") .Or<ProductEntity>("SnNum", ECondition.Like, "%" + searchKey + "%") .Or<ProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%") .End<ProductEntity>(); } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime)); } PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo, searchKey, beginTime, endTime); string json = ConvertJson.ListToJson<ProductEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return Content(this.ReturnJson.ToString()); }
public ActionResult ToExcel() { PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue }; string ProductName = WebUtil.GetFormValue<string>("ProductName", string.Empty); int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue<int>("pageSize", 0); string CateNum = WebUtil.GetFormValue<string>("CateNum", string.Empty); ProductProvider provider = new ProductProvider(); ProductEntity entity = new ProductEntity(); if (!ProductName.IsEmpty()) { entity.Where<ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%"); } if (!CateNum.IsEmpty()) { entity.Where<ProductEntity>("CateNum", ECondition.Eth, CateNum); } List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo); listResult = listResult.IsNull() ? new List<ProductEntity>() : listResult; if (listResult.IsNotNull()) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("序号 ")); dt.Columns.Add(new DataColumn("产品编号")); dt.Columns.Add(new DataColumn("条码编号")); dt.Columns.Add(new DataColumn("产品名称")); dt.Columns.Add(new DataColumn("类别名称")); dt.Columns.Add(new DataColumn("库存数")); dt.Columns.Add(new DataColumn("预警值下线")); dt.Columns.Add(new DataColumn("预警值上线")); dt.Columns.Add(new DataColumn("单位")); dt.Columns.Add(new DataColumn("平均价格")); dt.Columns.Add(new DataColumn("进口价格")); dt.Columns.Add(new DataColumn("出口价格")); dt.Columns.Add(new DataColumn("净重")); dt.Columns.Add(new DataColumn("毛重")); dt.Columns.Add(new DataColumn("备注")); int count = 1; foreach (ProductEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.SnNum; row[2] = t.BarCode; row[3] = t.ProductName; row[4] = t.CateName; row[5] = t.Num; row[6] = t.MinNum; row[7] = t.MaxNum; row[8] = t.UnitName; row[9] = t.AvgPrice; row[10] = t.InPrice; row[11] = t.OutPrice; row[12] = t.NetWeight.ToString(); row[13] = t.GrossWeight.ToString(); row[14] = t.Remark; dt.Rows.Add(row); count++; } string filePath = Server.MapPath("~/UploadFiles/"); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } string filename = string.Format("产品管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss")); NPOIExcel excel = new NPOIExcel("产品管理", "产品", System.IO.Path.Combine(filePath, filename)); excel.ToExcel(dt); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!"); } return Content(this.ReturnJson.ToString()); }
/// <summary> /// 修改 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Update(ProductEntity entity) { entity.InPrice = entity.AvgPrice; entity.OutPrice = entity.AvgPrice; entity.Include(a => new { a.ProductName, a.BarCode, a.MinNum, a.MaxNum, a.UnitNum, a.UnitName, a.CateNum, a.CateName, a.Size, a.InPrice, a.OutPrice, a.AvgPrice, a.GrossWeight, a.NetWeight, a.StorageNum, a.DefaultLocal, a.CusNum, a.CusName, a.Description }); entity.Where(a => a.SnNum == entity.SnNum); int line = this.Product.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE); } return line; }
/// <summary> /// 根据库存唯一编码号获取该位置的库存信息以及产品信息 /// </summary> /// <param name="sn"></param> /// <returns></returns> public LocalProductEntity GetLocalProductBySn(string sn, string productNum = null) { LocalProductEntity entity = new LocalProductEntity(); entity.IncludeAll(); ProductEntity ProEntity = new ProductEntity(); ProEntity.Include(a => new { Size = a.Size, InPrice = a.InPrice }); entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" }); entity.Where(a => a.Sn == sn); if (!productNum.IsEmpty()) { entity.Where(a => a.ProductNum == productNum); } entity = this.LocalProduct.GetSingle(entity); return entity; }
/// <summary> /// 在线库存报表 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List<LocalProductEntity> GetList(LocalProductEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); ProductEntity ProEntity = new ProductEntity(); ProEntity.Include(a => new { Size = a.Size, AvgPrice = a.AvgPrice,CateNum=a.CateNum, CateName = a.CateName, MinNum = a.MinNum, MaxNum = a.MaxNum }); entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" }); entity.OrderBy(a => a.ID, EOrderBy.DESC); int rowCount = 0; List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; List<ProductCategoryEntity> listCates = new ProductCategoryProvider().GetList(); listCates = listCates.IsNull() ? new List<ProductCategoryEntity>() : listCates; if (!listResult.IsNullOrEmpty()) { foreach (LocalProductEntity item in listResult) { if (item.CateName.IsEmpty()) { ProductCategoryEntity cate = listCates.FirstOrDefault(a => a.CateNum == item.CateNum); item.CateName = cate == null ? "" : cate.CateName; } } } return listResult; }
/// <summary> /// 根据产品条码或者产品编号或者产品名称搜索库存产品数量以及库存位置 /// 主要用于选择产品的界面中搜索功能。在搜索到相应产品之后查询库存信息 /// </summary> /// <returns></returns> public List<LocalProductEntity> GetList(string barCode) { LocalProductEntity entity = new LocalProductEntity(); entity.IncludeAll(); ProductEntity ProEntity = new ProductEntity(); ProEntity.Include(a => new { Size = a.Size, InPrice = a.InPrice }); entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" }); entity.Where(a => a.BarCode == barCode); entity.OrderBy(a => a.ID, EOrderBy.DESC); List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity); return listResult; }
private static void GetProCatInfo(System.Data.DataSet dataset, List<ProductEntity> list) { var rows = dataset.Tables[0].Rows; if (rows.Count > 2) { ProductCategoryProvider ProductCategory = new ProductCategoryProvider(); for (var i = 2; i < rows.Count; i++) { ProductEntity entity = new ProductEntity(); ProductCategoryEntity PCEntity = new ProductCategoryEntity(); var row = rows[i]; entity.SnNum = row[1].ToString(); if (string.IsNullOrEmpty(entity.SnNum)) continue; entity.BarCode = row[2].ToString(); entity.ProductName = row[3].ToString(); entity.CateName = row[4].ToString(); PCEntity = ProductCategory.GetSingleCateName(entity.CateName); if (PCEntity.IsNotNull()) { entity.CateNum = PCEntity.CateNum; } else { entity.CateNum = ""; } entity.Num = ConvertHelper.ToType<int>(row[5].ToString()); entity.MinNum = ConvertHelper.ToType<int>(row[6].ToString()); entity.MaxNum = ConvertHelper.ToType<int>(row[7].ToString()); entity.UnitName = row[8].ToString(); entity.UnitNum = entity.UnitNum; entity.AvgPrice = ConvertHelper.ToType<double>(row[9].ToString()); entity.InPrice = ConvertHelper.ToType<double>(row[10].ToString()); entity.OutPrice = ConvertHelper.ToType<double>(row[11].ToString()); entity.NetWeight = ConvertHelper.ToType<double>(row[12].ToString()); entity.GrossWeight = ConvertHelper.ToType<double>(row[13].ToString()); entity.Remark = row[14].ToString(); entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; list.Add(entity); } } }
/// <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; }
/// <summary> /// 获得满足条件的所有产品的总价格 /// </summary> /// <param name="localName"></param> /// <param name="localType"></param> /// <param name="searchKey"></param> /// <param name="storageNum"></param> /// <returns></returns> public double GetAllTotalPrice(string localName, string localType, string searchKey, string storageNum) { LocalProductEntity entity = new LocalProductEntity(); double allTotalPrice = 0; if (!storageNum.IsEmpty()) { entity.Where("StorageNum", ECondition.Eth, storageNum); } if (!localType.IsEmpty()) { entity.Where("LocalType", ECondition.Eth, localType); } if (!localName.IsEmpty()) { entity.Where("LocalName", ECondition.Like, "%" + localName + "%"); entity.Or("LocalNum", ECondition.Like, "%" + localName + "%"); } if (!searchKey.IsEmpty()) { entity.Begin<LocalProductEntity>() .Where<LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%") .Or<LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%") .Or<LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%") .End<LocalProductEntity>(); } entity.IncludeNum(true); ProductEntity ProEntity = new ProductEntity(); ProEntity.Include(a => new { AvgPrice = a.AvgPrice }); entity.Left<ProductEntity>(ProEntity, new Params<string, string>() { Item1 = "ProductNum", Item2 = "SnNum" }); entity.OrderBy(a => a.ID, EOrderBy.DESC); List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity); if (!listResult.IsNullOrEmpty()) { listResult.ForEach(a => { a.TotalPrice = a.Num * a.AvgPrice; allTotalPrice += a.TotalPrice; }); } return allTotalPrice; }
/// <summary> /// 获得产品的缓存数据 /// </summary> /// <returns></returns> public List<ProductEntity> GetListByCache() { List<ProductEntity> list = CacheHelper.Get(CacheKey.JOOSHOW_PRODUCT_CACHE) as List<ProductEntity>; if (!list.IsNullOrEmpty()) { return list; } ProductEntity entity = new ProductEntity(); entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); list = this.Product.GetList(entity); if (!list.IsNullOrEmpty()) { CacheHelper.Insert(CacheKey.JOOSHOW_PRODUCT_CACHE, list); } return list; }
public ActionResult ToProductReportExcel() { PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue }; string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty); string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty); string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty); string storageNum = this.DefaultStore; ProductProvider provider = new ProductProvider(); ProductEntity entity = new ProductEntity(); if (!searchKey.IsEmpty()) { entity.Begin<ProductEntity>() .Where<ProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%") .Or<ProductEntity>("SnNum", ECondition.Like, "%" + searchKey + "%") .Or<ProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%") .End<ProductEntity>(); } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime)); } if (storageNum.IsNotNull()) { entity.Where("StorageNum", ECondition.Eth, storageNum); } List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo, searchKey, beginTime, endTime); listResult = listResult.IsNull() ? new List<ProductEntity>() : listResult; if (!listResult.IsNullOrEmpty()) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("序号 ")); dt.Columns.Add(new DataColumn("产品编号")); dt.Columns.Add(new DataColumn("产品条码")); dt.Columns.Add(new DataColumn("产品名称")); dt.Columns.Add(new DataColumn("类别名称")); dt.Columns.Add(new DataColumn("预警值下限")); dt.Columns.Add(new DataColumn("预警值上限")); dt.Columns.Add(new DataColumn("规格")); dt.Columns.Add(new DataColumn("价格")); dt.Columns.Add(new DataColumn("库存数")); dt.Columns.Add(new DataColumn("进货总数")); dt.Columns.Add(new DataColumn("出货总数")); dt.Columns.Add(new DataColumn("报损总数")); int count = 1; foreach (ProductEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.SnNum; row[2] = t.BarCode; row[3] = t.ProductName; row[4] = t.CateName; row[5] = t.MinNum; row[6] = t.MaxNum; row[7] = t.Size; row[8] = t.AvgPrice; row[9] = t.LocalProductNum; row[10] = t.InStorageNum; row[11] = t.OutStorageNum; row[12] = t.BadReportNum; dt.Rows.Add(row); count++; } DataRow rowTemp = dt.NewRow(); rowTemp[0] = count; rowTemp[1] = ""; rowTemp[2] = ""; rowTemp[3] = ""; rowTemp[4] = ""; rowTemp[5] = ""; rowTemp[6] = ""; rowTemp[7] = ""; rowTemp[8] = "总计"; rowTemp[9] = listResult[0].TotalLocalProductNum; rowTemp[10] = listResult[0].TotalInStorageNum; rowTemp[11] = listResult[0].TotalOutStorageNum; rowTemp[12] = listResult[0].TotalBadReportNum; dt.Rows.Add(rowTemp); string filePath = Server.MapPath("~/UploadFiles/"); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } string filename = string.Format("产品在线库存报表{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss")); AsposeExcel excel = new AsposeExcel(System.IO.Path.Combine(filePath, filename), ""); excel.DatatableToExcel(dt, "产品在线库存报表", "产品在线库存报表"); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!"); } return Content(this.ReturnJson.ToString()); }
/// <summary> /// 修改 /// </summary> /// <param name="barCode"></param> /// <param name="productName"></param> /// <param name="unit"></param> /// <param name="snNum"></param> /// <returns></returns> public int Update(string barCode, string productName, string unit, string snNum) { ProductEntity entity = new ProductEntity(); entity.BarCode = barCode; entity.ProductName = productName; entity.UnitNum = unit; entity.Include(a => new { a.ProductName, a.BarCode, a.UnitNum }); entity.Where(a => a.SnNum == snNum); int line = this.Product.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE); } return line; }
public ActionResult ProductInOutReportList() { int queryTime = WebUtil.GetFormValue<int>("QueryTime", 0); string storageNum = this.DefaultStore; int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue<int>("pageSize", 0); string Key = "InOutReprt" + DateTime.Now.AddDays(-queryTime).ToString("yyMMdd") + DateTime.Now.ToString("yyMMdd") + storageNum; List<ProductEntity> listResult = CacheHelper.Get(Key) as List<ProductEntity>; if (listResult.IsNullOrEmpty()) { listResult = new List<ProductEntity>(); InStorageProvider inProvider = new InStorageProvider(); List<ReportChart> listInSource = inProvider.GetChartTop((int)EAudite.Pass, this.DefaultStore, DateTime.Now.AddDays(-queryTime), DateTime.Now); if (!listInSource.IsNullOrEmpty()) { foreach (ReportChart chart in listInSource) { ProductEntity entity = new ProductEntity(); entity.SnNum = chart.ProductNum; entity.BarCode = chart.BarCode; entity.ProductName = chart.ProductName; entity.InStorageNum = chart.Num; entity.Size = chart.Size.IsEmpty() ? "" : chart.Size; listResult.Add(entity); } } OutStorageProvider outProvider = new OutStorageProvider(); List<ReportChart> listOutSource = listInSource = outProvider.GetChartTop((int)EAudite.Pass, this.DefaultStore, DateTime.Now.AddDays(-queryTime), DateTime.Now); if (!listOutSource.IsNullOrEmpty()) { foreach (ReportChart chart in listOutSource) { if (listResult.Exists(a => a.SnNum == chart.ProductNum)) { ProductEntity entity = listResult.First(a => a.SnNum == chart.ProductNum); entity.OutStorageNum = chart.Num; } else { ProductEntity entity = new ProductEntity(); entity.SnNum = chart.ProductNum; entity.BarCode = chart.BarCode; entity.ProductName = chart.ProductName; entity.OutStorageNum = chart.Num; entity.Size = chart.Size.IsEmpty() ? "" : chart.Size; listResult.Add(entity); } } } if (!listResult.IsNullOrEmpty()) { double inTotalNum = listResult.Sum(a => a.InStorageNum); double outTotalNum = listResult.Sum(a => a.OutStorageNum); listResult.ForEach(a => { a.InStorageNumPCT = inTotalNum > 0 ? a.InStorageNum*100 / inTotalNum : 0; a.OutStorageNumPCT = outTotalNum > 0 ? a.OutStorageNum*100 / outTotalNum : 0; }); CacheHelper.Insert(Key, listResult, null, DateTime.Now.AddMinutes(30)); } } int rowCount = listResult.Count; listResult = listResult.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); string json = ConvertJson.ListToJson<ProductEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", rowCount); return Content(this.ReturnJson.ToString()); }
/// <summary> /// 删除产品信息 /// </summary> /// <param name="snNum"></param> /// <returns></returns> public int Delete(string snNum) { ProductEntity entity = new ProductEntity(); entity.IsDelete = (int)EIsDelete.Deleted; entity.Where(a => a.SnNum == snNum); entity.IncludeIsDelete(true); int line = this.Product.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE); } return line; }
public ActionResult GetList() { string ProductName = WebUtil.GetFormValue<string>("ProductName", string.Empty); int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue<int>("pageSize", 0); string CateNum = WebUtil.GetFormValue<string>("CateNum", string.Empty); ProductProvider provider = new ProductProvider(); ProductEntity entity = new ProductEntity(); if (!ProductName.IsEmpty()) { entity.Begin<ProductEntity>() .Where<ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%") .Or<ProductEntity>("SnNum", ECondition.Like, "%" + ProductName + "%") .Or<ProductEntity>("BarCode", ECondition.Like, "%" + ProductName + "%") .End<ProductEntity>(); } if (!CateNum.IsEmpty()) { entity.Where<ProductEntity>("CateNum", ECondition.Eth, CateNum); } PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo); string json = ConvertJson.ListToJson<ProductEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return Content(this.ReturnJson.ToString()); }