xf 1 年之前
父節點
當前提交
e05d89a904

+ 1 - 1
src/Hotline.Api.Sdk/Hotline.Api.Sdk.csproj

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
     <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-    <Version>1.0.5</Version>
+    <Version>1.0.7</Version>
     <Company>fw</Company>
     <Description>hotline.api.sdk</Description>
   </PropertyGroup>

+ 6 - 6
src/Hotline.Api.Sdk/Order/IHotlineClient.Order.cs

@@ -18,16 +18,16 @@ namespace Hotline.Api.Sdk
             ExecuteAsync("api/v1/Order/delay/province/result", Method.Post, request, cancellationToken);
 
         /// <summary>
-        /// 接受平台工单数据
+        /// 接受其他平台工单数据
         /// </summary>
-        public Task<ApiResponse<AddOrderResponse>> ReceiveOrderFromProvinceAsync(AddOrderDto request, CancellationToken cancellationToken) =>
-            ExecuteAsync<AddOrderDto, AddOrderResponse>("rec/province", Method.Post, request, cancellationToken);
+        public Task<ApiResponse<AddOrderResponse>> ReceiveOrderAsync(AddOrderDto request, CancellationToken cancellationToken) =>
+            ExecuteAsync<AddOrderDto, AddOrderResponse>("receive", Method.Post, request, cancellationToken);
 
         /// <summary>
-        /// 接受平台工单扩展信息
+        /// 接受其他平台工单扩展信息
         /// </summary>
-        public Task<ApiResponse<string>> ReceiveExtensionFromProvinceAsync(OrderExtensionDto request, CancellationToken cancellationToken) =>
-            ExecuteAsync<OrderExtensionDto, string>("rec/province/extension", Method.Post, request, cancellationToken);
+        public Task<ApiResponse<string>> ReceiveExtensionAsync(OrderExtensionDto request, CancellationToken cancellationToken) =>
+            ExecuteAsync<OrderExtensionDto, string>("receive/extension", Method.Post, request, cancellationToken);
 
         /// <summary>
         /// 工单退回结果

+ 19 - 15
src/Hotline.Api/Controllers/OrderController.cs

@@ -1858,10 +1858,10 @@ public class OrderController : BaseController
     }
 
     /// <summary>
-    /// 接受平台工单数据
+    /// 接受其他平台工单数据
     /// </summary>
-    [HttpPost("rec/province")]
-    public async Task<AddOrderResponse> ReceiveOrderFromProvince([FromBody] AddOrderDto dto)
+    [HttpPost("receive")]
+    public async Task<AddOrderResponse> ReceiveOrder([FromBody] AddOrderDto dto)
     {
         if (string.IsNullOrEmpty(dto.ProvinceNo))
             throw new UserFriendlyException("无效省工单编号");
@@ -1872,15 +1872,16 @@ public class OrderController : BaseController
             order = _mapper.Map<Order>(dto);
             var orderId = await _orderDomainService.AddAsync(order, HttpContext.RequestAborted);
 
-            var orderExtension =
-                await _orderDomainService.GetOrderExtensionsAsync(dto.ProvinceNo, HttpContext.RequestAborted);
-            if (orderExtension is not null)
+            if (order.Source is ESource.ProvinceStraight)
             {
-                orderExtension.Id = orderId;
-                await _orderDomainService.UpdateExtensionAsync(orderExtension, HttpContext.RequestAborted);
+                var orderExtension = await _orderDomainService.GetOrderExtensionsAsync(dto.ProvinceNo, HttpContext.RequestAborted);
+                if (orderExtension is not null)
+                {
+                    orderExtension.Id = orderId;
+                    await _orderDomainService.UpdateExtensionAsync(orderExtension, HttpContext.RequestAborted);
+                }
             }
 
-
             return new AddOrderResponse
             {
                 Id = orderId,
@@ -1890,23 +1891,26 @@ public class OrderController : BaseController
         }
         else
         {
-            //todo 特提(撤回至派单)
+            if (order.Source is ESource.ProvinceStraight)
+            {
+                //todo 特提(撤回至派单)
+                await _workflowApplication.RecallToSendAsync(order.WorkflowId, "省工单重派", HttpContext.RequestAborted);
+            }
 
             return _mapper.Map<AddOrderResponse>(order);
         }
     }
 
     /// <summary>
