瀏覽代碼

callrecord

Jason 1 年之前
父節點
當前提交
94d1e17cf4

+ 0 - 2
src/Hotline.Api/Controllers/OrderController.cs

@@ -470,7 +470,6 @@ public class OrderController : BaseController
 
     #endregion
 
-
     #region 工单甄别
 
    
@@ -478,7 +477,6 @@ public class OrderController : BaseController
 
     #endregion
 
-
     #region 工单督办
 
 

+ 2 - 2
src/Hotline.Api/Controllers/TestController.cs

@@ -102,8 +102,8 @@ public class TestController : BaseController
     [HttpGet("time")]
     public async Task<OpenResponse> GetTime()
     {
-        var tests = _uowWex.Db.Ado.SqlQuery<Test>("select * from view_telinfo_full where IsSynch=@IsSynch", new { IsSynch = 0 });
-
+        //var tests = _uowWex.Db.Ado.SqlQuery<Test>("select * from view_telinfo_full where IsSynch=@IsSynch", new { IsSynch = 0 });
+        //var a = _uowWex.Db.Ado.ExecuteCommand("update telinfo set IsSynch=1 where GUID=@CallId", new { CallId = "b1f97f3c-88b6-4f42-b8de-83ed448854b0" });
         //var rsp = await _wexClient.QueryTelsAsync(new QueryTelRequest {  }, HttpContext.RequestAborted);
 
         return OpenResponse.Ok(DateTime.Now.ToString("F"));

+ 125 - 17
src/Hotline.Application/CallCenter/Calls/CallRecordManager.cs

@@ -1,5 +1,6 @@
 using Hotline.CallCenter.Calls;
 using Hotline.Repository.SqlSugar;
+using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Logging;
@@ -10,32 +11,139 @@ namespace Hotline.Application.CallCenter
     public class CallRecordManager : BackgroundService
     {
         private readonly IServiceScopeFactory _serviceScopeFactory;
-        private readonly ISugarUnitOfWork<WexDbContext> _uowWex;
 
         public CallRecordManager(IServiceScopeFactory serviceScopeFactory,ISugarUnitOfWork<WexDbContext> uowWex)
         {
             _serviceScopeFactory = serviceScopeFactory;
-            _uowWex = uowWex;
         }
 
 
-
-        protected override Task ExecuteAsync(CancellationToken stoppingToken)
+        //TODO
+        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
         {
             //20秒扫描一次威尔信数据库
-            using var sc = _serviceScopeFactory.CreateScope();
-            var _logger = sc.ServiceProvider.GetService<ILogger<CallRecordManager>>();
-            var time = TimeSpan.FromSeconds(20);
-            while (!stoppingToken.IsCancellationRequested)
-            {
-                using var scope = _serviceScopeFactory.CreateScope();
-                var _wexCallRecordRepository = scope.ServiceProvider.GetService<IWexCallRecordRepository>();
-
-
-
-            }
-
-            throw new NotImplementedException();
+            //using var sc = _serviceScopeFactory.CreateScope();
+            //var _logger = sc.ServiceProvider.GetService<ILogger<CallRecordManager>>();
+            //var time = TimeSpan.FromSeconds(20);
+            //while (!stoppingToken.IsCancellationRequested)
+            //{
+            //    using var scope = _serviceScopeFactory.CreateScope();
+            //    var _wexCallRecordRepository = scope.ServiceProvider.GetService<IWexCallRecordRepository>();
+            //    var _uowWex = scope.ServiceProvider.GetService<ISugarUnitOfWork<WexDbContext>>();
+            //    var wexRes = _uowWex?.Db.Ado.SqlQuery<WexRecord>("select * from view_telinfo_full where IsSynch=@IsSynch and IsOk = @IsOk ", new { IsSynch = 0, IsOk = 1 });
+            //    if(wexRes !=null)
+            //    {
+            //        foreach (var item in wexRes)
+            //        {
+            //            var wexCallRecord = new WexCallRecord();
+            //            wexCallRecord.CallId = item.CallId;
+            //            //呼叫方向
+            //            switch (item.CallType)
+            //            {
+            //                case "外呼":
+            //                    wexCallRecord.Direction = Share.Enums.CallCenter.ECallDirection.Out;
+            //                    break;
+            //                case "来电":
+            //                    wexCallRecord.Direction = Share.Enums.CallCenter.ECallDirection.In;
+            //                    break;
+            //                case "中继":
+            //                    wexCallRecord.Direction = Share.Enums.CallCenter.ECallDirection.In;
+            //                    break;
+            //                case "留言":
+            //                    wexCallRecord.Direction = Share.Enums.CallCenter.ECallDirection.In;
+            //                    break;
+            //                case "黑名单":
+            //                    wexCallRecord.Direction = Share.Enums.CallCenter.ECallDirection.In;
+            //                    break;
+            //                default:
+            //                    break;
+            //            }
+            //            if (wexCallRecord.Direction == Share.Enums.CallCenter.ECallDirection.Out)
+            //            {
+            //                //TODO
+            //                wexCallRecord.CPN = "";
+            //                wexCallRecord.CDPN = "";
+            //            }
+            //            else
+            //            {
+            //                //TODO
+            //                wexCallRecord.CPN = "";
+            //                wexCallRecord.CDPN = "";
+            //            }
+            //            wexCallRecord.StaffNo = item.GongHao;
+            //            wexCallRecord.AreaName = item.AreaName;
+            //            wexCallRecord.InIvrTime = item.BeginIvrTime;
+            //            wexCallRecord.OutIvrTime = item.EndIvrTime;
+            //            wexCallRecord.InQueueTime = item.BeginQueueTime;
+            //            wexCallRecord.OutQueueTime = item.EndQueueTime;
+            //            wexCallRecord.BeginTime = item.CallTime;
+            //            wexCallRecord.BeginRingTime = item.BeginRingTime;
+            //            wexCallRecord.EndRingTime = item.EndRingTime;
+            //            wexCallRecord.RingTimes = item.RingTimes;
+            //            wexCallRecord.AnsweredTime = item.BeginTalking;
+            //            wexCallRecord.ByeTime = item.EndTalking;
+            //            wexCallRecord.TalkTime = item.TalkLength;
+            //            wexCallRecord.RecordUrl = item.RecordUrl;
+            //            wexCallRecord.RecordName = item.RecordName;
+            //            wexCallRecord.SourceRecord = item.SourceRecord;
+            //            switch (item.NoAnswerResult)
+            //            {
+            //                case "客户先挂机":
+
+            //                    break;
+            //                case "外呼挂机":
+
+            //                    break;
+            //                case "员工先挂机":
+
+            //                    break;
+            //                case "坐席振铃挂机":
+
+            //                    break;
+            //                case "对端振铃挂机":
+
+            //                    break;
+            //                case "自助语音挂机":
+
+            //                    break;
+            //                case "排队挂机":
+
+            //                    break;
+            //                case "中继转接挂机":
+
+            //                    break;
+            //                case "来电挂机":
+
+            //                    break;
+            //                case "开始转人工挂机":
+
+            //                    break;
+            //                case "电话广播":
+
+            //                    break;
+            //                case "播放工号":
+
+            //                    break;
+            //                default:
+            //                    wexCallRecord.EndBy = Share.Enums.CallCenter.EEndBy.From;
+            //                    break;
+            //            }
+            //            wexCallRecord.Result = item.Result;
+            //            wexCallRecord.EvaluateResult = item.AssessName;
+
+            //            var id = await _wexCallRecordRepository.AddAsync(wexCallRecord);
+            //            if(!string.IsNullOrEmpty(id))
+            //            {
+            //                //执行更新已下载数据
+            //                _uowWex?.Db.Ado.ExecuteCommand("update telinfo set IsSynch=1 where GUID=@CallId", new { CallId = wexCallRecord.CallId });
+            //            }
+            //        }
+            //    }
+            //    else
+            //    {
+            //        await Task.Delay(time, stoppingToken);
+            //    }
+            //}
         }
 
 

+ 24 - 3
src/Hotline/CallCenter/Calls/WexCallRecord.cs

@@ -6,6 +6,12 @@ namespace Hotline.CallCenter.Calls
 {
     public class WexCallRecord:CreationEntity
     {
+        /// <summary>
+        /// 通话记录ID(外部主键)
+        /// </summary>
+        public string CallId { get; set; }
+
+
         /// <summary>
         /// 电话方向
         /// </summary>
@@ -65,12 +71,17 @@ namespace Hotline.CallCenter.Calls
         /// <summary>
         /// 开始时间
         /// </summary>
-        public DateTime BeginTime { get; set; }
+        public DateTime? BeginTime { get; set; }
+
+        /// <summary>
+        /// 振铃开始时间
+        /// </summary>
+        public DateTime? BeginRingTime { get; set; }
 
         /// <summary>
-        /// 振铃时间
+        /// 振铃结束时间
         /// </summary>
-        public DateTime? RingTime { get; set; }
+        public DateTime? EndRingTime { get; set; }
 
         /// <summary>
         /// 振铃时长
@@ -97,6 +108,11 @@ namespace Hotline.CallCenter.Calls
         /// </summary>
         public string RecordUrl { get; set; }
 
+        /// <summary>
+        /// 录音本地路径
+        /// </summary>
+        public string RecordName { get; set; }
+
         /// <summary>
         /// 录音相对路径
         /// </summary>
@@ -113,6 +129,11 @@ namespace Hotline.CallCenter.Calls
         /// </summary>
         public EEndBy EndBy { get; set; }
 
+        /// <summary>
+        /// 成功or失败
+        /// </summary>
+        public string Result { get; set; }
+
 
         /// <summary>
         /// 评价结果