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

Merge branch 'release/yibin' of http://git.12345lm.cn/Fengwo/hotline into release/yibin

tangjiang 9 сар өмнө
parent
commit
dfc9a6c7b2

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

@@ -3936,7 +3936,7 @@ public class OrderController : BaseController
             var orderDto = _mapper.Map<OrderDto>(order);
             await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderExpiredTimeUpdate, orderDto, cancellationToken: HttpContext.RequestAborted);
             //}
-            await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, HttpContext.RequestAborted);
+            await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, order.Status >= EOrderStatus.Filed, HttpContext.RequestAborted);
             var publish = await _orderPublishRepository.GetAsync(x => x.OrderId == dto.OrderId);
             if (publish != null)
             {
@@ -4065,7 +4065,7 @@ public class OrderController : BaseController
             var processType = dto.FlowDirection == EFlowDirection.OrgToCenter || dto.FlowDirection == EFlowDirection.CenterToCenter ? EProcessType.Zhiban : EProcessType.Jiaoban;
             await _orderRepository.Updateable().SetColumns(o => new Orders.Order() { ProcessType = processType })
                 .Where(o => o.Id == order.Id).ExecuteCommandAsync(HttpContext.RequestAborted);
-            await _workflowApplication.RecallAsync(recall, endTime, HttpContext.RequestAborted);
+            await _workflowApplication.RecallAsync(recall, endTime, order.Status >= EOrderStatus.Filed, HttpContext.RequestAborted);
             var publish = await _orderPublishRepository.GetAsync(x => x.OrderId == dto.OrderId);
             if (publish != null)
             {
@@ -4146,7 +4146,7 @@ public class OrderController : BaseController
 
             //todo 特提重办,按审批通过时间依据中心派至部门的规则计算期满时间,更新order
 
-            await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, HttpContext.RequestAborted);
+            await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, order.Status >= EOrderStatus.Filed, HttpContext.RequestAborted);
             var publish = await _orderPublishRepository.GetAsync(x => x.OrderId == special.OrderId);
             if (publish != null)
             {
@@ -4246,7 +4246,7 @@ public class OrderController : BaseController
 
                 //todo 特提重办,按审批通过时间依据中心派至部门的规则计算期满时间,更新order
 
-                await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, HttpContext.RequestAborted);
+                await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, order.Status >= EOrderStatus.Filed, HttpContext.RequestAborted);
                 var publish = await _orderPublishRepository.GetAsync(x => x.OrderId == special.OrderId);
                 if (publish != null)
                 {

+ 0 - 11
src/Hotline.Api/Controllers/WorkflowController.cs

@@ -369,17 +369,6 @@ public class WorkflowController : BaseController
         return await _workflowApplication.GetRecallStepsAsync(workflowId, HttpContext.RequestAborted);
     }
 
-    /// <summary>
-    /// 撤回至任意节点
-    /// </summary>
-    /// <param name="dto"></param>
-    /// <returns></returns>
-    [HttpPost("recall")]
-    public async Task Recall([FromBody] RecallDto dto)
-    {
-        await _workflowApplication.RecallAsync(dto, null, HttpContext.RequestAborted);
-    }
-
     /// <summary>
     /// 终止流程
     /// </summary>

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

@@ -41,7 +41,7 @@ namespace Hotline.Application.FlowEngine
         /// <summary>
         /// 撤回至任意节点
         /// </summary>
-        Task RecallAsync(RecallDto dto, DateTime? expiredTime, CancellationToken cancellationToken);
+        Task RecallAsync(RecallDto dto, DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken);
 
         /// <summary>
         /// 办理至结束节点(无视流程模板配置,操作人需是当前节点办理对象)

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

@@ -147,25 +147,25 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
             current.RequiredUserId, current.RequiredOrgId,
             externalId, cancellationToken);
 
-		//var startStepHandles = new List<WorkflowStepHandler>{WorkflowStepHandler.Create(workflow.Id, workflow.ExternalId,
-		//    EFlowAssignType.User, current.RequiredUserId, current.UserName,
-		//    current.RequiredOrgId, current.OrgName)};
-
-		var defineHandler = startStepDefine.HandlerTypeItems.First();
-		var startStep = _workflowDomainService.CreateStartStep(workflow, startStepDefine, dto,
-			new FlowStepHandler
-			{
-				Key = current.RequiredUserId,
-				Value = current.UserName,
-				UserId = current.UserId,
-				Username = current.UserName,
-				OrgId = current.RequiredOrgId,
-				OrgName = current.OrgName,
-				RoleId = defineHandler.Key,
-				RoleName = defineHandler.Value,
-			}, expiredTime);
-
-		var flowAssignInfo =
+        //var startStepHandles = new List<WorkflowStepHandler>{WorkflowStepHandler.Create(workflow.Id, workflow.ExternalId,
+        //    EFlowAssignType.User, current.RequiredUserId, current.UserName,
+        //    current.RequiredOrgId, current.OrgName)};
+
+        var defineHandler = startStepDefine.HandlerTypeItems.First();
+        var startStep = _workflowDomainService.CreateStartStep(workflow, startStepDefine, dto,
+            new FlowStepHandler
+            {
+                Key = current.RequiredUserId,
+                Value = current.UserName,
+                UserId = current.UserId,
+                Username = current.UserName,
+                OrgId = current.RequiredOrgId,
+                OrgName = current.OrgName,
+                RoleId = defineHandler.Key,
+                RoleName = defineHandler.Value,
+            }, expiredTime);
+
+        var flowAssignInfo =
             await GetNextStepFlowAssignInfoAsync(workflow, startStep, dto, firstStepDefine, isNextDynamic, cancellationToken);
 
         //var firstStepHandlers = await GetNextStepHandlersAsync(workflow, firstStepDefine, dto, cancellationToken);