-    /// 接受平台工单扩展信息
+    /// 接受其他平台工单扩展信息
     /// </summary>
-    [HttpPost("rec/province/extension")]
-    public async Task<string> ReceiveExtensionFromProvince(OrderExtensionDto dto)
+    [HttpPost("receive/extension")]
+    public async Task<string> ReceiveExtension(OrderExtensionDto dto)
     {
         if (string.IsNullOrEmpty(dto.ProvinceNo))
             throw new UserFriendlyException("无效省工单编号");
 
-        var orderExtension =
-            await _orderDomainService.GetOrderExtensionsAsync(dto.ProvinceNo, HttpContext.RequestAborted);
+        var orderExtension = await _orderDomainService.GetOrderExtensionsAsync(dto.ProvinceNo, HttpContext.RequestAborted);
         if (orderExtension is not null) return string.Empty;
 
         var extension = _mapper.Map<OrderExtension>(dto);

+ 9 - 2
src/Hotline.Application/FlowEngine/IWorkflowApplication.cs

@@ -1,4 +1,5 @@
 using Hotline.FlowEngine.Definitions;
+using Hotline.Orders;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.FlowEngine;
 using Hotline.Share.Dtos.FlowEngine.Definition;
@@ -11,7 +12,8 @@ namespace Hotline.Application.FlowEngine
         /// <summary>
         /// 开始流程
         /// </summary>
-        Task<string> StartWorkflowAsync(StartWorkflowDto dto, string externalId, TimeResult? expiredTime = null, CancellationToken cancellationToken = default);
+        Task<string> StartWorkflowAsync(StartWorkflowDto dto, string externalId, TimeResult? expiredTime = null,
+            CancellationToken cancellationToken = default);
 
         /// <summary>
         /// 流转至下一节点(节点办理)
@@ -23,6 +25,11 @@ namespace Hotline.Application.FlowEngine
         /// </summary>
         Task RecallAsync(RecallDto dto, CancellationToken cancellationToken);
 
+        /// <summary>
+        /// 撤回至派单节点
+        /// </summary>
+        Task RecallToSendAsync(string workflowId, string opinion, CancellationToken cancellationToken);
+
         /// <summary>
         /// 跳转至任意节点
         /// </summary>
@@ -80,4 +87,4 @@ namespace Hotline.Application.FlowEngine
         /// </summary>
         Task<IReadOnlyList<Kv>> GetNextStepOptionsAsync(GetNextStepItemsDto dto, CancellationToken cancellationToken);
     }
-}
+}

+ 26 - 11
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -235,19 +235,31 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
     /// </summary>
     public async Task RecallAsync(RecallDto dto, CancellationToken cancellationToken)
     {
-        var workflow =
-            await _workflowDomainService.GetWorkflowAsync(dto.WorkflowId, true, true,
-                cancellationToken: cancellationToken);
-
+        var workflow = await _workflowDomainService.GetWorkflowAsync(dto.WorkflowId, true, true, cancellationToken: cancellationToken);
+        
         await _orderDomainService.ReadyToRecallAsync(workflow.ExternalId, cancellationToken);
 
         var targetStepDefine = _workflowDomainService.GetStepDefine(workflow.WorkflowDefinition, dto.NextStepCode);
         //var isStartCountersign = targetStepDefine.CouldPrevStartCountersign(dto.NextHandlers.Count);
-        var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.IsStartCountersign,
-            dto.NextHandlers, cancellationToken);
+        var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.IsStartCountersign, dto.NextHandlers, cancellationToken);
         await _workflowDomainService.RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, cancellationToken);
     }
 
