ZiGongCallReportApplicationTest.cs 6.8 KB

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