@@ -318,7 +318,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
     /// <summary>
     /// 撤回至任意节点
     /// </summary>
-    public async Task RecallAsync(RecallDto dto, DateTime? expiredTime, CancellationToken cancellationToken)
+    public async Task RecallAsync(RecallDto dto, DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken)
     {
         var validator = new RecallDtoValidator();
         var validationResult = await validator.ValidateAsync(dto, cancellationToken);
@@ -339,7 +339,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
 
         //var stepHandlers = await GetNextStepHandlersAsync(workflow, targetStepDefine, dto, cancellationToken);
 
-        await _workflowDomainService.RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, expiredTime, cancellationToken);
+        await _workflowDomainService.RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, expiredTime, isOrderFiled, cancellationToken);
     }
 
     /// <summary>
@@ -859,7 +859,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     users1 = users1.Where(d => d.OrgId.StartsWith(levelOneOrgId));
                 var defineTypeItem = stepDefine.HandlerTypeItems.First();
 
-				handlers = users1.Where(d => d != null && !string.IsNullOrEmpty(d.Id))
+                handlers = users1.Where(d => d != null && !string.IsNullOrEmpty(d.Id))
                     .Select(d => new FlowStepHandler
                     {
                         Key = d.Id,
@@ -870,7 +870,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                         OrgName = d.Organization.Name,
                         RoleId = defineTypeItem.Key,
                         RoleName = defineTypeItem.Value
-					})
+                    })
                     .ToList();
                 break;
             case EHandlerType.OrgLevel:

+ 2 - 2
src/Hotline.Application/Orders/OrderSecondaryHandlingApplication.cs

@@ -170,7 +170,7 @@ namespace Hotline.Application.Orders
                 var orderDto = _mapper.Map<OrderDto>(order);
                 await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderExpiredTimeUpdate, orderDto, cancellationToken: cancellationToken);
 
-                await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, cancellationToken);
+                await _workflowApplication.RecallAsync(recall, expiredTime.ExpiredTime, order.Status >= EOrderStatus.Filed, cancellationToken);
                 var publish = await _orderPublishRepository.GetAsync(x => x.OrderId == model.OrderId);
                 if (publish != null)
                 {
@@ -212,7 +212,7 @@ namespace Hotline.Application.Orders
                 .Includes(x => x.OrderVisit, y => y.Employee)
                 .Includes(x => x.SecondaryHandling)
                 .Where(x => x.OrderVisit.Order.IsProvince == false)
-				.LeftJoin<OrderScreen>((x, s) => x.Id == s.VisitDetailId && s.Status < EScreenStatus.End && s.IsDeleted == false)
+                .LeftJoin<OrderScreen>((x, s) => x.Id == s.VisitDetailId && s.Status < EScreenStatus.End && s.IsDeleted == false)
                 .Where((x, s) => s.Id == null && (x.SecondaryHandling.State == ESecondaryHandlingState.NotApply || x.SecondaryHandling.Id == null))
                 .Where(x => x.OrderVisit.VisitTime < dto.CreationTimeEnd && x.OrderVisit.VisitTime > dto.CreationTimeStart)
                 .WhereIF(!string.IsNullOrEmpty(dto.No), x => x.OrderVisit.Order!.No!.Contains(dto.No!))

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

@@ -67,7 +67,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 撤回(返回到之前任意节点)
         /// </summary>
         Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine, FlowAssignInfo flowAssignInfo,
-            DateTime? expiredTime, CancellationToken cancellationToken);
+            DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken);
 
         /// <summary>
         /// 撤回至开始节点

+ 13 - 11
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -262,7 +262,7 @@ namespace Hotline.FlowEngine.Workflows
 
             var unCompletedCountersign = workflow.Countersigns
                 .FirstOrDefault(d => !d.IsCompleted() && d.StarterId == userId);
-            if (unCompletedCountersign is null) 
+            if (unCompletedCountersign is null)
                 return (workflow, null, canHandle, canPrevious, previousOpinion);
 
             //var existCountersignEndStep = workflow.Steps.Exists(d =>
