Эх сурвалжийг харах

Merge branch 'master' of http://110.188.24.182:10023/Fengwo/hotline

xf 1 жил өмнө
parent
commit
09f16a2dc6

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

@@ -262,8 +262,8 @@ namespace Hotline.Api.Controllers
                 .Includes(x => x.AiOrderVisitDetails, s => s.Order)
                 .Includes(x => x.AiOrderVisitDetails, s => s.OrderVisit, q => q.OrderVisitDetails)
                 .FirstAsync(x => x.Id == id);
-            //TODO
-            //await _aiVisitService.CreateAiOrderVisitTask(pushModel, HttpContext.RequestAborted);
+            
+            await _aiVisitService.CreateAiOrderVisitTask(pushModel, HttpContext.RequestAborted);
         }
 
         #endregion

+ 1 - 1
src/Hotline.Api/Controllers/Bi/BiOrderController.cs

@@ -76,7 +76,7 @@ namespace Hotline.Api.Controllers.Bi
             var query = _orderRepository.Queryable(false, false, false)
                 .WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
                 .WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
-                //.WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => o.Name.Contains(dto.Keyword!))
+                .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.AcceptorName.Contains(dto.Keyword!))
                 .GroupBy(x => new { x.AcceptorId, x.AcceptorName })
                 .Select(x => new OrderBiCentreDataListVo
                 {

+ 4 - 1
src/Hotline.Api/StartupExtensions.cs

@@ -24,6 +24,7 @@ using Hotline.DataSharing;
 using System.Runtime.CompilerServices;
 using Hotline.Ai.Jths;
 using Hotline.Api.Sdk;
+using Hotline.YbEnterprise.Sdk;
 
 namespace Hotline.Api;
 
@@ -102,7 +103,9 @@ internal static class StartupExtensions
 		services.AddAiJths(configuration.GetSection("AiQuality").Get<AiQualityConfig>().Url);
 
         //宜宾企业服务
-        services.AddYbEnterpriseSdk("", "", "", "");
+        var enterpriseConfig = configuration.GetSection("Enterprise").Get<EnterpriseConfig>();
+
+		services.AddYbEnterpriseSdk(enterpriseConfig);
 
         var aiVisitConfig = configuration.GetSection("AiVisit").Get<AiVisitConfig>();
         services.AddAiVisitService(aiVisitConfig.Url, aiVisitConfig.Appkey, aiVisitConfig.ServiceVersion, aiVisitConfig.SceneUid, aiVisitConfig.RuleUid);

+ 12 - 4
src/Hotline.Api/config/appsettings.Development.json

@@ -197,10 +197,6 @@
       "token6_sm2_private": "QNTPy2nPBe2JY308G0LHO4r42iomDWcdedf81FapkWA=",
       "token6_sm4": "BKNpLwBCT2MvXwhLRcZ6FoMm4GaXs6LXqVmEa5hMJ3d9G+vC/5j7xtQh9HRKIfSfXkDQI0EQS7UR4inEXks/AnKsLYGhmhRjyzM7AGpEsujr2vJTwcwIWpBmpuc7k0uBQ34bN+kopafIo5UVyk7rIek=",
       "token6_sm4_mw": "2938d7acb2754a09"
-    },
-    //智能质检
-    "AiQuality": {
-      "Url": ""
     }
   },
   //智能回访
@@ -210,6 +206,18 @@
     "ServiceVersion": "V1.0.0", //接口版本号
     "SceneUid": "MTAwMDAxX0T7BfPTIqh8biWrOf58", //场景ID
     "RuleUid": "MTAwMDAxSGdDJryoQUgoDeiKlsTEyc" //现有规则ID
+  },
+  //智能质检
+  "AiQuality": {
+    "Url": ""
+  },
+  //企业服务
+  "Enterprise": {
+    "AddressUrl": "http://10.12.185.227:8834/",
+    "ClientId": "1462598736",
+    "ClientSecret": "6nZtVK4rKfnsncGymUHB",
+    "TenantId": "000000"
   }
 
