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

Merge branch 'master' of http://git.12345lm.cn/Fengwo/hotline

Dun.Jason 1 жил өмнө
parent
commit
0cd948ad3e

+ 99 - 98
src/Hotline.Ai.Jths/AiQualityService.cs

@@ -11,114 +11,115 @@ using System.Security.Cryptography;
 namespace Hotline.Ai.Jths
 {
     public class AiQualityService : IAiQualityService
-	{
-		private readonly RestClient _client;
-		private readonly string _baseUrl;
+    {
+        private readonly RestClient _client;
+        private readonly string _baseUrl;
 
-		public AiQualityService(string baseUrl)
+        public AiQualityService(string baseUrl)
         {
             _client = new RestClient();
             _baseUrl = baseUrl;
 
-		}
+        }
 
-        public async Task CreateAiOrderQualityTask(Hotline.Quality.Quality model, TrCallRecord call, Order order, CancellationToken cancellationToken)
-		{
-			var fileName = call.RecordingFileName.Split(".");
-			var length = fileName.Count() -1;
-			var recordForm = fileName.Any() && fileName.Length > 1 ? fileName[length] : string.Empty;
-			List<AiQualityDto> datalist = new List<AiQualityDto>();
-			AiQualityDto aiQuality = new AiQualityDto
-			{
-				RecordID = model.Id,
-				RecordPath = call.RecordingFileUrl,
-				AgentID = "1001",
-				CallNumber = call.CPN,
-				CallTime = call.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss"),
-				RecordForm = recordForm,
-				ywlx = model.Source.ToString(),
-			};
-			datalist.Add(aiQuality);
-			var data =JsonConvert.SerializeObject(datalist);
-			await ExecuteAsync(_baseUrl+"routeinfo/api", Method.Post, data, cancellationToken);
-		}
+        public async Task CreateAiOrderQualityTask(Hotline.Quality.Quality model, TrCallRecord? call, Order order, CancellationToken cancellationToken)
+        {
+            if (string.IsNullOrEmpty(call?.RecordingFileName)) return;
+            var fileName = call.RecordingFileName.Split(".");
+            var length = fileName.Count() - 1;
+            var recordForm = fileName.Any() && fileName.Length > 1 ? fileName[length] : string.Empty;
+            List<AiQualityDto> datalist = new List<AiQualityDto>();
+            AiQualityDto aiQuality = new AiQualityDto
+            {
+                RecordID = model.Id,
+                RecordPath = call.RecordingFileUrl,
+                AgentID = "1001",
+                CallNumber = call.CPN,
+                CallTime = call.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss"),
+                RecordForm = recordForm,
+                ywlx = model.Source.ToString(),
+            };
+            datalist.Add(aiQuality);
+            var data = JsonConvert.SerializeObject(datalist);
+            await ExecuteAsync(_baseUrl + "routeinfo/api", Method.Post, data, cancellationToken);
+        }
 
-		public async Task<ApiResponse<TResponse>> ExecuteAsync<TRequest, TResponse>(string path, Method httpMethod,
-			TRequest request, CancellationToken cancellationToken)
-			where TRequest : class
-		{
-			var req = new RestRequest(path, httpMethod);
-			if (httpMethod is Method.Get)
-			{
-				req.AddObject(request);
-			}
-			else
-			{
-				req.AddJsonBody(request);
-			}
+        public async Task<ApiResponse<TResponse>> ExecuteAsync<TRequest, TResponse>(string path, Method httpMethod,
+            TRequest request, CancellationToken cancellationToken)
+            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<ApiResponse<TResponse>>(req, cancellationToken);
-				return response.Data;
-			}
-			catch (Exception e)
-			{
-				throw new HttpRequestException($"智能质检平台错误,Error: {e.Message}");
-			}
-		}
+            try
+            {
+                var response = await _client.ExecuteAsync<ApiResponse<TResponse>>(req, cancellationToken);
+                return response.Data;
+            }
+            catch (Exception e)
+            {
+                throw new HttpRequestException($"智能质检平台错误,Error: {e.Message}");
+            }
+        }
 
