Browse Source

trcallrecord

Dun.Jason 10 months ago
parent
commit
7fd71c46d6

+ 31 - 2
src/Hotline.Api/Controllers/IPPbxController.cs

@@ -1,6 +1,7 @@
 using DotNetCore.CAP;
 using Hotline.Ai.Quality;
 using Hotline.Application.CallCenter.Calls;
+using Hotline.Application.Systems;
 using Hotline.Application.Tels;
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
@@ -59,7 +60,7 @@ namespace Hotline.Api.Controllers
         private readonly IRepository<QualityTemplate> _qualityTemplate;
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly IRepository<TelActionRecord> _telActionRecordRepository;
-
+        private readonly ISystemMobilAreaApplication _systemMobilAreaApplication;
 
         public IPPbxController(ITrClient trClient, IMapper mapper, IUserDomainService userDomainService,
             ISessionContext sessionContext, IRepository<TrCallRecord> trCallRecordRepository,
@@ -70,7 +71,8 @@ namespace Hotline.Api.Controllers
             ITelRestRepository telRestRepository, IRepository<User> userRepository,
             ITelApplication telApplication, IRepository<Quality.Quality> qualiteyRepository,
             IAiQualityService aiQualityService, IRepository<QualityTemplate> qualityTemplate, 
-            ISystemSettingCacheManager systemSettingCacheManager,IRepository<TelActionRecord> telActionRecordRepository)
+            ISystemSettingCacheManager systemSettingCacheManager,IRepository<TelActionRecord> telActionRecordRepository,
+            ISystemMobilAreaApplication systemMobilAreaApplication)
         {
             _trClient = trClient;
             _mapper = mapper;
@@ -93,6 +95,7 @@ namespace Hotline.Api.Controllers
             _qualityTemplate = qualityTemplate;
             _systemSettingCacheManager = systemSettingCacheManager;
             _telActionRecordRepository = telActionRecordRepository;
+            _systemMobilAreaApplication = systemMobilAreaApplication;
         }
 
         #region 添添呼
@@ -439,10 +442,32 @@ namespace Hotline.Api.Controllers
             if (model.CallDirection == ECallDirection.In)
             {
                 model.TelNo = model.CDPN;
+                try
+                {
+                    var areaModel = await _systemMobilAreaApplication.GetPhoneCardArea(model.CPN, HttpContext.RequestAborted);
+                    if (areaModel != null)
+                    {
+                        model.MobileAreaName = areaModel.MobileAreaName;
+                        model.OFlag = areaModel.OFlag;
+                        model.OperatorName = areaModel.OperatorName;
+                    }
+                }
+                catch{}
             }
             else
             {
                 model.TelNo = model.CPN;
+                try
+                {
+                    var areaModel = await _systemMobilAreaApplication.GetPhoneCardArea(model.CDPN, HttpContext.RequestAborted);
+                    if (areaModel != null)
+                    {
+                        model.MobileAreaName = areaModel.MobileAreaName;
+                        model.OFlag = areaModel.OFlag;
+                        model.OperatorName = areaModel.OperatorName;
+                    }
+                }
+                catch{}
             }
             //判断是否是内部通话(目前分机都为4位)
             if (model.CPN.Length==4 && model.CDPN.Length ==4) //是内部通话
@@ -453,6 +478,7 @@ namespace Hotline.Api.Controllers
             {
                 model.PhoneTypes = (EPhoneTypes)Convert.ToInt32(dto.phoneTypes);
             }
+            
 
             //获取关联 工单或是回访
             //var order = await _orderRepository.GetAsync(x => x.CallId == model.CallAccept, HttpContext.RequestAborted);//由CallAccept改为OtherAccept
@@ -593,6 +619,8 @@ namespace Hotline.Api.Controllers
                 .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.Gateway.Contains(dto.Gateway))
                 
                 .WhereIF(dto.IsAiAnswered == true,x=>string.IsNullOrEmpty(x.UserId) == true)
+
+                .WhereIF(dto.PhoneTypes!=null,x=>x.PhoneTypes == dto.PhoneTypes)
                 .OrderByDescending(x => x.CreatedTime)
                 .ToPagedListAsync(dto.PageIndex, dto.PageSize);
             return new PagedDto<TrCallDto>(total, _mapper.Map<IReadOnlyList<TrCallDto>>(items));
@@ -610,6 +638,7 @@ namespace Hotline.Api.Controllers
                 OnState = EnumExts.GetDescriptions<EOnState>(),
                 CallDirection = EnumExts.GetDescriptions<ECallDirection>(),
                 EndBy = EnumExts.GetDescriptions<EEndBy>(),
+                PhoneTypes = EnumExts.GetDescriptions<EPhoneTypes>()
             };
         }
 

+ 0 - 94
src/Hotline.Api/Controllers/SysController.cs

@@ -590,99 +590,5 @@ namespace Hotline.Api.Controllers
 
         #endregion
 
