瀏覽代碼

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

qinchaoyue 5 月之前
父節點
當前提交
0c0cfe0302

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

@@ -29,11 +29,11 @@ namespace Hotline.Application.FlowEngine
         /// </summary>
         Task<string> StartWorkflowToStartStepAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null,
             CancellationToken cancellationToken = default);
-        
+
         /// <summary>
         /// 查询下一节点办理对象类型(user or org)及实际办理对象
         /// </summary>
-		Task<FlowAssignInfo> GetNextStepFlowAssignInfoAsync(Workflow workflow, WorkflowStep currentStep,
+        Task<FlowAssignInfo> GetNextStepFlowAssignInfoAsync(Workflow workflow, WorkflowStep currentStep,
             BasicWorkflowDto dto, StepDefine nextStepDefine, bool isNextDynamic, CancellationToken cancellationToken);
 
         /// <summary>

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

@@ -343,7 +343,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
             _sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
             _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
             _sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
-            _sessionContextProvider.SessionContext.OrgIsCenter, _sessionContextProvider.SessionContext.Roles, cancellationToken);
+            _sessionContextProvider.SessionContext.OrgIsCenter, _sessionContextProvider.SessionContext.Roles,
+            cancellationToken);
     }
 
     /// <summary>
@@ -365,7 +366,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
     }
 
     /// <summary>
-    /// 撤回至任意节点
+    /// 撤回至之前任意节点
     /// </summary>
     public async Task RecallAsync(RecallDto dto, DateTime? expiredTime, bool isOrderFiled, EWorkflowTraceType traceType,
         CancellationToken cancellationToken)

+ 1 - 1
src/Hotline.Application/Mappers/WorkflowMapperConfigs.cs

@@ -37,7 +37,7 @@ public class WorkflowMapperConfigs : IRegister
             .Ignore(d => d.IsSms)
             .Ignore(d => d.Opinion)
             .Ignore(d => d.FileJson)
-            //.Ignore(d => d.StepExpiredTime)
+            .Ignore(d => d.StepExpiredTime)
             .Ignore(d => d.Workflow)
             .Ignore(d => d.WorkflowTrace)
             //.IgnoreIf((d, s) => s.StepHandlers == null || !s.StepHandlers.Any(), d => d.StepHandlers)

+ 13 - 7
src/Hotline.Application/Orders/OrderApplication.cs

@@ -1104,14 +1104,14 @@ public class OrderApplication : IOrderApplication, IScopeDependency
          .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.CurrentStepCode == dto.CurrentStepCode) //当前办理节点
-         .WhereIF(dto.ActualHandleTimeStart.HasValue, d => d.ActualHandleTime >= dto.ActualHandleTimeStart) //办结时间开始
-         .WhereIF(dto.ActualHandleTimeEnd.HasValue, d => d.ActualHandleTime <= dto.ActualHandleTimeEnd) //办结时间结束
+         .WhereIF(dto.ActualHandleTimeStart.HasValue, d => d.FiledTime >= dto.ActualHandleTimeStart) //办结时间开始
+         .WhereIF(dto.ActualHandleTimeEnd.HasValue, d => d.FiledTime <= dto.ActualHandleTimeEnd) //办结时间结束
          .WhereIF(dto.IsOverTime == true,
              d => (d.ExpiredTime < DateTime.Now && d.Status < EOrderStatus.Filed) ||
-                  (d.ExpiredTime < d.ActualHandleTime && d.Status >= EOrderStatus.Filed)) //是 超期
+                  (d.ExpiredTime < d.FiledTime && 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)) //否 超期
+                  (d.ExpiredTime > d.FiledTime && 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)) //区域
@@ -2607,10 +2607,16 @@ public class OrderApplication : IOrderApplication, IScopeDependency
 
     public async Task EndCountersign(EndCountersignDto dto, CancellationToken cancellationToken)
     {
-        var workflow = await _workflowDomainService.TerminalCountersignAsync(dto.CountersignId, cancellationToken);
-        var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflow.Id, cancellationToken);
+        var countersign = await _workflowCountersignRepository.GetAsync(dto.CountersignId, cancellationToken);
+        if (countersign is null)
+            throw new UserFriendlyException("无效会签编号");
+        
+        var order = await _orderRepository.GetAsync(d => d.WorkflowId == countersign.WorkflowId, cancellationToken);
         if (order is null)
