xfe 4 miesięcy temu
rodzic
commit
f8f2228858

+ 2 - 2
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -162,7 +162,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         var counterSignType = _workflowDomainService.GetCounterSignType(dto.IsStartCountersign, startStep.BusinessType);
 
         //办理开始节点
-        await _workflowDomainService.HandleStepAsync(startStep, workflow, dto, counterSignType, expiredTime, cancellationToken);
+        await _workflowDomainService.HandleStepAsync(startStep, workflow, dto, counterSignType, expiredTime, EHandleMode.Normal, cancellationToken);
 
         if (dto.Files.Any())
             startStep.FileJson =
@@ -421,7 +421,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         //var stepHandlers = await GetNextStepHandlersAsync(workflow, targetStepDefine, dto, cancellationToken);
 
         await _workflowDomainService.RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, traceType, expiredTime, isOrderFiled,
-            cancellationToken);
+          EHandleMode.Recall, cancellationToken);
     }
 
     /// <summary>

+ 1 - 1
src/Hotline.Application/Orders/OrderApplication.cs

@@ -3195,7 +3195,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
 
                 //await _workflowDomainService.RecallToStartStepAsync(order.WorkflowId, "省工单重派", current, order.Status >= EOrderStatus.Filed, cancellationToken);
                 var (isPaiDan, workflow) = await _workflowDomainService.RecallToCenterFirstToSendAsync(order.WorkflowId, "省工单重派", order.Status >= EOrderStatus.Filed,
-                    order.ExpiredTime, nextHandler, cancellationToken);
+                    order.ExpiredTime, nextHandler, EHandleMode.Redo, cancellationToken);
                 order.FileEmpty();
 
                 order.CurrentStepName = workflow.CurrentStepName;

+ 3 - 5
src/Hotline.Application/Subscribers/DatasharingSubscriber.cs

@@ -316,7 +316,7 @@ namespace Hotline.Application.Subscribers
                     }
                 }
                 var (isPaiDan, workflow) = await _workflowDomainService.RecallToCenterFirstToSendAsync(order.WorkflowId, 
-                    dto.Opinion, order.Status >= EOrderStatus.Filed, order.ExpiredTime, nextHandler, cancellationToken);
+                    dto.Opinion, order.Status >= EOrderStatus.Filed, order.ExpiredTime, nextHandler, EHandleMode.Recall, cancellationToken);
                 order.FiledTime = null;
                 order.Status = isPaiDan ? EOrderStatus.Special : EOrderStatus.WaitForAccept;
 
@@ -839,10 +839,8 @@ namespace Hotline.Application.Subscribers
                     //await _workflowDomainService.RecallToStartStepAsync(order.WorkflowId, dto.Opinion, order.Status >= EOrderStatus.Filed,
                     //    order.ExpiredTime, cancellationToken); //todo think是否需要保存附件至省平台办理节点?
                     var (isPaiDan, workflow) = await _workflowDomainService.RecallToCenterFirstToSendAsync(
-                        order.WorkflowId, 
-                        dto.Opinion, 
-                        order.Status >= EOrderStatus.Filed, 
-                        order.ExpiredTime, null, cancellationToken);
+                        order.WorkflowId, dto.Opinion, order.Status >= EOrderStatus.Filed, 
+                        order.ExpiredTime, null, EHandleMode.Recall, cancellationToken);
 
                     order.Status = isPaiDan ? EOrderStatus.Special : EOrderStatus.WaitForAccept;
                     order.CurrentStepName = workflow.CurrentStepName;

+ 6 - 11
src/Hotline.Share/Enums/FlowEngine/EHandleMode.cs

@@ -15,16 +15,6 @@ public enum EHandleMode
     [Description("正常")]
     Normal = 0,
 
-    // /// <summary>
-    // /// 开启会签
-    // /// </summary>
-    // StartCountersign = 1,
-    //
-    // /// <summary>
-    // /// 开启或签
-    // /// </summary>
-    // StartSignCountersign = 2
-
     /// <summary>
     /// 退回
     /// </summary>
