Dun.Jason 1 rok temu
rodzic
commit
44deb14232

+ 38 - 38
src/Hotline.Api/Controllers/OrderController.cs

@@ -1191,21 +1191,21 @@ public class OrderController : BaseController
     [LogFilter("开始工单延期流程")]
     public async Task InitialNextFlow([FromBody] DelayNextFlowDto dto)
     {
-	    var delay = await _orderDelayRepository.GetAsync(dto.Data.Id);
-	    _mapper.Map(dto.Data, delay);
-	    if (dto.Data.Files.Any())
-		    delay.FileJson = await _fileRepository.AddFileAsync(dto.Data.Files, delay.Id, "", HttpContext.RequestAborted);
-	    await _orderDelayRepository.UpdateAsync(delay, HttpContext.RequestAborted);
-	    try
-	    {
-		    dto.NextWorkflow.WorkflowId = delay.WorkflowId;
-		    await _workflowApplication.NextAsync(dto.NextWorkflow,
-			    cancellationToken: HttpContext.RequestAborted);
-	    }
-	    catch (Exception e)
-	    {
-		    throw new UserFriendlyException($"工单延期下一步流程失败!, {e.Message}", "工单延期下一步流程失败");
-	    }
+        var delay = await _orderDelayRepository.GetAsync(dto.Data.Id);
+        _mapper.Map(dto.Data, delay);
+        if (dto.Data.Files.Any())
+            delay.FileJson = await _fileRepository.AddFileAsync(dto.Data.Files, delay.Id, "", HttpContext.RequestAborted);
+        await _orderDelayRepository.UpdateAsync(delay, HttpContext.RequestAborted);
+        try
+        {
+            dto.NextWorkflow.WorkflowId = delay.WorkflowId;
+            await _workflowApplication.NextAsync(dto.NextWorkflow,
+                cancellationToken: HttpContext.RequestAborted);
+        }
+        catch (Exception e)
+        {
+            throw new UserFriendlyException($"工单延期下一步流程失败!, {e.Message}", "工单延期下一步流程失败");
+        }
     }
 
     /// <summary>
@@ -1282,7 +1282,7 @@ public class OrderController : BaseController
         var rspModel = _mapper.Map<OrderDelayDto>(model);
         rspModel.IsCanHandle = model.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId);
         rspModel.Handle = await _workflowDomainService.CheckCurrentIsStartStepAsync(rspModel.WorkflowId, _sessionContext.RequiredUserId, _sessionContext.RequiredOrgId, HttpContext.RequestAborted);
-		if (rspModel.FileJson != null && rspModel.FileJson.Any())
+        if (rspModel.FileJson != null && rspModel.FileJson.Any())
         {
             var ids = rspModel.FileJson.Select(x => x.Id).ToList();
             rspModel.Files = await _fileRepository.GetFilesAsync(ids, HttpContext.RequestAborted);
@@ -1390,7 +1390,7 @@ public class OrderController : BaseController
         var view = dto.source == 1;
         var handler = dto.source == 1 && dto.Status is EScreenStatus.Apply;
 
-		var query = _orderScreenRepository.Queryable(viewFilter: view, handlerFilter: handler)
+        var query = _orderScreenRepository.Queryable(viewFilter: view, handlerFilter: handler)
             .Includes(x => x.Order)
             .Includes(x => x.VisitDetail)
             .Includes(x => x.Visit, d => d.Order)
@@ -1417,10 +1417,10 @@ public class OrderController : BaseController
     }
 
 
-	/// <summary>
-	/// 开始工单甄别流程
-	/// </summary>
-	[Permission(EPermission.ApplyScreen)]
+    /// <summary>
+    /// 开始工单甄别流程
+    /// </summary>
+    [Permission(EPermission.ApplyScreen)]
     [HttpPost("screen/startflow")]
     [LogFilter("开始工单甄别流程")]
     public async Task StartFlow([FromBody] ScreenStartFlowDto dto)
