|
@@ -217,7 +217,7 @@ public abstract class DefaultCallApplication : ICallApplication
|
|
|
.WhereIF(dto.Direction != null, d => d.Direction == dto.Direction)
|
|
|
.WhereIF(dto.WaitDurationStart != null && dto.WaitDurationStart > 0, d => d.WaitDuration >= dto.WaitDurationStart)
|
|
|
.WhereIF(dto.WaitDurationEnd != null && dto.WaitDurationEnd > 0, d => d.WaitDuration <= dto.WaitDurationEnd)
|
|
|
- .OrderByDescending(d=>d.Id)
|
|
|
+ .OrderByDescending(d => d.Id)
|
|
|
.Select((d, o) => new CallNativeDto
|
|
|
{
|
|
|
OrderId = o.Id,
|
|
@@ -237,7 +237,7 @@ public abstract class DefaultCallApplication : ICallApplication
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.StaffNo), d => d.StaffNo == dto.StaffNo)
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.GroupId), d => d.GroupId == dto.GroupId)
|
|
|
.WhereIF(dto.OperateState != null, d => d.OperateState == dto.OperateState)
|
|
|
- .OrderByDescending(d=>d.Id)
|
|
|
+ .OrderByDescending(d => d.Id)
|
|
|
.ToFixedListAsync(dto, cancellationToken);
|
|
|
}
|
|
|
|
|
@@ -261,45 +261,29 @@ public abstract class DefaultCallApplication : ICallApplication
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
_logger.LogError($"写入callidRelation失败:{e.Message}");
|
|
|
+ return await GetOrSetCallIdAsync(callNo, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return callOrder.CallId;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 批量获取callId
|
|
|
- /// </summary>
|
|
|
- public virtual async Task<List<(string callNo, string callId)>> GetOrSetCallIdRangeAsync(List<string> callNos,
|
|
|
- CancellationToken cancellationToken)
|
|
|
+ public async Task<CallidRelation> GetRelationAsync(string callNo, CancellationToken cancellation)
|
|
|
{
|
|
|
- var relations = await _callIdRelationRepository.Queryable()
|
|
|
- .Where(d => callNos.Contains(d.Id))
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
+ return await _callIdRelationRepository.GetAsync(callNo, cancellation);
|
|
|
+ }
|
|
|
|
|
|
- var rsp = new List<(string callNo, string callId)>();
|
|
|
- var newRelations = new List<CallidRelation>();
|
|
|
- foreach (var callNo in callNos)
|
|
|
- {
|
|
|
- var relation = relations.FirstOrDefault(d => d.Id == callNo);
|
|
|
- if (relation is null)
|
|
|
- {
|
|
|
- relation = new CallidRelation
|
|
|
- {
|
|
|
- Id = callNo,
|
|
|
- CallId = Ulid.NewUlid().ToString(),
|
|
|
- };
|
|
|
- newRelations.Add(relation);
|
|
|
- rsp.Add(new(relation.Id, relation.CallId));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rsp.Add(new(relation.Id, relation.CallId));
|
|
|
- }
|
|
|
- }
|
|
|
+ public async Task AddRelationAsync(CallidRelation relation, CancellationToken cancellation)
|
|
|
+ {
|
|
|
+ await _callIdRelationRepository.AddAsync(relation, cancellation);
|
|
|
+ }
|
|
|
|
|
|
- await _callIdRelationRepository.AddRangeAsync(newRelations, cancellationToken);
|
|
|
- return rsp;
|
|
|
+ /// <summary>
|
|
|
+ /// 乐观并发更新映射关系
|
|
|
+ /// </summary>
|
|
|
+ public virtual async Task<int> UpdateRelationOptLockAsync(CallidRelation relation, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ return await _callIdRelationRepository.Updateable(relation).ExecuteCommandWithOptLockAsync();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -352,7 +336,7 @@ public abstract class DefaultCallApplication : ICallApplication
|
|
|
/// 查询通话记录
|
|
|
/// </summary>
|
|
|
public virtual Task<List<TrCallRecord>> QueryTianrunCallsAsync(
|
|
|
- string? phone = null,
|
|
|
+ string? phone = null,
|
|
|
ECallDirection? direction = null,
|
|
|
DateTime? callStartTimeStart = null,
|
|
|
DateTime? callStartTimeEnd = null,
|