using DotNetCore.CAP; using Hotline.Application.Quality; using Hotline.Caching.Interfaces; using Hotline.File; using Hotline.FlowEngine.Workflows; using Hotline.Orders; using Hotline.Repository.SqlSugar.Extensions; using Hotline.Repository.SqlSugar.Ts; using Hotline.Settings.TimeLimits; using Hotline.Share.Dtos; using Hotline.Share.Dtos.DataSharing.PusherHotlineDto; using Hotline.Share.Dtos.File; using Hotline.Share.Dtos.FlowEngine; using Hotline.Share.Dtos.FlowEngine.Workflow; using Hotline.Share.Dtos.Order; using Hotline.Share.Dtos.Settings; using Hotline.Share.Enums.Order; using Hotline.Share.Enums.Quality; using Hotline.Share.Enums.Settings; using Hotline.Tools; using MapsterMapper; using SqlSugar; using XF.Domain.Authentications; using XF.Domain.Constants; using XF.Domain.Dependency; using XF.Domain.Exceptions; using XF.Domain.Repository; namespace Hotline.Application.Orders; public class OrderApplication : IOrderApplication, IScopeDependency { private readonly IOrderDomainService _orderDomainService; private readonly IWorkflowDomainService _workflowDomainService; private readonly IOrderRepository _orderRepository; private readonly ITimeLimitDomainService _timeLimitDomainService; private readonly IMapper _mapper; private readonly ISystemSettingCacheManager _systemSettingCacheManager; private readonly IRepository _orderWrodRepository; private readonly IRepositoryTextSearch _repositoryts; private readonly IFileRepository _fileRepository; private readonly ISessionContext _sessionContext; private readonly IRepository _orderVisitRepository; private readonly IRepository _orderVisitDetailRepository; private readonly IQualityApplication _qualityApplication; private readonly ICapPublisher _capPublisher; public OrderApplication( IOrderDomainService orderDomainService, IOrderRepository orderRepository, IWorkflowDomainService workflowDomainService, ITimeLimitDomainService timeLimitDomainService, ISystemSettingCacheManager systemSettingCacheManager, IMapper mapper, IRepository orderWrodRepository, IRepositoryTextSearch repositoryts, IFileRepository fileRepository, ISessionContext sessionContext, IRepository orderVisitRepository, IRepository orderVisitDetailRepository, IQualityApplication qualityApplication, ICapPublisher capPublisher ) { _orderDomainService = orderDomainService; _workflowDomainService = workflowDomainService; _orderRepository = orderRepository; _timeLimitDomainService = timeLimitDomainService; _mapper = mapper; _systemSettingCacheManager = systemSettingCacheManager; _orderWrodRepository = orderWrodRepository; _repositoryts = repositoryts; _fileRepository = fileRepository; _sessionContext = sessionContext; _orderVisitRepository = orderVisitRepository; _orderVisitDetailRepository = orderVisitDetailRepository; _qualityApplication = qualityApplication; _capPublisher = capPublisher; } /// /// 更新工单办理期满时间(延期调用,其他不调用) /// 1.更新工单 2.更新流程 3.推送省平台 /// /// public async Task DelayOrderExpiredTimeAsync(string orderId, int timeCount, ETimeType timeType, CancellationToken cancellationToken) { var order = await _orderDomainService.GetOrderAsync(orderId, cancellationToken: cancellationToken); var expiredTimeConfig = _timeLimitDomainService.CalcEndTime(DateTime.Now, new TimeConfig(timeCount, timeType), order.AcceptTypeCode); order.TimeLimit = expiredTimeConfig.TimeText; order.TimeLimitCount = expiredTimeConfig.Count; order.TimeLimitUnit = expiredTimeConfig.TimeType; order.ExpiredTime = expiredTimeConfig.ExpiredTime; order.NearlyExpiredTime = expiredTimeConfig.NearlyExpiredTime; //if (string.IsNullOrEmpty(order.WorkflowId)) // throw new UserFriendlyException("该工单流程id异常"); //var workflow = await _workflowDomainService.GetWorkflowAsync(order.WorkflowId, cancellationToken: cancellationToken); //await _workflowDomainService.UpdateExpiredTimeAsync(workflow, expiredTimeConfig.ExpiredTime, // expiredTimeConfig.TimeText, expiredTimeConfig.Count, expiredTimeConfig.TimeType, expiredTimeConfig.NearlyExpiredTime, cancellationToken); if (string.IsNullOrEmpty(order.WorkflowId)) throw new UserFriendlyException("该工单流程id异常"); await _workflowDomainService.UpdateUnhandleExpiredTimeAsync(order.WorkflowId, expiredTimeConfig.ExpiredTime, cancellationToken); await _orderRepository.UpdateAsync(order, cancellationToken); } /// /// 新增工单办理流程记录 /// public async Task AddOrderTracesAsync(string orderId, ICollection traces, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderId, cancellationToken); if (order is null) throw new UserFriendlyException("工单不存在"); if (string.IsNullOrEmpty(order.WorkflowId)) throw new UserFriendlyException("工单未开启流程"); await _workflowDomainService.AddTracesAsync(order.WorkflowId, _mapper.Map>(traces), cancellationToken); } /// /// 撤销工单 /// public async Task CancelOrderAsync(string orderId, string opinion, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderId, cancellationToken); if (order is null) throw new UserFriendlyException("工单不存在"); if (!string.IsNullOrEmpty(order.WorkflowId)) { //结束流程 await _workflowDomainService.TerminateAsync(new TerminateDto { WorkflowId = order.WorkflowId, Opinion = opinion }, cancellationToken); } //归档工单 var now = DateTime.Now; var handleDuration = order.StartTime.HasValue ? _timeLimitDomainService.CalcWorkTime(order.StartTime.Value, now, order.ProcessType is EProcessType.Zhiban) : 0; var fileDuration = order.CenterToOrgTime.HasValue ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value, now, order.ProcessType is EProcessType.Zhiban) : 0; var allDuration = order.StartTime.HasValue ? _timeLimitDomainService.CalcWorkTime(order.StartTime.Value, now, order.ProcessType is EProcessType.Zhiban) : 0; order.File(now, handleDuration, fileDuration, allDuration); await _orderRepository.UpdateAsync(order, cancellationToken); } /// /// 即将超期列表 /// /// /// /// public async Task> GetAboutToExpireAsync(AboutToExpireListDto dto, CancellationToken cancellationToken) { var setting = _systemSettingCacheManager.GetSetting(SettingConstants.OrderAboutToExpire); var value = setting?.SettingValue[0]; value = string.IsNullOrEmpty(value) ? "0" : value; DateTime stTime = DateTime.Now.AddDays(int.Parse(value)); stTime = _timeLimitDomainService.WorkDay(DateTime.Now); DateTime stTime2 = _timeLimitDomainService.WorkDay(DateTime.Now); var (total, items) = await _orderRepository.Queryable(viewFilter: true) .WhereIF(dto.IsProvince.HasValue, x => x.IsProvince == dto.IsProvince) .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.Title.Contains(dto.Keyword!) || x.No.Contains(dto.Keyword!)) .Where(x => x.ExpiredTime != null && x.Status != EOrderStatus.Filed && x.Status != EOrderStatus.Published && x.Status != EOrderStatus.Visited && stTime >= x.ExpiredTime.Value && stTime2 <= x.ExpiredTime.Value) .OrderByDescending(x => x.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, cancellationToken); return new PagedDto(total, _mapper.Map>(items)); } // /// // /// 即将超期节点列表 // /// // /// // /// // /// //public async Task> GetAboutToExpireNodeAsync(AboutToExpireListDto dto, CancellationToken cancellationToken) //{ // var setting = _systemSettingCacheManager.GetSetting(SettingConstants.OrderAboutToExpire); // var value = setting?.SettingValue[0]; // value = string.IsNullOrEmpty(value) ? "0" : value; // DateTime stTime = DateTime.Now.AddDays(int.Parse(value)); // stTime = _timeLimitDomainService.WorkDay(DateTime.Now); // DateTime stTime2 = _timeLimitDomainService.WorkDay(DateTime.Now); // RefAsync total = 0; // var items = await Db.Queryable() // .LeftJoin((x, o) => x.ExternalId == o.Id) // .Where(x => x.ModuleCode == "OrderHandle") // .WhereIF(dto.IsProvince.HasValue, (x, o) => o.IsProvince == dto.IsProvince) // .WhereIF(!string.IsNullOrEmpty(dto.Keyword), (x, o) => o.Title.Contains(dto.Keyword!) || o.No.Contains(dto.Keyword!)) // .Where((x, o) => (int)x.Status < 20 && stTime >= x.ExpiredTime && stTime2 <= x.ExpiredTime) // .Select((x, o) => new WorkflowOrder { Order = o }, true) // .OrderByDescending(x => x.CreationTime) // .ToPageListAsync(dto.PageIndex, dto.PageSize, total, cancellationToken); // return new PagedDto(total, _mapper.Map>(items)); //} /// /// 已超期列表 /// /// /// /// public async Task> GetToExpireAsync(AboutToExpireListDto dto, CancellationToken cancellationToken) { DateTime stTime = _timeLimitDomainService.WorkDay(DateTime.Now); var (total, items) = await _orderRepository.Queryable(viewFilter: true) .WhereIF(dto.IsProvince.HasValue, x => x.IsProvince == dto.IsProvince) .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.Title.Contains(dto.Keyword!) || x.No.Contains(dto.Keyword!)) //.WhereIF(!string.IsNullOrEmpty(dto.No), x => x.No == dto.No) //.WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Title.Contains(dto.Title!)) .Where(x => x.ExpiredTime != null && (((x.Status == EOrderStatus.Filed || x.Status == EOrderStatus.Published || x.Status == EOrderStatus.Visited) && x.FiledTime >= x.ExpiredTime) || ((x.Status != EOrderStatus.Filed && x.Status != EOrderStatus.Published && x.Status != EOrderStatus.Visited) && stTime >= x.ExpiredTime.Value))) .OrderByDescending(x => x.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, cancellationToken); return new PagedDto(total, _mapper.Map>(items)); } // /// // /// 已超期节点列表 // /// // /// // /// // /// // public async Task> GetToExpireNodeAsync(AboutToExpireListDto dto, CancellationToken cancellationToken) // { // DateTime stTime = _timeLimitDomainService.WorkDay(DateTime.Now); //RefAsync total = 0; //var items= await Db.Queryable() // .LeftJoin((x,o)=>x.ExternalId == o.Id) // .Where(x => x.ModuleCode == "OrderHandle") // .WhereIF(dto.IsProvince.HasValue, (x, o) => o.IsProvince == dto.IsProvince) // .WhereIF(!string.IsNullOrEmpty(dto.Keyword), (x, o) => o.Title.Contains(dto.Keyword!) || o.No.Contains(dto.Keyword!)) // .Where((x,o) => (((int)x.Status >= 20 && x.EndTime >= x.ExpiredTime) || ((int)x.Status < 20 && stTime >= x.ExpiredTime))) // .Select((x, o) => new WorkflowOrder { Order = o }, true) // .OrderByDescending(x => x.CreationTime) // .ToPageListAsync(dto.PageIndex, dto.PageSize, total, cancellationToken); // return new PagedDto(total, _mapper.Map>(items)); // } /// /// 工单关键字分词 /// /// /// public async Task OrderParticiple(string inputStr, string orderId, CancellationToken cancellationToken) { var words = await _orderWrodRepository.Queryable().Where(x => x.IsEnable == 1 && x.Classify.Contains("普通标签")).Select(x => x.Tag).ToListAsync(cancellationToken); var res = new List(); if (words.Any()) res = ParticipleTool.SegMMDouble(inputStr, ref words); var participles = await _orderWrodRepository.Queryable().In(x => x.Tag, res).ToListAsync(cancellationToken); if (participles.Any()) { //关键词 var tags = participles.Select(x => x.Tag).ToList(); var tagsStr = string.Join(",", tags); await _orderRepository.Updateable().SetColumns(x => x.TagNames == tagsStr).Where(x => x.Id == orderId).ExecuteCommandAsync(cancellationToken); List synonyms = participles.Select(x => x.Synonym).ToList(); if (synonyms.Any()) { var synonymsStr = string.Join(",", synonyms); synonyms = synonymsStr.Split(",").Distinct().ToList(); tags.AddRange(synonyms); } var vector = await _orderRepository.Queryable().Where(x => x.Id == orderId).ToListAsync(cancellationToken); if (vector.Any()) await _repositoryts.UpdateVectorAsync(orderId, tags, cancellationToken); else await _repositoryts.AddVectorAsync(orderId, DateTime.Now, tags, cancellationToken); } } public async Task OrderSensitiveParticiple(string inputStr, string orderId, CancellationToken cancellationToken) { var words = await _orderWrodRepository.Queryable().Where(x => x.IsEnable == 1 && x.Classify.Contains("敏感标签")).Select(x => x.Tag).ToListAsync(cancellationToken); var res = new List(); if (words.Any()) res = ParticipleTool.SegMMDouble(inputStr, ref words); if (res.Any()) { var intersect = words.Intersect(res).ToList(); await _orderRepository.Updateable().SetColumns(o => new Order() { Sensitive = intersect }).Where(o => o.Id == orderId).ExecuteCommandAsync(cancellationToken); } } /// /// 接收外部平台工单 /// public Task ReceiveOrderFromExternalAsync(AddOrderDto dto, ISessionContext current, CancellationToken cancellationToken) { switch (dto.Source) { case ESource.ProvinceStraight: return ReceiveOrderFromProvinceAsync(dto, dto.Files, current, cancellationToken); case ESource.Police110: case ESource.CityDataExchangeLz: case ESource.ConvergenceMedia: case ESource.WebPortal: return ReceiveOrderFromOtherPlatformAsync(dto, dto.Files, current, cancellationToken); case ESource.Hotline: case ESource.HotlineImport: default: throw new ArgumentOutOfRangeException(); } } /// /// 接收外部平台修改工单附件 /// public async Task UpdateOrderFilesAnonymousAsync(UpdateOrderFilesDto dto, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(dto.Id) && string.IsNullOrEmpty(dto.OrderNo)) throw new UserFriendlyException("工单外部编号不能为空"); var order = await _orderRepository.Queryable() .FirstAsync(d => d.Id == dto.Id || d.No == dto.OrderNo, cancellationToken); if (order != null && dto.Files != null && dto.Files.Any()) { order.FileJson = await _fileRepository.AddFileAsync(dto.Files, order.Id, "", cancellationToken); await _orderRepository.UpdateAsync(order, cancellationToken); } } /// /// 工单回访 /// /// /// /// public async Task OrderVisitWeb(OrderVisitWebDto dto, CancellationToken cancellationToken) { var visit = await _orderVisitRepository.Queryable() .Includes(x => x.Order) .Includes(x => x.OrderVisitDetails) .FirstAsync(x => x.Id == dto.Id); if (visit != null) { var first = dto.OrderVisitDetailDto.FirstOrDefault(x => x.VisitTarget == EVisitTarget.Org); if (first != null) { visit.NowEvaluate = first.OrgProcessingResults; visit.Order.Visited(first.OrgProcessingResults.Key, first.OrgProcessingResults.Value); } visit.VisitState = EVisitState.Visited; visit.VisitTime = dto.VisitTime; visit.VisitType = dto.VisitType; for (int i = 0; i < visit.OrderVisitDetails.Count; i++) { var detail = visit.OrderVisitDetails[i]; var detaildto = dto.OrderVisitDetailDto.FirstOrDefault(x => x.Id == detail.Id); if (detaildto != null) { _mapper.Map(detaildto, visit.OrderVisitDetails[i]); } } await _orderVisitRepository.UpdateAsync(visit, cancellationToken); await _orderVisitDetailRepository.UpdateRangeAsync(visit.OrderVisitDetails, cancellationToken); await _orderRepository.UpdateAsync(visit.Order, cancellationToken); var orderDto = _mapper.Map(visit.Order); if (first != null) { //推省上 await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderVisited, new PublishVisitDto() { Order = orderDto, No = visit.No, VisitType = visit.VisitType, VisitName = visit.CreatorName, VisitTime = visit.VisitTime, VisitRemark = string.IsNullOrEmpty(first.VisitContent) ? first.OrgProcessingResults?.Value : first.VisitContent, AreaCode = visit.Order.AreaCode!, SubjectResultSatifyCode = first.OrgProcessingResults.Key, FirstSatisfactionCode = visit.Order.FirstVisitResultCode!, ClientGuid = "" }, cancellationToken: cancellationToken); } //写入质检 await _qualityApplication.AddQualityAsync(EQualitySource.Visit, orderDto.Id, visit.Id, cancellationToken); } } public ISugarQueryable QueryOrders(QueryOrderDto dto) { var isCenter = _sessionContext.OrgIsCenter; return _orderRepository.Queryable(viewFilter: isCenter ? false : true) .Includes(x => x.OrderScreens) .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Title.Contains(dto.Keyword!)) //标题 .WhereIF(!string.IsNullOrEmpty(dto.ProvinceNo), d => d.ProvinceNo.Contains(dto.ProvinceNo)) //省本地编号 .WhereIF(!string.IsNullOrEmpty(dto.No), d => d.No.Contains(dto.No)) //工单编码 //.WhereIF(!string.IsNullOrEmpty(dto.Content), d => d.Content.Contains(dto.Content!)) .WhereIF(dto.AcceptTypes.Any(), d => dto.AcceptTypes.Contains(d.AcceptTypeCode)) //受理类型 .WhereIF(dto.Channels.Any(), d => dto.Channels.Contains(d.SourceChannelCode)) //来源渠道 .WhereIF(dto.HotspotIds.Any(), d => dto.HotspotIds.Contains(d.HotspotId)) //热点类型 .WhereIF(!string.IsNullOrEmpty(dto.TransferPhone), d => d.TransferPhone.Contains(dto.TransferPhone!)) //转接号码 //.WhereIF(dto.OrgCodes.Any(), d => d.Workflow.Assigns.Any(s => dto.OrgCodes.Contains(s.OrgCode))) .WhereIF(dto.OrgCodes.Any(), d => dto.OrgCodes.Contains(d.ActualHandleOrgCode)) //接办部门 .WhereIF(!string.IsNullOrEmpty(dto.NameOrNo), d => d.AcceptorName.Contains(dto.NameOrNo!) || d.AcceptorStaffNo.Contains(dto.NameOrNo!)) //受理人/坐席 .WhereIF(dto.CreationTimeStart.HasValue, d => d.CreationTime >= dto.CreationTimeStart) //受理时间开始 .WhereIF(dto.CreationTimeEnd.HasValue, d => d.CreationTime <= dto.CreationTimeEnd) //受理时间结束 .WhereIF(dto.EmergencyLevels.Any(), d => dto.EmergencyLevels.Contains(d.EmergencyLevel)) //紧急程度 .WhereIF(!string.IsNullOrEmpty(dto.FromPhone), d => d.FromPhone.Contains(dto.FromPhone)) //来电号码 .WhereIF(!string.IsNullOrEmpty(dto.PhoneNo), d => d.Contact.Contains(dto.PhoneNo!)) //联系电话 .WhereIF(!string.IsNullOrEmpty(dto.PushTypeCode), d => d.PushTypeCode == dto.PushTypeCode) //推送分类 .WhereIF(dto.ExpiredTimeStart.HasValue, d => d.ExpiredTime >= dto.ExpiredTimeStart) //超期时间开始 .WhereIF(dto.ExpiredTimeEnd.HasValue, d => d.ExpiredTime <= dto.ExpiredTimeEnd) //超期时间结束 .WhereIF(dto.Statuses.Any(), d => dto.Statuses.Contains(d.Status)) //工单状态 .WhereIF(dto.Statuses.Any(d => d == EOrderStatus.SpecialToUnAccept), d => d.Status <= EOrderStatus.SpecialToUnAccept) .WhereIF(!string.IsNullOrEmpty(dto.ActualHandlerName), d => d.ActualHandlerName.Contains(dto.ActualHandlerName)) //接办人 .WhereIF(dto.IsScreen == true, d => d.OrderScreens.Any(x => x.Status != EScreenStatus.Refuse)) //有甄别 .WhereIF(dto.IsScreen == false, d => !d.OrderScreens.Any(x => x.Status != EScreenStatus.Refuse)) //无甄别 .WhereIF(!string.IsNullOrEmpty(dto.CurrentStepCode), d => d.ActualHandleStepCode == dto.CurrentStepCode) //当前办理节点 .WhereIF(dto.ActualHandleTimeStart.HasValue, d => d.ActualHandleTime >= dto.ActualHandleTimeStart) //办结时间开始 .WhereIF(dto.ActualHandleTimeEnd.HasValue, d => d.ActualHandleTime <= dto.ActualHandleTimeEnd) //办结时间结束 .WhereIF(dto.IsOverTime == true, d => (d.ExpiredTime < DateTime.Now && d.Status < EOrderStatus.Filed) || (d.ExpiredTime < d.ActualHandleTime && d.Status >= EOrderStatus.Filed)) //是 超期 .WhereIF(dto.IsOverTime == false, d => (d.ExpiredTime > DateTime.Now && d.Status < EOrderStatus.Filed) || (d.ExpiredTime > d.ActualHandleTime && d.Status >= EOrderStatus.Filed)) //否 超期 .WhereIF(dto.IdentityType != null, d => d.IdentityType == dto.IdentityType) //来电主体 .WhereIF(!string.IsNullOrEmpty(dto.FromName), d => d.FromName.Contains(dto.FromName)) //来电人姓名 .WhereIF(dto.AreaCodes.Any(), d => dto.AreaCodes.Contains(d.AreaCode)) //区域 .WhereIF(dto.IsProvinceOrder.HasValue && dto.IsProvinceOrder == true, x => x.IsProvince == true) .WhereIF(dto.IsProvinceOrder.HasValue && dto.IsProvinceOrder == false, x => x.IsProvince == false) .WhereIF(!string.IsNullOrEmpty(dto.SensitiveWord), x => SqlFunc.JsonArrayAny(x.Sensitive, dto.SensitiveWord)) .WhereIF(dto.IsSensitiveWord.HasValue && dto.IsSensitiveWord == true, x => x.Sensitive != null && SqlFunc.JsonArrayLength(x.Sensitive) > 0) .OrderByDescending(d => d.CreationTime); } #region private /// /// 接受外部工单(除省平台) /// /// /// /// private async Task ReceiveOrderFromOtherPlatformAsync(AddOrderDto dto, List files, ISessionContext current, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(dto.ExternalId)) throw new UserFriendlyException("工单外部编号不能为空"); var order = await _orderRepository.Queryable() .FirstAsync(d => d.ExternalId == dto.ExternalId, cancellationToken); if (order == null) { order = _mapper.Map(dto); order.InitId(); if (files != null && files.Any()) order.FileJson = await _fileRepository.AddFileAsync(files, order.Id, "", cancellationToken); await _orderDomainService.AddAsync(order, cancellationToken: cancellationToken); } else { _mapper.Map(dto, order); if (files != null && files.Any()) order.FileJson = await _fileRepository.AddFileAsync(files, order.Id, "", cancellationToken); await _orderRepository.UpdateAsync(order, cancellationToken); } return _mapper.Map(order); } /// /// 接受省平台工单 /// private async Task ReceiveOrderFromProvinceAsync(AddOrderDto dto, List files, ISessionContext current, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(dto.ProvinceNo)) throw new UserFriendlyException("无效省工单编号"); var orderExtension = await _orderDomainService.GetOrderExtensionsAsync(dto.ProvinceNo, cancellationToken); var order = await _orderRepository.GetAsync(d => d.ProvinceNo == dto.ProvinceNo, cancellationToken); if (order is null) { order = _mapper.Map(dto); order.InitId(); if (files != null && files.Any()) order.FileJson = await _fileRepository.AddFileAsync(files, order.Id, "", cancellationToken); await _orderDomainService.AddAsync(order, cancellationToken: cancellationToken); if (orderExtension is not null) { orderExtension.Id = order.Id; if (dto.OrderExtension != null) _mapper.Map(dto.OrderExtension, orderExtension); await _orderDomainService.UpdateExtensionAsync(orderExtension, cancellationToken); } } else { _mapper.Map(dto, order); if (files != null && files.Any()) order.FileJson = await _fileRepository.AddFileAsync(files, order.Id, "", cancellationToken); await _orderRepository.UpdateAsync(order, cancellationToken); if (orderExtension is not null) { orderExtension.Id = order.Id; if (dto.OrderExtension != null) _mapper.Map(dto.OrderExtension, orderExtension); await _orderDomainService.UpdateExtensionAsync(orderExtension, cancellationToken); } //特提(撤回至发起) if (!string.IsNullOrEmpty(order.WorkflowId)) await _workflowDomainService.RecallToStartStepAsync(order.WorkflowId, "省工单重派", current, cancellationToken); } return _mapper.Map(order); } #endregion }