@@ -36,5 +26,10 @@ public enum EHandleMode
     /// </summary>
     [Description("特提")]
     Recall = 200,
-    
+
+    /// <summary>
+    /// 重办
+    /// </summary>
+    [Description("重办")]
+    Redo = 201,
 }

+ 5 - 5
src/Hotline/FlowEngine/Workflows/IWorkflowDomainService.cs

@@ -78,18 +78,18 @@ namespace Hotline.FlowEngine.Workflows
         /// 撤回(返回到之前任意节点)
         /// </summary>
         Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine, FlowAssignInfo flowAssignInfo,
-            EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken);
+            EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, CancellationToken cancellationToken);
 
         /// <summary>
         /// 撤回至开始节点
         /// </summary>
-        Task RecallToStartStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime,
+        Task RecallToStartStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime, EHandleMode handleMode,
             CancellationToken cancellationToken);
 
         /// <summary>
         /// 特提至派单节点(无派单节点会抛异常)
         /// </summary>
-        Task RecallToSendStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime,
+        Task RecallToSendStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime, EHandleMode handleMode,
             CancellationToken cancellationToken);
 
         /// <summary>
@@ -97,7 +97,7 @@ namespace Hotline.FlowEngine.Workflows
         /// </summary>
         /// <returns></returns>
         Task<(bool, Workflow workflow)> RecallToCenterFirstToSendAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime, List<FlowStepHandler> handlers,
-			CancellationToken cancellationToken);
+            EHandleMode handleMode, CancellationToken cancellationToken);
 
         ///// <summary>
         ///// 跳转(直接将流程跳转至任意节点)
@@ -201,7 +201,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 办理节点
         /// </summary>
         Task HandleStepAsync(WorkflowStep step, Workflow workflow, BasicWorkflowDto dto,
-            ECounterSignType? counterSignType, DateTime? expiredTime,
+            ECounterSignType? counterSignType, DateTime? expiredTime, EHandleMode handleMode,
             CancellationToken cancellationToken);
 
         /// <summary>

+ 4 - 2
src/Hotline/FlowEngine/Workflows/StepBasicEntity.cs

@@ -435,8 +435,8 @@ public abstract class StepBasicEntity : CreationEntity
         string userId, string? userName,
         string orgId, string? orgName,
         string? orgAreaCode, string? orgAreaName,
-        bool orgIsCenter, string opinion,
-        string? nextStepCode = null)
+        bool orgIsCenter, EHandleMode handleMode,
+        string opinion, string? nextStepCode = null)
     {
         if (!HasAccepted())
             Accept(userId, userName, orgId, orgName, orgAreaCode, orgAreaName);
@@ -475,6 +475,8 @@ public abstract class StepBasicEntity : CreationEntity
             if (step != null)
                 step.Selected = true;
         }
+
+        HandleMode = handleMode;
     }
 
     /// <summary>

+ 59 - 59
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -401,7 +401,7 @@ namespace Hotline.FlowEngine.Workflows
                 }
             }
 
-            await HandleStepAsync(currentStep, workflow, dto, counterSignType, expiredTime, cancellationToken);
+            await HandleStepAsync(currentStep, workflow, dto, counterSignType, expiredTime, EHandleMode.Normal, cancellationToken);
 
             currentStep.IsActualHandled = CheckIsActualHandle(workflow, currentStep, nextStepDefine, dto);
 
@@ -989,7 +989,7 @@ namespace Hotline.FlowEngine.Workflows
             trace.Handle(applicantId, applicantName,
                 applicantOrgId, applicantOrgName,
                 applicantOrgAreaCode, applicantOrgAreaName,
-                applicantIsCenter, dto.Opinion);
+                applicantIsCenter, EHandleMode.Previous, dto.Opinion);
 
             //await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
 
