瀏覽代碼

通话统计修改开始时间字段

qinchaoyue 6 月之前
父節點
當前提交
6ef805d63d

+ 13 - 13
src/Hotline.Application/StatisticalReport/CallReport/CallReportApplicationBase.cs

@@ -88,12 +88,12 @@ public abstract class CallReportApplicationBase : ICallReportApplication
         int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
 
         var callData = await _callNativeRepository.Queryable()
-                .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime && p.CallState != ECallState.Invalid)
+                .Where(p => p.BeginIvrTime >= dto.StartTime && p.BeginIvrTime <= dto.EndTime && p.CallState != ECallState.Invalid)
                  .WhereIF(!string.IsNullOrEmpty(dto.Keyword), p => p.ToNo == dto.Keyword)
-                 .GroupBy(p => p.CreationTime.ToString("yyyy-MM-dd"))
+                 .GroupBy(p => p.BeginIvrTime.Value.ToString("yyyy-MM-dd"))
                 .Select(p => new QueryCallsDetailDto
                 {
-                    Date = p.CreationTime.ToString("yyyy-MM-dd"),
+                    Date = p.BeginIvrTime.Value.ToString("yyyy-MM-dd"),
                     InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
                     InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && (p.CallState == ECallState.Missed || p.CallState == ECallState.NotAcceptedHang || p.CallState == ECallState.IVRNoAccept || p.CallState == ECallState.On), 1, 0)),//呼入接通量
                     NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.RingDuration <= noConnectByeTimes && p.RingDuration > 0 && p.Direction == ECallDirection.In, 1, 0)), //未接通秒挂
@@ -123,10 +123,10 @@ public abstract class CallReportApplicationBase : ICallReportApplication
         var recordPrefix = _systemSettingCacheManager.RecordPrefix;
         var query = _callNativeRepository.Queryable()
                 .LeftJoin<Order>((p, o) => p.Id == o.CallId)
-                .Where((p, o) => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime && p.Direction == ECallDirection.In && p.CallState != ECallState.Invalid)
+                .Where((p, o) => p.BeginIvrTime >= dto.StartTime && p.BeginIvrTime <= dto.EndTime && p.Direction == ECallDirection.In && p.CallState != ECallState.Invalid)
                 .WhereIF(dto.TypeCode == "2", (p, o) => p.AnsweredTime != null)
                 .WhereIF(!string.IsNullOrEmpty(dto.Keyword), (p, o) => p.TelNo == dto.Keyword)
-                 .OrderByDescending((p, o) => p.CreationTime)
+                 .OrderByDescending((p, o) => p.BeginIvrTime)
                  .Select((p, o) => new CallRecordOutDto
                  {
                      OtherAccept = p.Id,
@@ -162,11 +162,11 @@ public abstract class CallReportApplicationBase : ICallReportApplication
         int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
 
         var callData = await _callNativeRepository.Queryable()
-                .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime && p.CallState != ECallState.Invalid)
-                .GroupBy(p => p.CreationTime.ToString("yyyy-MM-dd"))
+                .Where(p => p.BeginIvrTime >= dto.StartTime && p.BeginIvrTime <= dto.EndTime && p.CallState != ECallState.Invalid)
+                .GroupBy(p => p.BeginIvrTime.Value.ToString("yyyy-MM-dd"))
                 .Select(p => new QueryCallsDetailStatistics
                 {
-                    Date = p.CreationTime.ToString("yyyy-MM-dd"),
+                    Date = p.BeginIvrTime.Value.ToString("yyyy-MM-dd"),
                     //InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
                     InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, 1, 0)),//呼入接通量
                     NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.CallState == ECallState.NotAcceptedHang && p.Direction == ECallDirection.In, 1, 0)), //呼入队列挂断
