|
@@ -12,6 +12,9 @@ using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
+using System.Text.Encodings.Web;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Text.Unicode;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Constants;
|
|
|
using XF.Domain.Dependency;
|
|
@@ -32,7 +35,7 @@ namespace Hotline.Application.Quality
|
|
|
private readonly IRepository<QualityTemplate> _qualityTemplate;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly ILogger<Hotline.Quality.Quality> _logger;
|
|
|
- private readonly ICallApplication _callApplication;
|
|
|
+ private readonly ICallApplication _callApplication;
|
|
|
private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
|
|
|
|
|
|
public QualityApplication(
|
|
@@ -43,7 +46,7 @@ namespace Hotline.Application.Quality
|
|
|
IAiQualityService aiQualityService,
|
|
|
//IRepository<TrCallRecord> trCallRecordRepository,
|
|
|
IRepository<QualityTemplate> qualityTemplate,
|
|
|
- IOrderRepository orderRepository,
|
|
|
+ IOrderRepository orderRepository,
|
|
|
ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
ICallApplication callApplication,
|
|
|
IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
|
|
@@ -56,13 +59,13 @@ namespace Hotline.Application.Quality
|
|
|
_aiQualityService = aiQualityService;
|
|
|
//_trCallRecordRepository = trCallRecordRepository;
|
|
|
_qualityTemplate = qualityTemplate;
|
|
|
- _orderRepository = orderRepository;
|
|
|
+ _orderRepository = orderRepository;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
_callApplication = callApplication;
|
|
|
_callcenterOptions = callcenterOptions;
|
|
|
_logger = logger;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
public async Task AddQualityAsync(EQualitySource Source, string OrderId, string VisitId, CancellationToken cancellationToken)
|
|
|
{
|
|
@@ -78,7 +81,7 @@ namespace Hotline.Application.Quality
|
|
|
else
|
|
|
{
|
|
|
if (Source == EQualitySource.Visit) await _qualityRepository.Updateable().SetColumns(x => x.VisitId == VisitId).Where(x => x.OrderId == OrderId && x.Source == Source).ExecuteCommandAsync();
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public async Task AddQualityAsync(EQualitySource Source, string OrderId, CancellationToken cancellationToken)
|
|
@@ -97,7 +100,7 @@ namespace Hotline.Application.Quality
|
|
|
{
|
|
|
var quality = _mapper.Map<Hotline.Quality.Quality>(model);
|
|
|
quality.InitId();
|
|
|
-
|
|
|
+
|
|
|
if (model.QualityDetails.Any())
|
|
|
{
|
|
|
foreach (var item in model.QualityDetails)
|
|
@@ -110,19 +113,19 @@ namespace Hotline.Application.Quality
|
|
|
//受理智能质检
|
|
|
if (model.Source == EQualitySource.Accepted)
|
|
|
{
|
|
|
- var teAny = await _qualityTemplate.Queryable()
|
|
|
- .LeftJoin<QualityTemplateDetail>((x, d) => x.Id == d.TemplateId)
|
|
|
- .LeftJoin<QualityItem>((x, d, i) => d.ItemId == i.Id)
|
|
|
- .Where((x, d, i) => i.IsIntelligent == 1).AnyAsync();
|
|
|
- if (teAny)
|
|
|
- {
|
|
|
- var order = await _orderRepository.GetAsync(model.OrderId);
|
|
|
- if (order != null && !string.IsNullOrEmpty(order.CallId))
|
|
|
- {
|
|
|
- quality.AiQuality = true;
|
|
|
- quality.Mode = "智能质检";
|
|
|
- //var call = await _trCallRecordRepository.GetAsync(x => x.CallAccept == order.CallId); //由CallAccept改成OtherAccept
|
|
|
- //var call = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == order.CallId);
|
|
|
+ var teAny = await _qualityTemplate.Queryable()
|
|
|
+ .LeftJoin<QualityTemplateDetail>((x, d) => x.Id == d.TemplateId)
|
|
|
+ .LeftJoin<QualityItem>((x, d, i) => d.ItemId == i.Id)
|
|
|
+ .Where((x, d, i) => i.IsIntelligent == 1).AnyAsync();
|
|
|
+ if (teAny)
|
|
|
+ {
|
|
|
+ var order = await _orderRepository.GetAsync(model.OrderId);
|
|
|
+ if (order != null && !string.IsNullOrEmpty(order.CallId))
|
|
|
+ {
|
|
|
+ quality.AiQuality = true;
|
|
|
+ quality.Mode = "智能质检";
|
|
|
+ //var call = await _trCallRecordRepository.GetAsync(x => x.CallAccept == order.CallId); //由CallAccept改成OtherAccept
|
|
|
+ //var call = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == order.CallId);
|
|
|
|
|
|
var audioFile = string.Empty;
|
|
|
var fromNo = string.Empty;
|
|
@@ -143,25 +146,28 @@ namespace Hotline.Application.Quality
|
|
|
}
|
|
|
|
|
|
var setting = _systemSettingCacheManager.GetSetting(SettingConstants.ViteRecordPrefix);
|
|
|
- //await _aiQualityService.CreateAiOrderQualityTask(quality, call, order, setting?.SettingValue[0], cancellationToken);
|
|
|
- try
|
|
|
- {
|
|
|
- await _aiQualityService.CreateAiOrderQualityTask(
|
|
|
- quality,
|
|
|
- audioFile,
|
|
|
- fromNo,
|
|
|
- callStartTime,
|
|
|
- order, setting?.SettingValue[0], cancellationToken);
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- _logger.LogError($"写入智能质检异常!, \r\n{e.Message}");
|
|
|
- }
|
|
|
+ //await _aiQualityService.CreateAiOrderQualityTask(quality, call, order, setting?.SettingValue[0], cancellationToken);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ await _aiQualityService.CreateAiOrderQualityTask(
|
|
|
+ quality,
|
|
|
+ audioFile,
|
|
|
+ fromNo,
|
|
|
+ callStartTime,
|
|
|
+ order, setting?.SettingValue[0], cancellationToken);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ _logger.LogError($"写入智能质检异常!, \r\n{e.Message}");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
- await _qualityRepository.AddAsync(quality, cancellationToken);
|
|
|
- }
|
|
|
+
|
|
|
+ _logger.LogInformation($"质检对象:{System.Text.Json.JsonSerializer.Serialize(quality,
|
|
|
+ new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.CjkUnifiedIdeographs) })}");
|
|
|
+ await _qualityRepository.AddAsync(quality, cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
public async Task UpdateQualityAsync(UpdateQualityDto model, CancellationToken cancellationToken)
|
|
|
{
|