Эх сурвалжийг харах

修改省工单重派办理人为空

tangjiang 9 сар өмнө
parent
commit
8806270c4d

+ 67 - 62
src/Hotline.Application/Orders/OrderApplication.cs

@@ -41,6 +41,7 @@ using Hotline.Users;
 using PanGu.Match;
 using Hotline.Settings.Hotspots;
 using Hotline.Share.Enums.FlowEngine;
+using Hotline.Authentications;
 
 namespace Hotline.Application.Orders;
 
@@ -370,6 +371,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     /// </summary>
     public Task<AddOrderResponse> ReceiveOrderFromExternalAsync(AddOrderDto dto, ISessionContext current, CancellationToken cancellationToken)
     {
+
         switch (dto.Source)
         {
             case ESource.ProvinceStraight:
@@ -495,27 +497,27 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             .WhereIF(!string.IsNullOrEmpty(dto.ProvinceNo), d => d.ProvinceNo == dto.ProvinceNo) //省本地编号
             .WhereIF(!string.IsNullOrEmpty(dto.No), d => d.No == dto.No) //工单编码
             .WhereIF(!string.IsNullOrEmpty(dto.AcceptType), d => d.AcceptType == dto.AcceptType)//受理类型
-            //.WhereIF(dto.AcceptTypes.Any(), d => dto.AcceptTypes.Contains(d.AcceptTypeCode)) //受理类型
-            .WhereIF(!string.IsNullOrEmpty(dto.Channel), d=> d.SourceChannel == dto.Channel)
+                                                                                                //.WhereIF(dto.AcceptTypes.Any(), d => dto.AcceptTypes.Contains(d.AcceptTypeCode)) //受理类型
+            .WhereIF(!string.IsNullOrEmpty(dto.Channel), d => d.SourceChannel == dto.Channel)
             //.WhereIF(dto.Channels.Any(), d => dto.Channels.Contains(d.SourceChannelCode)) //来源渠道
-                                                                                          //.WhereIF(dto.HotspotIds.Any(), d => dto.HotspotIds.Contains(d.HotspotId)) //热点类型
+            //.WhereIF(dto.HotspotIds.Any(), d => dto.HotspotIds.Contains(d.HotspotId)) //热点类型
             .WhereIF(!string.IsNullOrEmpty(dto.Hotspot), d => d.HotspotSpliceName != null && d.HotspotSpliceName.Contains(dto.Hotspot))
             .WhereIF(!string.IsNullOrEmpty(dto.TransferPhone), d => d.TransferPhone == 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.OrgName), d=>d.CurrentHandleOrgName == dto.OrgName)//接办部门
+                                                                                                           //.WhereIF(dto.OrgCodes.Any(), d => dto.OrgCodes.Contains(d.ActualHandleOrgCode)) //接办部门
+            .WhereIF(!string.IsNullOrEmpty(dto.OrgName), d => d.CurrentHandleOrgName == dto.OrgName)//接办部门
             .WhereIF(!string.IsNullOrEmpty(dto.NameOrNo), d => d.AcceptorName == dto.NameOrNo! || d.AcceptorStaffNo == 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(dto.EmergencyLevels.Any(), d => dto.EmergencyLevels.Contains(d.EmergencyLevel))  //紧急程度
             .WhereIF(!string.IsNullOrEmpty(dto.FromPhone), d => d.FromPhone == dto.FromPhone) //来电号码
             .WhereIF(!string.IsNullOrEmpty(dto.PhoneNo), d => d.Contact == 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.Status.HasValue, d=>d.Status == dto.Status)//工单状态
-            //.WhereIF(dto.Statuses.Any(d => d == EOrderStatus.SpecialToUnAccept), d => d.Status <= EOrderStatus.SpecialToUnAccept)
+                                                                                            //.WhereIF(dto.Statuses.Any(), d => dto.Statuses.Contains(d.Status))  //工单状态
+            .WhereIF(dto.Status.HasValue, d => d.Status == dto.Status)//工单状态
+                                                                      //.WhereIF(dto.Statuses.Any(d => d == EOrderStatus.SpecialToUnAccept), d => d.Status <= EOrderStatus.SpecialToUnAccept)
             .WhereIF(!string.IsNullOrEmpty(dto.ActualHandlerName), d => d.ActualHandlerName == 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)) //无甄别
@@ -526,8 +528,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             .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 == dto.FromName) //来电人姓名
-            //.WhereIF(dto.AreaCodes.Any(), d => dto.AreaCodes.Contains(d.AreaCode)) //区域
-            .WhereIF(!string.IsNullOrEmpty(dto.AreaCode), d=>d.AreaCode == dto.AreaCode)//区域
+                                                                                           //.WhereIF(dto.AreaCodes.Any(), d => dto.AreaCodes.Contains(d.AreaCode)) //区域
+            .WhereIF(!string.IsNullOrEmpty(dto.AreaCode), d => d.AreaCode == dto.AreaCode)//区域
             .WhereIF(dto.IsProvinceOrder.HasValue && dto.IsProvinceOrder == true, d => d.Source == ESource.ProvinceStraight)
             .WhereIF(dto.IsProvinceOrder.HasValue && dto.IsProvinceOrder == false, d => d.Source != ESource.ProvinceStraight)
             .WhereIF(!string.IsNullOrEmpty(dto.SensitiveWord), d => SqlFunc.JsonArrayAny(d.Sensitive, dto.SensitiveWord))