-		public async Task<ApiResponse> ExecuteAsync<TRequest>(string path, Method httpMethod, TRequest request,
-			CancellationToken cancellationToken)
-			where TRequest : class
-		{
-			var req = new RestRequest(path, httpMethod);
-			req.AddHeader("content-type", "application/json");
-			req.AddHeader("token", "");
-			req.AddHeader("version", "V1.0");
-			var sign = MD5Encrypt(request.ToString());
-			req.AddHeader("sign", sign);
-			req.AddHeader("signType", "md5");
-			req.AddHeader("appkey", "MTAwMDAx");
-			if (httpMethod is Method.Get)
-			{
-				req.AddObject(request);
-			}
-			else
-			{
-				req.AddJsonBody(request);
-			}
+        public async Task<ApiResponse> ExecuteAsync<TRequest>(string path, Method httpMethod, TRequest request,
+            CancellationToken cancellationToken)
+            where TRequest : class
+        {
+            var req = new RestRequest(path, httpMethod);
+            req.AddHeader("content-type", "application/json");
+            req.AddHeader("token", "");
+            req.AddHeader("version", "V1.0");
+            var sign = MD5Encrypt(request.ToString());
+            req.AddHeader("sign", sign);
+            req.AddHeader("signType", "md5");
+            req.AddHeader("appkey", "MTAwMDAx");
+            if (httpMethod is Method.Get)
+            {
+                req.AddObject(request);
+            }
+            else
+            {
+                req.AddJsonBody(request);
+            }
 
-			try
-			{
-				var response = await _client.ExecuteAsync<ApiResponse>(req, cancellationToken);
-				return response.Data;
-			}
-			catch (Exception e)
-			{
-				throw new HttpRequestException($"智能质检平台错误,Error: {e.Message}");
-			}
-		}
+            try
+            {
+                var response = await _client.ExecuteAsync<ApiResponse>(req, cancellationToken);
+                return response.Data;
+            }
+            catch (Exception e)
+            {
+                throw new HttpRequestException($"智能质检平台错误,Error: {e.Message}");
+            }
+        }
 
-		/// <summary>
-		/// MD5加密
-		/// </summary>
-		/// <param name="input">需要加密的字符串</param>
-		/// <returns></returns>
-		private static string MD5Encrypt(string? input)
-		{
-			using var md5 = MD5.Create();
-			var t = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
-			var sb = new StringBuilder(32);
-			for (var i = 0; i < t.Length; i++)
-				sb.Append(t[i].ToString("x").PadLeft(2, '0'));
-			return sb.ToString();
-		}
+        /// <summary>
+        /// MD5加密
+        /// </summary>
+        /// <param name="input">需要加密的字符串</param>
+        /// <returns></returns>
+        private static string MD5Encrypt(string? input)
+        {
+            using var md5 = MD5.Create();
+            var t = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
+            var sb = new StringBuilder(32);
+            for (var i = 0; i < t.Length; i++)
+                sb.Append(t[i].ToString("x").PadLeft(2, '0'));
+            return sb.ToString();
+        }
 
-		private static string Base64En(string? model) 
-		{
-			var bytes = Encoding.UTF8.GetBytes(model);
-			return Convert.ToBase64String(bytes);
-		}
-	}
+        private static string Base64En(string? model)
+        {
+            var bytes = Encoding.UTF8.GetBytes(model);
+            return Convert.ToBase64String(bytes);
+        }
+    }
 }

+ 13 - 13
src/Hotline.Api/Controllers/OrderController.cs

@@ -356,7 +356,7 @@ public class OrderController : BaseController
 
         orderPublish.OrderId = order.Id;
         orderPublish.No = order.No;
-        
+
         string id = await _orderPublishRepository.AddAsync(orderPublish);
         order.Publish(orderPublish.PublishState);
         await _orderRepository.UpdateAsync(order);
@@ -2357,7 +2357,7 @@ public class OrderController : BaseController
         {
             if (isAdd)
                 await Remove(id);
-            throw new UserFriendlyException($"工单开启流程失败!, {e.Message}", "工单开启流程失败");
+            throw new UserFriendlyException($"工单开启流程失败!, {e.Message}, {e.StackTrace}", "工单开启流程失败");
         }
     }
 
@@ -2551,9 +2551,9 @@ public class OrderController : BaseController
             .WhereIF(dto.IsProvince.HasValue, d => d.IsProvince == dto.IsProvince)
             .WhereIF(!string.IsNullOrEmpty(dto.Keyword),
                 d => d.No.Contains(dto.Keyword) || d.Title.Contains(dto.Keyword))