+
 }

+ 3 - 0
src/Hotline.Share/Dtos/Ai/AiDto.cs

@@ -72,6 +72,7 @@ namespace Hotline.Share.Dtos.Ai
 
     public class AiOrderVisitDto
     {
+        public string Id { get; set; }
         public string Name { get; set; }
 
         public DateTime BeginTime { get; set; }
@@ -119,6 +120,8 @@ namespace Hotline.Share.Dtos.Ai
         public int VisitedFailCount { get; set; }
 
         public DateTime CreationTime { get; set; }
+
+        public string? CreatorName { get; set; }
     }
 
     public class AiOrderVisitDetailDto

+ 38 - 0
src/Hotline.Share/Dtos/EnterpriseDto.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Dtos
+{
+	public class EnterpriseVo 
+	{
+		/// <summary>
+		/// access_token
+		/// </summary>
+		[JsonPropertyName("access_token")]
+		public string AccessToken { get; set; }
+
+		/// <summary>
+		/// 
+		/// </summary>
+		[JsonPropertyName("refresh_token")]
+		public string RefreshToken { get; set; }
+
+		/// <summary>
+		/// token类型
+		/// </summary>
+		[JsonPropertyName("token_type")]
+		public string TokenType { get; set; }
+
+		/// <summary>
+		/// token有效期,单位秒
+		/// </summary>
+		[JsonPropertyName("expires_in")]
+		public string ExpiresIn { get; set; }
+
+		public DateTime? EndTime { get; set; }
+	}
+}

+ 19 - 0
src/Hotline.YbEnterprise.Sdk/EnterpriseConfig.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.YbEnterprise.Sdk
+{
+	public class EnterpriseConfig
+	{
+		public string AddressUrl { get; set; }
+
+		public string ClientId { get; set; }
+
+		public string ClientSecret { get; set; }
+
+		public string TenantId { get; set; }
+	}
+}

+ 248 - 0
src/Hotline.YbEnterprise.Sdk/EnterpriseService.cs