@@ -788,7 +788,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 批量修改工单办理对象
         /// </summary>
         public async Task ChangeHandlerBatchAsync(
-            IReadOnlyList<(string userId, string username, string orgId, string orgName,string? roleId,string? roleName, ICollection<WorkflowStep> steps
+            IReadOnlyList<(string userId, string username, string orgId, string orgName, string? roleId, string? roleName, ICollection<WorkflowStep> steps
                 )> handlers,
             CancellationToken cancellationToken)
         {
@@ -798,7 +798,7 @@ namespace Hotline.FlowEngine.Workflows
                 {
                     step.FlowAssignType = EFlowAssignType.User;
                     step.Assign(handler.userId, handler.username,
-                        handler.orgId, handler.orgName,handler.roleId,handler.roleName);
+                        handler.orgId, handler.orgName, handler.roleId, handler.roleName);
                     if (step.WorkflowTrace is null)
                         throw new UserFriendlyException("未查询节点对应快照信息");
                     step.WorkflowTrace.Assign(handler.userId, handler.username,
@@ -1015,7 +1015,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 撤回(返回到之前任意节点)
         /// </summary>
         public async Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine,
-            FlowAssignInfo flowAssignInfo, DateTime? expiredTime,
+            FlowAssignInfo flowAssignInfo, DateTime? expiredTime, bool isOrderFiled,
             CancellationToken cancellationToken)
         {
             var targetStep = workflow.Steps.FirstOrDefault(d => d.Code == dto.NextStepCode && d.IsOrigin);
@@ -1026,7 +1026,7 @@ namespace Hotline.FlowEngine.Workflows
             //await RecallTraceAsync(workflow.Traces, dto.Opinion, _sessionContext, cancellationToken);
 
             var isOrgToCenter = await RecallAsync(workflow, dto, flowAssignInfo, targetStepDefine, targetStep,
-                EWorkflowTraceType.Recall, expiredTime, cancellationToken);
+                EWorkflowTraceType.Recall, expiredTime, isOrderFiled, cancellationToken);
 
             await _workflowRepository.UpdateAsync(workflow, cancellationToken);
 
@@ -1882,15 +1882,15 @@ namespace Hotline.FlowEngine.Workflows
             newStep.CountersignId = step.CountersignId;
             newStep.IsStartedCountersignEnd = step.IsStartedCountersignEnd;
 
-			//退回场景:指派给原办理人,其余场景:按照原节点原始指派方式复制
-			if (traceType is EWorkflowTraceType.Previous)
+            //退回场景:指派给原办理人,其余场景:按照原节点原始指派方式复制
+            if (traceType is EWorkflowTraceType.Previous)
             {
-	            //newStep.FlowAssignType = EFlowAssignType.User;
+                //newStep.FlowAssignType = EFlowAssignType.User;
                 // 是否中心  临时紧急修改 后续在流程模版定义是否原办理人退回类型 来实现流程 禅道200
                 newStep.FlowAssignType = !step.HandlerOrgIsCenter!.Value ? EFlowAssignType.Org : EFlowAssignType.Role;
                 if (newStep is { FlowAssignType: EFlowAssignType.Role, BusinessType: EBusinessType.Send })
                     newStep.FlowAssignType = EFlowAssignType.User;
-				newStep.Assign(step.HandlerId, step.HandlerName, step.HandlerOrgId, step.HandlerOrgName, step.RoleId, step.RoleName);
+                newStep.Assign(step.HandlerId, step.HandlerName, step.HandlerOrgId, step.HandlerOrgName, step.RoleId, step.RoleName);
             }
 
             await _workflowStepRepository.AddAsync(newStep, cancellationToken);
@@ -2089,7 +2089,7 @@ namespace Hotline.FlowEngine.Workflows
 
         private async Task<bool> RecallAsync(Workflow workflow, BasicWorkflowDto dto, FlowAssignInfo flowAssignInfo,
             StepDefine targetStepDefine, WorkflowStep targetStep, EWorkflowTraceType traceType,
-            DateTime? expiredTime, CancellationToken cancellationToken)
+            DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken)
         {
             var targetIsStartStep = targetStepDefine.StepType is EStepType.Start;
             var updateTraces = new List<WorkflowTrace>();
@@ -2136,7 +2136,9 @@ namespace Hotline.FlowEngine.Workflows
                 //await UpdateTracesStateAsync(updateTraces, EWorkflowTraceState.StepRemoveByRecall, cancellationToken);
                 foreach (var trace in traces)
                 {
-                    trace.TraceState = EWorkflowTraceState.StepRemoveByRecall;
+                    trace.TraceState = isOrderFiled
+                        ? EWorkflowTraceState.StepRemoveByRecallWhenFiled
+                        : EWorkflowTraceState.StepRemoveByRecall;
                 }
 
                 updateTraces.AddRange(traces);

+ 6 - 1
src/Hotline/FlowEngine/Workflows/WorkflowTrace.cs

@@ -60,7 +60,12 @@ public enum EWorkflowTraceState
     StepRemoveByPrevious = 10,
 
     /// <summary>
-    /// 对应节点因撤回被删除
+    /// 对应节点因撤回被删除(工单未归档)
     /// </summary>
     StepRemoveByRecall = 20,
+
+    /// <summary>
+    /// 对应节点因撤回被删除(工单已归档)
+    /// </summary>
+    StepRemoveByRecallWhenFiled = 21,
 }