-        /// <summary>
-        ///  获取电话号码归属地和手机号码卡类型
-        /// </summary>
-        /// <param name="PhoneNum"></param>
-        /// <returns></returns>
-        [HttpGet("getphonecardarea")]
-        public async Task<SystemMobilAreaDto> GetPhoneCardArea(string PhoneNum)
-        {
-            SystemMobilAreaDto areaDto = new SystemMobilAreaDto();
-            if (true == string.IsNullOrEmpty(PhoneNum) || PhoneNum.Length < 6)
-            {
-                return areaDto;
-            }
-
-            // 验证电话号码是否是手机号码
-            bool bCheckMobile = e_VerificationMobile(PhoneNum);
-            // 电话归属编码
-            string strPhoneCode = "";
-            if (bCheckMobile)
-            {
-                // 手机号码第一位是否是0
-                if (PhoneNum.Substring(0, 1) == "0")
-                    strPhoneCode = PhoneNum.Substring(1, 7);
-                else
-                    strPhoneCode = PhoneNum.Substring(0, 7);
-
-                var data = await _systemMobilAreaRepository.GetAsync(p => p.MobileCode.Trim() == strPhoneCode, HttpContext.RequestAborted);
-                if (data != null)
-                {
-                    areaDto.OFlag = data.OFlag == "1" ? "电信" : data.OFlag == "2" ? "移动" : "联通";
-                    areaDto.MobileAreaName = data.MobileAreaName;
-                    areaDto.OperatorName = data.OperatorName;
-                }
-            }
-            else
-            {
-                // 验证电话号码是否是座机号码
-                bCheckMobile = e_VerificationTel(PhoneNum);
-                if (true == bCheckMobile)
-                {
-                    strPhoneCode = PhoneNum.Substring(0, 3);
-
-                    SystemMobilArea data = await _systemMobilAreaRepository.GetAsync(p => p.TelCode.Trim() == strPhoneCode, HttpContext.RequestAborted);
-                    if (data == null)
-                    {
-                        strPhoneCode = PhoneNum.Substring(0, 4);
-                        data = await _systemMobilAreaRepository.GetAsync(p => p.TelCode.Trim() == strPhoneCode, HttpContext.RequestAborted);
-                    }
-                    
-                    if (data != null)
-                    {
-                        areaDto.MobileAreaName = data.MobileAreaName;
-                    }
-                }
-            }
-            return areaDto;
-        }
-
-        #region 验证手机号码
-        /// <summary>
-        /// 验证手机号码
-        /// </summary>
-        /// <param name="strPhoneNum">电话号码</param>
-        /// <returns></returns>
-        public static bool e_VerificationMobile(string strPhoneNum)
-        {
-            // 手机号码正则表达式
-            string strVer = @"^(0)?(13\d|15\d|18\d|17\d|14\d|19\d|16\d)\d{5}(\d{3}|\*{3})$";
-            Regex regex = new Regex(strVer);
-            if (true == regex.IsMatch(strPhoneNum))
-                return true;
-            else
-                return false;
-        }
-        #endregion
-
-        #region 验证座机号码
-        /// <summary>
-        /// 验证座机号码
-        /// </summary>
-        /// <param name="strPhoneNum">电话号码</param>
-        /// <returns></returns>
-        public static bool e_VerificationTel(string strPhoneNum)
-        {
-            // 座机号码正则表达式
-            string strVer = @"^((0\d{2,3})(-)?)?(\d{7,8})(-(\d{3,}))?$";
-            Regex regex = new Regex(strVer);
-            if (true == regex.IsMatch(strPhoneNum))
-                return true;
-            else
-                return false;
-        }
-        #endregion
-
     }
 }

+ 14 - 0
src/Hotline.Application/Systems/ISystemMobilAreaApplication.cs

@@ -0,0 +1,14 @@
+using Hotline.Share.Dtos.Settings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Application.Systems
+{
+    public interface ISystemMobilAreaApplication
+    {
+        Task<SystemMobilAreaDto> GetPhoneCardArea(string PhoneNum,CancellationToken cancellationToken);
+    }
+}

+ 112 - 0
src/Hotline.Application/Systems/SystemMobilAreaApplication.cs