@@ -1484,7 +1484,7 @@ namespace Hotline.FlowEngine.Workflows
             await _workflowStepRepository.UpdateAsync(prevStep, cancellationToken);
 
             var endTrace = workflow.Traces.FirstOrDefault(p => p.Id == prevStep.Id);
-            if (endTrace!=null)
+            if (endTrace != null)
             {
                 endTrace.Opinion = prevStep.Opinion;
                 endTrace.FileJson = prevStep.FileJson;
@@ -1535,7 +1535,7 @@ namespace Hotline.FlowEngine.Workflows
 
             foreach (var step in unhandleSteps)
             {
-                await HandleStepAsync(step, workflow, dto, null, null, cancellationToken);
+                await HandleStepAsync(step, workflow, dto, null, null, EHandleMode.Normal, cancellationToken);
                 if (step.IsStartCountersign)
                     step.CountersignEnd();
 
@@ -1604,7 +1604,7 @@ namespace Hotline.FlowEngine.Workflows
         /// </summary>
         public async Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine,
             FlowAssignInfo flowAssignInfo, EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled,
-            CancellationToken cancellationToken)
+            EHandleMode handleMode, CancellationToken cancellationToken)
         {
             var targetStep = workflow.Steps.FirstOrDefault(d => d.Code == dto.NextStepCode && d.IsOrigin);
             if (targetStep is null)
@@ -1614,7 +1614,7 @@ namespace Hotline.FlowEngine.Workflows
             //await RecallTraceAsync(workflow.Traces, dto.Opinion, _sessionContext, cancellationToken);
 
             var isOrgToCenter = await RecallAsync(workflow, dto, flowAssignInfo, targetStepDefine, targetStep,
-                traceType, expiredTime, isOrderFiled, cancellationToken);
+                traceType, expiredTime, isOrderFiled, handleMode, cancellationToken);
 
             await _workflowRepository.UpdateAsync(workflow, cancellationToken);
 
@@ -1626,7 +1626,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 撤回至开始节点
         /// </summary>
         public async Task RecallToStartStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime,
-            CancellationToken cancellationToken)
+           EHandleMode handleMode, CancellationToken cancellationToken)
         {
             //todo 1.当前待办节点删掉 2.当前待办trace更新(status, opinion) 3.复制startStep为待办 4.更新workflow(status, csStatus, handlers) 5.publish event
             var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true, withTraces: true, withCountersigns: true,
@@ -1665,14 +1665,14 @@ namespace Hotline.FlowEngine.Workflows
                 dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
             //flowAssignInfo.FlowAssignType = EFlowAssignType.Role;
             await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
-                cancellationToken);
+               handleMode, cancellationToken);
         }
 
         /// <summary>
         /// 撤回至派单节点
         /// </summary>
         public async Task RecallToSendStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime,
-            CancellationToken cancellationToken)
+           EHandleMode handleMode, CancellationToken cancellationToken)
         {
             var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true, withTraces: true, withCountersigns: true,
                 cancellationToken: cancellationToken);
@@ -1710,7 +1710,7 @@ namespace Hotline.FlowEngine.Workflows
                 dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
             //flowAssignInfo.FlowAssignType = EFlowAssignType.Role;
             await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
-                cancellationToken);
+                handleMode, cancellationToken);
         }
 
         /// <summary>
@@ -1718,7 +1718,7 @@ namespace Hotline.FlowEngine.Workflows
         /// </summary>
         /// <returns>true 派单组  false 话务部</returns>
         public async Task<(bool, Workflow workflow)> RecallToCenterFirstToSendAsync(string workflowId, string opinion, bool isOrderFiled,
-            DateTime? expiredTime, List<FlowStepHandler>? handlers, CancellationToken cancellationToken)
+            DateTime? expiredTime, List<FlowStepHandler>? handlers, EHandleMode handleMode, CancellationToken cancellationToken)
         {
             bool isPaiDan = true;
             var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true, withTraces: true, withCountersigns: true,
@@ -1758,7 +1758,7 @@ namespace Hotline.FlowEngine.Workflows
                 var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.HandlerType, dto.IsStartCountersign,
                     dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
                 await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
-                    cancellationToken);
+                   handleMode, cancellationToken);
             }
             else
             {
@@ -1796,7 +1796,7 @@ namespace Hotline.FlowEngine.Workflows
                     dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
                 //flowAssignInfo.FlowAssignType = EFlowAssignType.Role;
                 await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
-                    cancellationToken);
+                   handleMode, cancellationToken);
                 isPaiDan = false;
             }
 
