xfe 1 rok pred
rodič
commit
8c09443f13

+ 20 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -2390,7 +2390,6 @@ public class OrderController : BaseController
     [HttpPost("handle")]
     public async Task Handle([FromBody] NextWorkflowDto dto)
     {
-        //todo 需求待确认
         var order = await _orderRepository.Queryable()
             .FirstAsync(d => d.WorkflowId == dto.WorkflowId, HttpContext.RequestAborted);
         //if (await _orderDelayRepository.AnyAsync(x => x.OrderId == order.Id && x.DelayState == EDelayState.Examining, HttpContext.RequestAborted))
@@ -2402,6 +2401,26 @@ public class OrderController : BaseController
             throw UserFriendlyException.SameMessage("该工单存在正在审核中的退回,不能办理");
         }
 
+        if (dto.FlowDirection.HasValue
+            && dto.External.TimeLimit.HasValue
+            && dto.External.TimeLimitUnit.HasValue)
+        {
+            var expiredTimeConfig = _timeLimitDomainService.CalcEndTime(DateTime.Now,
+                new TimeConfig(dto.External.TimeLimit.Value, dto.External.TimeLimitUnit.Value), order.AcceptTypeCode);
+            if (dto.FlowDirection is EFlowDirection.CenterToOrg)
+            {
+                order.CenterToOrg(expiredTimeConfig.TimeText, expiredTimeConfig.Count,
+                    expiredTimeConfig.TimeType, expiredTimeConfig.ExpiredTime, expiredTimeConfig.NearlyExpiredTime);
+                //写入质检
+                await _qualityApplication.AddQualityAsync(EQualitySource.Send, order.Id, HttpContext.RequestAborted);
+            }
+            else if(dto.FlowDirection is EFlowDirection.OrgToCenter)
+            {
+                order.OrgToCenter(expiredTimeConfig.TimeText, expiredTimeConfig.Count,
+                    expiredTimeConfig.TimeType, expiredTimeConfig.ExpiredTime, expiredTimeConfig.NearlyExpiredTime);
+            }
+        }
+
         await _workflowApplication.NextAsync(dto, HttpContext.RequestAborted);
     }
 

+ 10 - 0
src/Hotline/FlowEngine/Workflows/StepBasicEntity.cs

@@ -1,6 +1,7 @@
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.File;
 using Hotline.Share.Enums.FlowEngine;
+using Hotline.Share.Enums.Order;
 using SqlSugar;
 using XF.Domain.Entities;
 using XF.Domain.Repository;
@@ -44,6 +45,11 @@ public abstract class StepBasicEntity : CreationEntity
     /// </summary>
     public bool IsActualHandled { get; set; }
 
+    /// <summary>
+    /// 节点超期状态
+    /// </summary>
+    public EExpiredStatus? ExpiredStatus { get; set; }
+
     #region 接办
 
     /// <summary>
@@ -286,6 +292,10 @@ public abstract class StepBasicEntity : CreationEntity
 
         if (!string.IsNullOrEmpty(opinion))
             Opinion = opinion;
+
+        ExpiredStatus = HandleTime > StepExpiredTime
+            ? EExpiredStatus.Expired
+            : EExpiredStatus.Normal;
     }
 
     #endregion

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

@@ -260,9 +260,9 @@ namespace Hotline.FlowEngine.Workflows
             if (workflow.CanHandle(userId, orgId))
             {
                 var currentStep = FindCurrentStepWaitForHandle(workflow, userId, orgId);
-                if(currentStep.Status is not EWorkflowStepStatus.Handled)
+                if (currentStep.Status is not EWorkflowStepStatus.Handled)
                 {
-                    canPrevious = !(currentStep.IsInCountersign() && 
+                    canPrevious = !(currentStep.IsInCountersign() &&
                                     !currentStep.IsTopCountersignEndStep(workflow.TopCountersignStepId));
                 }
             }
@@ -467,9 +467,16 @@ namespace Hotline.FlowEngine.Workflows
             ////if (isCenterToOrg)
             ////    workflow.CenterToOrg(CalculateExpiredTime(workflow.WorkflowDefinition.Code));//todo 过期时间
 
+            //todo 如果是工单办理类型 并且参数传入期满时间有值, 将值赋予workflow
+            //if (workflow.FlowType is EFlowType.Handle && )
+            //{
+            //    workflow.NearlyExpiredTime =
+            //workflow.ExpiredTime =
+            //}
+
             //创建下一/N个节点(会签汇总节点:会签未全部办理时不创建,最后一个会签办理节点创建会签汇总节点)
             var nextSteps = await CreateNextStepsAsync(workflow, currentStep, dto, nextStepDefine, isNextDynamic,
-                flowAssignInfo, cancellationToken);
+                    flowAssignInfo, cancellationToken);
 
             //赋值当前节点的下级办理节点
             if (dto.IsStartCountersign
@@ -640,7 +647,7 @@ namespace Hotline.FlowEngine.Workflows
 
             //更新实际办理节点信息
             workflow.UpdateActualStepWhenAssign(newPrevStep, prevStep.HandlerOrgName, prevStep.HandlerOrgId);
-            
+
             //更新流程可办理对象
             workflow.UpdatePreviousHandlers(operater.Id, operater.OrgId, prevStep);