|
@@ -23,46 +23,82 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
|
|
|
|
|
|
public async Task Handle(CdrNotification notification, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var callDetail = await
|
|
|
- _callDetailRepository.GetAsync(x => x.OMCallId == notification.CallId, cancellationToken);
|
|
|
-
|
|
|
- if (callDetail!=null)
|
|
|
+ //内部互拨
|
|
|
+ if (notification.Type == "LO")
|
|
|
{
|
|
|
- var model = new CallRecord()
|
|
|
+ //获取最后一通内线电话
|
|
|
+ var call = await _callRepository.GetLastLOCall(notification.CPN, notification.CDPN);
|
|
|
+ if (call != null)
|
|
|
{
|
|
|
- CallId = callDetail.CallId,
|
|
|
- CdrId = notification.Id,
|
|
|
- CDRCallId = notification.CallId,
|
|
|
- TimeStart = notification.TimeStart,
|
|
|
- Group = notification.Group,
|
|
|
- Type = (ECDRType)Enum.Parse(typeof(ECDRType), notification.Type),
|
|
|
- Route = (ECDRRoute)Enum.Parse(typeof(ECDRRoute), notification.Route),
|
|
|
- CPN = notification.CPN,
|
|
|
- CDPN = notification.CDPN,
|
|
|
- TimeEnd = notification.TimeEnd,
|
|
|
- Duration = notification.Duration,
|
|
|
- TrunkNumber = notification.TrunkNumber,
|
|
|
- Recording = notification.Recording,
|
|
|
- RecCodec = notification.RecCodec,
|
|
|
- };
|
|
|
- if (!string.IsNullOrEmpty(notification.VisitorId))
|
|
|
- model.VisitorId = notification.VisitorId;
|
|
|
+ var model = new CallRecord()
|
|
|
+ {
|
|
|
+ CallId = call.Id,
|
|
|
+ CdrId = notification.Id,
|
|
|
+ CDRCallId = notification.CallId,
|
|
|
+ TimeStart = notification.TimeStart,
|
|
|
+ Group = notification.Group,
|
|
|
+ Type = (ECDRType)Enum.Parse(typeof(ECDRType),notification.Type),
|
|
|
+ Route = (ECDRRoute)Enum.Parse(typeof(ECDRRoute),notification.Route),
|
|
|
+ CPN = notification.CPN,
|
|
|
+ CDPN= notification.CDPN,
|
|
|
+ TimeEnd = notification.TimeEnd,
|
|
|
+ Duration= notification.Duration,
|
|
|
+ TrunkNumber = notification.TrunkNumber,
|
|
|
+ Recording = notification.Recording,
|
|
|
+ RecCodec = notification.RecCodec,
|
|
|
+ };
|
|
|
+ await _callRecordRepository.AddAsync(model, cancellationToken);
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(notification.OuterId))
|
|
|
- model.OuterId = notification.OuterId;
|
|
|
+ call.Duration = double.Parse(model.Duration);
|
|
|
+ await _callRepository.UpdateAsync(call, cancellationToken);
|
|
|
|
|
|
- await _callRecordRepository.AddAsync(model,cancellationToken);
|
|
|
+ //处理Hold计算
|
|
|
+ await _telHoldRepository.HandleHoldTime(call.Id, notification.TimeEnd, cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
- var callModel = await _callRepository.GetAsync(x => x.Id == callDetail.CallId,cancellationToken);
|
|
|
- if (callModel!=null)
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var callDetail = await
|
|
|
+ _callDetailRepository.GetAsync(x => x.OMCallId == notification.CallId, cancellationToken);
|
|
|
+
|
|
|
+ if (callDetail != null)
|
|
|
{
|
|
|
- callModel.Duration = double.Parse(model.Duration);
|
|
|
- await _callRepository.UpdateAsync(callModel, cancellationToken);
|
|
|
- }
|
|
|
+ var model = new CallRecord()
|
|
|
+ {
|
|
|
+ CallId = callDetail.CallId,
|
|
|
+ CdrId = notification.Id,
|
|
|
+ CDRCallId = notification.CallId,
|
|
|
+ TimeStart = notification.TimeStart,
|
|
|
+ Group = notification.Group,
|
|
|
+ Type = (ECDRType)Enum.Parse(typeof(ECDRType), notification.Type),
|
|
|
+ Route = (ECDRRoute)Enum.Parse(typeof(ECDRRoute), notification.Route),
|
|
|
+ CPN = notification.CPN,
|
|
|
+ CDPN = notification.CDPN,
|
|
|
+ TimeEnd = notification.TimeEnd,
|
|
|
+ Duration = notification.Duration,
|
|
|
+ TrunkNumber = notification.TrunkNumber,
|
|
|
+ Recording = notification.Recording,
|
|
|
+ RecCodec = notification.RecCodec,
|
|
|
+ };
|
|
|
+ if (!string.IsNullOrEmpty(notification.VisitorId))
|
|
|
+ model.VisitorId = notification.VisitorId;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(notification.OuterId))
|
|
|
+ model.OuterId = notification.OuterId;
|
|
|
|
|
|
- //处理Hold计算
|
|
|
- await _telHoldRepository.HandleHoldTime(callDetail.CallId,notification.TimeEnd, cancellationToken);
|
|
|
+ await _callRecordRepository.AddAsync(model, cancellationToken);
|
|
|
|
|
|
+ var callModel = await _callRepository.GetAsync(x => x.Id == callDetail.CallId, cancellationToken);
|
|
|
+ if (callModel != null)
|
|
|
+ {
|
|
|
+ callModel.Duration = double.Parse(model.Duration);
|
|
|
+ await _callRepository.UpdateAsync(callModel, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理Hold计算
|
|
|
+ await _telHoldRepository.HandleHoldTime(callDetail.CallId, notification.TimeEnd, cancellationToken);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|