@@ -2058,7 +2058,7 @@ namespace Hotline.FlowEngine.Workflows
         /// </summary>
         public async Task HandleStepAsync(WorkflowStep step, Workflow workflow,
             BasicWorkflowDto dto, ECounterSignType? counterSignType,
-            DateTime? expiredTime, CancellationToken cancellationToken)
+            DateTime? expiredTime, EHandleMode handleMode, CancellationToken cancellationToken)
         {
             if (step.Status is EWorkflowStepStatus.Handled)
                 throw UserFriendlyException.SameMessage("当前节点状态已办理");
@@ -2079,7 +2079,7 @@ namespace Hotline.FlowEngine.Workflows
             step.Remark = dto.Remark;
 
             //step办理状态
-            HandleStep(step, dto.Opinion, dto.NextStepCode);
+            HandleStep(step, handleMode, dto.Opinion, dto.NextStepCode);
         }
 
         /// <summary>
@@ -2573,13 +2573,13 @@ namespace Hotline.FlowEngine.Workflows
         /// <summary>
         /// 办理节点(赋值节点的办理对象信息)
         /// </summary>
-        private void HandleStep(WorkflowStep step, string opinion, string nextStepCode)
+        private void HandleStep(WorkflowStep step, EHandleMode handleMode, string opinion, string nextStepCode)
         {
             //todo 重构:ISessionContext传入
             step.Handle(_sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
                 _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
                 _sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
-                _sessionContextProvider.SessionContext.OrgIsCenter, opinion, nextStepCode);
+                _sessionContextProvider.SessionContext.OrgIsCenter, handleMode, opinion, nextStepCode);
 
             //var handler = step.FindActualHandler(current.Roles, current.RequiredUserId, current.RequiredOrgId);
             //if (handler is not null)
@@ -2776,51 +2776,51 @@ namespace Hotline.FlowEngine.Workflows
         //    await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
         //}
 
-        private async Task RecallTraceAsync(List<WorkflowTrace> traces, string opinion, ISessionContext current,
-            CancellationToken cancellationToken)
-        {
-            //未办理的traces
-            //var uncompleteTraces =
-            //    await _workflowTraceRepository.QueryAsync(d =>
-            //        d.WorkflowId == workflowId && string.IsNullOrEmpty(d.HandlerId));
+        //private async Task RecallTraceAsync(List<WorkflowTrace> traces, string opinion, ISessionContext current,
+        //    CancellationToken cancellationToken)
+        //{
+        //    //未办理的traces
+        //    //var uncompleteTraces =
+        //    //    await _workflowTraceRepository.QueryAsync(d =>
+        //    //        d.WorkflowId == workflowId && string.IsNullOrEmpty(d.HandlerId));
 
-            var uncompleteTraces = traces.Where(d => d.Status != EWorkflowStepStatus.Handled).ToList();
+        //    var uncompleteTraces = traces.Where(d => d.Status != EWorkflowStepStatus.Handled).ToList();
 
-            if (uncompleteTraces.Any())
-            {
-                foreach (var trace in uncompleteTraces)
-                {
-                    trace.Handle(
-                        current.RequiredUserId, current.UserName,
-                        current.RequiredOrgId, current.OrgName,
-                        current.OrgAreaCode, current.OrgAreaName,
-                        current.OrgIsCenter, opinion);
-                }
+        //    if (uncompleteTraces.Any())
+        //    {
+        //        foreach (var trace in uncompleteTraces)
+        //        {
+        //            trace.Handle(
+        //                current.RequiredUserId, current.UserName,
+        //                current.RequiredOrgId, current.OrgName,
+        //                current.OrgAreaCode, current.OrgAreaName,
+        //                current.OrgIsCenter, opinion);
+        //        }
 
-                await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
-            }
-        }
+        //        await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
+        //    }
+        //}
 