@@ -637,9 +639,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             }).MergeTable();
 
         var query =
-			_systemOrganizeRepository.Queryable()
-            .LeftJoin(queryOrder,(x,or) => x.Id == or.OrgId)
-			.LeftJoin(queryCountersign, (x,or, co) => x.Id == co.OrgId)
+            _systemOrganizeRepository.Queryable()
+            .LeftJoin(queryOrder, (x, or) => x.Id == or.OrgId)
+            .LeftJoin(queryCountersign, (x, or, co) => x.Id == co.OrgId)
             //.LeftJoin<SystemOrganize>((or, co, so) => or.OrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == so.Id)
             .LeftJoin<SystemOrganize>((x, or, co, so) => or.OrgId == so.Id && so.Level == 1)
             .GroupBy((x, or, co, so) => new { so.Id, so.Name })
@@ -654,7 +656,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             }).MergeTable();
 
         query = query.WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.OrgName.Contains(dto.Keyword!))
-            .Where(x=>x.OrgName != null ).Where(x => x.HandlerExtendedNum > 0 || x.NoHandlerExtendedNum > 0 || x.CounterHandlerExtendedNum > 0 || x.CounterNoHandlerExtendedNum > 0);
+            .Where(x => x.OrgName != null).Where(x => x.HandlerExtendedNum > 0 || x.NoHandlerExtendedNum > 0 || x.CounterHandlerExtendedNum > 0 || x.CounterNoHandlerExtendedNum > 0);
         switch (dto.SortField)
         {
             case "handlerExtendedNum":
@@ -736,13 +738,13 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         var queryCountersign = _workflowStepRepository.Queryable()
             .Includes(x => x.Workflow)
             .InnerJoin<SystemOrganize>((x, so) => x.HandlerOrgId == so.Id && so.Level == 1)
-            .LeftJoin<Order>((x,so,o)=>x.ExternalId  == o.Id)
+            .LeftJoin<Order>((x, so, o) => x.ExternalId == o.Id)
             .Where((x, so) => x.CountersignPosition != ECountersignPosition.None && x.Workflow.ModuleCode == "OrderHandle")
             .Where((x, so) => x.CreationTime >= dto.StartTime && x.CreationTime <= dto.EndTime)
             .Where((x, so) => (x.Status == Share.Enums.FlowEngine.EWorkflowStepStatus.Handled && x.StepExpiredTime < x.HandleTime) || (x.Status != Share.Enums.FlowEngine.EWorkflowStepStatus.Handled && x.StepExpiredTime < SqlFunc.GetDate()))
             .WhereIF(IsCenter == false, (x, so) => x.HandlerOrgId == _sessionContext.RequiredOrgId)
-            .WhereIF(dto.ExpiredType is 2, (x, so,o) => o.OrderDelays.Any(x => x.DelayState == EDelayState.Pass))
-			.GroupBy(x => new { x.ExternalId, x.HandlerOrgName })
+            .WhereIF(dto.ExpiredType is 2, (x, so, o) => o.OrderDelays.Any(x => x.DelayState == EDelayState.Pass))
+            .GroupBy(x => new { x.ExternalId, x.HandlerOrgName })
             .Select(x => new { Id = x.ExternalId, WorkflowId = x.ExternalId, HandlerOrgName = x.HandlerOrgName });
 
         var queryCountersignOrder = _orderRepository.Queryable().InnerJoin(queryCountersign, (o, w) => o.Id == w.Id)
@@ -783,10 +785,10 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     /// <returns></returns>
     public ISugarQueryable<OrderSpecialDetail> QueryOrderSourceDetail(QueryOrderReTransactDetailRequest dto)
     {
-	    if (!dto.StartTime.HasValue || !dto.EndTime.HasValue)
-		    throw UserFriendlyException.SameMessage("请选择时间!");
-	    dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
-		return _orderSpecialDetailRepository.Queryable()
+        if (!dto.StartTime.HasValue || !dto.EndTime.HasValue)
+            throw UserFriendlyException.SameMessage("请选择时间!");
+        dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+        return _orderSpecialDetailRepository.Queryable()
             .Includes(x => x.OrderSpecial, s => s.Order)
             .WhereIF(!string.IsNullOrEmpty(dto.OrgName), x => x.OrgName.Contains(dto.OrgName!))
             .WhereIF(!string.IsNullOrEmpty(dto.ErrorName), x => x.ErrorName.Contains(dto.ErrorName!))
@@ -1266,9 +1268,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         {
             data = await list.GroupBy((x, h) => new
             {
-	            HotspotName = h.HotSpotName,
-				HotspotId = h.Id
-			})
+                HotspotName = h.HotSpotName,
+                HotspotId = h.Id
+            })
             .Select((x, h) => new VisitAndHotspotSatisfactionStatisticsDto()
             {
                 HotspotName = h.HotSpotName,
@@ -1286,16 +1288,16 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         }
         else
         {
-            data = await list.GroupBy( (x, h) => new
+            data = await list.GroupBy((x, h) => new
             {
-				HotspotName = h.HotSpotName,
-				HotspotId = h.Id
-			})
+                HotspotName = h.HotSpotName,
+                HotspotId = h.Id
+            })
             .Select((x, h) => new VisitAndHotspotSatisfactionStatisticsDto()
             {
-				HotspotName = h.HotSpotName,
-				HotspotId = h.Id,
-				TotalSumCount = SqlFunc.AggregateCount(x.OrderVisit.Order.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2"))),
+                HotspotName = h.HotSpotName,
+                HotspotId = h.Id,
+                TotalSumCount = SqlFunc.AggregateCount(x.OrderVisit.Order.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2"))),
                 VerySatisfiedCount = SqlFunc.IIF(dto.TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "5", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "5", 1, 0))),//非常满意数
                 SatisfiedCount = SqlFunc.IIF(dto.TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "4", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "4", 1, 0))), //满意数
                 RegardedAsSatisfiedCount = SqlFunc.IIF(dto.TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "-1", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "-1", 1, 0))),//视为满意
