Dun.Jason 1 жил өмнө
parent
commit
1b0e2f6079

+ 68 - 0
src/Hotline.Api/Controllers/Bi/BiOrderController.cs

@@ -30,6 +30,7 @@ namespace Hotline.Api.Controllers.Bi
         private readonly IRepository<OrderSpecial> _orderSpecialRepository;
 		private readonly IRepository<OrderVisit> _orderVisitRepository;
 
+
 		public BiOrderController(
 			IOrderRepository orderRepository,
 			IRepository<Hotspot> hotspotTypeRepository,
@@ -591,6 +592,73 @@ namespace Hotline.Api.Controllers.Bi
 			return list;
         }
 
+		/// <summary>
+		/// 热点类型小类统计
+		/// </summary>
+		/// <param name="StartDate"></param>
+		/// <param name="EndDate"></param>
+		/// <param name="TypeId">0:全部 ,1:市民,2:企业</param>
+		/// <returns></returns>
+		[HttpGet("hotspot-statistics")]
+		public async Task<object> HotspotStatistics(DateTime StartDate,DateTime EndDate,int TypeId,string? HotspotCode)
+		{
+            EndDate = EndDate.AddDays(1).AddSeconds(-1);
+
+
+			if (string.IsNullOrEmpty(HotspotCode))
+			{
+                var list = await _hotspotTypeRepository.Queryable()
+                .LeftJoin<Order>((it, o) => it.Id == o.HotspotId)
+                .Where((it, o) => o.StartTime >= StartDate && o.StartTime <= EndDate && o.Id!=null)
+                .GroupBy((it, o) => new { Id = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")) })
+                .Select((it, o) => new
+                {
+                    HotspotCode = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")),
+                    SumCount = SqlFunc.AggregateCount(it.HotSpotName)
+                })
+				.MergeTable()
+				.LeftJoin<Hotspot>((x,q)=> x.HotspotCode == q.Id)
+				.Select((x, q) => new {
+                    HotspotCode = x.HotspotCode,
+                    SumCount = x.SumCount,
+					HotspotName = q.HotSpotName
+                })
+				.ToListAsync();
+
+				return list;
+            }
+			else
+			{
+				string count = (HotspotCode.Length + 2).ToString();
+				string countx = HotspotCode.Length.ToString();
+                var list = await _hotspotTypeRepository.Queryable()
+                .LeftJoin<Order>((it, o)=> it.Id == o.HotspotId)
+                .Where((it, o) => o.StartTime >= StartDate && o.StartTime <= EndDate && it.ParentId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(countx)) == HotspotCode)
+                .GroupBy((it, o) => new { Id = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(count)) })
+                .Select((it, o) => new
+                {
+                    HotspotCode = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(count)),
+                    SumCount = SqlFunc.AggregateCount(it.HotSpotName)
+                })
+				.MergeTable()
+				.LeftJoin<Hotspot>((x, q) => x.HotspotCode == q.Id)
+				.Select((x, q) => new
+				{
+					HotspotCode = x.HotspotCode,
+					SumCount = x.SumCount,
+					HotspotName = q.HotSpotName
+				})
+				.ToListAsync();
+                return list;
+
+            }
+        }
+
+
+
+
+
+
         /// <summary>
         /// 部门满意度统计
         /// </summary>

+ 2 - 2
src/Hotline.Repository.SqlSugar/Extensions/SqlSugarStartupExtensions.cs

@@ -207,8 +207,8 @@ namespace Hotline.Repository.SqlSugar.Extensions
             /***写AOP等方法***/
             db.Aop.OnLogExecuting = (sql, pars) =>
             {
-                //Log.Information("Sql: {0}", sql);
-                //Log.Information("SqlParameters: {0}", string.Join(',', pars.Select(d => d.Value)));
+                Log.Information("Sql: {0}", sql);
+                Log.Information("SqlParameters: {0}", string.Join(',', pars.Select(d => d.Value)));
             };
             db.Aop.OnError = (exp) =>//SQL报错
             {