+    /// <summary>
+    /// 撤回至派单节点
+    /// </summary>
+    public async Task RecallToSendAsync(string workflowId, string opinion, CancellationToken cancellationToken)
+    {
+        //var workflow = await _workflowDomainService.GetWorkflowAsync(workflowId, true, true, cancellationToken: cancellationToken);
+     
+        //await _orderDomainService.ReadyToRecallAsync(workflow.ExternalId, cancellationToken);
+
+        //var targetStep = workflow.WorkflowDefinition.FindSendStepDefine();
+        //var targetStepDefine = _workflowDomainService.GetStepDefine(workflow.WorkflowDefinition, targetStep.Code);
+        //var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, false, dto.NextHandlers, cancellationToken);
+        //await _workflowDomainService.RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, cancellationToken);
+    }
+
     /// <summary>
     /// 跳转至任意节点
     /// </summary>
@@ -438,7 +450,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         //        .ToList();
         return new NextStepsDto
         {
-            Steps = await GetConfigStepsAsync(definition.FlowType, startStepDefine.StepType, startStepDefine.BusinessType, firstStepDefines, cancellationToken)
+            Steps = await GetConfigStepsAsync(definition.FlowType, startStepDefine.StepType, startStepDefine.BusinessType, firstStepDefines,
+                cancellationToken)
         };
         //dto.Steps = steps;
         //return dto;
@@ -467,7 +480,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         if (currentStep.InstanceMode is EInstanceMode.Dynamic && !DynamicShouldTerminal(currentStep))
         {
             //动态生成下一步
-            var nextStepOption = await GetDynamicStepAsync(currentStep.InstancePolicy.Value, currentStep.StepType, currentStep.BusinessType, cancellationToken);
+            var nextStepOption = await GetDynamicStepAsync(currentStep.InstancePolicy.Value, currentStep.StepType, currentStep.BusinessType,
+                cancellationToken);
             dto.Steps = new List<NextStepOption> { nextStepOption };
             return dto;
         }
@@ -613,7 +627,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
     public async Task RejectAsync(RejectDto dto, CancellationToken cancellationToken)
     {
         var workflow = await _workflowDomainService.GetWorkflowAsync(dto.WorkflowId, true, true,
-            cancellationToken: cancellationToken);
+                cancellationToken: cancellationToken);
         var basicDto = _mapper.Map<BasicWorkflowDto>(dto);
         basicDto.NextStepCode = string.Empty;
         basicDto.IsStartCountersign = false;
@@ -935,7 +949,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         return new NextStepOption
         {
             Key = prevStep.Code,
-            Value = text, //parentStep.Name,//todo name不对,目前为definition.name,需改为x级部门办理
+            Value = text,
             BackToCountersignEnd = true,
             StepType = prevStep.StepType,
             BusinessType = prevStep.BusinessType,
@@ -978,7 +992,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         };
     }
 
-    private async Task<NextStepOption> GetDynamicStepAsync(EDynamicPolicy policy, EStepType stepType, EBusinessType businessType, CancellationToken cancellationToken)
+    private async Task<NextStepOption> GetDynamicStepAsync(EDynamicPolicy policy, EStepType stepType, EBusinessType businessType,
+        CancellationToken cancellationToken)
     {
         int orgLevel;
         List<Kv> items;

+ 3 - 0
src/Hotline/FlowEngine/Definitions/WorkflowDefinition.cs

@@ -47,6 +47,9 @@ public class WorkflowDefinition : CreationEntity
     public StepDefine FindEndStepDefine() =>
         Steps.First(d => d.StepType is EStepType.End);
 
+    public StepDefine FindSendStepDefine() =>
+        Steps.First(d => d.BusinessType is EBusinessType.Send);
+
     public List<StepDefine> FindStepDefines(IEnumerable<string> stepCodes) =>
         Steps.Where(d => stepCodes.Contains(d.Code)).ToList();
 

+ 5 - 1
src/Hotline/FlowEngine/Workflows/WorkflowStep.cs

@@ -141,7 +141,11 @@ public class WorkflowStep : StepBasicEntity
         if (!IsInCountersign()
             && InstanceMode is EInstanceMode.Config
             && StepType is not EStepType.End)
-            NextSteps.First(d => d.Code == nextStepCode).Selected = true;
+        {
+            var step = NextSteps.FirstOrDefault(d => d.Code == nextStepCode);
+            if (step != null)
+                step.Selected = true;
+        }
     }
 
     /// <summary>