using Furion.DynamicApiController; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Nirvana.Common.ApiBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YBDevice.Application.ReportInfo { /// /// 统计报表 /// [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] public class ReportAppService : IDynamicApiController { private readonly IReportService _Service; public ReportAppService(IReportService Service) { _Service = Service; } /// /// 获取日统计数据 /// /// /// /// [QueryParameters] public async Task GetListAsync(DateTime? starttime, DateTime? endtime) { var result= await _Service.GetListAsync(starttime, endtime); var resultlist = new List(); var reglist = new List(); var devlist = new List(); var timelist = new List(); var incomelist = new List(); result.ForEach(x => { resultlist.Add(x.DayResultCnt); reglist.Add(x.DayRegCnt); devlist.Add(x.DayDevCnt); timelist.Add(x.Time); incomelist.Add(x.DayInCome); }); return new ResultInfo(ResultState.SUCCESS, "success", new { resultlist = resultlist, timelist = timelist, devlist = devlist, incomelist = incomelist }); } /// /// 获取指定设备统计数据 /// /// /// /// /// [QueryParameters] public async Task GetDevListAsync(int id,DateTime? starttime, DateTime? endtime) { var result = await _Service.GetDevListAsync(id,starttime, endtime); var resultlist = new List(); var reglist = new List(); var devlist = new List(); var timelist = new List(); var incomelist = new List(); result.ForEach(x => { resultlist.Add(x.DayResultCnt); reglist.Add(x.DayRegCnt); devlist.Add(x.DayDevCnt); timelist.Add(x.Time); incomelist.Add(x.DayInCome); }); return new ResultInfo(ResultState.SUCCESS, "success", new { resultlist = resultlist, timelist = timelist, devlist = devlist, incomelist = incomelist }); } } }