@@ -1648,7 +1648,7 @@ public class OrderController : BaseController
                         };
                         await _mediator.Publish(new PushMessageNotify(messageDto), HttpContext.RequestAborted);
                     }
-                    
+
                 }
                 catch { }
             }
@@ -2173,13 +2173,13 @@ public class OrderController : BaseController
                     OrderId = order.Id,
                     PushPlatform = EPushPlatform.Sms,
                     //Content =
-                      //  $"温馨提示:您的来电已受理(流水号:{order.No};提取码:{order.Password},可通过网站(http://hotline.12345lm.cn)进行查询,谢谢。【宜宾12345热线平台】)",
+                    //  $"温馨提示:您的来电已受理(流水号:{order.No};提取码:{order.Password},可通过网站(http://hotline.12345lm.cn)进行查询,谢谢。【宜宾12345热线平台】)",
                     Remark = order.Title,
                     Name = order.FromName,
                     TemplateCode = "1005",
                     Params = new List<string>() { order.No, order.Password },
                     TelNumber = order.Contact,
-                    
+
                 };
                 await _mediator.Publish(new PushMessageNotify(messageDto), HttpContext.RequestAborted);
                 //await _pushDomainService.PushAsync(MessageDto, HttpContext.RequestAborted);
@@ -2307,18 +2307,6 @@ public class OrderController : BaseController
         await _workflowApplication.NextAsync(dto, HttpContext.RequestAborted);
     }
 
-    /// <summary>
-    /// 结束会签
-    /// </summary>
-    [HttpPost("cs-end")]
-    public async Task EndCountersign([FromBody] EndCountersignDto dto)
-    {
-        var order = await _orderDomainService.GetOrderAsync(dto.OrderId, cancellationToken: HttpContext.RequestAborted);
-        if (string.IsNullOrEmpty(order.WorkflowId))
-            throw new UserFriendlyException("该工单未开启流程");
-        await _workflowDomainService.EndCountersignAsync(order.WorkflowId, HttpContext.RequestAborted);
-    }
-
     /// <summary>
     /// 查询工单办理下一步可选节点(带推荐部门)
     /// </summary>
@@ -2327,7 +2315,7 @@ public class OrderController : BaseController
     {
         var order = await _orderDomainService.GetOrderAsync(orderId, cancellationToken: HttpContext.RequestAborted);
         if (string.IsNullOrEmpty(order.WorkflowId))
-            throw new UserFriendlyException("该工单无关联流程id");
+            throw UserFriendlyException.SameMessage("该工单未开启流程");
         var dto = await _workflowApplication.GetNextStepsAsync(order.WorkflowId, HttpContext.RequestAborted);
         var rsp = _mapper.Map<NextStepsDto<RecommendStepOption>>(dto);
         foreach (var step in rsp.Steps)
@@ -2343,6 +2331,18 @@ public class OrderController : BaseController
         return rsp;
     }
 
+    /// <summary>
+    /// 结束会签
+    /// </summary>
+    [HttpPost("cs-end")]
+    public async Task EndCountersign([FromBody] EndCountersignDto dto)
+    {
+        var order = await _orderDomainService.GetOrderAsync(dto.OrderId, cancellationToken: HttpContext.RequestAborted);
+        if (string.IsNullOrEmpty(order.WorkflowId))
+            throw new UserFriendlyException("该工单未开启流程");
+        await _workflowDomainService.EndCountersignAsync(order.WorkflowId, HttpContext.RequestAborted);
+    }
+
     /// <summary>
     /// 查询工单办理的期满时间配置
     /// </summary>
@@ -2583,7 +2583,7 @@ public class OrderController : BaseController
         {
             await _workflowApplication.OrderPreviousAsync(sendBack.SendBackData, sendBack.WorkflowUserId, HttpContext.RequestAborted);
             //发送短信TODO
-            
+
         }
         await _orderSendBackAuditRepository.UpdateAsync(sendBack, HttpContext.RequestAborted);
     }

