Browse Source

Update

master
fanwensheng 3 years ago
parent
commit
008d6045a8
  1. 4
      04.系统编码/App/Controllers/StatisticAnalysisController.cs
  2. 4
      04.系统编码/BLL/ComputeBLL.cs
  3. 21
      04.系统编码/DAL/ComputeDAL.cs

4
04.系统编码/App/Controllers/StatisticAnalysisController.cs

@ -15,9 +15,9 @@ namespace Pingchuan.BeijingSafeguard.App.Controllers
}
[HttpPost]
public JsonResult Query(DateTime fromTime, DateTime toTime, int page, int rows)
public JsonResult Query(string typeCode, DateTime fromTime, DateTime toTime, int page, int rows)
{
Pagination<Statistic> pagination = ComputeBLL.Statistics(fromTime, toTime, page, rows);
Pagination<Statistic> pagination = ComputeBLL.Statistics(typeCode, fromTime, toTime, page, rows);
return Json(pagination);
}
}

4
04.系统编码/BLL/ComputeBLL.cs

@ -6,9 +6,9 @@ namespace Pingchuan.BeijingSafeguard.BLL
{
public class ComputeBLL
{
public static Pagination<Statistic> Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize)
public static Pagination<Statistic> Statistics(string typeCode, DateTime fromTime, DateTime toTime, int pageIndex, int pageSize)
{
return ComputeDAL.Statistics(fromTime, toTime, pageIndex, pageSize);
return ComputeDAL.Statistics(typeCode, fromTime, toTime, pageIndex, pageSize);
}
}
}

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

@ -6,7 +6,15 @@ namespace Pingchuan.BeijingSafeguard.DAL
{
public class ComputeDAL : BaseDAL
{
public static Pagination<Statistic> Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize)
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
return OrgStatistics(fromTime, toTime, pageIndex, pageSize);
}
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 from (
select user_id, count(*) compute_count, max(create_time) last_compute_time from computes
@ -17,5 +25,16 @@ namespace Pingchuan.BeijingSafeguard.DAL
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 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…
Cancel
Save