@@ -218,7 +218,7 @@ public abstract class CallReportApplicationBase : ICallReportApplication
             .WhereIF(dto.ToNo.NotNullOrEmpty(), (c, o) => c.ToNo == dto.ToNo)
             .WhereIF(dto.TelNo.NotNullOrEmpty(), (c, o) => c.TelNo == dto.TelNo)
             .WhereIF(dto.EndBy.IsNotNull(), (c, o) => c.EndBy == dto.EndBy)
-            .Where((c, o) => c.CreationTime >= dto.StartTime && c.CreationTime <= dto.EndTime);
+            .Where((c, o) => c.BeginIvrTime >= dto.StartTime && c.BeginIvrTime <= dto.EndTime);
 
         if (dto.FieldName == "intotal") // 呼入总量
             query = query.Where((c, o) => c.Direction == ECallDirection.In);
@@ -254,8 +254,8 @@ public abstract class CallReportApplicationBase : ICallReportApplication
               .LeftJoin<CallNative>((u, c) => u.Id == c.UserId)
               .Where((u, c) => c.CallState != ECallState.Invalid)
               .Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
-              .Where((u, c) => c.CreationTime >= dto.StartTime)
-              .Where((u, c) => c.CreationTime <= dto.EndTime)
+              .Where((u, c) => c.BeginIvrTime >= dto.StartTime)
+              .Where((u, c) => c.BeginIvrTime <= dto.EndTime)
               .GroupBy((u, c) => new { c.UserName, c.UserId })
               .Select((u, c) => new BiSeatCallsDto
               {
@@ -297,8 +297,8 @@ public abstract class CallReportApplicationBase : ICallReportApplication
             .Where(x => !string.IsNullOrEmpty(x.AgentTransferNumber) && x.CallState != ECallState.Invalid)
             .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
             .WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.ToNo.Contains(dto.CDPN))
-            .Where(x => x.CreationTime >= dto.StartTime)
-            .Where(x => x.CreationTime <= dto.EndTime)
+            .Where(x => x.BeginIvrTime >= dto.StartTime)
+            .Where(x => x.BeginIvrTime <= dto.EndTime)
             .Select(x => new BiSeatSwitchDto
             {
                 UserId = x.UserId,

+ 11 - 11
src/Hotline.Repository.SqlSugar/CallCenter/CallNativeRepository.cs

@@ -37,7 +37,7 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
         }
 
         var list = await Db.Reportable(dts).ToQueryable<DateTime>()
-            .LeftJoin<CallNative>((it, o) => o.CreationTime >= it.ColumnName && o.CreationTime < it.ColumnName.AddHours(1) && o.Direction == ECallDirection.In)
+            .LeftJoin<CallNative>((it, o) => o.BeginIvrTime >= it.ColumnName && o.BeginIvrTime < it.ColumnName.AddHours(1) && o.Direction == ECallDirection.In)
              //.Where((it, o) => o.CallDirection == ECallDirection.In)
              .WhereIF(!string.IsNullOrEmpty(source), (it, o) => o.ToNo == source)
             .GroupBy((it, o) => it.ColumnName)
@@ -92,12 +92,12 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
         var listHour = Db.Reportable(dts).ToQueryable<int>();
 
         var list = Db.Queryable<CallNative>()
-              .Where(p => p.CreationTime >= beginDate && p.CreationTime <= endDate && p.CallState != ECallState.Invalid)
+              .Where(p => p.BeginIvrTime >= beginDate && p.BeginIvrTime <= endDate && p.CallState != ECallState.Invalid)
               .WhereIF(!string.IsNullOrEmpty(Line), p => p.TelNo == Line)
-               .GroupBy(p => p.CreationTime.Hour)
+               .GroupBy(p => p.BeginIvrTime.Value.Hour)
                .Select(p => new
                {
-                   Hour = p.CreationTime.Hour, //小时段
+                   Hour = p.BeginIvrTime.Value.Hour, //小时段
                    InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
                    InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, 1, 0)),//呼入接通量
                    NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.RingDuration <= noConnectByeTimes && p.RingDuration > 0 && p.Direction == ECallDirection.In, 1, 0)), //未接通秒挂
