|
@@ -4,22 +4,30 @@ using DataSharing.RawData;
|
|
using DataSharing.SendTask;
|
|
using DataSharing.SendTask;
|
|
using DataSharing.Share.Dtos;
|
|
using DataSharing.Share.Dtos;
|
|
using DataSharing.Share.Dtos.Enterprise;
|
|
using DataSharing.Share.Dtos.Enterprise;
|
|
|
|
+using DataSharing.Share.Dtos.Province;
|
|
using DataSharing.Share.Dtos.Province.Extend;
|
|
using DataSharing.Share.Dtos.Province.Extend;
|
|
using DataSharing.Share.Dtos.Province.HuiJu;
|
|
using DataSharing.Share.Dtos.Province.HuiJu;
|
|
using DataSharing.Share.Dtos.Province.XieTong.Knowledge;
|
|
using DataSharing.Share.Dtos.Province.XieTong.Knowledge;
|
|
using DataSharing.Share.Dtos.Province.XieTong.Receive;
|
|
using DataSharing.Share.Dtos.Province.XieTong.Receive;
|
|
using DataSharing.Share.Dtos.Province.XieTong.Send;
|
|
using DataSharing.Share.Dtos.Province.XieTong.Send;
|
|
|
|
+using DataSharing.Share.Dtos.WebPortal;
|
|
using DataSharing.Share.Enums;
|
|
using DataSharing.Share.Enums;
|
|
using DotNetCore.CAP;
|
|
using DotNetCore.CAP;
|
|
using Hotline.Share.Dtos.Knowledge;
|
|
using Hotline.Share.Dtos.Knowledge;
|
|
using Hotline.Share.Dtos.Order;
|
|
using Hotline.Share.Dtos.Order;
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
|
|
+using Hotline.Share.Enums.CallCenter;
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
using Hotline.Share.Enums.Order;
|
|
using Hotline.Share.Enums.Order;
|
|
|
|
+using Mapster.Utils;
|
|
using MapsterMapper;
|
|
using MapsterMapper;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
+using System;
|
|
|
|
+using System.Collections.Generic;
|
|
using System.Security.Cryptography;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Text;
|
|
|
|
+using System.Threading;
|
|
|
|
+using XF.Domain.Cache;
|
|
using XF.Domain.Dependency;
|
|
using XF.Domain.Dependency;
|
|
using XF.Domain.Repository;
|
|
using XF.Domain.Repository;
|
|
|
|
|
|
@@ -38,6 +46,8 @@ namespace DataSharing.Application.Receivers
|
|
private readonly IRepository<DsKnowledgeRawData> _knowledgeRawDataRepository;
|
|
private readonly IRepository<DsKnowledgeRawData> _knowledgeRawDataRepository;
|
|
private readonly IChannelConfigurationManager _channelConfigurationManager;
|
|
private readonly IChannelConfigurationManager _channelConfigurationManager;
|
|
private readonly IRepository<DsSendCaseInfo> _sendCaseInfoRepository;
|
|
private readonly IRepository<DsSendCaseInfo> _sendCaseInfoRepository;
|
|
|
|
+ private readonly ITypedCache<MissedCallModelDto> _missedCallModelCache;
|
|
|
|
+ private readonly string MissedCallKey = "missedCallKey_";
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 资源注入
|
|
/// 资源注入
|
|
@@ -58,7 +68,8 @@ namespace DataSharing.Application.Receivers
|
|
IRepository<DsOrderWorkFlow> dataOrderWorkFlowRepository,
|
|
IRepository<DsOrderWorkFlow> dataOrderWorkFlowRepository,
|
|
IRepository<DsKnowledgeRawData> knowledgeRawDataRepository,
|
|
IRepository<DsKnowledgeRawData> knowledgeRawDataRepository,
|
|
IChannelConfigurationManager channelConfigurationManager,
|
|
IChannelConfigurationManager channelConfigurationManager,
|
|
- IRepository<DsSendCaseInfo> sendCaseInfoRepository)
|
|
|
|
|
|
+ IRepository<DsSendCaseInfo> sendCaseInfoRepository,
|
|
|
|
+ ITypedCache<MissedCallModelDto> missedCallModelCache)
|
|
{
|
|
{
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
_logger = logger;
|
|
_logger = logger;
|
|
@@ -70,6 +81,7 @@ namespace DataSharing.Application.Receivers
|
|
_knowledgeRawDataRepository = knowledgeRawDataRepository;
|
|
_knowledgeRawDataRepository = knowledgeRawDataRepository;
|
|
_channelConfigurationManager = channelConfigurationManager;
|
|
_channelConfigurationManager = channelConfigurationManager;
|
|
_sendCaseInfoRepository = sendCaseInfoRepository;
|
|
_sendCaseInfoRepository = sendCaseInfoRepository;
|
|
|
|
+ _missedCallModelCache = missedCallModelCache;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -528,6 +540,13 @@ namespace DataSharing.Application.Receivers
|
|
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineCallBye)]
|
|
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineCallBye)]
|
|
public async Task SubmitCaseRecordAsync(PublishCallRecrodDto dto, CancellationToken cancellationToken)
|
|
public async Task SubmitCaseRecordAsync(PublishCallRecrodDto dto, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
|
|
+ //验证是否需要推送未接数据
|
|
|
|
+ if (dto != null && dto.TrCallRecordDto != null && dto.TrCallRecordDto.OnState == EOnState.NoOn)
|
|
|
|
+ {
|
|
|
|
+ if (!await IsPublishMissedCall(dto.TrCallRecordDto, cancellationToken))
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
var data = _mapper.Map<SubmitCaseRecordInfo>(dto.TrCallRecordDto);
|
|
var data = _mapper.Map<SubmitCaseRecordInfo>(dto.TrCallRecordDto);
|
|
if (dto.Order != null)
|
|
if (dto.Order != null)
|
|
{
|
|
{
|
|
@@ -552,7 +571,6 @@ namespace DataSharing.Application.Receivers
|
|
//将待推送数据写入待推送表
|
|
//将待推送数据写入待推送表
|
|
await InitPushDataAsync("SubmitCaseRecord", "submit_case_record", jsonData, pathType: EPathType.HuiJu, taskPriority: 20, cancellationToken: cancellationToken);
|
|
await InitPushDataAsync("SubmitCaseRecord", "submit_case_record", jsonData, pathType: EPathType.HuiJu, taskPriority: 20, cancellationToken: cancellationToken);
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -1465,6 +1483,78 @@ namespace DataSharing.Application.Receivers
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 检查是否需要推送未接通话记录
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private async Task<bool> IsPublishMissedCall(TrCallDto dto, CancellationToken cancellationToken)
|
|
|
|
+ {
|
|
|
|
+ var key = MissedCallKey + DateTime.Now.ToString("yyyyMMdd");
|
|
|
|
+ var provinceConfiguration = _channelConfigurationManager.GetConfigurationProvince();
|
|
|
|
+ var missedCallCount = provinceConfiguration.MissedCallCount;
|
|
|
|
+
|
|
|
|
+ var dataCache = await _missedCallModelCache.GetAsync(key, cancellationToken);
|
|
|
|
+ if (dataCache != null)
|
|
|
|
+ {
|
|
|
|
+ //如果存在值,检查是否已经达到推送最大值
|
|
|
|
+ if (!dataCache.IsMax && dataCache.DateTimeList.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ //没有达到最大值
|
|
|
|
+ //检查第一条数据是否匹配当前推送时间
|
|
|
|
+ var list = dataCache.DateTimeList;
|
|
|
|
+ if (list[0] < dto.AnsweredTime)
|
|
|
|
+ {
|
|
|
|
+ //处理数据
|
|
|
|
+ list.RemoveAt(0);
|
|
|
|
+
|
|
|
|
+ dataCache.DateTimeList = list;
|
|
|
|
+ //是否推送完成
|
|
|
|
+ if (list == null || list.Count == 0)
|
|
|
|
+ dataCache.IsMax = true;
|
|
|
|
+
|
|
|
|
+ //从新写入数据
|
|
|
|
+ await _missedCallModelCache.SetAsync(key, dataCache, TimeSpan.FromDays(1), cancellationToken);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ #region 生成时间
|
|
|
|
+ //生成时间
|
|
|
|
+ List<DateTime> timeLists = new();
|
|
|
|
+ Random random = new((int)(DateTime.Now.Ticks));
|
|
|
|
+ for (int i = 0; i < missedCallCount; i++)
|
|
|
|
+ {
|
|
|
|
+ int hour = random.Next(2, 23);
|
|
|
|
+ int minute = random.Next(0, 60);
|
|
|
|
+ int second = random.Next(0, 60);
|
|
|
|
+ string tempStr = string.Format("{0} {1}:{2}:{3}", DateTime.Now.ToString("yyyy-MM-dd"), hour, minute, second);
|
|
|
|
+ DateTime rTime = Convert.ToDateTime(tempStr);
|
|
|
|
+ timeLists.Add(rTime);
|
|
|
|
+ }
|
|
|
|
+ timeLists.Sort();
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ if (timeLists[0] < dto.AnsweredTime)
|
|
|
|
+ //处理数据
|
|
|
|
+ timeLists.RemoveAt(0);
|
|
|
|
+
|
|
|
|
+ MissedCallModelDto missedCall = new()
|
|
|
|
+ {
|
|
|
|
+ DateTimeList = timeLists
|
|
|
|
+ };
|
|
|
|
+ if (timeLists == null || timeLists.Count == 0)
|
|
|
|
+ missedCall.IsMax = true;
|
|
|
|
+
|
|
|
|
+ await _missedCallModelCache.SetAsync(key, missedCall, TimeSpan.FromDays(1), cancellationToken);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region 组装110数据
|
|
#region 组装110数据
|