|
@@ -1,6 +1,7 @@
|
|
|
|
|
|
using Consul;
|
|
|
using DotNetCore.CAP;
|
|
|
+using Hotline.Ai.CallOut;
|
|
|
using Hotline.Ai.Jths;
|
|
|
using Hotline.Ai.Visit;
|
|
|
using Hotline.Application.Quality;
|
|
@@ -45,8 +46,9 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly IQualityApplication _qualityApplication;
|
|
|
private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
|
|
|
+ private readonly IRepository<CallOutTemplate> _callOutTemplateRepository;
|
|
|
|
|
|
- public AiController(ISystemSettingCacheManager systemSettingCacheManager,IRepository<AiOrderVisit> aiOrderVisitRepository,IRepository<AiOrderVisitDetail> aiOrderVisitDetailRepository,IRepository<OrderVisit> orderVisitRepository,IRepository<OrderVisitDetail> orderVisitDetailRepository,IMapper mapper, /*IOptionsSnapshot<AiVisitConfig> options,*/IAiVisitService aiVisitService, ILogger<AiController> logger,ICapPublisher capPublisher,IOrderRepository orderRepository,IQualityApplication qualityApplication, ISystemDicDataCacheManager sysDicDataCacheManager)
|
|
|
+ public AiController(ISystemSettingCacheManager systemSettingCacheManager,IRepository<AiOrderVisit> aiOrderVisitRepository,IRepository<AiOrderVisitDetail> aiOrderVisitDetailRepository,IRepository<OrderVisit> orderVisitRepository,IRepository<OrderVisitDetail> orderVisitDetailRepository,IMapper mapper, /*IOptionsSnapshot<AiVisitConfig> options,*/IAiVisitService aiVisitService, ILogger<AiController> logger,ICapPublisher capPublisher,IOrderRepository orderRepository,IQualityApplication qualityApplication, ISystemDicDataCacheManager sysDicDataCacheManager,IRepository<CallOutTemplate> callOutTemplateRepository)
|
|
|
{
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
_aiOrderVisitRepository = aiOrderVisitRepository;
|
|
@@ -61,6 +63,7 @@ namespace Hotline.Api.Controllers
|
|
|
_orderRepository = orderRepository;
|
|
|
_qualityApplication = qualityApplication;
|
|
|
_sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
+ _callOutTemplateRepository = callOutTemplateRepository;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -99,7 +102,101 @@ namespace Hotline.Api.Controllers
|
|
|
return IsOk;
|
|
|
}
|
|
|
|
|
|
+ #region 批量外呼
|
|
|
|
|
|
+ #region 批量外呼模板
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 外呼模板列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("callout-template-list")]
|
|
|
+ public async Task<PagedDto<AiCallOutTemplateQueryRep>> AiCallOutTemplateQuery([FromQuery]AiCallOutTemplateQueryRequest dto)
|
|
|
+ {
|
|
|
+ var (total,items) =await _callOutTemplateRepository.Queryable()
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.TemplateName), x => x.TemplateName.Contains(dto.TemplateName))
|
|
|
+ .WhereIF(dto.StartTime != null, x => x.CreationTime >= dto.StartTime)
|
|
|
+ .WhereIF(dto.EndTime != null, x => x.CreationTime <= dto.EndTime)
|
|
|
+ .OrderByDescending(x => x.CreationTime)
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
+ return new PagedDto<AiCallOutTemplateQueryRep>(total, _mapper.Map<IReadOnlyList<AiCallOutTemplateQueryRep>>(items));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 新增外呼模板
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("add-callouttemplate")]
|
|
|
+ public async Task AddCallOutTemplate([FromBody]CallOutTemplateDto dto)
|
|
|
+ {
|
|
|
+ var callOutTemplate = _mapper.Map<CallOutTemplate>(dto);
|
|
|
+ callOutTemplate.IsEnable = true;
|
|
|
+ await _callOutTemplateRepository.AddAsync(callOutTemplate, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 修改外呼模板
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("update-callouttemplate")]
|
|
|
+ public async Task UpdateCallOutTemplate([FromBody] UpdateCallOutTemplateDto dto)
|
|
|
+ {
|
|
|
+ var model = await _callOutTemplateRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (model == null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效模板");
|
|
|
+ //验证是否有待执行的外呼任务TODO
|
|
|
+
|
|
|
+ model.TemplateName = dto.TemplateName;
|
|
|
+ model.TemplateContent = dto.TemplateContent;
|
|
|
+
|
|
|
+ await _callOutTemplateRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除外呼模板
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpDelete("del-callouttemplate")]
|
|
|
+ public async Task DelCallOutTemplate([FromQuery]string id)
|
|
|
+ {
|
|
|
+ var model = await _callOutTemplateRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (model == null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效模板");
|
|
|
+
|
|
|
+ //验证是否有待执行的外呼任务TODO
|
|
|
+ await _callOutTemplateRepository.RemoveAsync(id, true, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 外呼模板启用禁用
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("callouttemplate-enable-unenable")]
|
|
|
+ public async Task CallOutTemplateEnableAndUnEnable([FromQuery]string id)
|
|
|
+ {
|
|
|
+ var model = await _callOutTemplateRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (model == null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效模板");
|
|
|
+
|
|
|
+ //验证是否有待执行的外呼任务TODO
|
|
|
+
|
|
|
+ model.IsEnable = !model.IsEnable;
|
|
|
+
|
|
|
+ await _callOutTemplateRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region 批量外呼任务
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
#region 智能回访
|
|
|
|
|
@@ -566,5 +663,8 @@ namespace Hotline.Api.Controllers
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|