diff --git a/04.系统编码/App/Controllers/StatisticAnalysisController.cs b/04.系统编码/App/Controllers/StatisticAnalysisController.cs index 3834212..9cb8bd4 100644 --- a/04.系统编码/App/Controllers/StatisticAnalysisController.cs +++ b/04.系统编码/App/Controllers/StatisticAnalysisController.cs @@ -8,7 +8,6 @@ namespace Pingchuan.BeijingSafeguard.App.Controllers { public class StatisticAnalysisController : BaseController { - // GET: StatisticAnalysis public ActionResult Index() { return View(); @@ -17,7 +16,7 @@ namespace Pingchuan.BeijingSafeguard.App.Controllers [HttpPost] public JsonResult Query(string typeCode, DateTime fromTime, DateTime toTime, int page, int rows) { - Pagination pagination = ComputeBLL.Statistics(typeCode, fromTime, toTime, page, rows); + Pagination pagination = TaskBLL.Statistics(typeCode, fromTime, toTime, page, rows); return Json(pagination); } } diff --git a/04.系统编码/BLL/BLL.csproj b/04.系统编码/BLL/BLL.csproj index fe1c026..3383447 100644 --- a/04.系统编码/BLL/BLL.csproj +++ b/04.系统编码/BLL/BLL.csproj @@ -46,7 +46,6 @@ - diff --git a/04.系统编码/BLL/ComputeBLL.cs b/04.系统编码/BLL/ComputeBLL.cs deleted file mode 100644 index a878efb..0000000 --- a/04.系统编码/BLL/ComputeBLL.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Pingchuan.BeijingSafeguard.DAL; -using Pingchuan.BeijingSafeguard.Model; - -namespace Pingchuan.BeijingSafeguard.BLL -{ - public class ComputeBLL - { - public static Pagination Statistics(string typeCode, DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) - { - return ComputeDAL.Statistics(typeCode, fromTime, toTime, pageIndex, pageSize); - } - } -} diff --git a/04.系统编码/BLL/TaskBLL.cs b/04.系统编码/BLL/TaskBLL.cs index ce258ef..00cb08c 100644 --- a/04.系统编码/BLL/TaskBLL.cs +++ b/04.系统编码/BLL/TaskBLL.cs @@ -30,6 +30,11 @@ namespace Pingchuan.BeijingSafeguard.BLL return TaskDAL.GetTaskIdByRegion(region); } + public static Pagination Statistics(string typeCode, DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) + { + return TaskDAL.Statistics(typeCode, fromTime, toTime, pageIndex, pageSize); + } + public static Task ToModel(int userId, string taskId, string region, decimal longitude, decimal latitude, decimal height, decimal simulatedDuration, decimal simulatedInterval, DateTime releaseTime, int resultState, string resultMessage) { return new Task diff --git a/04.系统编码/DAL/ComputeDAL.cs b/04.系统编码/DAL/ComputeDAL.cs deleted file mode 100644 index 7868e84..0000000 --- a/04.系统编码/DAL/ComputeDAL.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using PetaPoco; -using Pingchuan.BeijingSafeguard.Model; - -namespace Pingchuan.BeijingSafeguard.DAL -{ - public class ComputeDAL : BaseDAL - { - public static Pagination 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 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 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, 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 page = db.Page(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize); - return Pagination.FromPage(page); - } - } -} \ No newline at end of file diff --git a/04.系统编码/DAL/DAL.csproj b/04.系统编码/DAL/DAL.csproj index 83c42d1..9d17df4 100644 --- a/04.系统编码/DAL/DAL.csproj +++ b/04.系统编码/DAL/DAL.csproj @@ -50,7 +50,6 @@ - diff --git a/04.系统编码/DAL/TaskDAL.cs b/04.系统编码/DAL/TaskDAL.cs index d848707..be2c16d 100644 --- a/04.系统编码/DAL/TaskDAL.cs +++ b/04.系统编码/DAL/TaskDAL.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; +using PetaPoco; using Pingchuan.BeijingSafeguard.Model; namespace Pingchuan.BeijingSafeguard.DAL @@ -47,5 +48,38 @@ namespace Pingchuan.BeijingSafeguard.DAL where c.user_id = {userId} and c.region = '{regionCode}' and c.release_time >= '{startTime}' and c.release_time < '{endTime}' order by c.release_time desc"; } + + public static Pagination 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 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 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, 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 page = db.Page(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize); + return Pagination.FromPage(page); + } } } \ No newline at end of file