Bläddra i källkod

Merge branch 'dev' of http://110.188.24.182:10023/Fengwo/hotline into dev

tangjiang 6 månader sedan
förälder
incheckning
427c6ccf18

+ 38 - 0
src/Hotline.Application.Contracts/Validators/CallCenter/StartEndTimeDtoValidator.cs

@@ -0,0 +1,38 @@
+using FluentValidation;
+using Hotline.Share.Dtos.CallCenter;
+using Hotline.Share.Requests;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Application.Contracts.Validators.CallCenter;
+
+
+public class StartEndTimeDtoValidator : AbstractValidator<StartEndTimeDto>
+{
+    public StartEndTimeDtoValidator()
+    {
+        RuleFor(d => d.StartTime).NotEmpty();
+        RuleFor(d => d.EndTime).NotEmpty();
+    }
+}
+
+public class ReportRequiredPagedRequestValidator : AbstractValidator<ReportRequiredPagedRequest>
+{
+    public ReportRequiredPagedRequestValidator()
+    {
+        RuleFor(d => d.StartTime).NotEmpty();
+        RuleFor(d => d.EndTime).NotEmpty();
+    }
+}
+
+public class QueryCallListDtoValidator : AbstractValidator<QueryCallListDto>
+{
+    public QueryCallListDtoValidator()
+    {
+        RuleFor(d => d.StartTime).NotEmpty();
+        RuleFor(d => d.EndTime).NotEmpty();
+    }
+}

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

@@ -210,6 +210,7 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
             .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)
             .Select(x => new BiSeatSwitchDto
             {
+                Id = x.Id,
                 CPN = x.FromNo,
                 CDPN = x.ToNo,
                 CreatedTime = x.CreationTime
@@ -221,12 +222,12 @@ 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.TelNo) > 4)
-            .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.TelNo == dto.Gateway)
-            .GroupBy(x => x.TelNo)
+            .Where(x => x.CreationTime >= dto.StartTime && x.CreationTime <= dto.EndTime && SqlFunc.Length(x.ToNo) > 4)
+            .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.ToNo == dto.Gateway)
+            .GroupBy(x => x.ToNo)
             .Select(x => new CallHotLineDto()
             {
-                GateWay = x.TelNo,
+                GateWay = x.ToNo,
                 CallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Direction == ECallDirection.In, 1, 0)),//接通
                 ConnectCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Direction == ECallDirection.In && x.AnsweredTime != null, 1, 0)),//接通
                 NoConnectByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Direction == ECallDirection.In && x.Duration == 0 && x.RingDuration <= noConnectByeTimes && x.RingDuration > 0, 1, 0)), //未接通秒挂

+ 8 - 32
src/Hotline.Share/Dtos/CallCenter/BiQueryCallsDto.cs

@@ -3,28 +3,8 @@ using System.ComponentModel.DataAnnotations;
 
 namespace Hotline.Share.Dtos.CallCenter;
 
-public record BiQueryCallsDto : ReportPagedRequest
+public record BiQueryCallsDto : ReportRequiredPagedRequest
 {
-    /// <summary>
-    /// 开始时间
-    /// </summary>
-    [Required(ErrorMessage = "开始时间不能为空")]
-    public override DateTime? StartTime
-    {
-        get { return base.StartTime ?? throw new InvalidOperationException("开始时间不能为空"); }
-        set { base.StartTime = value; }
-    }
-
-    /// <summary>
-    /// 结束时间
-    /// </summary>
-    [Required(ErrorMessage = "结束时间不能为空")]
-    public override DateTime? EndTime
-    {
-        get { return base.EndTime ??  throw new InvalidOperationException("结束时间不能为空"); }
-        set { base.EndTime = value; }
-    }
-
     /// <summary>
     /// 线路
     /// </summary>
@@ -38,32 +18,28 @@ public record BiQueryCallsDto : ReportPagedRequest
 
 public record QueryCallListDto : PagedRequest
 {
-    [Required(ErrorMessage = "开始时间不能为空")]
     public DateTime StartTime { get; set; }
-    [Required(ErrorMessage = "结束时间不能为空")]
     public DateTime EndTime { get; set; }
     public string Type { get; set; }
     public string Source { get; set; }
     public TimeSpan? StartHourTo { get; set; }
 }
 
-public class BiQueryHourCallDto
+public class BiQueryHourCallDto : StartEndTimeDto
 {
 
-    public DateTime StartTime { get; set; }
-
-    [Required(ErrorMessage = "结束时间不能为空")]
-    public DateTime EndTime { get; set; }
     public string Source { get; set; }
 }
 
-public class BiQueryGateWayDto
+public class BiQueryGateWayDto : StartEndTimeDto
 {
-    public DateTime StartTime { get; set; }
+    public string Gateway { get; set; }
+}
 
+public class StartEndTimeDto
+{
+    public DateTime StartTime { get; set; }
     public DateTime EndTime { get; set; }
-
-    public string Gateway { get; set; }
 }
 
 public class TotalList<T>

+ 6 - 23
src/Hotline.Share/Requests/PagedKeywordRequest.cs

@@ -10,12 +10,12 @@ public record PagedKeywordRequest : PagedRequest
     /// <summary>
     /// 开始时间
     /// </summary>
-    public virtual DateTime? StartTime { get; set; }
+    public DateTime? StartTime { get; set; }
 
     /// <summary>
     /// 结束时间
     /// </summary>
-    public virtual DateTime? EndTime { get; set; }
+    public DateTime? EndTime { get; set; }
 
     public string? Keyword { get; set; }
 
@@ -86,35 +86,18 @@ public record ReportPagedRequest : PagedKeywordRequest
     public int? TypeId { get; set; }
 }
 
+/// <summary>
+/// 验证了 startTime 和 endTime 不能为空;
+/// <inheritdoc cref="ReportRequiredPagedRequestValidator"/>
+/// </summary>
 public record ReportRequiredPagedRequest : PagedKeywordRequest
 {
-    /// <summary>
-    /// 开始时间
-    /// </summary>
-    [Required(ErrorMessage = "开始时间不能为空")]
-    public override DateTime? StartTime
-    {
-        get { return base.StartTime ?? throw new InvalidOperationException("开始时间不能为空"); }
-        set { base.StartTime = value; }
-    }
-
-    /// <summary>
-    /// 结束时间
-    /// </summary>
-    [Required(ErrorMessage = "结束时间不能为空")]
-    public override DateTime? EndTime
-    {
-        get { return base.EndTime ?? throw new InvalidOperationException("结束时间不能为空"); }
-        set { base.EndTime = value; }
-    }
-
     /// <summary>
     /// 来电/信人身份0:全部 ,1:市民,2:企业
     /// </summary>
     public int? TypeId { get; set; }
 }
 
-
 public record OrgDataListDetailRequest : PagedRequest
 {
     /// <summary>