-            throw new UserFriendlyException($"工单未开启流程, workflowId: {workflow.Id}");
+            throw new UserFriendlyException($"工单未开启流程, workflowId: {countersign.WorkflowId}");
+        
+        var workflow = await _workflowDomainService.TerminalCountersignAsync(countersign, order.ExpiredTime.Value, cancellationToken);
+        
         order.UpdateHandlingStatus(workflow.IsInCountersign);
         _mapper.Map(workflow, order);
         await _orderRepository.UpdateAsync(order, cancellationToken);

+ 3 - 1
src/Hotline/FlowEngine/Workflows/IWorkflowDomainService.cs

@@ -193,7 +193,9 @@ namespace Hotline.FlowEngine.Workflows
         /// <param name="countersignId"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        Task<Workflow> TerminalCountersignAsync(string countersignId, CancellationToken cancellationToken);
+        Task<Workflow> TerminalCountersignAsync(string countersignId, DateTime expireTime, CancellationToken cancellationToken);
+
+        Task<Workflow> TerminalCountersignAsync(WorkflowCountersign countersign, DateTime expireTime, CancellationToken cancellationToken);
 
         /// <summary>
         /// 办理节点

+ 43 - 19
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -589,16 +589,20 @@ namespace Hotline.FlowEngine.Workflows
                 d.Status is not EWorkflowStepStatus.Handled
             );
 
-            var unCompletedCountersign = workflow.Countersigns
-                .FirstOrDefault(d => !d.IsCompleted() && d.StarterOrgId == orgId);
-            if (unCompletedCountersign is null)
-                return (workflow, null, canHandle, canPrevious, unhandlePreviousTrace);
+            WorkflowCountersign? unCompletedCountersign = null;
+            if (!canHandle)
+            {
+                unCompletedCountersign = workflow.Countersigns
+                    .FirstOrDefault(d => !d.IsCompleted() && d.StarterOrgId == orgId);
+                if (unCompletedCountersign is null)
+                    return (workflow, null, canHandle, canPrevious, unhandlePreviousTrace);
+            }
 
             //var existCountersignEndStep = workflow.Steps.Exists(d =>
             //    d.IsCountersignEndStep && d.CountersignStartStepId == unCompletedCountersign.StartStepId);
             //return (workflow, existCountersignEndStep ? null : unCompletedCountersign.Id, canPrevious);
 
-            return (workflow, unCompletedCountersign.Id, canHandle, canPrevious, unhandlePreviousTrace);
+            return (workflow, unCompletedCountersign?.Id ?? null, canHandle, canPrevious, unhandlePreviousTrace);
         }
 
         /// <summary>
@@ -882,8 +886,8 @@ namespace Hotline.FlowEngine.Workflows
             string applicantId, string applicantName,
             string applicantOrgId, string applicantOrgName,
             string applicantOrgAreaCode, string applicantOrgAreaName,
-            bool applicantIsCenter,
-            string[] applicantRoleIds, CancellationToken cancellationToken)
+            bool applicantIsCenter, string[] applicantRoleIds,
+            CancellationToken cancellationToken)
         {
             //ValidatePermission(workflow, operater.OrgId, operater.Id);
 
@@ -961,7 +965,7 @@ namespace Hotline.FlowEngine.Workflows
             //复制上一个节点为待接办
             // var newPrevStep =
             //     await DuplicateStepWithTraceAsync(workflow, prevStep, EWorkflowTraceType.Previous, cancellationToken);
-            var newPrevStep = DuplicateStep(prevStep, EWorkflowTraceType.Previous);
+            var newPrevStep = DuplicateStep(prevStep, EWorkflowTraceType.Previous, dto.ExpiredTime);
             //退给派单组节点,需按照平均分配原则派给一个派单员 禅道299 TODO
             if (dto.Handler != null) //todo 改为按策略判断
             {
@@ -1693,11 +1697,12 @@ namespace Hotline.FlowEngine.Workflows
                         }
                     }
                 };
-				if (_appOptions.Value.IsZiGong && handlers.Any())
-				{
+                if (_appOptions.Value.IsZiGong && handlers.Any())
+                {
                     dto.NextHandlers = handlers;
-				}
-				var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.HandlerType, dto.IsStartCountersign,
+                }
+
+                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);
@@ -2524,9 +2529,9 @@ namespace Hotline.FlowEngine.Workflows
         /// 复制一个节点为待接办
         /// </summary>
         private async Task<WorkflowStep> DuplicateStepWithTraceAsync(Workflow workflow, WorkflowStep step,
-            EWorkflowTraceType traceType, CancellationToken cancellationToken)
+            EWorkflowTraceType traceType, DateTime expiredTime, CancellationToken cancellationToken)
         {
-            var newStep = DuplicateStep(step, traceType);
+            var newStep = DuplicateStep(step, traceType, expiredTime);
 
             await _workflowStepRepository.AddAsync(newStep, cancellationToken);
             //await _workflowStepRepository.AddNav(newStep)
@@ -2539,7 +2544,7 @@ namespace Hotline.FlowEngine.Workflows
             return newStep;
         }
 
