提交代码
This commit is contained in:
parent
ec23f1ddad
commit
2d5d89d987
|
|
@ -37,4 +37,16 @@ public class MonitorController : CloudGamingControllerBase
|
|||
{
|
||||
return await new MonitorBLL(ServiceProvider).GetActiveUserCount(startTimeStamp, endTimeStamp);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取每小时统计
|
||||
/// </summary>
|
||||
/// <param name="startTimeStamp"></param>
|
||||
/// <param name="endTimeStamp"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetAppMonitorHourAsync([FromQuery] long startTimeStamp = 0, [FromQuery] long endTimeStamp = 0)
|
||||
{
|
||||
return await new MonitorBLL(ServiceProvider).GetAppMonitorHourAsync(startTimeStamp, endTimeStamp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using CloudGaming.Code.DataAccess;
|
||||
using CloudGaming.DtoModel.Other;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
|
@ -7,6 +8,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using static SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.CreateNewTaxControlFapiaoApplicationRequest.Types.Fapiao.Types;
|
||||
|
|
@ -112,10 +114,58 @@ public class MonitorBLL : CloudGamingBase
|
|||
/// 获取近一月登录人数统计
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task GetLoginUserCount()
|
||||
public async Task<dynamic> GetAppMonitorHourAsync(long startTimeStamp = 0, long endTimeStamp = 0)
|
||||
{
|
||||
if (endTimeStamp == 0)
|
||||
{
|
||||
endTimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
}
|
||||
if (startTimeStamp == 0)
|
||||
{
|
||||
startTimeStamp = DateTimeOffset.UtcNow.AddHours(-24).ToUnixTimeSeconds();
|
||||
}
|
||||
//开始时间
|
||||
var startDate = DateTimeOffset.FromUnixTimeSeconds(startTimeStamp).ToLocalTime().DateTime;
|
||||
//结束时间
|
||||
var endDate = DateTimeOffset.FromUnixTimeSeconds(endTimeStamp).ToLocalTime().DateTime;
|
||||
var curr = startDate;
|
||||
var list = await Dao.DaoExt.Context.T_App_Channel.Where(it => !string.IsNullOrEmpty(it.ChannelId)).Select(it => it.ChannelId).ToListAsync();
|
||||
int startDateHour = int.Parse(startDate.ToString("yyyyMMddHH"));
|
||||
int endDateHour = int.Parse(endDate.ToString("yyyyMMddHH"));
|
||||
var userStatisticsList = await Dao.DaoExt.Context.T_Statistics_UserHour.Where(it => it.LoginHour >= startDateHour && it.LoginHour <= endDateHour).ToListAsync();
|
||||
List<StatisticsDto> userLogin = new List<StatisticsDto>();
|
||||
List<StatisticsDto> userRegistr = new List<StatisticsDto>();
|
||||
while (curr <= endDate)
|
||||
{
|
||||
var loginAll = GetStatisticsDto(curr, "全部", 0);
|
||||
var registrAll = GetStatisticsDto(curr, "全部", 0);
|
||||
userLogin.Add(loginAll);
|
||||
userRegistr.Add(registrAll);
|
||||
int dayHour = int.Parse(curr.ToString("yyyyMMddHH"));
|
||||
foreach (var channelId in list)
|
||||
{
|
||||
var statis = userStatisticsList.FirstOrDefault(it => it.LoginHour == dayHour && it.Channel == channelId);
|
||||
var _loginCount = statis?.LoginCount ?? 0;
|
||||
var _registrCount = statis?.RegistrCount ?? 0;
|
||||
loginAll.Value += _loginCount;
|
||||
registrAll.Value += _registrCount;
|
||||
userLogin.Add(GetStatisticsDto(curr, channelId, _loginCount));
|
||||
userRegistr.Add(GetStatisticsDto(curr, channelId, _registrCount));
|
||||
}
|
||||
curr = curr.AddHours(1);
|
||||
}
|
||||
return new { Login = userLogin, Registr = userRegistr };
|
||||
|
||||
}
|
||||
private StatisticsDto GetStatisticsDto(DateTime curr, string channelId, int count)
|
||||
{
|
||||
return new StatisticsDto()
|
||||
{
|
||||
Category = channelId,
|
||||
TimeStamp = curr.ToString("dd-HH"),
|
||||
Value = count
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取近一月注册人数统计
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user