@@ -154,12 +154,12 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
         var listHour = Db.Reportable(dts).ToQueryable<int>();
 
         var list = Db.Queryable<CallNative>()
-             .Where(p => p.CreationTime >= beginDate && p.CreationTime <= endDate && p.Direction == ECallDirection.In && p.CallState != ECallState.Invalid)
+             .Where(p => p.BeginIvrTime >= beginDate && p.BeginIvrTime <= endDate && p.Direction == ECallDirection.In && p.CallState != ECallState.Invalid)
              .WhereIF(!string.IsNullOrEmpty(Line), p => p.ToNo == Line)
-           .GroupBy(p => p.CreationTime.Hour)
+           .GroupBy(p => p.BeginIvrTime.Value.Hour)
            .Select(p => new
            {
-               Hour = p.CreationTime.Hour, //小时段
+               Hour = p.BeginIvrTime.Value.Hour, //小时段
                Total = SqlFunc.AggregateCount(p.Id),
                Answered = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime != null, 1, 0)), //应答数
                Hanguped = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime == null && 
@@ -199,7 +199,7 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
         }
         RefAsync<int> total = 0;
         var res = await Db.Queryable<CallNative>()
-            .Where(x => x.CreationTime >= dto.StartTime && x.CreationTime <= dto.EndTime)
+            .Where(x => x.BeginIvrTime >= dto.StartTime && x.BeginIvrTime <= dto.EndTime)
             .Where(x => x.Direction == ECallDirection.In && x.CallState != ECallState.Invalid)
             .WhereIF(!string.IsNullOrEmpty(dto.Source), x => x.ToNo == dto.Source)
             .WhereIF(!string.IsNullOrEmpty(dto.Type) && ("QueueBye".Equals(dto.Type) || "queueByeCount".Equals(dto.Type)), x => x.CallState == ECallState.NotAcceptedHang) //队列挂断
@@ -214,13 +214,13 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
             || (x.Duration >= effectiveTimes)//有效接通
             || (x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.AnsweredTime == null) //IVR挂断
             || (x.WaitDuration > 0 && x.RingDuration == 0))//队列挂断
-            .WhereIF(dto.StartHourTo.HasValue, x => SqlFunc.ToTime(x.CreationTime.ToString("HH:mm:ss")) >= dto.StartHourTo.Value && SqlFunc.ToTime(x.CreationTime.ToString("HH:mm:ss")) < endHourTo)
+            .WhereIF(dto.StartHourTo.HasValue, x => SqlFunc.ToTime(x.BeginIvrTime.Value.ToString("HH:mm:ss")) >= dto.StartHourTo.Value && SqlFunc.ToTime(x.BeginIvrTime.Value.ToString("HH:mm:ss")) < endHourTo)
             .Select(x => new BiSeatSwitchDto
             {
                 Id = x.Id,
                 CPN = x.FromNo,
                 CDPN = x.ToNo,
-                CreatedTime = x.CreationTime
+                CreatedTime = x.BeginIvrTime.Value
             })
             .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
         return new TotalData<BiSeatSwitchDto>(res, total.Value);
@@ -229,7 +229,7 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
     public async Task<List<CallHotLineDto>> GetCallHotLineListAsync(BiQueryGateWayDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int ringTims)
     {
         var list = await Db.Queryable<CallNative>()
-            .Where(x => x.CreationTime >= dto.StartTime && x.CreationTime <= dto.EndTime && SqlFunc.Length(x.ToNo) > 4 && x.CallState != ECallState.Invalid)
+            .Where(x => x.BeginIvrTime >= dto.StartTime && x.BeginIvrTime <= dto.EndTime && SqlFunc.Length(x.ToNo) > 4 && x.CallState != ECallState.Invalid)
             .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.ToNo == dto.Gateway)
             .GroupBy(x => x.ToNo)
             .Select(x => new CallHotLineDto()