Browse Source

Update

master
fanwensheng 3 years ago
parent
commit
f9c4159374
  1. 13
      04.系统编码/DAL/ComputeDAL.cs
  2. 5
      04.系统编码/DAL/UserDAL.cs
  3. 9
      04.系统编码/Model/Statistic.cs

13
04.系统编码/DAL/ComputeDAL.cs

@ -8,11 +8,14 @@ namespace Pingchuan.BeijingSafeguard.DAL
{
public static Pagination<Statistic> Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize)
{
string sql = $@"select user_id, count(*) total_count, max(create_time) last_time from computes
where create_time >= @0 and create_time <= @1
group by user_id";
Page<Statistic> page = db.Page<Statistic>(pageIndex, pageSize, sql, pageIndex, pageSize);
string sql = $@"select temp.*, u.real_name user_name, o.id org_id, o.name org_name from (
select user_id, count(*) total_count, max(create_time) last_time from computes
where create_time >= @0 and create_time < @1
group by user_id) temp
left join users u on u.id = temp.user_id
left join orgs o on o.id = u.id";
Page<Statistic> page = db.Page<Statistic>(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize);
return Pagination<Statistic>.FromPage(page);
}
}
}
}

5
04.系统编码/DAL/UserDAL.cs

@ -46,9 +46,10 @@ namespace Pingchuan.BeijingSafeguard.DAL
public static Pagination<UserDTO> Query(int orgId, int pageIndex, int pageSize)
{
string condition = orgId == 0 ? string.Empty : $"where org_id = {orgId}";
string sql = $@"select u.*, o.name org_name from users u {condition}
string condition = orgId == 0 ? string.Empty : $"where u.org_id = {orgId}";
string sql = $@"select u.*, o.name org_name from users u
left join orgs o on o.id = u.org_id
{condition}
order by u.create_time desc";
Page<UserDTO> users = db.Page<UserDTO>(pageIndex, pageSize, sql);
return Pagination<UserDTO>.FromPage(users);

9
04.系统编码/Model/Statistic.cs

@ -8,6 +8,15 @@ namespace Pingchuan.BeijingSafeguard.Model
[Column("user_id")]
public int UserId { get; set; }
[Column("user_name")]
public string UserName { get; set; }
[Column("org_id")]
public int OrgId { get; set; }
[Column("org_name")]
public string OrgName { get; set; }
[Column("compute_count")]
public int ComputeCount { get; set; }

Loading…
Cancel
Save