ZiGongCallReportApplicationTest.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using Hotline.Application.StatisticalReport.CallReport;
  2. using Hotline.Caching.Interfaces;
  3. using Hotline.Share.Dtos.CallCenter;
  4. using Hotline.Share.Enums.CallCenter;
  5. using Hotline.Share.Requests;
  6. using Hotline.Share.Tools;
  7. using Shouldly;
  8. using SqlSugar.Extensions;
  9. namespace Hotline.Tests.Application;
  10. public class ZiGongCallReportApplicationTest
  11. {
  12. private readonly ZiGongCallReportApplication _ziGongCallReportApplication;
  13. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  14. public ZiGongCallReportApplicationTest(ZiGongCallReportApplication ziGongCallReportApplication, ISystemDicDataCacheManager systemDicDataCacheManager)
  15. {
  16. _ziGongCallReportApplication = ziGongCallReportApplication;
  17. _systemDicDataCacheManager = systemDicDataCacheManager;
  18. }
  19. [Fact]
  20. public async Task QueryCallsDetailInTotal_Test()
  21. {
  22. var inDto = new BiQueryCallsDto
  23. {
  24. StartTime = "2024-10-30".ObjToDate(),
  25. EndTime = "2024-10-30 23:59:59".ObjToDate()
  26. };
  27. var (total, items) = await _ziGongCallReportApplication.QueryCallsDetailInTotalAsync(inDto, false);
  28. total.ShouldNotBe(0);
  29. }
  30. [Fact]
  31. public async Task QuerySeatCall_Test()
  32. {
  33. var inDto = new ReportRequiredPagedRequest
  34. {
  35. StartTime = "2024-06-01".ObjToDate(),
  36. EndTime = DateTime.Now
  37. };
  38. var result = await _ziGongCallReportApplication.QuerySeatCallAsync(inDto, CancellationToken.None);
  39. result.ShouldNotBeNull();
  40. }
  41. [Theory]
  42. [InlineData(null, null, null, null)]
  43. [InlineData(null, "19136073037", null, null)]
  44. [InlineData(null, null, "67387546", null)]
  45. [InlineData("20240805000001", null, null, null)]
  46. [InlineData(null, null, null, "From")]
  47. public async Task QueryCallsStatisticsDetail_Test(string? orderNo, string? fromNo, string? toNo, string? endBy)
  48. {
  49. return;
  50. var inDto = new QueryCallsStatisticsDetailInDto
  51. {
  52. StartTime = "2024-10-30".ObjToDate(),
  53. EndTime = "2024-10-30 23:59:59".ObjToDate(),
  54. OrderNo = orderNo,
  55. FromNo = fromNo,
  56. ToNo = toNo,
  57. EndBy = endBy?.ToEnum<EEndBy>()
  58. };
  59. var (total, items) = await _ziGongCallReportApplication.QueryCallsStatisticsDetailAsync(inDto, CancellationToken.None);
  60. total.ShouldNotBe(0);
  61. items.Any(m => m.OrderNo.NotNullOrEmpty()).ShouldBeTrue();
  62. items.Any(m => m.OrderTitle.NotNullOrEmpty()).ShouldBeTrue();
  63. if (fromNo != null)
  64. items.Any(m => m.FromNo != fromNo).ShouldBeFalse();
  65. if (toNo != null)
  66. items.Any(m => m.ToNo != toNo).ShouldBeFalse();
  67. if (orderNo != null)
  68. items.Any(m => m.OrderNo != orderNo).ShouldBeFalse();
  69. if (endBy != null)
  70. items.Any(m => m.EndBy != inDto.EndBy).ShouldBeFalse();
  71. }
  72. [Theory]
  73. [InlineData()]
  74. public async Task QueryCallsDetailStatistics_Test()
  75. {
  76. var inDto = new StartEndTimeDto
  77. {
  78. StartTime = "2024-07-29".ObjToDate(),
  79. EndTime = "2024-07-29 23:59:59".ObjToDate(),
  80. };
  81. var result = await _ziGongCallReportApplication.QueryCallsDetailStatisticsAsync(inDto, CancellationToken.None);
  82. result.Any(m => m.InConnectionRate.IsNullOrEmpty()).ShouldBeFalse();
  83. result.ShouldNotBeNull();
  84. }
  85. /// <summary>
  86. /// 测试通话时段分析中的数量是否和通话时段明细表中的数量是否相等
  87. /// </summary>
  88. /// <returns></returns>
  89. [Fact]
  90. public async Task HourCall_Test()
  91. {
  92. var inDto = new BiQueryHourCallDto
  93. {
  94. StartTime = "2024-10-30 00:00:00".ObjToDate(),
  95. EndTime = "2024-10-30 23:59:59".ObjToDate()
  96. };
  97. var hourList = await _ziGongCallReportApplication.GetCallHourListAsync(inDto, CancellationToken.None);
  98. var hour = hourList.Where(m => m.Hour == 7).FirstOrDefault();
  99. var bInDto = new QueryCallListDto
  100. {
  101. Type = "effectiveCount",
  102. PageIndex = 1,
  103. PageSize = 20,
  104. StartHourTo = TimeSpan.Parse("07:00"),
  105. StartTime = "2024-10-30 00:00:00".ObjToDate(),
  106. EndTime = "2024-10-30 23:59:59".ObjToDate()
  107. };
  108. var bhour = await _ziGongCallReportApplication.GetCallListAsync(bInDto, CancellationToken.None);
  109. bhour.Total.ShouldBe(hour.EffectiveCount, "effectiveCount 列表和详情的数量对不上");
  110. hour = hourList.Where(m => m.Hour == 12).FirstOrDefault();
  111. bInDto = new QueryCallListDto
  112. {
  113. Type = "connectByeCount",
  114. PageIndex = 1,
  115. PageSize = 20,
  116. StartHourTo = TimeSpan.Parse("12:00"),
  117. StartTime = "2024-10-30 00:00:00".ObjToDate(),
  118. EndTime = "2024-10-30 23:59:59".ObjToDate()
  119. };
  120. bhour = await _ziGongCallReportApplication.GetCallListAsync(bInDto, CancellationToken.None);
  121. bhour.Total.ShouldBe(hour.ConnectByeCount, "connectByeCount 列表和详情的数量对不上");
  122. hour = hourList.Where(m => m.Hour == 9).FirstOrDefault();
  123. bInDto = new QueryCallListDto
  124. {
  125. Type = "noConnectByeCount",
  126. PageIndex = 1,
  127. PageSize = 20,
  128. StartHourTo = TimeSpan.Parse("9:00"),
  129. StartTime = "2024-10-30 00:00:00".ObjToDate(),
  130. EndTime = "2024-10-30 23:59:59".ObjToDate()
  131. };
  132. bhour = await _ziGongCallReportApplication.GetCallListAsync(bInDto, CancellationToken.None);
  133. bhour.Total.ShouldBe(hour.NoConnectByeCount, "noConnectByeCount 列表和详情的数量对不上");
  134. hour = hourList.Where(m => m.Hour == 6).FirstOrDefault();
  135. bInDto = new QueryCallListDto
  136. {
  137. Type = "count",
  138. PageIndex = 1,
  139. PageSize = 20,
  140. StartHourTo = TimeSpan.Parse("06:00"),
  141. StartTime = "2024-10-30 00:00:00".ObjToDate(),
  142. EndTime = "2024-10-30 23:59:59".ObjToDate()
  143. };
  144. bhour = await _ziGongCallReportApplication.GetCallListAsync(bInDto, CancellationToken.None);
  145. bhour.Total.ShouldBe(hour.Count, "Count 列表和详情的数量对不上");
  146. }
  147. [Fact]
  148. public async Task GetCallHotLineList_Test()
  149. {
  150. var dto = new BiQueryGateWayDto
  151. {
  152. StartTime = DateTime.Now.AddMonths(-1),
  153. EndTime = DateTime.Now
  154. };
  155. var result = await _ziGongCallReportApplication.GetCallHotLineListAsync(dto, CancellationToken.None);
  156. var hotlines = _systemDicDataCacheManager.CallForwardingSource.Select(m => m.DicDataValue).ToList();
  157. result.Any(m => !hotlines.Contains(m.GateWay)).ShouldBeFalse();
  158. }
  159. }