-        private WorkflowStep DuplicateStep(WorkflowStep step, EWorkflowTraceType traceType)
+        private WorkflowStep DuplicateStep(WorkflowStep step, EWorkflowTraceType traceType, DateTime? expiredTime)
         {
             var newStep = _mapper.Map<WorkflowStep>(step);
             newStep.Reset();
@@ -2552,6 +2557,7 @@ namespace Hotline.FlowEngine.Workflows
             newStep.StartCountersignId = step.StartCountersignId;
             newStep.CountersignId = step.CountersignId;
             newStep.IsStartedCountersignEnd = step.IsStartedCountersignEnd;
+            newStep.StepExpiredTime = expiredTime;
             newStep.InitId();
 
             //退回场景:指派给原办理人,其余场景:按照原节点原始指派方式复制 //todo 重构为参数传入办理对象
@@ -3111,12 +3117,29 @@ namespace Hotline.FlowEngine.Workflows
         /// <param name="countersignId"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public async Task<Workflow> TerminalCountersignAsync(string countersignId, CancellationToken cancellationToken)
+        public async Task<Workflow> TerminalCountersignAsync(string countersignId, DateTime expireTime, CancellationToken cancellationToken)
         {
             var countersign = await _workflowCountersignRepository.GetAsync(countersignId, cancellationToken);
             if (countersign is null)
                 throw new UserFriendlyException("无效会签编号");
 
+            //1. 检查会签是否已结束 t: return 2.检查是否有嵌套会签 t: 一起结束 3.结束会签 4.trace 5.检查workflow会签状态,如果会签全结束需更新状态 6.cp会签发起节点变为待办节点
+            if (countersign.IsCompleted())
+                throw new UserFriendlyException("该会签已结束");
+
+            return await TerminalCountersignAsync(countersign, expireTime, cancellationToken);
+        }
+
+        /// <summary>
+        /// 终止会签
+        /// </summary>
+        public async Task<Workflow> TerminalCountersignAsync(WorkflowCountersign countersign, DateTime expireTime,
+            CancellationToken cancellationToken)
+        {
+            // var countersign = await _workflowCountersignRepository.GetAsync(countersignId, cancellationToken);
+            // if (countersign is null)
+            //     throw new UserFriendlyException("无效会签编号");
+
             //1. 检查会签是否已结束 t: return 2.检查是否有嵌套会签 t: 一起结束 3.结束会签 4.trace 5.检查workflow会签状态,如果会签全结束需更新状态 6.cp会签发起节点变为待办节点
             if (countersign.IsCompleted())
                 throw new UserFriendlyException("该会签已结束");
@@ -3125,9 +3148,9 @@ namespace Hotline.FlowEngine.Workflows
                 withCountersigns: true, cancellationToken: cancellationToken);
             if (!workflow.IsInCountersign)
                 throw new UserFriendlyException("该流程未处于会签中");
-            countersign = workflow.Countersigns.First(d => d.Id == countersignId);
+            countersign = workflow.Countersigns.First(d => d.Id == countersign.Id);
 
-            var startCountersignStep = workflow.Steps.Find(d => d.StartCountersignId == countersignId);
+            var startCountersignStep = workflow.Steps.Find(d => d.StartCountersignId == countersign.Id);
             if (startCountersignStep is null)
                 throw new UserFriendlyException("未查询到发起会签节点");
             if (startCountersignStep.IsStartedCountersignEnd)
@@ -3156,7 +3179,8 @@ namespace Hotline.FlowEngine.Workflows
 
                 //cp会签发起节点变为待办节点
                 //1. create terminal trace 2. 撤回至startStep
-                var newStep = await DuplicateStepWithTraceAsync(workflow, startCountersignStep, EWorkflowTraceType.Normal, cancellationToken);
+                var newStep = await DuplicateStepWithTraceAsync(workflow, startCountersignStep, EWorkflowTraceType.Normal, expireTime,
+                    cancellationToken);
 
                 //当topcsStep结束cs时,实际办理节点应该更新为newStep
                 if (startCountersignStep.Id == workflow.TopCountersignStepId)