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()); }
public ActionResult BindPieData() { int queryTime = WebUtil.GetFormValue<int>("QueryTime", 0); string storageNum = this.DefaultStore; InStorageProvider inProvider = new InStorageProvider(); List<ReportChart> listInSource = inProvider.GetChartTop((int)EAudite.Pass, this.DefaultStore, DateTime.Now.AddDays(-queryTime), DateTime.Now); StringBuilder sbInStorage = new StringBuilder(); sbInStorage.Append("<pie>"); listInSource.ForEach(a => { sbInStorage.AppendFormat("<slice title=\"{0}\">{1}</slice>", a.ProductName, a.Num); }); sbInStorage.Append("</pie>"); OutStorageProvider outProvider = new OutStorageProvider(); listInSource = outProvider.GetChartTop((int)EAudite.Pass, this.DefaultStore, DateTime.Now.AddDays(-queryTime), DateTime.Now); StringBuilder sbOutStorage = new StringBuilder(); sbOutStorage.Append("<pie>"); listInSource.ForEach(a => { sbOutStorage.AppendFormat("<slice title=\"{0}\">{1}</slice>", a.ProductName, a.Num); }); sbOutStorage.Append("</pie>"); this.ReturnJson.AddProperty("InStorageData", sbInStorage.ToString()); this.ReturnJson.AddProperty("OutStorageData", sbOutStorage.ToString()); return Content(this.ReturnJson.ToString()); }