@@ -1321,32 +1323,32 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         var key = string.Empty;
         if (!string.IsNullOrEmpty(dto.TitleCode))
         {
-	        switch (dto.TitleCode)
-	        {
-		        case "verySatisfiedCount":
-			        key = "5";
-			        break;
-		        case "satisfiedCount":
-			        key = "4";
-			        break;
-		        case "regardedAsSatisfiedCount":
-			        key = "-1";
-			        break;
-		        case "defaultSatisfiedCount":
-			        key = "0";
-			        break;
-		        case "noSatisfiedCount":
-			        key = "2";
-			        break;
-		        case "noEvaluateCount":
-			        key = "7";
-			        break;
-		        case "noPutThroughCount":
-			        key = "6";
-			        break;
-	        }
+            switch (dto.TitleCode)
+            {
+                case "verySatisfiedCount":
+                    key = "5";
+                    break;
+                case "satisfiedCount":
+                    key = "4";
+                    break;
+                case "regardedAsSatisfiedCount":
+                    key = "-1";
+                    break;
+                case "defaultSatisfiedCount":
+                    key = "0";
+                    break;
+                case "noSatisfiedCount":
+                    key = "2";
+                    break;
+                case "noEvaluateCount":
+                    key = "7";
+                    break;
+                case "noPutThroughCount":
+                    key = "6";
+                    break;
+            }
         }
-		return _orderVisitDetailRepository.Queryable()
+        return _orderVisitDetailRepository.Queryable()
             .Includes(x => x.OrderVisit, o => o.Order)
             .Where(x => x.OrderVisit.VisitTime >= dto.StartTime && x.OrderVisit.VisitTime <= dto.EndTime && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited)
             .WhereIF(!string.IsNullOrEmpty(dto.HotspotName), x => x.OrderVisit.Order.Hotspot.HotSpotFullName.StartsWith(dto.HotspotName))
@@ -1384,8 +1386,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             if (files != null && files.Any())
                 order.FileJson = await _fileRepository.AddFileAsync(files, order.Id, "", cancellationToken);
             else
-	            order.FileJson = new List<Share.Dtos.File.FileJson>();
-			await _orderRepository.UpdateAsync(order, cancellationToken);
+                order.FileJson = new List<Share.Dtos.File.FileJson>();
+            await _orderRepository.UpdateAsync(order, cancellationToken);
         }
 
         return _mapper.Map<AddOrderResponse>(order);
@@ -1425,9 +1427,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             if (files != null && files.Any())
                 order.FileJson = await _fileRepository.AddFileAsync(files, order.Id, "", cancellationToken);
             else
-	            order.FileJson = new List<Share.Dtos.File.FileJson>();
-			order.ReTransactNum++;
-			await _orderRepository.UpdateAsync(order, cancellationToken);
+                order.FileJson = new List<Share.Dtos.File.FileJson>();
+            order.ReTransactNum++;
+            await _orderRepository.UpdateAsync(order, cancellationToken);
 
             if (orderExtension is not null)
             {
@@ -1439,7 +1441,10 @@ public class OrderApplication : IOrderApplication, IScopeDependency
 
             //特提(撤回至发起)
             if (!string.IsNullOrEmpty(order.WorkflowId))
+            {
+                current = SessionContextCreator.CreateSessionContext("province");
                 await _workflowDomainService.RecallToStartStepAsync(order.WorkflowId, "省工单重派", current, cancellationToken);
+            }
         }
         return _mapper.Map<AddOrderResponse>(order);
     }