@@ -0,0 +1,112 @@
+using Hotline.Settings;
+using Hotline.Share.Dtos.Settings;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using XF.Domain.Repository;
+
+namespace Hotline.Application.Systems
+{
+    public class SystemMobilAreaApplication : ISystemMobilAreaApplication
+    {
+        private readonly IRepository<SystemMobilArea> _systemMobilAreaRepository;
+
+        public SystemMobilAreaApplication(IRepository<SystemMobilArea> systemMobilAreaRepository)
+        {
+            _systemMobilAreaRepository = systemMobilAreaRepository;
+        }
+
+        public async Task<SystemMobilAreaDto> GetPhoneCardArea(string PhoneNum, CancellationToken cancellationToken)
+        {
+            SystemMobilAreaDto areaDto = new SystemMobilAreaDto();
+            if (true == string.IsNullOrEmpty(PhoneNum) || PhoneNum.Length < 6)
+            {
+                return areaDto;
+            }
+
+            // 验证电话号码是否是手机号码
+            bool bCheckMobile = e_VerificationMobile(PhoneNum);
+            // 电话归属编码
+            string strPhoneCode = "";
+            if (bCheckMobile)
+            {
+                // 手机号码第一位是否是0
+                if (PhoneNum.Substring(0, 1) == "0")
+                    strPhoneCode = PhoneNum.Substring(1, 7);
+                else
+                    strPhoneCode = PhoneNum.Substring(0, 7);
+
+                var data = await _systemMobilAreaRepository.GetAsync(p => p.MobileCode.Trim() == strPhoneCode, cancellationToken);
+                if (data != null)
+                {
+                    areaDto.OFlag = data.OFlag == "1" ? "电信" : data.OFlag == "2" ? "移动" : "联通";
+                    areaDto.MobileAreaName = data.MobileAreaName;
+                    areaDto.OperatorName = data.OperatorName;
+                }
+            }
+            else
+            {
+                // 验证电话号码是否是座机号码
+                bCheckMobile = e_VerificationTel(PhoneNum);
+                if (true == bCheckMobile)
+                {
+                    strPhoneCode = PhoneNum.Substring(0, 3);
+
+                    var data = await _systemMobilAreaRepository.GetAsync(p => p.TelCode.Trim() == strPhoneCode, cancellationToken);
+                    if (data == null)
+                    {
+                        strPhoneCode = PhoneNum.Substring(0, 4);
+                        data = await _systemMobilAreaRepository.GetAsync(p => p.TelCode.Trim() == strPhoneCode, cancellationToken);
+                    }
+
+                    if (data != null)
+                    {
+                        areaDto.MobileAreaName = data.MobileAreaName;
+                    }
+                }
+            }
+            return areaDto;
+        }
+
+
+        #region 验证手机号码
+        /// <summary>
+        /// 验证手机号码
+        /// </summary>
+        /// <param name="strPhoneNum">电话号码</param>
+        /// <returns></returns>
+        public static bool e_VerificationMobile(string strPhoneNum)
+        {
+            // 手机号码正则表达式
+            string strVer = @"^(0)?(13\d|15\d|18\d|17\d|14\d|19\d|16\d)\d{5}(\d{3}|\*{3})$";
+            Regex regex = new Regex(strVer);
+            if (true == regex.IsMatch(strPhoneNum))
+                return true;
+            else
+                return false;
+        }
+        #endregion
+
+        #region 验证座机号码
+        /// <summary>
+        /// 验证座机号码
+        /// </summary>
+        /// <param name="strPhoneNum">电话号码</param>
+        /// <returns></returns>
+        public static bool e_VerificationTel(string strPhoneNum)
+        {
+            // 座机号码正则表达式
+            string strVer = @"^((0\d{2,3})(-)?)?(\d{7,8})(-(\d{3,}))?$";
+            Regex regex = new Regex(strVer);
+            if (true == regex.IsMatch(strPhoneNum))
+                return true;
+            else
+                return false;
+        }
+        #endregion
+    }
+}

+ 3 - 3
src/Hotline.Share/Dtos/Settings/SystemMobilAreaDto.cs

@@ -5,16 +5,16 @@
         /// <summary>
         /// 归属地
         /// </summary>
-        public string MobileAreaName { get; set; }
+        public string? MobileAreaName { get; set; }
 
         /// <summary>
         /// 运营商
         /// </summary>
-        public string OFlag { get; set; }
+        public string? OFlag { get; set; }
 
         /// <summary>
         /// 卡类型
         /// </summary>
-        public string OperatorName { get; set; }
+        public string? OperatorName { get; set; }
     }
 }

+ 20 - 0
src/Hotline.Share/Dtos/TrCallCenter/TrTelDao.cs

@@ -544,6 +544,11 @@ namespace Hotline.Share.Dtos.TrCallCenter
         /// </summary>
         public bool IsAiAnswered { get; set; }
 
+        /// <summary>
+        /// 电话类型
+        /// </summary>
+        public EPhoneTypes? PhoneTypes { get; set; }
+
     }
 
 
@@ -717,6 +722,21 @@ namespace Hotline.Share.Dtos.TrCallCenter
         /// </summary>
         public OrderDto Order { get; set; }
 
+        /// <summary>
+        /// 归属地
+        /// </summary>
+        public string? MobileAreaName { get; set; }
+
+        /// <summary>
+        /// 运营商
+        /// </summary>
+        public string? OFlag { get; set; }
+
+        /// <summary>
+        /// 卡类型
+        /// </summary>
+        public string? OperatorName { get; set; }
+
         #endregion
     }
 

+ 15 - 0
src/Hotline/CallCenter/Calls/TrCallRecord.cs

@@ -173,6 +173,21 @@ namespace Hotline.CallCenter.Calls
         /// </summary>
         public EPhoneTypes? PhoneTypes { get; set; }
 
+        /// <summary>
+        /// 归属地
+        /// </summary>
+        public string? MobileAreaName { get; set; }
+
+        /// <summary>
+        /// 运营商
+        /// </summary>
+        public string? OFlag { get; set; }
+
+        /// <summary>
+        /// 卡类型
+        /// </summary>
+        public string? OperatorName { get; set; }
+
         #endregion
     }
 }