7 changed files with 40 additions and 60 deletions
@ -1,14 +0,0 @@ |
|||||
using System; |
|
||||
using Pingchuan.BeijingSafeguard.DAL; |
|
||||
using Pingchuan.BeijingSafeguard.Model; |
|
||||
|
|
||||
namespace Pingchuan.BeijingSafeguard.BLL |
|
||||
{ |
|
||||
public class ComputeBLL |
|
||||
{ |
|
||||
public static Pagination<Statistic> Statistics(string typeCode, DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) |
|
||||
{ |
|
||||
return ComputeDAL.Statistics(typeCode, fromTime, toTime, pageIndex, pageSize); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,42 +0,0 @@ |
|||||
using System; |
|
||||
using PetaPoco; |
|
||||
using Pingchuan.BeijingSafeguard.Model; |
|
||||
|
|
||||
namespace Pingchuan.BeijingSafeguard.DAL |
|
||||
{ |
|
||||
public class ComputeDAL : BaseDAL |
|
||||
{ |
|
||||
public static Pagination<Statistic> Statistics(string typeCode, DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) |
|
||||
{ |
|
||||
if (typeCode == "user") |
|
||||
return UserStatistics(fromTime, toTime, pageIndex, pageSize); |
|
||||
else if (typeCode == "org") |
|
||||
return OrgStatistics(fromTime, toTime, pageIndex, pageSize); |
|
||||
else |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public static Pagination<Statistic> UserStatistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) |
|
||||
{ |
|
||||
string sql = $@"select temp.*, u.real_name user_name, o.id org_id, o.name org_name, o.name org_name2 from (
|
|
||||
select user_id, count(*) compute_count, max(create_time) last_compute_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); |
|
||||
} |
|
||||
|
|
||||
public static Pagination<Statistic> OrgStatistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) |
|
||||
{ |
|
||||
string sql = $@"select temp.*, o.name org_name, o.name org_name2 from (
|
|
||||
select org_id, count(*) compute_count, max(create_time) last_compute_time from computes |
|
||||
where create_time >= @0 and create_time < @1 |
|
||||
group by org_id) temp |
|
||||
left join orgs o on o.id = temp.org_id";
|
|
||||
Page<Statistic> page = db.Page<Statistic>(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize); |
|
||||
return Pagination<Statistic>.FromPage(page); |
|
||||
} |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue