|
@@ -57,6 +57,8 @@ using SqlSugar;
|
|
|
using StackExchange.Redis;
|
|
|
using System.Diagnostics.Tracing;
|
|
|
using Hotline.Application.CallCenter;
|
|
|
+using Hotline.CallCenter.Configs;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Cache;
|
|
|
using XF.Domain.Constants;
|
|
@@ -64,6 +66,7 @@ using XF.Domain.Entities;
|
|
|
using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Repository;
|
|
|
using XF.Utility.EnumExtensions;
|
|
|
+using Hotline.Repository.SqlSugar.CallCenter;
|
|
|
|
|
|
namespace Hotline.Api.Controllers;
|
|
|
|
|
@@ -127,6 +130,7 @@ public class OrderController : BaseController
|
|
|
private readonly IRepository<ExternalCitizens> _externalCitizensRepository;
|
|
|
private readonly IRepository<OrderModifyingRecords> _orderModifyingRecordsRepository;
|
|
|
private readonly ICallApplication _callApplication;
|
|
|
+ private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
|
|
|
|
|
|
public OrderController(
|
|
|
IOrderDomainService orderDomainService,
|
|
@@ -183,8 +187,8 @@ public class OrderController : BaseController
|
|
|
IRepository<OrderCopy> orderCopyRepository,
|
|
|
IRepository<ExternalCitizens> externalCitizensRepository,
|
|
|
IRepository<OrderModifyingRecords> orderModifyingRecordsRepository,
|
|
|
- ICallApplication callApplication
|
|
|
- )
|
|
|
+ ICallApplication callApplication,
|
|
|
+ IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
_orderRepository = orderRepository;
|
|
@@ -241,6 +245,7 @@ public class OrderController : BaseController
|
|
|
_externalCitizensRepository = externalCitizensRepository;
|
|
|
_orderModifyingRecordsRepository = orderModifyingRecordsRepository;
|
|
|
_callApplication = callApplication;
|
|
|
+ _callcenterOptions = callcenterOptions;
|
|
|
}
|
|
|
|
|
|
#region 工单发布
|
|
@@ -728,15 +733,29 @@ public class OrderController : BaseController
|
|
|
var dissatisfiedReason = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.DissatisfiedReason);
|
|
|
var visitManner = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.VisitManner).Where(x => x.DicDataValue != "-1");
|
|
|
//var callRecord = await _trCallRecordRepository.GetAsync(x => x.CallAccept == orderVisit.CallId); //由CallAccept改为OtherAccept
|
|
|
- var callRecord = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == orderVisit.CallId && string.IsNullOrEmpty(x.OtherAccept) == false, HttpContext.RequestAborted);
|
|
|
+ //var callRecord = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == orderVisit.CallId && string.IsNullOrEmpty(x.OtherAccept) == false, HttpContext.RequestAborted);
|
|
|
var recordingFileUrl = "";
|
|
|
var recordingBaseAddress = "";
|
|
|
var recordingAbsolutePath = "";
|
|
|
- if (callRecord != null)
|
|
|
+ if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
|
|
|
{
|
|
|
- recordingFileUrl = callRecord.RecordingFileUrl;
|
|
|
- recordingBaseAddress = callRecord.RecordingBaseAddress;
|
|
|
- recordingAbsolutePath = callRecord.RecordingAbsolutePath;
|
|
|
+ var callRecord = await _callApplication.GetTianrunCallAsync(orderVisit.CallId, HttpContext.RequestAborted);
|
|
|
+ if (callRecord != null)
|
|
|
+ {
|
|
|
+ recordingFileUrl = callRecord.RecordingFileUrl;
|
|
|
+ recordingBaseAddress = callRecord.RecordingBaseAddress;
|
|
|
+ recordingAbsolutePath = callRecord.RecordingAbsolutePath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
|
|
|
+ {
|
|
|
+ var call = await _callApplication.GetCallAsync(orderVisit.CallId, HttpContext.RequestAborted);
|
|
|
+ if (call is not null)
|
|
|
+ {
|
|
|
+ recordingFileUrl = call.AudioFile;
|
|
|
+ recordingBaseAddress = call.AudioFile;
|
|
|
+ recordingAbsolutePath = call.AudioFile;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return new
|
|
@@ -2529,11 +2548,30 @@ public class OrderController : BaseController
|
|
|
}
|
|
|
|
|
|
//var call = await _trCallRecordRepository.Queryable().Where(x => x.CallAccept == order.CallId).FirstAsync();//由CallAccept改为OtherAccept
|
|
|
- var call = await _trCallRecordRepository.Queryable().Where(x => x.OtherAccept == order.CallId).FirstAsync();
|
|
|
- if (call != null)
|
|
|
+ //var call = await _trCallRecordRepository.Queryable().Where(x => x.OtherAccept == order.CallId).FirstAsync();
|
|
|
+ //if (call != null)
|
|
|
+ //{
|
|
|
+ // dto.RecordingBaseAddress = call.RecordingBaseAddress;
|
|
|
+ // dto.RecordingAbsolutePath = call.RecordingAbsolutePath;
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
|
|
|
+ {
|
|
|
+ var callRecord = await _callApplication.GetTianrunCallAsync(order.CallId, HttpContext.RequestAborted);
|
|
|
+ if (callRecord != null)
|
|
|
+ {
|
|
|
+ dto.RecordingBaseAddress = callRecord.RecordingBaseAddress;
|
|
|
+ dto.RecordingAbsolutePath = callRecord.RecordingAbsolutePath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
|
|
|
{
|
|
|
- dto.RecordingBaseAddress = call.RecordingBaseAddress;
|
|
|
- dto.RecordingAbsolutePath = call.RecordingAbsolutePath;
|
|
|
+ var call = await _callApplication.GetCallAsync(order.CallId, HttpContext.RequestAborted);
|
|
|
+ if (call is not null)
|
|
|
+ {
|
|
|
+ dto.RecordingBaseAddress = call.AudioFile;
|
|
|
+ dto.RecordingAbsolutePath = call.AudioFile;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var repeatablesMap = await _repeatableEventDetailRepository.Queryable()
|
|
@@ -2598,12 +2636,17 @@ public class OrderController : BaseController
|
|
|
|
|
|
//工单ID跟通话记录相关联
|
|
|
//var callRecord = await _trCallRecordRepository.GetAsync(p => p.CallAccept == order.CallId, HttpContext.RequestAborted);//由CallAccept改为OtherAccept
|
|
|
- var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept == order.CallId && string.IsNullOrEmpty(p.OtherAccept) == false, HttpContext.RequestAborted);
|
|
|
- if (callRecord != null && string.IsNullOrEmpty(callRecord.ExternalId))
|
|
|
+ //var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept == order.CallId && string.IsNullOrEmpty(p.OtherAccept) == false, HttpContext.RequestAborted);
|
|
|
+ //if (callRecord != null && string.IsNullOrEmpty(callRecord.ExternalId))
|
|
|
+ //{
|
|
|
+ // callRecord.ExternalId = order.Id;
|
|
|
+ // callRecord.CallOrderType = Share.Enums.CallCenter.ECallOrderType.Order;
|
|
|
+ // await _trCallRecordRepository.UpdateAsync(callRecord, HttpContext.RequestAborted);
|
|
|
+ //}
|
|
|
+ if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
|
|
|
{
|
|
|
- callRecord.ExternalId = order.Id;
|
|
|
- callRecord.CallOrderType = Share.Enums.CallCenter.ECallOrderType.Order;
|
|
|
- await _trCallRecordRepository.UpdateAsync(callRecord, HttpContext.RequestAborted);
|
|
|
+ if (!string.IsNullOrEmpty(order.CallId))
|
|
|
+ await _callApplication.RelateTianrunCallWithOrderAsync(order.CallId, order.Id, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
//内容分词
|
|
@@ -2749,7 +2792,7 @@ public class OrderController : BaseController
|
|
|
}
|
|
|
|
|
|
_mapper.Map(dto, order);
|
|
|
- if (order.SourceChannelCode != OrderDefaults.SourceChannel.DianHua)
|
|
|
+ if (order.SourceChannelCode != AppDefaults.SourceChannel.DianHua)
|
|
|
order.CallId = null;
|
|
|
|
|
|
if (dto.Files.Any())
|
|
@@ -4574,10 +4617,29 @@ public class OrderController : BaseController
|
|
|
var citizen = await _citizenRepository.Queryable()
|
|
|
.Includes(x => x.labelDetails)
|
|
|
.FirstAsync(x => x.PhoneNumber == phone);
|
|
|
- var calls = await _trCallRecordRepository.Queryable().Where(x => x.CallDirection == 0 && x.CPN == phone).OrderBy(x => x.CreatedTime).ToListAsync();
|
|
|
- var oneCallTime = calls != null && calls.Count() > 0 ? calls[0].CreatedTime : DateTime.Now;
|
|
|
- var lastNum = calls != null && calls.Count() > 0 ? calls.Count() - 1 : -1;
|
|
|
- var lastCallTime = lastNum >= 0 ? calls[lastNum].CreatedTime : DateTime.Now;
|
|
|
+ //var calls = await _trCallRecordRepository.Queryable().Where(x => x.CallDirection == 0 && x.CPN == phone).OrderBy(x => x.CreatedTime).ToListAsync();
|
|
|
+ //var oneCallTime = calls != null && calls.Count() > 0 ? calls[0].CreatedTime : DateTime.Now;
|
|
|
+ //var lastNum = calls != null && calls.Count() > 0 ? calls.Count() - 1 : -1;
|
|
|
+ //var lastCallTime = lastNum >= 0 ? calls[lastNum].CreatedTime : DateTime.Now;
|
|
|
+
|
|
|
+ var oneCallTime = DateTime.Now;
|
|
|
+ var lastCallTime = DateTime.Now;
|
|
|
+ if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
|
|
|
+ {
|
|
|
+ var calls = await _callApplication.QueryTianrunCallsAsync(phone, ECallDirection.In, HttpContext.RequestAborted);
|
|
|
+ oneCallTime = calls.FirstOrDefault()?.CreatedTime ?? DateTime.Now;
|
|
|
+ var count = calls.Count;
|
|
|
+ lastCallTime = count > 1 ? calls[count - 2].CreatedTime : oneCallTime;
|
|
|
+ }
|
|
|
+ else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
|
|
|
+ {
|
|
|
+ var calls = await _callApplication.QueryCallsAsync(phone, ECallDirection.In, HttpContext.RequestAborted);
|
|
|
+ oneCallTime = calls.FirstOrDefault()?.BeginIvrTime ?? DateTime.Now;
|
|
|
+ var count = calls.Count;
|
|
|
+ lastCallTime = count > 1 ? calls[count - 2].CreationTime : oneCallTime;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//工单历史
|
|
|
var oders = await _orderRepository.Queryable().Where(x => x.Contact == phone)
|
|
|
.OrderBy(x => x.CreationTime, OrderByType.Desc).ToListAsync();
|
|
@@ -4592,16 +4654,40 @@ public class OrderController : BaseController
|
|
|
SqlFunc.JsonField(x.OrgProcessingResults, "Value") == "非常不满意"))
|
|
|
.Distinct().Select(x => new { x.OrderVisit.OrderId }).CountAsync();
|
|
|
//来电历史
|
|
|
- var callsHistory = await _trCallRecordRepository.Queryable().Where(x => x.CPN == phone || x.CDPN == phone).ToListAsync();
|
|
|
+ //var callsHistory = await _trCallRecordRepository.Queryable().Where(x => x.CPN == phone || x.CDPN == phone).ToListAsync();
|
|
|
var allCallNum = 0;
|
|
|
var connectNum = 0;
|
|
|
var callBackNum = 0;
|
|
|
- if (callsHistory != null && callsHistory.Any())
|
|
|
+ //if (callsHistory != null && callsHistory.Any())
|
|
|
+ //{
|
|
|
+ // allCallNum = callsHistory.Count(x => x.CallDirection == ECallDirection.In);
|
|
|
+ // connectNum = callsHistory.Count(x => x.CallDirection == ECallDirection.In && x.Duration > 0);
|
|
|
+ // callBackNum = callsHistory.Count(x => x.CallDirection == ECallDirection.Out);
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
|
|
|
+ {
|
|
|
+ var callsHistory =
|
|
|
+ await _callApplication.QueryTianrunCallsAsync(phone, cancellationToken: HttpContext.RequestAborted);
|
|
|
+ if (callsHistory != null && callsHistory.Any())
|
|
|
+ {
|
|
|
+ allCallNum = callsHistory.Count(x => x.CallDirection == ECallDirection.In);
|
|
|
+ connectNum = callsHistory.Count(x => x.CallDirection == ECallDirection.In && x.Duration > 0);
|
|
|
+ callBackNum = callsHistory.Count(x => x.CallDirection == ECallDirection.Out);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
|
|
|
{
|
|
|
- allCallNum = callsHistory.Count(x => x.CallDirection == ECallDirection.In);
|
|
|
- connectNum = callsHistory.Count(x => x.CallDirection == ECallDirection.In && x.Duration > 0);
|
|
|
- callBackNum = callsHistory.Count(x => x.CallDirection == ECallDirection.Out);
|
|
|
+ var histories =
|
|
|
+ await _callApplication.QueryCallsAsync(phone, cancellationToken: HttpContext.RequestAborted);
|
|
|
+ if(histories.Any())
|
|
|
+ {
|
|
|
+ allCallNum = histories.Count(x => x.Direction == ECallDirection.In);
|
|
|
+ connectNum = histories.Count(x => x.Direction == ECallDirection.In && x.Duration > 0);
|
|
|
+ callBackNum = histories.Count(x => x.Direction == ECallDirection.Out);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//关注诉求
|
|
|
var hotspotNames = string.Join(",", oders.Select(x => x.HotspotName).Distinct().Take(5).ToList());
|
|
|
var rsp = new
|