public JsonResult SearchStatistics(string BuyBusinessmanName, string BuyBusinessmanCode) { using (ChannelFactory <ITravelPaperService> cf = new ChannelFactory <ITravelPaperService>(typeof(ITravelPaperService).Name)) { var client = cf.CreateChannel(); TravelPaperStaticsDto travelPaperStaticsDto = client.FindTravelPaperStatistics(BuyBusinessmanCode, BuyBusinessmanName); travelPaperStaticsDto.ItemStaticsList.Add(travelPaperStaticsDto.Total); return(Json(travelPaperStaticsDto.ItemStaticsList, JsonRequestBehavior.AllowGet)); } }
public TravelPaperStaticsDto FindTravelPaperStatistics(string buyBusinessmanCode, string buyBusinessmanName) { string BusinessmanCode = currentUser.Code; TravelPaperStaticsDto travelPaperStaticsDto = new TravelPaperStaticsDto(); var result = m_travelPaperRepository.FindAll(p => p.BusinessmanCode.Trim() != "" && p.BusinessmanCode.Trim() == BusinessmanCode.Trim()); result.GroupBy(p => p.UseBusinessmanCode.Trim()).Each(p => { TravelPaper travelPaper = null; if (string.IsNullOrEmpty(buyBusinessmanCode) && string.IsNullOrEmpty(buyBusinessmanName)) { travelPaper = result.FirstOrDefault(p1 => p1.UseBusinessmanCode.Trim() == p.Key.Trim()); } else { if (!string.IsNullOrEmpty(buyBusinessmanCode)) { result = result.Where(p1 => p1.UseBusinessmanCode.Trim() == buyBusinessmanCode.Trim()); } if (!string.IsNullOrEmpty(buyBusinessmanName)) { result = result.Where(p1 => p1.UseBusinessmanName.Trim() == buyBusinessmanName.Trim()); } travelPaper = result.FirstOrDefault(p1 => p1.UseBusinessmanCode.Trim() == p.Key.Trim()); } if (travelPaper != null && !string.IsNullOrEmpty(travelPaper.UseBusinessmanCode)) { travelPaperStaticsDto.ItemStaticsList.Add( new TravelPaperItem() { BusinessmanCode = travelPaper.BusinessmanCode, BusinessmanName = travelPaper.BusinessmanName, UseBusinessmanCode = travelPaper.UseBusinessmanCode, UseBusinessmanName = travelPaper.UseBusinessmanName, TotalCount = result.Where(p2 => p2.UseBusinessmanCode == p.Key && (int)p2.TripStatus != 3).Count(), TotalNoUse = result.Where(p2 => p2.UseBusinessmanCode == p.Key && ((int)p2.TripStatus == 0)).Count(), TotalUse = result.Where(p2 => p2.UseBusinessmanCode == p.Key && ((int)p2.TripStatus == 1)).Count(), TotalVoid = result.Where(p2 => p2.UseBusinessmanCode == p.Key && ((int)p2.TripStatus == 2)).Count(), TotalBlankRecovery = result.Where(p2 => p2.UseBusinessmanCode == p.Key && (int)p2.TripStatus == 3).Count(), TotalValidateUse = result.Where(p2 => p2.UseBusinessmanCode == p.Key && (int)p2.TripStatus == 4).Count() + result.Where(p2 => p2.UseBusinessmanCode == p.Key && ((int)p2.TripStatus == 0)).Count() }); } }); travelPaperStaticsDto.Total.UseBusinessmanName = "合计"; travelPaperStaticsDto.Total.TotalCount = travelPaperStaticsDto.ItemStaticsList.Sum(p => p.TotalCount); travelPaperStaticsDto.Total.TotalUse = travelPaperStaticsDto.ItemStaticsList.Sum(p => p.TotalUse); travelPaperStaticsDto.Total.TotalNoUse = travelPaperStaticsDto.ItemStaticsList.Sum(p => p.TotalNoUse); travelPaperStaticsDto.Total.TotalBlankRecovery = travelPaperStaticsDto.ItemStaticsList.Sum(p => p.TotalBlankRecovery); travelPaperStaticsDto.Total.TotalVoid = travelPaperStaticsDto.ItemStaticsList.Sum(p => p.TotalVoid); travelPaperStaticsDto.Total.TotalValidateUse = travelPaperStaticsDto.ItemStaticsList.Sum(p => p.TotalValidateUse); return(travelPaperStaticsDto); }
/// <summary> /// 商户分类数据导出 /// </summary> /// <returns></returns> public ActionResult ImportStatistics(string BusinessmanCode, string BusinessmanName, string exportType) { ExportExcelContext export = new ExportExcelContext(exportType); DataTable dt = new DataTable("行程单商户分类"); List <KeyValuePair <string, Type> > headArray = new List <KeyValuePair <string, Type> > { new KeyValuePair <string, Type>("商户名称", typeof(string)), new KeyValuePair <string, Type>("商户号", typeof(string)), new KeyValuePair <string, Type>("全部行程单", typeof(string)), new KeyValuePair <string, Type>("已使用", typeof(string)), new KeyValuePair <string, Type>("未使用", typeof(string)), new KeyValuePair <string, Type>("可使用", typeof(string)), new KeyValuePair <string, Type>("已作废", typeof(string)) }; headArray.ForEach(p => dt.Columns.Add(p.Key, p.Value)); using (ChannelFactory <ITravelPaperService> cf = new ChannelFactory <ITravelPaperService>(typeof(ITravelPaperService).Name)) { var client = cf.CreateChannel(); TravelPaperStaticsDto travelPaperStaticsDto = client.FindTravelPaperStatistics(BusinessmanCode, BusinessmanName); travelPaperStaticsDto.ItemStaticsList.Add(travelPaperStaticsDto.Total); travelPaperStaticsDto.ItemStaticsList.ForEach(p => { dt.Rows.Add( p.UseBusinessmanName, p.UseBusinessmanCode, p.TotalCount, p.TotalUse, p.TotalNoUse, p.TotalValidateUse, p.TotalVoid ); }); } return(File(export.GetMemoryStream(dt), "application/ms-excel", HttpUtility.UrlEncode(string.Format("商户分类查询_{0}.{1}", System.DateTime.Now.ToString("yyy-MM-ddHHMMss"), export.TypeName), System.Text.Encoding.UTF8))); }