HotlineWebController.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. using DataSharing.HotlineWeb;
  2. using DataSharing.Province;
  3. using DataSharing.RawData;
  4. using DataSharing.SendTask;
  5. using DataSharing.Share.Consts;
  6. using DataSharing.Share.Dtos.HotlineWeb;
  7. using DataSharing.Share.Dtos.WebPortal;
  8. using DotNetCore.CAP;
  9. using Hotline.Share.Dtos;
  10. using MapsterMapper;
  11. using MediatR;
  12. using Microsoft.AspNetCore.Authorization;
  13. using Microsoft.AspNetCore.Mvc;
  14. using SqlSugar;
  15. using XF.Domain.Cache;
  16. using XF.Domain.Repository;
  17. namespace DataSharing.Host.Controllers
  18. {
  19. public class HotlineWebController : BaseController
  20. {
  21. private readonly IMapper _mapper;
  22. private readonly IMediator _mediator;
  23. private readonly ICapPublisher _capPublisher;
  24. private readonly IRepository<DsOrder> _dsOrderRepository;
  25. private readonly IRepository<DsTelCall> _dsTelCallRepository;
  26. private readonly IRepository<DsSendTask> _taskRepository;
  27. private readonly IRepository<DsSendTaskInfo> _taskInfoRepository;
  28. private readonly IRepository<ConfigurationInformation> _configurationInformationRepository;
  29. private readonly ITypedCache<ConfigurationInformationDto> _configurationInformationCache;
  30. private readonly IRepository<DsOrderVisitSend> _dsOrderVisitSendRepository;
  31. private readonly IRepository<DsKnowledgeRawData> _knowledgeRawDataRepository;
  32. /// <summary>
  33. ///
  34. /// </summary>
  35. /// <param name="mapper"></param>
  36. /// <param name="mediator"></param>
  37. /// <param name="capPublisher"></param>
  38. /// <param name="dsOrderRepository"></param>
  39. /// <param name="dsTelCallRepository"></param>
  40. /// <param name="taskRepository"></param>
  41. /// <param name="taskInfoRepository"></param>
  42. /// <param name="configurationInformationRepository"></param>
  43. /// <param name="configurationInformationCache"></param>
  44. /// <param name="dsOrderVisitSendRepository"></param>
  45. /// <param name="knowledgeRawDataRepository"></param>
  46. public HotlineWebController(IMapper mapper,
  47. IMediator mediator,
  48. ICapPublisher capPublisher,
  49. IRepository<DsOrder> dsOrderRepository,
  50. IRepository<DsTelCall> dsTelCallRepository,
  51. IRepository<DsSendTask> taskRepository,
  52. IRepository<DsSendTaskInfo> taskInfoRepository,
  53. IRepository<ConfigurationInformation> configurationInformationRepository,
  54. ITypedCache<ConfigurationInformationDto> configurationInformationCache,
  55. IRepository<DsOrderVisitSend> dsOrderVisitSendRepository,
  56. IRepository<DsKnowledgeRawData> knowledgeRawDataRepository
  57. )
  58. {
  59. _mapper = mapper;
  60. _mediator = mediator;
  61. _capPublisher = capPublisher;
  62. _dsOrderRepository = dsOrderRepository;
  63. _dsTelCallRepository = dsTelCallRepository;
  64. _taskRepository = taskRepository;
  65. _taskInfoRepository = taskInfoRepository;
  66. _configurationInformationRepository = configurationInformationRepository;
  67. _configurationInformationCache = configurationInformationCache;
  68. _dsOrderVisitSendRepository = dsOrderVisitSendRepository;
  69. _knowledgeRawDataRepository = knowledgeRawDataRepository;
  70. }
  71. /// <summary>
  72. /// 查询推送任务
  73. /// </summary>
  74. /// <param name="dto"></param>
  75. /// <returns></returns>
  76. [HttpGet("getdssendtask")]
  77. [AllowAnonymous]
  78. public async Task<PagedDto<DsSendTaskDto>> GetDsSendTask([FromQuery] QuerySendTaskDto dto)
  79. {
  80. //数据查询
  81. RefAsync<int> total = 0;
  82. var items = await _taskRepository.Queryable()
  83. .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime)
  84. .WhereIF(dto.EndTime.HasValue, p => p.CreationTime <= dto.EndTime)
  85. .WhereIF(!string.IsNullOrEmpty(dto.Id), p => p.Id == dto.Id)
  86. .WhereIF(dto.IsSuccess.HasValue, p => p.IsSuccess == dto.IsSuccess)
  87. .OrderByDescending(p => p.CreationTime)
  88. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  89. return new PagedDto<DsSendTaskDto>(total, _mapper.Map<List<DsSendTaskDto>>(items));
  90. }
  91. /// <summary>
  92. /// 查询任务推送明细
  93. /// </summary>
  94. /// <param name="dto"></param>
  95. /// <returns></returns>
  96. [HttpGet("getdssendtaskinfo")]
  97. [AllowAnonymous]
  98. public async Task<PagedDto<DsSendTaskInfo>> GetDsSendTaskInfo([FromQuery] QuerySendTaskDto dto)
  99. {
  100. //数据查询
  101. RefAsync<int> total = 0;
  102. var items = await _taskInfoRepository.Queryable()
  103. .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime)
  104. .WhereIF(dto.EndTime.HasValue, p => p.CreationTime <= dto.EndTime)
  105. .WhereIF(!string.IsNullOrEmpty(dto.Id), p => p.TaskId == dto.Id)
  106. .WhereIF(dto.IsSuccess.HasValue, p => p.IsSuccess == dto.IsSuccess)
  107. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  108. return new PagedDto<DsSendTaskInfo>(total, items);
  109. }
  110. /// <summary>
  111. /// 根据ID从新推送
  112. /// </summary>
  113. /// <param name="id">推送任务Id</param>
  114. /// <returns></returns>
  115. [HttpGet("fromnewtasksend")]
  116. [AllowAnonymous]
  117. public async Task FromNewTaskSend(string id)
  118. {
  119. var dto = await _taskRepository.GetAsync(p => p.Id == id, HttpContext.RequestAborted);
  120. if (dto != null)
  121. {
  122. dto.IsSuccess = false;
  123. dto.SendTimes = 1;
  124. await _taskRepository.UpdateAsync(dto, HttpContext.RequestAborted);
  125. }
  126. // await _pusherProviderService.SendProvinceDataPusher(dto, HttpContext.RequestAborted);
  127. }
  128. /// <summary>
  129. /// 修改状态为已推送,防止错误数据一直请求
  130. /// </summary>
  131. /// <param name="id"></param>
  132. /// <returns></returns>
  133. [HttpGet("updatetasksendstate")]
  134. [AllowAnonymous]
  135. public async Task UpdateTaskSendState(string id)
  136. {
  137. var dto = await _taskRepository.GetAsync(p => p.Id == id, HttpContext.RequestAborted);
  138. if (dto != null)
  139. {
  140. dto.SendTimes = 7;
  141. await _taskRepository.UpdateAsync(dto, HttpContext.RequestAborted);
  142. }
  143. }
  144. /// <summary>
  145. /// 查询工单及时上传列表
  146. /// </summary>
  147. /// <param name="dto"></param>
  148. /// <returns></returns>
  149. [HttpGet("getorderlist")]
  150. [AllowAnonymous]
  151. public async Task<PagedDto<DsOrder>> GetOrderlist([FromQuery] QuerySendTaskDto dto)
  152. {
  153. if (!dto.StartTime.HasValue)
  154. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  155. if (!dto.EndTime.HasValue)
  156. dto.EndTime = dto.StartTime.Value.AddDays(1).AddSeconds(-1);
  157. else
  158. dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
  159. //数据查询
  160. RefAsync<int> total = 0;
  161. var items = await _dsOrderRepository.Queryable()
  162. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  163. .Where(p => p.FirstSendProvinceTime != null)
  164. .Where(p => p.StartTime != null)
  165. .Select(p => new
  166. {
  167. p.OrderId,
  168. p.OrderNo,
  169. p.ProvinceNo,
  170. p.WorkflowId,
  171. p.ExternalId,
  172. p.Password,
  173. p.Title,
  174. p.FromName,
  175. p.Contact,
  176. p.Content,
  177. p.CaseDate,
  178. p.StartTime,
  179. p.CallId,
  180. p.FirstSendProvinceTime,
  181. p.LastSendProvinceTime,
  182. p.CaseSource,
  183. p.CaseSourceCode,
  184. p.HotspotId,
  185. p.HotspotName,
  186. p.HotspotSpliceName,
  187. p.ExpiredTime,
  188. p.CaseType,
  189. p.CaseTypeCode
  190. })
  191. .MergeTable()
  192. .Select(p => new
  193. {
  194. p.OrderId,
  195. p.OrderNo,
  196. p.ProvinceNo,
  197. p.WorkflowId,
  198. p.ExternalId,
  199. p.Password,
  200. p.Title,
  201. p.FromName,
  202. p.Contact,
  203. p.Content,
  204. p.CaseDate,
  205. p.StartTime,
  206. p.CallId,
  207. p.FirstSendProvinceTime,
  208. p.LastSendProvinceTime,
  209. p.CaseSource,
  210. p.CaseSourceCode,
  211. p.HotspotId,
  212. p.HotspotName,
  213. p.HotspotSpliceName,
  214. p.ExpiredTime,
  215. p.CaseType,
  216. p.CaseTypeCode
  217. })
  218. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => SqlFunc.DateDiff(DateType.Second, p.StartTime.Value, p.FirstSendProvinceTime.Value) <= 180)//及时上传
  219. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => SqlFunc.DateDiff(DateType.Second, p.StartTime.Value, p.FirstSendProvinceTime.Value) > 180)//不及时上传
  220. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  221. return new PagedDto<DsOrder>(total, _mapper.Map<IReadOnlyList<DsOrder>>(items));
  222. }
  223. /// <summary>
  224. /// 查询通话记录及时上传列表
  225. /// </summary>
  226. /// <param name="dto"></param>
  227. /// <returns></returns>
  228. [HttpGet("getcalllist")]
  229. [AllowAnonymous]
  230. public async Task<PagedDto<DsTelCall>> GetCalllist([FromQuery] QuerySendTaskDto dto)
  231. {
  232. if (!dto.StartTime.HasValue)
  233. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  234. if (!dto.EndTime.HasValue)
  235. dto.EndTime = dto.StartTime.Value.AddDays(1).AddSeconds(-1);
  236. else
  237. dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
  238. RefAsync<int> total = 0;
  239. var items = await _dsTelCallRepository.Queryable()
  240. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  241. .Where(p => p.FirstSendProvinceTime != null)
  242. .Where(p => p.OverTime != null)
  243. .Select(p => new
  244. {
  245. p.CallId,
  246. p.CPN,
  247. p.CDPN,
  248. p.CallDirection,
  249. p.TelNo,
  250. p.UserName,
  251. p.BeginIvrTime,
  252. p.EndIvrTime,
  253. p.BeginQueueTime,
  254. p.EndQueueTime,
  255. p.BeginRingTime,
  256. p.EndRingTimg,
  257. p.AnsweredTime,
  258. p.OverTime,
  259. p.Duration,
  260. p.RingTimes,
  261. p.QueueTims,
  262. p.OnState,
  263. p.RecordingFileUrl,
  264. p.ProvinceNo,
  265. p.FirstSendProvinceTime,
  266. p.LastSendProvinceTime,
  267. p.TaskId
  268. })
  269. .MergeTable()
  270. .Select(p => new
  271. {
  272. p.CallId,
  273. p.CPN,
  274. p.CDPN,
  275. p.CallDirection,
  276. p.TelNo,
  277. p.UserName,
  278. p.BeginIvrTime,
  279. p.EndIvrTime,
  280. p.BeginQueueTime,
  281. p.EndQueueTime,
  282. p.BeginRingTime,
  283. p.EndRingTimg,
  284. p.AnsweredTime,
  285. p.OverTime,
  286. p.Duration,
  287. p.RingTimes,
  288. p.QueueTims,
  289. p.OnState,
  290. p.RecordingFileUrl,
  291. p.ProvinceNo,
  292. p.FirstSendProvinceTime,
  293. p.LastSendProvinceTime,
  294. p.TaskId
  295. })
  296. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => SqlFunc.DateDiff(DateType.Second, p.OverTime.Value, p.FirstSendProvinceTime.Value) <= 180)//及时
  297. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => SqlFunc.DateDiff(DateType.Second, p.OverTime.Value, p.FirstSendProvinceTime.Value) > 180)//不及时
  298. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  299. return new PagedDto<DsTelCall>(total, _mapper.Map<IReadOnlyList<DsTelCall>>(items));
  300. }
  301. /// <summary>
  302. /// 查询没匹配到通话记录的电话来源工单
  303. /// </summary>
  304. /// <param name="dto"></param>
  305. /// <returns></returns>
  306. [HttpGet("getordermatchingcall")]
  307. [AllowAnonymous]
  308. public async Task<PagedDto<DsOrder>> GetOrderMatchingCall([FromQuery] QuerySendTaskDto dto)
  309. {
  310. if (!dto.StartTime.HasValue)
  311. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  312. if (!dto.EndTime.HasValue)
  313. dto.EndTime = dto.StartTime.Value.AddDays(1).AddSeconds(-1);
  314. else
  315. dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
  316. RefAsync<int> total = 0;
  317. var items = await _dsOrderRepository.Queryable()
  318. .LeftJoin<DsTelCall>((p, o) => p.CallId == o.CallId)
  319. .Where((p, o) => p.FirstSendProvinceTime >= dto.StartTime && p.FirstSendProvinceTime <= dto.EndTime && p.CaseSourceCode == "RGDH")
  320. .Where((p, o) => p.FirstSendProvinceTime.HasValue)
  321. .Where((p, o) => o.CallId == null)
  322. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  323. return new PagedDto<DsOrder>(total, _mapper.Map<IReadOnlyList<DsOrder>>(items));
  324. }
  325. /// <summary>
  326. /// 及时率查询
  327. /// </summary>
  328. /// <param name="StartDate"></param>
  329. /// <param name="EndDate"></param>
  330. /// <returns></returns>
  331. [HttpGet("calculateuploadrate")]
  332. [AllowAnonymous]
  333. public async Task<CalculateUploadRateDto> CalculateUploadRate(DateTime StartDate, DateTime EndDate)
  334. {
  335. EndDate = EndDate.AddDays(1).AddSeconds(-1);
  336. CalculateUploadRateDto calculateUploadRateDto = new();
  337. //工单
  338. var orderRate = await _dsOrderRepository.Queryable()
  339. .LeftJoin<DsTelCall>((p, o) => p.CallId == o.CallId)
  340. .Where((p, o) => p.CreationTime >= StartDate && p.CreationTime <= EndDate && p.FirstSendProvinceTime >= StartDate && p.FirstSendProvinceTime <= EndDate)
  341. .Where((p, o) => p.FirstSendProvinceTime.HasValue)
  342. .Where((p, o) => p.StartTime.HasValue)
  343. .Select((p, o) => new
  344. {
  345. p.OrderId,
  346. p.StartTime,
  347. p.FirstSendProvinceTime,
  348. p.CaseSourceCode,
  349. o.CallId,
  350. p.HandleState,
  351. p.ExpiredTime,
  352. p.ActualHandleTime
  353. }).MergeTable()
  354. .Select(p => new CalculateUploadRateDto
  355. {
  356. OrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.OrderId != null, 1, 0)),//总工单数
  357. OrderTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.StartTime.Value, p.FirstSendProvinceTime.Value) <= 180, 1, 0)),//及时
  358. OrderNotTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.StartTime.Value, p.FirstSendProvinceTime.Value) > 180, 1, 0)),//为及时
  359. RGDHOrderCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CaseSourceCode == "RGDH", 1, 0)),
  360. ContainTel = SqlFunc.AggregateSum(SqlFunc.IIF(p.CaseSourceCode == "RGDH" && p.CallId != null, 1, 0)),//匹配数
  361. NotContainTel = SqlFunc.AggregateSum(SqlFunc.IIF(p.CaseSourceCode == "RGDH" && p.CallId == null, 1, 0)),//未匹配数
  362. HandleEndOrderNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.HandleState == "办理完成", 1, 0)),//办结件数
  363. HandleEndOrderOnTime = SqlFunc.AggregateSum(SqlFunc.IIF(p.HandleState == "办理完成" && p.ExpiredTime < p.ActualHandleTime, 1, 0)),//按时办结件数
  364. })
  365. .ToListAsync();
  366. ///电话
  367. var callRate = await _dsTelCallRepository.Queryable()
  368. .Where(p => p.OverTime >= StartDate && p.OverTime <= EndDate && p.FirstSendProvinceTime >= StartDate && p.FirstSendProvinceTime <= EndDate)
  369. .Where(p => p.FirstSendProvinceTime.HasValue)
  370. .Where(p => p.OverTime.HasValue)
  371. .Select(p => new
  372. {
  373. p.CallId,
  374. p.OverTime,
  375. p.FirstSendProvinceTime,
  376. p.OnState
  377. })
  378. .MergeTable()
  379. .Select(p => new CalculateUploadRateDto
  380. {
  381. TelCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.CallId != null, 1, 0)),//总电话数
  382. TelTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.OverTime.Value, p.FirstSendProvinceTime.Value) <= 180, 1, 0)),//及时
  383. TelNotTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.OverTime.Value, p.FirstSendProvinceTime.Value) > 180, 1, 0)),//为及时
  384. TelConnectCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.OnState == "1", 1, 0)),//接通数量
  385. TelNotConnectCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.OnState != "1", 1, 0)),//未接通数量
  386. })
  387. .ToListAsync();
  388. //回访
  389. var visitList = await _dsOrderVisitSendRepository.Queryable()
  390. .Where(p => p.VisitTime >= StartDate && p.VisitTime <= EndDate && p.IsProvince == false && p.FirstSendProvinceTime >= StartDate && p.FirstSendProvinceTime <= EndDate)
  391. .Select(p => new
  392. {
  393. p.SubjectResultSatifyCode,
  394. p.VisitTime,
  395. p.IsProvince,
  396. p.Source,
  397. p.ProvinceNo
  398. })
  399. .MergeTable()
  400. .Select(p => new CalculateUploadRateDto
  401. {
  402. VisitCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.SubjectResultSatifyCode != null, 1, 0)),//回访总量
  403. SatisfactionCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.SubjectResultSatifyCode != null && p.SubjectResultSatifyCode != "2", 1, 0)),//满意数量
  404. NotSatisfiedCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.SubjectResultSatifyCode != null && p.SubjectResultSatifyCode == "2", 1, 0)),//不满意数量
  405. })
  406. .ToListAsync();
  407. //查询知识总量
  408. calculateUploadRateDto.KnowledgeCount = await _knowledgeRawDataRepository.Queryable()
  409. .Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate)
  410. .CountAsync();
  411. //修改知识库量-以第一次上传成功的记录为准
  412. calculateUploadRateDto.UpdateKnowledgeCount = await _taskRepository.Queryable()
  413. .Where(p => p.FirstTime >= StartDate && p.FirstTime <= EndDate && p.TaskType == "GetKnowledgeInfoUpdate")
  414. .Select(p => new
  415. {
  416. p.Id,
  417. RowID = SqlFunc.RowNumber($"{p.CreationTime} asc ")
  418. })
  419. .MergeTable()
  420. .Where(p => p.RowID == 1)
  421. .CountAsync();
  422. //工单
  423. if (orderRate != null && orderRate.Count > 0)
  424. {
  425. var orderRateData = orderRate[0];
  426. calculateUploadRateDto.OrderCountNum = orderRateData.OrderCountNum;
  427. calculateUploadRateDto.OrderTimely = orderRateData.OrderTimely;
  428. calculateUploadRateDto.OrderNotTimely = orderRateData.OrderNotTimely;
  429. calculateUploadRateDto.RGDHOrderCount = orderRateData.RGDHOrderCount;
  430. calculateUploadRateDto.ContainTel = orderRateData.ContainTel;
  431. calculateUploadRateDto.NotContainTel = orderRateData.NotContainTel;
  432. calculateUploadRateDto.HandleEndOrderNum = orderRateData.HandleEndOrderNum;
  433. calculateUploadRateDto.HandleEndOrderOnTime = orderRateData.HandleEndOrderOnTime;
  434. }
  435. //电话
  436. if (callRate != null && callRate.Count > 0)
  437. {
  438. var callRateData = callRate[0];
  439. calculateUploadRateDto.TelCountNum = callRateData.TelCountNum;
  440. calculateUploadRateDto.TelTimely = callRateData.TelTimely;
  441. calculateUploadRateDto.TelNotTimely = callRateData.TelNotTimely;
  442. calculateUploadRateDto.TelConnectCountNum = callRateData.TelConnectCountNum;
  443. calculateUploadRateDto.TelNotConnectCountNum = callRateData.TelNotConnectCountNum;
  444. }
  445. //回访
  446. if (visitList != null && visitList.Count > 0)
  447. {
  448. var visitRateData = visitList[0];
  449. calculateUploadRateDto.VisitCountNum = visitRateData.VisitCountNum;
  450. calculateUploadRateDto.SatisfactionCountNum = visitRateData.SatisfactionCountNum;
  451. calculateUploadRateDto.NotSatisfiedCountNum = visitRateData.NotSatisfiedCountNum;
  452. }
  453. return calculateUploadRateDto;
  454. }
  455. #region 系统配置
  456. /// <summary>
  457. /// 上传数据系统配置-查询详情
  458. /// </summary>
  459. /// <returns></returns>
  460. [AllowAnonymous]
  461. [HttpGet("info-configurationinformation")]
  462. public async Task<ConfigurationInformation> GetStandard()
  463. {
  464. var sandard = await _configurationInformationRepository.Queryable().FirstAsync();
  465. if (sandard == null)
  466. {
  467. ConfigurationInformation configuration = new()
  468. {
  469. CrntSeatNum = 0,
  470. CrntTelNum = 0,
  471. SeatNum = 0,
  472. SeatHwyNum = 0,
  473. MissedCallCount = 0
  474. };
  475. var Id = await _configurationInformationRepository.AddAsync(configuration, HttpContext.RequestAborted);
  476. return await _configurationInformationRepository.GetAsync(Id, HttpContext.RequestAborted);
  477. }
  478. return sandard;
  479. }
  480. /// <summary>
  481. /// 上传数据系统配置-修改
  482. /// </summary>
  483. /// <param name="dto"></param>
  484. /// <returns></returns>
  485. [AllowAnonymous]
  486. [HttpPut("update-configurationinformation")]
  487. public async Task UpdateStandard([FromBody] ConfigurationInformationDto dto)
  488. {
  489. var standard = await _configurationInformationRepository.GetAsync(dto.Id);
  490. if (standard != null)
  491. {
  492. _mapper.Map(dto, standard);
  493. await _configurationInformationRepository.UpdateAsync(standard, HttpContext.RequestAborted);
  494. await _configurationInformationCache.GetOrSetAsync(ConstantSettings.ConfigurationInformationCacheKey, dto, cancellationToken: HttpContext.RequestAborted);
  495. }
  496. }
  497. #endregion
  498. }
  499. }