@@ -0,0 +1,248 @@
+using Hotline.Enterprise;
+using Hotline.Share.Dtos;
+using Microsoft.AspNetCore.Mvc.Formatters;
+using RestSharp;
+using System.Collections;
+using System.Text;
+using XF.Domain.Cache;
+using XF.Domain.Exceptions;
+
+namespace Hotline.YbEnterprise.Sdk
+{
+	public class EnterpriseService : IEnterpriseService
+	{
+		private readonly RestClient _client;
+		private readonly EnterpriseConfig _config;
+		private readonly ITypedCache<EnterpriseVo> _cacheResponse;
+
+		public EnterpriseService(EnterpriseConfig config)
+		{
+			_client = new RestClient();
+			_config = config;
+		}
+
+		/// <summary>
+		/// 获取企业列表
+		/// </summary>
+		/// <param name="name"></param>
+		/// <param name="current"></param>
+		/// <param name="size"></param>
+		/// <param name="cancellationToken"></param>
+		/// <returns></returns>
+		public async Task<EnterpriseListData> GetEnterpriseList(string name = "", int current = 1, int size = 10, CancellationToken cancellationToken =default)
+		{
+			var request = new EnterpriseListRequest
+			{
+				EnterpriseName = name,
+				Current = current,
+				Size = size
+			};
+			var  token  = await _cacheResponse.GetAsync("EnterpriseResponse", cancellationToken);
+			if (token != null && token.EndTime > DateTime.Now) 
+			{
+				token = await GetTokenAsync(cancellationToken);
+				token.EndTime = DateTime.Now.AddMinutes(45);
+				await _cacheResponse.SetAsync("EnterpriseResponse",token, cancellationToken: cancellationToken);
+			}
+			var path = _config.AddressUrl + "platform/12345/selectEnterpriseList";
+			var rest = new RestRequest(path, Method.Post);
+			rest.AddHeader("content-type", "application/json");
+			rest.AddHeader("Blade-Auth", "application/json");
+			var res = await ExecuteAsync<EnterpriseListRequest, EnterpriseListResponse>(path, Method.Post, request, rest, cancellationToken);
+			return res.data;
+		}
+
+		/// <summary>
+		/// 获取TOKEN
+		/// </summary>
+		/// <param name="cancellationToken"></param>
+		/// <returns></returns>
+		/// <exception cref="UserFriendlyException"></exception>
+		public async Task<EnterpriseVo> GetTokenAsync(CancellationToken cancellationToken) {
+
+			string authorization = _config.ClientId + ":" + _config.ClientSecret;
+			authorization = Encoder.Base64Code(authorization);
+			authorization = authorization.Replace("@", "=");
+
+			var path = _config.AddressUrl + "blade-auth/oauth/getAccessToken";
+			var rest = new RestRequest(path, Method.Post);
+			rest.AddHeader("content-type", "application/json");
+			rest.AddHeader("Authorization", "Basic " + authorization);
+			rest.AddHeader("Tenant-Id", _config.TenantId);
+			var res = await ExecuteAsync<string,EnterpriseServiceResponse>(path, Method.Post,"", rest, cancellationToken);
+
+			if (res is null)
+				throw new UserFriendlyException("获取token请求失败");
+			if (res.success)
+				throw new UserFriendlyException("获取token请求失败");
+			return res.data;
+		}
+		public async Task<TResponse> ExecuteAsync<TRequest, TResponse>(string path, Method httpMethod, TRequest request, RestRequest restRequest = null,
+			CancellationToken cancellationToken = default)
+			where TRequest : class
+		{
+			var req = new RestRequest(path, httpMethod);
+			if (httpMethod is Method.Get)
+			{
+				req.AddObject(request);
+			}
+			else
+			{
+				req.AddJsonBody(request);
+			}
+
+			try
+			{
+				var response = await _client.ExecuteAsync<TResponse>(req, cancellationToken);
+				return response.Data;
+			}
+			catch (Exception e)
+			{
+				throw new HttpRequestException($"智能质检平台错误,Error: {e.Message}");
+			}
+		}
+
+		public static class Encoder
+		{
+			/// <summary>
+			/// 对string 进行 Base64 编码 
+			/// </summary>
+			/// <param name="strMessage">string 参数</param>
+			/// <returns> Base64 编码</returns>
+			public static string Base64Code(string strMessage)
+			{
+				bool flag = string.IsNullOrEmpty(strMessage);
+				string result;
+				if (flag)
+				{
+					result = "";
+				}
+				else
+				{
+					char[] array = new char[]
+					{
+			'A',
+			'B',
+			'C',
+			'D',
+			'E',
+			'F',
+			'G',
+			'H',
+			'I',
+			'J',
+			'K',
+			'L',
+			'M',
+			'N',
+			'O',
+			'P',
+			'Q',
+			'R',
+			'S',
+			'T',
+			'U',
+			'V',
+			'W',
+			'X',
+			'Y',
+			'Z',
+			'a',
+			'b',
+			'c',
+			'd',
+			'e',
+			'f',
+			'g',
+			'h',
+			'i',
+			'j',
+			'k',
+			'l',
+			'm',
+			'n',
+			'o',
+			'p',
+			'q',
+			'r',
+			's',
+			't',
+			'u',
+			'v',
+			'w',
+			'x',
+			'y',
+			'z',
+			'0',
+			'1',
+			'2',
+			'3',
+			'4',
+			'5',
+			'6',
+			'7',
+			'8',
+			'9',
+			'+',
+			'/',
+			'='
+					};
+					byte b = 0;
+					ArrayList arrayList = new ArrayList(Encoding.Default.GetBytes(strMessage));
+					int count = arrayList.Count;
+					int num = count / 3;
+					int num2 = count % 3;
+					bool flag2 = num2 > 0;
+					if (flag2)
+					{
+						for (int i = 0; i < 3 - num2; i++)
+						{
+							arrayList.Add(b);
+						}
+						num++;
+					}
+					StringBuilder stringBuilder = new StringBuilder(num * 4);
+					for (int i = 0; i < num; i++)
+					{
+						byte[] array2 = new byte[]
+						{
+				(byte)arrayList[i * 3],
+				(byte)arrayList[i * 3 + 1],
+				(byte)arrayList[i * 3 + 2]
+						};
+						int[] array3 = new int[4];
+						array3[0] = array2[0] >> 2;
+						array3[1] = ((int)(array2[0] & 3) << 4 ^ array2[1] >> 4);
+						bool flag3 = !array2[1].Equals(b);
+						if (flag3)
+						{
+							array3[2] = ((int)(array2[1] & 15) << 2 ^ array2[2] >> 6);
+						}
+						else
+						{
+							array3[2] = 64;
+						}
+						bool flag4 = !array2[2].Equals(b);
+						if (flag4)
+						{
+							array3[3] = (int)(array2[2] & 63);
+						}
+						else
+						{
+							array3[3] = 64;
+						}
+						stringBuilder.Append(array[array3[0]]);
+						stringBuilder.Append(array[array3[1]]);
+						stringBuilder.Append(array[array3[2]]);
+						stringBuilder.Append(array[array3[3]]);
+					}
+					string text = stringBuilder.ToString();
+					text = text.Replace("=", "@");
+					text = text.Replace("+", "%2B");
+					result = text;
+				}
+				return result;
+			}
+		}
+	}
+}