-        private async Task<WorkflowTrace> PreviousTraceAsync(string workflowId,
-            PreviousWorkflowDto dto, WorkflowStep step,
-            string applicantId, string applicantName,
-            string applicantOrgId, string applicantOrgName,
-            string applicantOrgAreaCode, string applicantOrgAreaName,
-            bool applicantIsCenter, CancellationToken cancellationToken)
-        {
-            var trace = await GetWorkflowTraceAsync(workflowId, step.Id, cancellationToken);
-            _mapper.Map(dto, trace);
+        //private async Task<WorkflowTrace> PreviousTraceAsync(string workflowId,
+        //    PreviousWorkflowDto dto, WorkflowStep step,
+        //    string applicantId, string applicantName,
+        //    string applicantOrgId, string applicantOrgName,
+        //    string applicantOrgAreaCode, string applicantOrgAreaName,
+        //    bool applicantIsCenter, CancellationToken cancellationToken)
+        //{
+        //    var trace = await GetWorkflowTraceAsync(workflowId, step.Id, cancellationToken);
+        //    _mapper.Map(dto, trace);
 
-            //HandleTrace(trace, dto.Opinion, current);
+        //    //HandleTrace(trace, dto.Opinion, current);
 
-            trace.Handle(applicantId, applicantName,
-                applicantOrgId, applicantOrgName,
-                applicantOrgAreaCode, applicantOrgAreaName,
-                applicantIsCenter, dto.Opinion);
+        //    trace.Handle(applicantId, applicantName,
+        //        applicantOrgId, applicantOrgName,
+        //        applicantOrgAreaCode, applicantOrgAreaName,
+        //        applicantIsCenter, dto.Opinion);
 
-            await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
-            return trace;
-        }
+        //    await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
+        //    return trace;
+        //}
 
         //private async Task EndTraceAsync(Workflow workflow, BasicWorkflowDto dto, WorkflowStep step, CancellationToken cancellationToken)
         //{
@@ -2916,7 +2916,7 @@ namespace Hotline.FlowEngine.Workflows
 
         private async Task<bool> RecallAsync(Workflow workflow, BasicWorkflowDto dto, FlowAssignInfo flowAssignInfo,
             StepDefine targetStepDefine, WorkflowStep targetStep, EWorkflowTraceType traceType,
-            DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken)
+            DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, CancellationToken cancellationToken)
         {
             var targetIsStartStep = targetStepDefine.StepType is EStepType.Start;
             var updateTraces = new List<WorkflowTrace>();
@@ -2931,7 +2931,7 @@ namespace Hotline.FlowEngine.Workflows
                         _sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
                         _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
                         _sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
-                        _sessionContextProvider.SessionContext.OrgIsCenter, dto.Opinion);
+                        _sessionContextProvider.SessionContext.OrgIsCenter, handleMode, dto.Opinion);
                 }
 
                 //await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
@@ -3111,7 +3111,7 @@ namespace Hotline.FlowEngine.Workflows
             //    _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
             //    _sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName);
 
-            HandleStep(step, "流程归档", string.Empty);
+            HandleStep(step, EHandleMode.Normal, "流程归档", string.Empty);
 
             await _workflowStepRepository.AddAsync(step, cancellationToken);
             workflow.Steps.Add(step);
@@ -3520,7 +3520,7 @@ namespace Hotline.FlowEngine.Workflows
                 step.Handle(_sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
                     _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
                     _sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
-                    _sessionContextProvider.SessionContext.OrgIsCenter, opinion);
+                    _sessionContextProvider.SessionContext.OrgIsCenter, EHandleMode.Normal, opinion);
             }
 
             updateSteps.Add(step);