+ 54 - 14
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -590,16 +590,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         if (!nextDefines.Any())
             throw new UserFriendlyException("未正确配置下一节点");
 
-        dto.Steps = await GetConfigStepsAsync(workflow.FlowType, currentStep.StepType, currentStep.BusinessType, nextDefines, cancellationToken);
-
-        //if (currentStep.IsInCountersign() && currentStep.IsTopCountersignEndStep(workflow.TopCountersignStepId))
-        //{
-        //    foreach (var nextStepOption in dto.Steps)
-        //    {
-        //        if (nextStepOption.StepType is EStepType.End or EStepType.Summary)
-        //            nextStepOption.InputRealHandler = true;
-        //    }
-        //}
+        dto.Steps = await GetConfigStepsAsync(workflow, currentStep, nextDefines, cancellationToken);
 
         return dto;
     }
@@ -710,6 +701,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         await _workflowDomainService.RejectAsync(workflow, basicDto, cancellationToken);
     }
 
+    //开启流程调用
     private async Task<List<NextStepOption>> GetConfigStepsAsync(
         EFlowType flowType,
         EStepType currentStepType,
@@ -725,10 +717,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                                               stepDefine.StepType is EStepType.Summary or EStepType.End;
             stepOptions.Add(nextStepOption);
 
-            if (stepDefine.StepType is EStepType.End)
-            {
-                continue;
-            }
+            if (stepDefine.StepType is EStepType.End) continue;
 
             nextStepOption.FlowDirection = CheckFlowDirection(currentBusinessType, stepDefine.BusinessType);
             //stepOptions.Add(nextStepOption);
@@ -737,6 +726,57 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         return stepOptions;
     }
 
+    /// <summary>
+    /// 办理流程调用(根据办理过程过滤汇总节点待选办理对象)
+    /// </summary>
+    private async Task<List<NextStepOption>> GetConfigStepsAsync(
+        Workflow workflow,
+        WorkflowStep currentStep,
+        //EStepType currentStepType,
+        //EBusinessType currentBusinessType,
+        List<StepDefine> stepDefines,
+        CancellationToken cancellationToken)
+    {
+        var stepOptions = new List<NextStepOption>();
+        foreach (var stepDefine in stepDefines)
+        {
+            NextStepOption nextStepOption;
+
+            //汇总节点只能选择对应节点办理对象
+            if (workflow.FlowType is EFlowType.Handle && stepDefine.StepType is EStepType.Summary)
+            {
+                var prevStep = workflow.Steps.FirstOrDefault(d => d.Id == currentStep.PrevStepId);
+                if (prevStep is null)
+                    throw UserFriendlyException.SameMessage("未查询到汇总对象节点");
+                var handlers = prevStep.Handlers
+                    .Where(d => d.Key == prevStep.HandlerId || d.Key == prevStep.HandlerOrgId).ToList();
+
+                nextStepOption = new NextStepOption
+                {
+                    Key = stepDefine.Code,
+                    Value = stepDefine.Name,
+                    StepType = stepDefine.StepType,
+                    BusinessType = stepDefine.BusinessType,
+                    HandlerType = stepDefine.HandlerType,
+                    Items = handlers
+                };
+            }
+            else
+            {
+                nextStepOption = await GetConfigStepAsync(workflow.FlowType, stepDefine, cancellationToken);
+            }
+            nextStepOption.InputRealHandler = currentStep.StepType == EStepType.Normal &&
+                                              stepDefine.StepType is EStepType.Summary or EStepType.End;
+            stepOptions.Add(nextStepOption);
+
+            if (stepDefine.StepType is EStepType.End) continue;
+
+            nextStepOption.FlowDirection = CheckFlowDirection(currentStep.BusinessType, stepDefine.BusinessType);
+        }
+
+        return stepOptions;
+    }
+
     public async Task<NextStepOption> GetConfigStepAsync(EFlowType flowType, StepDefine stepDefine,
         CancellationToken cancellationToken)
     {