public PagedList <SumReportTable> GetSumReportTable(SumTableInput inputParas) { var queryList = QueryList(x => x.CreateTime >= inputParas.StartTime && x.CreateTime <= inputParas.EndTime); var rsList = ReportStoreCommons <TEntity, TKey> .GetSumReportTable(queryList, inputParas); return(rsList); }
public void GetSumReport_SumTableInput_test() { SumTableInput reportInput = null; var result = Resolve <IAutoReportService>().GetSumReport(reportInput); Assert.NotNull(result); Resolve <IAutoReportService>().GetSumReport(reportInput); }
public PagedList <SumReportTable> GetSumReportTable(SumTableInput inputParas) { Expression <Func <TEntity, bool> > predicate = x => x.CreateTime > DateTime.MinValue; if (inputParas.StartTime != null && inputParas.EndTime != null) { predicate = predicate.And(x => x.CreateTime >= inputParas.StartTime); } var queryList = QueryList(predicate); var rsList = ReportStoreCommons <TEntity, TKey> .GetSumReportTable(queryList, inputParas); return(rsList); }
/// <summary> /// 根据字段求和 统计报表 /// </summary> /// <param name="reportInput"></param> /// <returns></returns> public Tuple <ServiceResult, List <AutoReport> > GetSumReport2(SumTableInput reportInput) { var returnList = new List <AutoReport>(); #region 安全验证 if (reportInput == null) { if (string.IsNullOrEmpty(reportInput.Type)) { return(Tuple.Create(ServiceResult.FailedMessage("实体类型不能为空"), returnList)); } return(Tuple.Create(ServiceResult.FailedMessage("实体类型不能为空"), returnList)); } Type typeFind = null; object instanceFind = null; var checkType = Resolve <IUIBaseService>().CheckType(reportInput.Type, ref typeFind, ref instanceFind); if (!checkType.Succeeded) { return(Tuple.Create(ServiceResult.FailedMessage("实体类型不存在"), returnList)); } if (!(instanceFind is IEntity)) // 非实体类型不能完成数据统计 { return(Tuple.Create(ServiceResult.FailedMessage("非实体类型不能进行数据统计"), returnList)); } if (reportInput.Fields.Count <= 0) { return(Tuple.Create(ServiceResult.FailedMessage("统计的字段不能为空"), returnList)); } //验证传入的统计字段和表是否匹配 var fieldsList = reportInput.Fields; fieldsList.ForEach(p => { }); #endregion 安全验证 var table = Resolve <ITableService>().GetSingle(r => r.Key == typeFind.Name); if (table == null) { return(Tuple.Create(ServiceResult.FailedMessage("查询的表不存在"), returnList)); } var rs = DynamicService.ResolveMethod(typeFind.Name, "GetSumReport", reportInput); var rsList = rs.Item2 as List <AutoReport>; return(Tuple.Create(ServiceResult.Success, rsList)); }
/// <summary> /// 根据字段求和 生成报表表格 /// </summary> /// <param name="reportInput"></param> /// <returns></returns> public Tuple <ServiceResult, PagedList <SumReportTable> > GetCountSumTable2(SumTableInput reportInput) { var resultPage = new PagedList <SumReportTable>(); #region 安全验证 if (reportInput == null) { if (string.IsNullOrEmpty(reportInput.Type)) { return(Tuple.Create(ServiceResult.Failure("实体类型不能为空"), resultPage)); } return(Tuple.Create(ServiceResult.Failure("实体类型不能为空"), resultPage)); } Type typeFind = null; object instanceFind = null; var checkType = Resolve <IUIBaseService>().CheckType(reportInput.Type, ref typeFind, ref instanceFind); if (!checkType.Succeeded) { return(Tuple.Create(ServiceResult.Failure("所输入实体不存在"), resultPage)); } if (!(instanceFind is IEntity)) // 非实体类型不能完成数据统计 { return(Tuple.Create(ServiceResult.Failure("非实体类型不能进行数据统计"), resultPage)); } if (reportInput.Fields.Count <= 0) { return(Tuple.Create(ServiceResult.Failure("统计的字段不能为空"), resultPage)); } #endregion 安全验证 var table = Resolve <ITableService>().GetSingle(r => r.Key == typeFind.Name); if (table == null) { return(Tuple.Create(ServiceResult.Failure("查询的表不存在"), resultPage)); } var rs = DynamicService.ResolveMethod(typeFind.Name, "GetSumReportTable", reportInput); var rsList = rs.Item2 as PagedList <SumReportTable>; return(Tuple.Create(ServiceResult.Success, rsList)); }
public ApiResult <PagedList <SumReportTable> > GetSumTable2([FromQuery] SumTableInput reportInput) { var result = Resolve <IAutoReportService>().GetCountSumTable2(null); return(ToResult(result)); }
public ApiResult <List <AutoReport> > GetSumReport2([FromQuery] SumTableInput reportInput) { var result = Resolve <IAutoReportService>().GetSumReport2(reportInput); return(ToResult(result)); }
public static PagedList <SumReportTable> GetSumReportTable(IEnumerable <TEntity> queryList, SumTableInput inputParas) { var rsList = new PagedList <SumReportTable>(); var type = typeof(TEntity); var gpListByDate = queryList.GroupBy(x => x.CreateTime.Date).OrderBy(x => x.Key); var colList = new List <SumColumns> { new SumColumns { name = "日期", type = "日期" } }; var rowList = new List <object>(); var dicEnumNameValue = new Dictionary <string, string>(); if (inputParas.SpecialField.IsNotNullOrEmpty()) { var objEnum = type.GetProperty(inputParas.SpecialField); // IsEnum == true if (objEnum != null && objEnum.PropertyType.IsEnum) { var enumMembers = objEnum.PropertyType.GetFields().Where(x => x.IsLiteral); foreach (var item in enumMembers) { var enumItem = item.GetValue(null); dicEnumNameValue.Add(enumItem.GetDisplayName(), enumItem.ToString()); } } } if (inputParas.Fields.Count > 0) { foreach (var gItemList in gpListByDate) { var dic = new Dictionary <string, string> { { "日期", gItemList.Key.ToString("yyyy-MM-dd") } }; foreach (var fieldName in inputParas.Fields) { var fieldDispName = type.FullName.GetFiledDisplayName(fieldName); if (dicEnumNameValue.Count > 0) { foreach (var enumItem in dicEnumNameValue) { var keyName = $"{fieldDispName}[{enumItem.Key}]"; if (colList.Where(x => x.type == keyName).Count() < 1) { colList.Add(new SumColumns { name = keyName, type = keyName }); } var gListByEnum = WhereQuery(gItemList, inputParas.SpecialField, enumItem.Value) .ToList(); var rsSum = 0M; var prop = type.GetProperty(fieldName); foreach (var row in gListByEnum) { rsSum += prop.GetValue(row).ToDecimal(); } dic.Add(keyName, rsSum.ToString()); } } else { if (colList.Where(x => x.type == fieldDispName).Count() < 1) { colList.Add(new SumColumns { name = fieldDispName, type = fieldDispName }); } var prop = type.GetProperty(fieldName); var rsSum = 0M; foreach (var row in gItemList) { rsSum += prop.GetValue(row).ToDecimal(); } dic.Add(fieldName, rsSum.ToString()); } } rowList.Add(dic); } } var rsRowList = rowList.Skip((int)((inputParas.PageIndex - 1) * inputParas.PageSize)) .Take((int)inputParas.PageSize).ToList(); rsList.Add(new SumReportTable { Name = $"{inputParas.Type} SumTable 统计", SumReportTableItem = new SumReportTableItems { CurrentSize = inputParas.PageSize, PageIndex = inputParas.PageIndex, TotalCount = rowList.Count, PageCount = rowList.Count % inputParas.PageSize == 0 ? rowList.Count / inputParas.PageSize : rowList.Count / inputParas.PageSize + 1, PageSize = inputParas.PageSize, Columns = colList, Rows = rsRowList } }); return(rsList); }
public static List <AutoReport> GetSumReport(IEnumerable <TEntity> queryList, SumTableInput inputParas) { var rsList = new List <AutoReport>(); var type = typeof(TEntity); var gpListByDate = queryList.GroupBy(x => x.CreateTime.Date).OrderBy(x => x.Key); var colList = new List <string> { "日期" }; var rowList = new List <object>(); var dicEnumNameValue = new Dictionary <string, string>(); if (inputParas.SpecialField.IsNotNullOrEmpty()) { var objEnum = type.GetProperty(inputParas.SpecialField); // IsEnum == true if (objEnum != null && objEnum.PropertyType.IsEnum) { var enumMembers = objEnum.PropertyType.GetFields().Where(x => x.IsLiteral); foreach (var item in enumMembers) { var enumItem = item.GetValue(null); dicEnumNameValue.Add(enumItem.GetDisplayName(), enumItem.ToString()); } } } if (inputParas.Fields.Count > 0) { foreach (var gItemList in gpListByDate) { var dic = new Dictionary <string, string> { { "日期", gItemList.Key.ToString("yyyy-MM-dd") } }; foreach (var fieldName in inputParas.Fields) { var fieldDispName = type.FullName.GetFiledDisplayName(fieldName); if (dicEnumNameValue.Count > 0) { foreach (var enumItem in dicEnumNameValue) { var keyName = $"{fieldDispName}[{enumItem.Key}]"; if (colList.Where(x => x == keyName).Count() < 1) { colList.Add(keyName); } var gListByEnum = WhereQuery(gItemList, inputParas.SpecialField, enumItem.Value) .ToList(); var rsSum = 0M; var prop = type.GetProperty(fieldName); foreach (var row in gListByEnum) { rsSum += prop.GetValue(row).ToDecimal(); } dic.Add(keyName, rsSum.ToString()); } } else { if (!colList.Contains(fieldName)) { colList.Add(fieldName); } var prop = type.GetProperty(fieldName); var rsSum = 0M; foreach (var row in gItemList) { rsSum += prop.GetValue(row).ToDecimal(); } dic.Add(fieldName, rsSum.ToString()); } rowList.Add(dic); } } } rsList.Add(new AutoReport { Name = $"{inputParas.Type}SumReport统计", AutoReportChart = new AutoReportChart { // Type = ReportChartType.Line, Columns = colList, Rows = rowList } }); return(rsList); }
public PagedList <SumReportTable> GetSumReportTable(SumTableInput inputParas) { return(Store.GetSumReportTable(inputParas)); }
public List <AutoReport> GetSumReport(SumTableInput inputParas) { return(Store.GetSumReport(inputParas)); }