using Hotline.Caching.Interfaces; using MapsterMapper; using XF.Domain.Authentications; using XF.Domain.Repository; using Hotline.Quality; using Hotline.Permissions; using Hotline.Repository.SqlSugar.Extensions; using Hotline.Settings; using Hotline.Share.Dtos; using Microsoft.AspNetCore.Mvc; using XF.Domain.Exceptions; using Hotline.Share.Dtos.Quality; using Hotline.Share.Enums.Quality; using XF.Utility.EnumExtensions; using Hotline.Application.Quality; using Microsoft.AspNetCore.Authorization; using Hotline.Orders; using Hotline.Ai.Quality; using Hotline.Api.Filter; using Hotline.Application.CallCenter; using Hotline.CallCenter.Configs; using Microsoft.Extensions.Options; using Hotline.Configurations; using Hotline.CallCenter.Calls; using System.Linq; using Hotline.Repository.SqlSugar.Quality; namespace Hotline.Api.Controllers { public class QualityController : BaseController { private readonly ISessionContext _sessionContext; private readonly IMapper _mapper; private readonly IQualityRepository _qualitey; private readonly IRepository _qualiteyDetail; private readonly IRepository _qualiteyItem; private readonly IRepository _qualityTemplate; private readonly IRepository _qualiteyTemplateDetail; private readonly IRepository _qualiteyProhibited; private readonly ISystemDicDataCacheManager _systemDicDataCacheManager; //private readonly IRepository _trCallRecordRepository; private readonly IQualityApplication _qualityApplication; private readonly IOrderRepository _orderRepository; private readonly IServiceProvider _serviceProvider; //private readonly IAiQualityService _aiQualityService; private readonly ILogger _logger; private readonly ISystemSettingCacheManager _systemSettingCacheManager; private readonly ICallApplication _callApplication; private readonly IOptionsSnapshot _appOptions; private readonly IRepository _logRepository; private readonly IRepository _qualityTransferRecordsRepository; public QualityController( ISessionContext sessionContext, IMapper mapper, IQualityRepository qualitey, IRepository qualiteyDetail, IRepository qualiteyItem, IRepository qualityTemplate, IRepository qualiteyTemplateDetail, IRepository qualiteyProhibited, ISystemDicDataCacheManager systemDicDataCacheManager, //IRepository trCallRecordRepository, IQualityApplication qualityApplication, IOrderRepository orderRepository, //IAiQualityService aiQualityService, IServiceProvider serviceProvider, ILogger logger, ISystemSettingCacheManager systemSettingCacheManager, ICallApplication callApplication, IOptionsSnapshot appOptions, IRepository logRepository, IRepository qualityTransferRecordsRepository) { _sessionContext = sessionContext; _mapper = mapper; _qualitey = qualitey; _qualiteyDetail = qualiteyDetail; _qualiteyItem = qualiteyItem; _qualityTemplate = qualityTemplate; _qualiteyTemplateDetail = qualiteyTemplateDetail; _qualiteyProhibited = qualiteyProhibited; _systemDicDataCacheManager = systemDicDataCacheManager; //_trCallRecordRepository = trCallRecordRepository; _qualityApplication = qualityApplication; _orderRepository = orderRepository; _serviceProvider = serviceProvider; //_aiQualityService = aiQualityService; _logger = logger; _systemSettingCacheManager = systemSettingCacheManager; _callApplication = callApplication; _appOptions = appOptions; _logRepository = logRepository; _qualityTransferRecordsRepository = qualityTransferRecordsRepository; } #region 质检管理 /// /// 删除质检 /// /// /// [HttpDelete] public async Task Delete([FromBody] DeleteQualityDto dto) { foreach (var Id in dto.Ids) { await _qualitey.RemoveAsync(x => x.Id == Id); List details = await _qualiteyDetail.Queryable().Where(x => x.QualityId == Id).ToListAsync(); await _qualiteyDetail.RemoveRangeAsync(details, HttpContext.RequestAborted); } } /// /// 更新质检 /// /// /// [HttpPut] public async Task Update([FromBody] UpdateQualityDto dto) { await _qualityApplication.UpdateQualityAsync(dto, HttpContext.RequestAborted); } /// /// 获取质检列表 /// /// /// [HttpGet("list")] public async Task> List([FromQuery] QualityListDto dto) { var (total, items) = await _qualitey.Queryable() .Includes(x => x.Order) .Includes(x => x.Visit) .Includes(x => x.Visit, e => e.Employee) .Includes(x => x.QualityDetails) .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.Order.Title.Contains(dto.Keyword!) || x.Order.No.Contains(dto.Keyword!)) .WhereIF(dto.State.HasValue, x => x.State == dto.State) .WhereIF(dto.Source.HasValue, x => x.Source == dto.Source) .WhereIF(dto.Source.HasValue && dto.Source == EQualitySource.Accepted, x => !string.IsNullOrEmpty(x.Order.CallId)) .WhereIF(dto.Source.HasValue && dto.Source == EQualitySource.Visit, x => !string.IsNullOrEmpty(x.Visit.CallId)) .WhereIF(dto.CreationTimeStart.HasValue, x => x.CreationTime >= dto.CreationTimeStart) .WhereIF(dto.CreationTimeEnd.HasValue, x => x.CreationTime <= dto.CreationTimeEnd) .WhereIF(dto.MaxGrade.HasValue, x => x.Grade <= dto.MaxGrade) .WhereIF(dto.MinGrade.HasValue, x => x.Grade >= dto.MinGrade) .OrderByDescending(x => x.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); return new PagedDto(total, _mapper.Map>(items)); } /// /// 获取质检实体 /// /// /// [HttpGet("{id}")] public async Task Entity(string id) { var quality = await _qualitey.Queryable() .Includes(x => x.Order) .Includes(x => x.Visit) .Includes(x => x.Visit, e => e.Employee) .Includes(x => x.QualityDetails) .FirstAsync(x => x.Id == id); var qualityDto = _mapper.Map(quality); // if (qualityDto.Order != null) { // //var call = await _trCallRecordRepository.Queryable().Where(x => x.CallAccept == qualityDto.Order.CallId).FirstAsync(); //由CallAccept改为OtherAccept // var call = await _trCallRecordRepository.Queryable().Where(x => x.OtherAccept == qualityDto.Order.CallId).FirstAsync(); // if (call != null) // { // qualityDto.Order.RecordingBaseAddress = call.RecordingBaseAddress; // qualityDto.Order.RecordingAbsolutePath = call.RecordingAbsolutePath; // } // } // if (qualityDto.Visit != null) // { // //var call = await _trCallRecordRepository.Queryable().Where(x => x.CallAccept == qualityDto.Visit.CallId).FirstAsync(); //由CallAccept改为OtherAccept // var call = await _trCallRecordRepository.Queryable().Where(x => x.OtherAccept == qualityDto.Visit.CallId).FirstAsync(); // if (call != null) // { // qualityDto.Visit.RecordingBaseAddress = call.RecordingBaseAddress; // qualityDto.Visit.RecordingAbsolutePath = call.RecordingAbsolutePath; // } // } if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun) { if (qualityDto.Order != null) { //var call = await _trCallRecordRepository.Queryable().Where(x => x.CallAccept == qualityDto.Order.CallId).FirstAsync(); //由CallAccept改为OtherAccept //var call = await _trCallRecordRepository.Queryable().Where(x => x.OtherAccept == qualityDto.Order.CallId).FirstAsync(); var call = await _callApplication.GetTianrunCallAsync(qualityDto.Order.CallId, HttpContext.RequestAborted); if (call != null) { qualityDto.Order.RecordingBaseAddress = call.RecordingBaseAddress; qualityDto.Order.RecordingAbsolutePath = call.RecordingAbsolutePath; } } if (qualityDto.Visit != null) { //var call = await _trCallRecordRepository.Queryable().Where(x => x.CallAccept == qualityDto.Visit.CallId).FirstAsync(); //由CallAccept改为OtherAccept // var call = await _trCallRecordRepository.Queryable().Where(x => x.OtherAccept == qualityDto.Visit.CallId).FirstAsync(); var call = await _callApplication.GetTianrunCallAsync(qualityDto.Visit.CallId, HttpContext.RequestAborted); if (call != null) { qualityDto.Visit.RecordingBaseAddress = call.RecordingBaseAddress; qualityDto.Visit.RecordingAbsolutePath = call.RecordingAbsolutePath; } } } else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang) { if (!string.IsNullOrEmpty(qualityDto?.Order?.CallId)) { var call = await _callApplication.GetCallAsync(qualityDto.Order.CallId, HttpContext.RequestAborted); if (call != null) { qualityDto.Order.RecordingBaseAddress = call.AudioFile; qualityDto.Order.RecordingAbsolutePath = call.AudioFile; } } if (!string.IsNullOrEmpty(qualityDto?.Visit?.CallId)) { var call = await _callApplication.GetCallAsync(qualityDto.Visit.CallId, HttpContext.RequestAborted); if (call != null) { qualityDto.Visit.RecordingBaseAddress = call.AudioFile; qualityDto.Visit.RecordingAbsolutePath = call.AudioFile; } } } return qualityDto; } #endregion #region 质检项管理 /// /// 新增项目 /// /// /// [HttpPost("item")] public async Task Add([FromBody] QualityItemAddDto dto) { var count = await _qualiteyItem.CountAsync(x => x.Name == dto.Name); if (count > 0) throw UserFriendlyException.SameMessage("质检项目名称已存在"); var model = _mapper.Map(dto); await _qualiteyItem.AddAsync(model, HttpContext.RequestAborted); } ///// ///// 删除项目 ///// ///// ///// //[HttpDelete("item")] //public async Task Delete([FromBody] QualityItemDeleteDto dto) //{ // await _qualiteyItem.RemoveAsync(x => x.Id == dto.Id); //} /// /// 删除项目 /// /// /// [HttpDelete("itemBatch")] public async Task Delete([FromBody] QualityItemBatchDeleteDto dto) { List items = await _qualiteyItem.Queryable().In(x => x.Id, dto.Ids).ToListAsync(); foreach (var item in items) { var detail = await _qualiteyDetail.Queryable().Where(x => x.Name == item.Name).AnyAsync(); //质检中已存在不可以删 if (detail) items.Remove(item); } if (items.Any()) { await _qualiteyItem.RemoveRangeAsync(items, true, HttpContext.RequestAborted); var tempItems = await _qualiteyTemplateDetail.Queryable().In(x => x.ItemId, items.Select(x => x.Id)).ToListAsync(HttpContext.RequestAborted); if (tempItems.Any()) await _qualiteyTemplateDetail.RemoveRangeAsync(tempItems, HttpContext.RequestAborted); } } /// /// 更新项目 /// /// /// [HttpPut("item")] public async Task Update([FromBody] QualityItemUpdateDto dto) { var item = await _qualiteyItem.GetAsync(dto.Id, HttpContext.RequestAborted); if (item is null) throw UserFriendlyException.SameMessage("无效质检项目"); if (item.IsEnable != dto.IsEnable || item.Name != dto.Name) { var detail = await _qualiteyDetail.Queryable().Where(x => x.Name == item.Name && !x.IsDeleted).AnyAsync(); if (detail) throw UserFriendlyException.SameMessage("质检项目在中心质检中已使用,不能修改状态和名称!"); } _mapper.Map(dto, item); item.LastModificationName = _sessionContext.UserName; await _qualiteyItem.UpdateAsync(item, HttpContext.RequestAborted); } /// /// 获取项目列表 /// /// /// [HttpGet("item/list")] public async Task> List([FromQuery] QualityItemListDto dto) { var (total, items) = await _qualiteyItem.Queryable() .WhereIF(!string.IsNullOrEmpty(dto.Name), d => d.Name.Contains(dto.Name!)) .WhereIF(!string.IsNullOrEmpty(dto.GroupingName), d => d.GroupingName.Contains(dto.GroupingName!)) .WhereIF(dto.IsEnable.HasValue, d => d.IsEnable == dto.IsEnable) .OrderByDescending(x => x.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); return new PagedDto(total, _mapper.Map>(items)); } /// /// 获取项目实体 /// /// /// [HttpGet("item/{id}")] public async Task ItemEntity(string id) { return await _qualiteyItem.Queryable() .FirstAsync(x => x.Id == id); } #endregion #region 质检模版管理 /// /// 新增模版 /// /// /// [HttpPost("template")] public async Task Add([FromBody] TemplateAddDto dto) { var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.IsEnable == 1); if (groupingCount > 0 && dto.IsEnable == 1) throw UserFriendlyException.SameMessage("当前已存在"); var names = dto.TemplateDetails.Select(x => x.ItemId).ToList(); var nameCount = names.GroupBy(x => x).Count(c => c.Count() > 1); if (nameCount > 0) throw UserFriendlyException.SameMessage("质检模版存在重复质检项"); var model = _mapper.Map(dto); var id = await _qualityTemplate.AddAsync(model, HttpContext.RequestAborted); if (!string.IsNullOrEmpty(id)) { foreach (var item in dto.TemplateDetails) { item.TemplateId = id; } List details = _mapper.Map>(dto.TemplateDetails); await _qualiteyTemplateDetail.AddRangeAsync(details, HttpContext.RequestAborted); } } /// /// 删除模版 /// /// /// [HttpDelete("template")] public async Task Delete([FromBody] TemplateDeleteDto dto) { await _qualityTemplate.RemoveAsync(x => x.Id == dto.Id); List details = await _qualiteyTemplateDetail.Queryable().Where(x => x.TemplateId == dto.Id).ToListAsync(); await _qualiteyTemplateDetail.RemoveRangeAsync(details, HttpContext.RequestAborted); } /// /// 删除模版 /// /// /// [HttpDelete("templateBatch")] public async Task Delete([FromBody] TemplateBatchDeleteDto dto) { List templates = await _qualityTemplate.Queryable().In(x => x.Id, dto.Ids).ToListAsync(); List details = await _qualiteyTemplateDetail.Queryable().In(x => x.TemplateId, dto.Ids).ToListAsync(); await _qualityTemplate.RemoveRangeAsync(templates, HttpContext.RequestAborted); await _qualiteyTemplateDetail.RemoveRangeAsync(details, HttpContext.RequestAborted); } /// /// 更新模版 /// /// /// [HttpPut("template")] public async Task Update([FromBody] TemplateUpdateDto dto) { var template = await _qualityTemplate.GetAsync(dto.Id, HttpContext.RequestAborted); if (template is null) throw UserFriendlyException.SameMessage("无效质检模版"); var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.Id != dto.Id && x.IsEnable == 1); if (groupingCount > 0) throw UserFriendlyException.SameMessage("当前质检分类已存在"); _mapper.Map(dto, template); template.LastModificationName = _sessionContext.UserName; await _qualityTemplate.UpdateAsync(template, HttpContext.RequestAborted); if (dto.TemplateDetails.Any()) { List details = await _qualiteyTemplateDetail.Queryable().Where(x => x.TemplateId == dto.Id).ToListAsync(); await _qualiteyTemplateDetail.RemoveRangeAsync(details, HttpContext.RequestAborted); foreach (var item in dto.TemplateDetails) { item.TemplateId = dto.Id; } List newDetails = _mapper.Map>(dto.TemplateDetails); await _qualiteyTemplateDetail.AddRangeAsync(newDetails, HttpContext.RequestAborted); } } /// /// 获取模版列表 /// /// /// [HttpGet("template/list")] public async Task> List([FromQuery] TemplateListDto dto) { var (total, items) = await _qualityTemplate.Queryable() .Includes(x => x.templateDetails) .Includes(x => x.templateDetails, y => y.QualityItem) .WhereIF(!string.IsNullOrEmpty(dto.Name), d => d.Name.Contains(dto.Name!)) .WhereIF(dto.Grouping.HasValue, d => d.Grouping == dto.Grouping) .WhereIF(dto.IsEnable.HasValue, d => d.IsEnable == dto.IsEnable) .OrderByDescending(x => x.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); return new PagedDto(total, _mapper.Map>(items)); } /// /// 获取模版实体 /// /// /// [HttpGet("template/{id}")] public async Task TemplateEntity(string id) { var template = await _qualityTemplate.Queryable() .Includes(x => x.templateDetails) .Includes(x => x.templateDetails, y => y.QualityItem) .FirstAsync(x => x.Id == id); return _mapper.Map(template); } /// /// 启禁用 /// /// /// [HttpPut("template/enable")] public async Task Enable([FromBody] TemplateUpdateDto dto) { var template = await _qualityTemplate.GetAsync(dto.Id, HttpContext.RequestAborted); var groupingCount = await _qualityTemplate.CountAsync(x => x.Grouping == dto.Grouping && x.Id != dto.Id && x.IsEnable == 1); if (groupingCount > 0) throw UserFriendlyException.SameMessage("当前质检分类已存在"); if (template is null) throw UserFriendlyException.SameMessage("无效质检模版"); _mapper.Map(dto, template); await _qualityTemplate.UpdateAsync(template, HttpContext.RequestAborted); } #endregion #region 质检词库管理 /// /// 新增违禁词 /// /// /// [HttpPost("prohibited")] public async Task Add([FromBody] ProhibitedAddDto dto) { var model = _mapper.Map(dto); await _qualiteyProhibited.AddAsync(model, HttpContext.RequestAborted); } /// /// 删除违禁词 /// /// /// [HttpDelete("prohibited")] public async Task Delete([FromBody] ProhibitedDeleteDto dto) { await _qualiteyProhibited.RemoveAsync(x => x.Id == dto.Id); } /// /// 删除违禁词 /// /// /// [HttpDelete("prohibitedBatch")] public async Task Delete([FromBody] ProhibitedBatchDeleteDto dto) { List prohibiteds = await _qualiteyProhibited.Queryable().In(x => x.Id, dto.Ids).ToListAsync(); await _qualiteyProhibited.RemoveRangeAsync(prohibiteds, HttpContext.RequestAborted); } /// /// 更新违禁词 /// /// /// [HttpPut("prohibited")] public async Task Update([FromBody] ProhibitedUpdateDto dto) { var prohibited = await _qualiteyProhibited.GetAsync(dto.Id, HttpContext.RequestAborted); if (prohibited is null) throw UserFriendlyException.SameMessage("无效质检模版"); _mapper.Map(dto, prohibited); prohibited.LastModificationName = _sessionContext.UserName; await _qualiteyProhibited.UpdateAsync(prohibited, HttpContext.RequestAborted); } /// /// 获取违禁词列表 /// /// /// [HttpGet("prohibited/list")] public async Task> List([FromQuery] ProhibitedListDto dto) { var (total, items) = await _qualiteyProhibited.Queryable() .WhereIF(!string.IsNullOrEmpty(dto.Name), d => d.Name.Contains(dto.Name!)) .WhereIF(!string.IsNullOrEmpty(dto.Classify), d => d.Classify.Contains(dto.Classify!)) .WhereIF(!string.IsNullOrEmpty(dto.Type), d => d.Type.Contains(dto.Type!)) .OrderByDescending(x => x.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); return new PagedDto(total, _mapper.Map>(items)); } /// /// 获取违禁词实体 /// /// /// [HttpGet("prohibited/{id}")] public async Task ProhibitedEntity(string id) { return await _qualiteyProhibited.Queryable() .FirstAsync(x => x.Id == id); } #endregion /// /// 获取质检基本信息 /// /// [HttpGet("base")] public async Task Base() { var rsp = new { QualityState = EnumExts.GetDescriptions(), QualitySource = EnumExts.GetDescriptions() }; return rsp; } /// /// 获取质检项目基本信息 /// /// [HttpGet("item_base")] public async Task ItemBase() { var rsp = new { QualityItemGrouping = _systemDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.QualityItemGrouping) }; return rsp; } /// /// 获取质检模版基本信息 /// /// [HttpGet("template_base")] public async Task TemplateBase() { var rsp = new { TemplateGrouping = EnumExts.GetDescriptions() }; return rsp; } /// /// 获取质检违禁词基本信息 /// /// [HttpGet("prohibited_base")] public async Task ProhibitedBase() { var rsp = new { ProhibitedClassify = _systemDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.ProhibitedClassify), ProhibitedType = _systemDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.ProhibitedType), }; return rsp; } /// /// 智能质检转写_兴唐 /// /// /// [HttpPost("aitransfer_xt")] [LogFilter("智能质检转写_兴唐")] public async Task AiTransfer_XT([FromBody] List dto) { var transfers = new List(); foreach (var item in dto) { var records = await _qualityTransferRecordsRepository.Queryable().Where(x=>x.QualityId == item.Id && x.IsFinished == false).AnyAsync(); if (records) continue; var transfer = new QualityTransferRecords(); transfer.QualityId = item.Id; transfer.IsFinished = false; transfer.TransferState = EQualityTransferState.NotStarted; transfers.Add(transfer); await _qualitey.Updateable().SetColumns(x => new Hotline.Quality.Quality { TransferState = EQualityTransferState.Translating }).Where(x => x.Id == item.Id).ExecuteCommandAsync(); } await _qualityTransferRecordsRepository.AddRangeAsync(transfers); } /// /// 智能质检转写 /// /// /// [AllowAnonymous] [HttpPost("transfer")] [LogFilter("智能质检转写_兴唐_定时调用")] public async Task AiTransfer_XT() { var translatings = await _qualityTransferRecordsRepository.Queryable().Where(x => x.IsFinished == false && x.TransferState == EQualityTransferState.Translating).OrderBy(x => x.TransferTime).ToListAsync(); if (translatings.Any()) { var transfer = translatings.FirstOrDefault(); if ((DateTime.Now - transfer.TransferTime.Value).TotalMinutes >= 30) { await _qualityTransferRecordsRepository.Updateable().SetColumns(x => new QualityTransferRecords { TransferState = EQualityTransferState.Lose }).Where(x => x.Id == transfer.Id).ExecuteCommandAsync(); } return; } else { var notStarted = await _qualityTransferRecordsRepository.Queryable().Where(x => x.IsFinished == false && x.TransferState == EQualityTransferState.NotStarted).OrderBy(x => x.TransferTime).FirstAsync(); await _qualityTransferRecordsRepository.Updateable().SetColumns(x => new QualityTransferRecords { TransferState = EQualityTransferState.Translating , TransferTime = DateTime.Now }).Where(x => x.Id == notStarted.Id).ExecuteCommandAsync(); _qualityApplication.Transfer_XT(notStarted.QualityId, HttpContext.RequestAborted); } } /// /// 智能质检结果返回接收 /// /// /// [AllowAnonymous] [HttpPost("AiResult")] [LogFilter("智能质检结果返回接收")] public async Task AiResult([FromBody] List dto) { //Request.EnableBuffering(); //var sr = new StreamReader(Request.Body); //var data = await sr.ReadToEndAsync(HttpContext.RequestAborted); // _logger.LogInformation(data); // await _logRepository.Updateable().SetColumns( x=> new SystemLog(){ ExecuteParam = data }).Where(x => x.Id == "08dcb132-cf60-4d1f-84ae-eb0c463f2175").ExecuteCommandAsync(); await _qualityApplication.AiResultAsync(dto, HttpContext.RequestAborted); } /// /// 重推质检 /// /// /// [AllowAnonymous] [HttpPost("AiResultTest/{id}")] public async Task TaskAsync(string id) { var quality = await _qualitey.GetAsync(id, HttpContext.RequestAborted); var order = await _orderRepository.GetAsync(quality.OrderId, HttpContext.RequestAborted); if (order != null && !string.IsNullOrEmpty(order.CallId)) { quality.AiQuality = true; //var call = await _trCallRecordRepository.GetAsync(x => x.CallAccept == order.CallId, HttpContext.RequestAborted); //由CallAccept改为OtherAccept //var call = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == order.CallId, HttpContext.RequestAborted); var audioFile = string.Empty; var fromNo = string.Empty; DateTime? callStartTime = null; if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun) { var call = await _callApplication.GetTianrunCallAsync(order.CallId, HttpContext.RequestAborted); audioFile = call.RecordingAbsolutePath; fromNo = call.CPN; callStartTime = call.CreatedTime; } else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang) { var call = await _callApplication.GetCallAsync(order.CallId, HttpContext.RequestAborted); audioFile = call.AudioFile; fromNo = call.FromNo; callStartTime = call.BeginIvrTime; } if (_appOptions.Value.IsYiBin) { var aiQualityService = _serviceProvider.GetRequiredService(); var setting = _systemSettingCacheManager.GetSetting(SettingConstants.ViteRecordPrefix); try { await aiQualityService.CreateAiOrderQualityTask( quality.Id, audioFile, fromNo, callStartTime, setting?.SettingValue[0], quality.Source.ToString(), HttpContext.RequestAborted); } catch (Exception e) { _logger.LogError($"写入智能质检异常!, \r\n{e.Message}"); } } await _qualitey.UpdateAsync(quality, HttpContext.RequestAborted); } } } }