diff --git a/04.系统编码/App/Controllers/StatisticAnalysisController.cs b/04.系统编码/App/Controllers/StatisticAnalysisController.cs index e7400f0..ca5ac46 100644 --- a/04.系统编码/App/Controllers/StatisticAnalysisController.cs +++ b/04.系统编码/App/Controllers/StatisticAnalysisController.cs @@ -15,10 +15,10 @@ namespace Pingchuan.BeijingSafeguard.App.Controllers } [HttpPost] - public JsonResult Query(int pageIndex, int pageSize) + public JsonResult Query(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) { - Pagination users = UserBLL.Query(pageIndex, pageSize); - return Json(users); + Pagination page = ComputeBLL.Statistics(fromTime, toTime, pageIndex, pageSize); + return Json(page); } } } \ No newline at end of file diff --git a/04.系统编码/BLL/BLL.csproj b/04.系统编码/BLL/BLL.csproj index 282e602..12bf80e 100644 --- a/04.系统编码/BLL/BLL.csproj +++ b/04.系统编码/BLL/BLL.csproj @@ -46,6 +46,7 @@ + diff --git a/04.系统编码/BLL/ComputeBLL.cs b/04.系统编码/BLL/ComputeBLL.cs new file mode 100644 index 0000000..2496e02 --- /dev/null +++ b/04.系统编码/BLL/ComputeBLL.cs @@ -0,0 +1,14 @@ +using System; +using Pingchuan.BeijingSafeguard.DAL; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.BLL +{ + public class ComputeBLL + { + public static Pagination Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) + { + return ComputeDAL.Statistics(fromTime, toTime, pageIndex, pageSize); + } + } +} diff --git a/04.系统编码/BLL/UserBLL.cs b/04.系统编码/BLL/UserBLL.cs index 41fd277..5b2a2fa 100644 --- a/04.系统编码/BLL/UserBLL.cs +++ b/04.系统编码/BLL/UserBLL.cs @@ -42,5 +42,6 @@ namespace Pingchuan.BeijingSafeguard.BLL { return UserDAL.Query(pageIndex, pageSize); } + } } \ No newline at end of file diff --git a/04.系统编码/DAL/ComputeDAL.cs b/04.系统编码/DAL/ComputeDAL.cs new file mode 100644 index 0000000..d66da2b --- /dev/null +++ b/04.系统编码/DAL/ComputeDAL.cs @@ -0,0 +1,18 @@ +using System; +using PetaPoco; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.DAL +{ + public class ComputeDAL : BaseDAL + { + public static Pagination 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 page = db.Page(pageIndex, pageSize, sql, pageIndex, pageSize); + return Pagination.FromPage(page); + } + } +} diff --git a/04.系统编码/DAL/DAL.csproj b/04.系统编码/DAL/DAL.csproj index 8bf2b30..7e15c99 100644 --- a/04.系统编码/DAL/DAL.csproj +++ b/04.系统编码/DAL/DAL.csproj @@ -50,6 +50,7 @@ + diff --git a/04.系统编码/Model/Model.csproj b/04.系统编码/Model/Model.csproj index 5f77f3b..ed24aea 100644 --- a/04.系统编码/Model/Model.csproj +++ b/04.系统编码/Model/Model.csproj @@ -51,6 +51,7 @@ + diff --git a/04.系统编码/Model/Statistic.cs b/04.系统编码/Model/Statistic.cs new file mode 100644 index 0000000..e0ddd8d --- /dev/null +++ b/04.系统编码/Model/Statistic.cs @@ -0,0 +1,17 @@ +using System; +using PetaPoco; + +namespace Pingchuan.BeijingSafeguard.Model +{ + public class Statistic + { + [Column("user_id")] + public int UserId { get; set; } + + [Column("compute_count")] + public int ComputeCount { get; set; } + + [Column("last_compute_time")] + public DateTime LastComputeTime { get; set; } + } +}