+ 54 - 0
src/Hotline.YbEnterprise.Sdk/EnterpriseServiceResponse.cs

@@ -0,0 +1,54 @@
+using Hotline.Share.Dtos;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.YbEnterprise.Sdk
+{
+	public class EnterpriseServiceResponse
+	{
+		public int code {  get; set; }
+		public bool success { get; set; }
+		public EnterpriseVo data { get; set; }
+		public string msg { get; set; }
+	}
+
+	public class EnterpriseListRequest 
+	{
+		public string EnterpriseName { get; set; }
+
+		public int Current {  get; set; }
+
+		public int Size { get; set; }
+	}
+
+	public class EnterpriseListResponse
+	{
+		public int code { get; set; }
+		public bool success { get; set; }
+		public EnterpriseListData data { get; set; }
+	}
+
+	public class EnterpriseListData
+	{
+		public EnterpriseListDataRecords records { get; set; }
+
+		public int total { get; set; }
+
+		public int size { get; set; }
+
+		public int current { get; set; }
+
+		public int pages { get; set; }
+	}
+
+	public class EnterpriseListDataRecords 
+	{
+		public string enterpriseCode { get; set; }
+		public string enterpriseName { get; set; }
+		public string specialTeamCode { get; set; }
+		public string specialTeamName { get; set; }
+	}
+}

+ 4 - 0
src/Hotline.YbEnterprise.Sdk/Hotline.YbEnterprise.Sdk.csproj

@@ -12,4 +12,8 @@
     <PackageReference Include="Fw.Utility.UnifyResponse" Version="1.0.0" />
   </ItemGroup>
 
+  <ItemGroup>
+    <ProjectReference Include="..\Hotline\Hotline.csproj" />
+  </ItemGroup>
+
 </Project>

+ 7 - 9
src/Hotline.YbEnterprise.Sdk/HotlineYbEnterpriseStartupExtensions.cs

@@ -1,18 +1,16 @@
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Hotline.Ai.Quality;
+using Microsoft.Extensions.DependencyInjection;
+using Hotline.Enterprise;
+using Hotline.YbEnterprise.Sdk;
 
 namespace Hotline.Api.Sdk
 {
     public static class HotlineYbEnterpriseStartupExtensions
     {
-        public static IServiceCollection AddYbEnterpriseSdk(this IServiceCollection services, string baseUrl, string clientId, string clientSecret, string tenantId)
+        public static IServiceCollection AddYbEnterpriseSdk(this IServiceCollection services, EnterpriseConfig config)
         {
-            
-            return services;
+			services.AddSingleton<IEnterpriseService, EnterpriseService>(_ => new EnterpriseService(config));
+			return services;
         }
     }
 }