-            .WhereIF(dto.IsCounterSign.HasValue && dto.IsCounterSign == true,d=>d.CounterSignType.HasValue)
-            .WhereIF(dto.IsCounterSign.HasValue && dto.IsCounterSign == false,d=>!d.CounterSignType.HasValue)
-            .Where(x=>x.Source< ESource.MLSQ || x.Source> ESource.WZSC)
+            .WhereIF(dto.IsCounterSign.HasValue && dto.IsCounterSign == true, d => d.CounterSignType.HasValue)
+            .WhereIF(dto.IsCounterSign.HasValue && dto.IsCounterSign == false, d => !d.CounterSignType.HasValue)
+            .Where(x => x.Source < ESource.MLSQ || x.Source > ESource.WZSC)
             .OrderByDescending(d => d.StartTime)
             .ToPagedListAsync(dto, HttpContext.RequestAborted);
 
@@ -3765,7 +3765,7 @@ public class OrderController : BaseController
     public async Task<object> DownLoadOrderTemplate()
     {
         List<ExcelContent> list = new List<ExcelContent>();
-        ExcelContent excelContent = new ExcelContent() {  ExternalId = "自编号",  AcceptTypeCode="字典值", AcceptType="字典名称"  };
+        ExcelContent excelContent = new ExcelContent() { ExternalId = "自编号", AcceptTypeCode = "字典值", AcceptType = "字典名称" };
         list.Add(excelContent);
         return _exportApplication.ExportData(list, "demo.xlsx");
     }
@@ -3778,7 +3778,7 @@ public class OrderController : BaseController
     [HttpPost("import-order")]
     public async Task<object> ImportOrder(IFormFile file)
     {
-       
+
         using (var stream = new MemoryStream())
         {
             file.CopyTo(stream);
@@ -3787,7 +3787,7 @@ public class OrderController : BaseController
             int errorCount = 0;
             int addCount = 0;
             int modifyCount = 0;
-            if (list!=null && list.Count>0)
+            if (list != null && list.Count > 0)
             {
                 count = list.Count;
                 foreach (var item in list)
@@ -3799,12 +3799,12 @@ public class OrderController : BaseController
                             errorCount++;
                             continue;
                         }
-                        var order =await _orderRepository.GetAsync(x => x.ExternalId == item.ExternalId && x.Source == item.Source, HttpContext.RequestAborted);
+                        var order = await _orderRepository.GetAsync(x => x.ExternalId == item.ExternalId && x.Source == item.Source, HttpContext.RequestAborted);
                         if (order is null)
                         {
                             order = _mapper.Map<Order>(item);
                             //order.Source = item;
-                            var id = await _orderRepository.AddAsync(order,HttpContext.RequestAborted);
+                            var id = await _orderRepository.AddAsync(order, HttpContext.RequestAborted);
                             if (!string.IsNullOrEmpty(id))
                             {
                                 addCount++;
@@ -3817,18 +3817,18 @@ public class OrderController : BaseController
                         else
                         {
                             _mapper.Map(item, order);
-                            await _orderRepository.UpdateAsync(order,HttpContext.RequestAborted);
+                            await _orderRepository.UpdateAsync(order, HttpContext.RequestAborted);
                             modifyCount++;
                         }
 
                     }
-                    catch(Exception ex)
+                    catch (Exception ex)
                     {
                         errorCount++;
                     }
                 }
             }
-            return new { Count = count, ErrorCount = errorCount, AddCount = addCount,ModifyCount = modifyCount };
+            return new { Count = count, ErrorCount = errorCount, AddCount = addCount, ModifyCount = modifyCount };
         }
     }
 

+ 1 - 1
src/Hotline/Ai/Quality/IAiQualityService.cs

@@ -13,6 +13,6 @@ namespace Hotline.Ai.Quality
 {
     public interface IAiQualityService
 	{
-        Task CreateAiOrderQualityTask(Hotline.Quality.Quality model, TrCallRecord call,Order order, CancellationToken cancellationToken);
+        Task CreateAiOrderQualityTask(Hotline.Quality.Quality model, TrCallRecord? call,Order order, CancellationToken cancellationToken);
 	}
 }