Selaa lähdekoodia

修复通话时段分析接口异常

qinchaoyue 5 kuukautta sitten
vanhempi
commit
a3add423bb

+ 8 - 5
src/Hotline.Repository.SqlSugar/CallCenter/CallNativeRepository.cs

@@ -36,10 +36,12 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
             dts.Add(dts.Last().AddHours(1));
         }
 
-        var list = await Db.Reportable(dts).ToQueryable<DateTime>()
+        Db.Ado.BeginTran();
+        Db.Ado.ExecuteCommand("SET max_stack_depth = '4MB';");
+        var query = Db.Reportable(dts).ToQueryable<DateTime>()
             .LeftJoin<CallNative>((it, o) => o.BeginIvrTime >= it.ColumnName && o.BeginIvrTime < it.ColumnName.AddHours(1) && o.Direction == ECallDirection.In && o.CallState != ECallState.Invalid)
              //.Where((it, o) => o.CallDirection == ECallDirection.In)
-             .WhereIF(!string.IsNullOrEmpty(source), (it, o) => o.ToNo == source)
+            .WhereIF(!string.IsNullOrEmpty(source), (it, o) => o.ToNo == source)
             .GroupBy((it, o) => it.ColumnName)
             .Select((it, o) => new TrCallHourDto()
             {
@@ -52,9 +54,10 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
                 IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(o.CallState == ECallState.IVRNoAccept, 1, 0)), //IVR挂断
             })
             .MergeTable()
-            .OrderBy(x => x.Hour)
-            .ToListAsync();
-
+            .OrderBy(x => x.Hour);
+        var sql = query.ToSqlString();
+        var list = await query.ToListAsync();
+        Db.Ado.CommitTran();
         var resultList = list.GroupBy(x => x.Hour)
              .Select(x => new TrCallHourDto()
              {