|
@@ -20,6 +20,8 @@ using System.Threading;
|
|
|
using Hotline.CallCenter.Calls;
|
|
|
using Hotline.Application.Quality;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
+using Hotline.Orders;
|
|
|
+using Hotline.Ai.Quality;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
@@ -36,6 +38,8 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
|
|
|
private readonly IRepository<TrCallRecord> _trCallRecordRepository;
|
|
|
private readonly IQualityApplication _qualityApplication;
|
|
|
+ private readonly IOrderRepository _orderRepository;
|
|
|
+ private readonly IAiQualityService _aiQualityService;
|
|
|
|
|
|
public QualityController(
|
|
|
ISessionContext sessionContext,
|
|
@@ -48,7 +52,11 @@ namespace Hotline.Api.Controllers
|
|
|
IRepository<QualityProhibited> qualiteyProhibited,
|
|
|
ISystemDicDataCacheManager systemDicDataCacheManager,
|
|
|
IRepository<TrCallRecord> trCallRecordRepository,
|
|
|
- IQualityApplication qualityApplication
|
|
|
+ IQualityApplication qualityApplication,
|
|
|
+
|
|
|
+ IOrderRepository orderRepository,
|
|
|
+ IAiQualityService aiQualityService
|
|
|
+
|
|
|
)
|
|
|
{
|
|
|
_sessionContext = sessionContext;
|
|
@@ -62,6 +70,8 @@ namespace Hotline.Api.Controllers
|
|
|
_systemDicDataCacheManager = systemDicDataCacheManager;
|
|
|
_trCallRecordRepository = trCallRecordRepository;
|
|
|
_qualityApplication = qualityApplication;
|
|
|
+ _orderRepository = orderRepository;
|
|
|
+ _aiQualityService = aiQualityService;
|
|
|
}
|
|
|
#region 质检管理
|
|
|
/// <summary>
|
|
@@ -105,13 +115,13 @@ namespace Hotline.Api.Controllers
|
|
|
.Includes(x => x.Visit)
|
|
|
.Includes(x => x.Visit,e=>e.Employee)
|
|
|
.Includes(x => x.QualityDetails)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Order.Title.Contains(dto.Keyword!) || d.Order.No.Contains(dto.Keyword!))
|
|
|
- .WhereIF(dto.State.HasValue, d => d.State == dto.State)
|
|
|
- .WhereIF(dto.Source.HasValue, d => d.Source == dto.Source)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.Order.Title.Contains(dto.Keyword!) || x.Order.No.Contains(dto.Keyword!))
|
|
|
+ .WhereIF(dto.State.HasValue, x => x.State == dto.State)
|
|
|
+ .WhereIF(dto.Source.HasValue, x=> x.Source == dto.Source)
|
|
|
.WhereIF(dto.Source.HasValue && dto.Source == EQualitySource.Accepted, x=> !string.IsNullOrEmpty(x.Order.CallId))
|
|
|
.WhereIF(dto.Source.HasValue && dto.Source == EQualitySource.Visit, x => !string.IsNullOrEmpty(x.Visit.CallId))
|
|
|
- .WhereIF(dto.CreationTimeStart.HasValue, d => d.CreationTime >= dto.CreationTimeStart)
|
|
|
- .WhereIF(dto.CreationTimeEnd.HasValue, d => d.CreationTime <= dto.CreationTimeEnd)
|
|
|
+ .WhereIF(dto.CreationTimeStart.HasValue, x => x.CreationTime >= dto.CreationTimeStart)
|
|
|
+ .WhereIF(dto.CreationTimeEnd.HasValue, x => x.CreationTime <= dto.CreationTimeEnd)
|
|
|
.OrderByDescending(x => x.CreationTime)
|
|
|
.ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
return new PagedDto<QualityDto>(total, _mapper.Map<IReadOnlyList<QualityDto>>(items));
|
|
@@ -256,7 +266,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("template")]
|
|
|
public async Task Add([FromBody] TemplateAddDto dto)
|
|
|
{
|
|
|
- var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.IsEnable == 0);
|
|
|
+ var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.IsEnable == 1);
|
|
|
if (groupingCount > 0)
|
|
|
throw UserFriendlyException.SameMessage("当前已存在");
|
|
|
var names = dto.TemplateDetails.Select(x => x.ItemId).ToList();
|
|
@@ -317,7 +327,7 @@ namespace Hotline.Api.Controllers
|
|
|
var template = await _qualityTemplate.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
if (template is null)
|
|
|
throw UserFriendlyException.SameMessage("无效质检模版");
|
|
|
- var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.Id != dto.Id && x.IsEnable == 0);
|
|
|
+ var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.Id != dto.Id && x.IsEnable == 1);
|
|
|
if (groupingCount > 0)
|
|
|
throw UserFriendlyException.SameMessage("当前质检分类已存在");
|
|
|
_mapper.Map(dto, template);
|
|
@@ -380,6 +390,9 @@ namespace Hotline.Api.Controllers
|
|
|
public async Task Enable([FromBody] TemplateUpdateDto dto)
|
|
|
{
|
|
|
var template = await _qualityTemplate.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.Id != dto.Id && x.IsEnable == 1);
|
|
|
+ if (groupingCount > 0)
|
|
|
+ throw UserFriendlyException.SameMessage("当前质检分类已存在");
|
|
|
if (template is null)
|
|
|
throw UserFriendlyException.SameMessage("无效质检模版");
|
|
|
_mapper.Map(dto, template);
|
|
@@ -561,5 +574,18 @@ namespace Hotline.Api.Controllers
|
|
|
await _qualiteyDetail.AddRangeAsync(details);
|
|
|
}
|
|
|
}
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost("AiResultTest")]
|
|
|
+ public async Task TaskAsync()
|
|
|
+ {
|
|
|
+ var quality = await _qualitey.GetAsync("08dbfc81-a43b-4be1-8266-8f0f55fb0024");
|
|
|
+ var order = await _orderRepository.GetAsync(quality.OrderId);
|
|
|
+ if (order != null && !string.IsNullOrEmpty(order.CallId))
|
|
|
+ {
|
|
|
+ var call = await _trCallRecordRepository.GetAsync(x => x.CallAccept == order.CallId);
|
|
|
+ await _aiQualityService.CreateAiOrderQualityTask(quality, call, order, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|