diff --git a/04.系统编码/App/Controllers/StatisticAnalysisController.cs b/04.系统编码/App/Controllers/StatisticAnalysisController.cs index ac6c12c..3834212 100644 --- a/04.系统编码/App/Controllers/StatisticAnalysisController.cs +++ b/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 pagination = ComputeBLL.Statistics(fromTime, toTime, page, rows); + Pagination pagination = ComputeBLL.Statistics(typeCode, fromTime, toTime, page, rows); return Json(pagination); } } diff --git a/04.系统编码/BLL/ComputeBLL.cs b/04.系统编码/BLL/ComputeBLL.cs index 2496e02..a878efb 100644 --- a/04.系统编码/BLL/ComputeBLL.cs +++ b/04.系统编码/BLL/ComputeBLL.cs @@ -6,9 +6,9 @@ namespace Pingchuan.BeijingSafeguard.BLL { public class ComputeBLL { - public static Pagination Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) + public static Pagination 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); } } } diff --git a/04.系统编码/DAL/ComputeDAL.cs b/04.系统编码/DAL/ComputeDAL.cs index 838d1ec..3f9b082 100644 --- a/04.系统编码/DAL/ComputeDAL.cs +++ b/04.系统编码/DAL/ComputeDAL.cs @@ -6,7 +6,15 @@ namespace Pingchuan.BeijingSafeguard.DAL { public class ComputeDAL : BaseDAL { - public static Pagination Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) + public static Pagination 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 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 page = db.Page(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize); return Pagination.FromPage(page); } + + public static Pagination 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 page = db.Page(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize); + return Pagination.FromPage(page); + } } } \ No newline at end of file