+ 12 - 0
src/Hotline/Enterprise/IEnterpriseService.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Enterprise
+{
+	public interface IEnterpriseService
+	{
+	}
+}

+ 91 - 1
src/Hotline/Permissions/EPermission.cs

@@ -713,6 +713,24 @@ namespace Hotline.Permissions
 
         #endregion
 
+        #region 智能回访(120000)
+        /// <summary>
+        /// 智能回访
+        /// </summary>
+        [Display(GroupName ="智能回访",Name ="智能回访",Description ="智能回访")]
+        AiVisitDir = 120000,
+        /// <summary>
+        /// 智能回访任务
+        /// </summary>
+        [Display(GroupName ="智能回访",Name ="智能回访任务",Description ="智能回访任务")]
+        AiVisitTask = 120100,
+        /// <summary>
+        /// 新增智能回访任务
+        /// </summary>
+        [Display(GroupName = "智能回访",Name ="新增智能回访任务",Description ="新增智能回访任务")]
+        AddAiVisitTask = 120101,
+        #endregion
+
         #region 系统管理(50,00,00)
 
         /// <summary>
@@ -1570,9 +1588,82 @@ namespace Hotline.Permissions
         #endregion
 
         #region 大屏管理(100000)
+        /// <summary>
+        /// 大屏管理
+        /// </summary>
+        [Display(GroupName = "大屏管理",Name = "大屏管理",Description ="大屏管理")]
+        ScreenManage = 100000,
 
+        #region 大屏数据
+        /// <summary>
+        /// 数据大屏
+        /// </summary>
+        [Display(GroupName ="大屏管理",Name = "数据大屏",Description ="数据大屏")]
+        ScreenData = 100100,
+
+        #endregion
+        #endregion
+
+        #region 数据统计(110000)
+        /// <summary>
+        /// 数据统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name ="数据统计",Description ="数据统计")]
+        DataCanter = 110000,
+
+        #region 话务统计
+        /// <summary>
+        /// 话务统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name ="话务统计",Description ="话务统计")]
+        CallStatistics = 110100,
+        /// <summary>
+        /// 话务统计分析
+        /// </summary>
+        [Display(GroupName = "数据统计",Name = "话务统计分析",Description ="话务统计分析")]
+        CallStatisticsAnalysis = 110101,
+        /// <summary>
+        /// 坐席话务统计分析
+        /// </summary>
+        [Display(GroupName = "数据统计",Name = "坐席话务统计分析",Description ="坐席话务统计分析")]
+        SeatCallStatisticsAnalysis = 110102,
+        /// <summary>
+        /// 话机动作统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name = "话机动作统计",Description = "话机动作统计")]
+        TelActStatistics = 110103,
+        #endregion
 
+        #region 工单统计
+        /// <summary>
+        /// 工单统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name = "工单统计",Description ="工单统计")]
+        OrderStatistics = 110200,
+        /// <summary>
+        /// 中心统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name = "中心统计",Description ="中心统计")]
+        CenterStatistics = 110201,
+        /// <summary>
+        /// 部门超期统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name = "部门超期统计",Description ="部门超期统计")]
+        OrgOverdueStatistics = 110202,
+        #endregion
 
+        #region 知识库统计
+        /// <summary>
+        /// 知识库统计
+        /// </summary>
+        [Display(GroupName = "数据统计",Name ="知识库统计",Description ="知识库统计")]
+        KnowledgeStatistics = 110300,
+        /// <summary>
+        /// 知识库数据统计
+        /// </summary>
+        [Display(GroupName ="数据统计",Name ="知识库数据统计",Description ="知识库数据统计")]
+        KnowledgeDataStatistics = 110301,
+        #endregion
 
         #endregion
 
@@ -1781,7 +1872,6 @@ namespace Hotline.Permissions
         #endregion
         #endregion
 
-
         #region 通话相关接口(200)
 
         ///// <summary>