Преглед на файлове

workflow、order add actualHandlerKey Value

xf преди 1 година
родител
ревизия
69b53ddfc4

+ 0 - 1
src/Hotline.Api/Controllers/BaseController.cs

@@ -7,7 +7,6 @@ namespace Hotline.Api.Controllers;
 [ApiController]
 [Produces("application/json")]
 [Route("api/v1/[controller]")]
-[LogFilterAttribute]
 public class BaseController : ControllerBase
 {
     

+ 2 - 2
src/Hotline.Api/Controllers/CommonPController.cs

@@ -103,11 +103,11 @@ namespace Hotline.Api.Controllers
 			var handleNum = await _orderRepository.Queryable(false, false, false)
 				.Includes(o => o.Workflow, w => w.Steps)
                 .Where(o => o.Workflow.Steps.Any(s => s.Status != EWorkflowStepStatus.Handled))
-                .Where(o => o.Workflow.CurrentHandleTime != null && SqlFunc.JsonListObjectAny(o.Workflow.HandlerUsers, "Key", _sessionContext.RequiredUserId) && o.Workflow.CurrentHandleTime.Value.ToString("yyyy-MM-dd") == tadayTime).CountAsync();
+                .Where(o => o.Workflow.ActualHandleTime != null && SqlFunc.JsonListObjectAny(o.Workflow.HandlerUsers, "Key", _sessionContext.RequiredUserId) && o.Workflow.ActualHandleTime.Value.ToString("yyyy-MM-dd") == tadayTime).CountAsync();
             var handleOrgNum = await _orderRepository.Queryable(false, false, false)
 	            .Includes(o => o.Workflow, w => w.Steps)
                 .Where(o => o.Workflow.Steps.Any(s => s.Status != EWorkflowStepStatus.Handled))
-                .Where(o => o.Workflow.CurrentHandleTime != null && SqlFunc.JsonListObjectAny(o.Workflow.HandlerOrgs, "Key", _sessionContext.RequiredOrgId) && o.Workflow.CurrentHandleTime.Value.ToString("yyyy-MM-dd") == tadayTime).CountAsync();
+                .Where(o => o.Workflow.ActualHandleTime != null && SqlFunc.JsonListObjectAny(o.Workflow.HandlerOrgs, "Key", _sessionContext.RequiredOrgId) && o.Workflow.ActualHandleTime.Value.ToString("yyyy-MM-dd") == tadayTime).CountAsync();
 			//部门超期
 			var exceedTasksOkNum = await _orderRepository.Queryable(false, false, false)
 				.Includes(o => o.Workflow, w => w.Steps)

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

@@ -2044,7 +2044,7 @@ public class OrderController : BaseController
             .WhereIF(!string.IsNullOrEmpty(dto.ActualHandlerName), d => d.ActualHandlerName.Contains(dto.ActualHandlerName)) //接办人
             .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(!string.IsNullOrEmpty(dto.CurrentStepCode), d => d.ActualHandleStepCode == dto.CurrentStepCode) //当前办理节点
             .WhereIF(dto.ActualHandleTimeStart.HasValue, d => d.ActualHandleTime >= dto.ActualHandleTimeStart) //办结时间开始
             .WhereIF(dto.ActualHandleTimeEnd.HasValue, d => d.ActualHandleTime <= dto.ActualHandleTimeEnd) //办结时间结束
             .WhereIF(dto.IsOverTime == true, d => (d.ExpiredTime < DateTime.Now && d.Status < EOrderStatus.Filed) || (d.ExpiredTime < d.ActualHandleTime && d.Status >= EOrderStatus.Filed)) //是 超期
@@ -2312,6 +2312,17 @@ public class OrderController : BaseController
 
         try
         {
+            //if (dto.Workflow.NextHandlers.Any(d => d.Key == "001170" || d.Key == "001177"))
+            //{
+            //    var s = _timeLimitDomainService.CalcEndTime(DateTime.Now, ETimeType.WorkDay, 45, 80);
+            //    var n = new ExpiredTimeWithConfig
+            //    {
+            //        Count = s.
+            //    }
+            //}
+            // if(dto.Workflow.HandlerType is EHandlerType.AssignedOrg or EHandlerType.OrgLevel or EHandlerType.OrgType && dto.Workflow.NextStepCode)
+
+
             //期满时间
             var expiredTimeConfig = _timeLimitDomainService.CalcExpiredTime(DateTime.Now, EFlowDirection.OrgToCenter, dto.Data.AcceptTypeCode);
 
@@ -3741,7 +3752,7 @@ public class OrderController : BaseController
     [HttpPost("import-order")]
     public async Task ImportOrder(/*[FromForm]*/IFormFile file,/*[FromBody]*/ESource source)
     {
-        if (source< ESource.MALASHEQU || source > ESource.WENZHENGSC)
+        if (source < ESource.MALASHEQU || source > ESource.WENZHENGSC)
         {
             throw UserFriendlyException.SameMessage("不支持导入该渠道");
         }
@@ -3749,8 +3760,8 @@ public class OrderController : BaseController
         {
             file.CopyTo(stream);
             var list = MiniExcel.Query<ExcelContent>(stream).ToList();
-            
-            if (list!=null && list.Count>0)
+
+            if (list != null && list.Count > 0)
             {
                 int count = list.Count;
                 int errorCount = 0;
@@ -3759,12 +3770,12 @@ public class OrderController : BaseController
                 {
                     try
                     {
-                        var order =await _orderRepository.GetAsync(x => x.No == item.No, HttpContext.RequestAborted);
+                        var order = await _orderRepository.GetAsync(x => x.No == item.No, HttpContext.RequestAborted);
                         if (order is null)
                         {
                             order = _mapper.Map<Order>(item);
                             order.Source = source;
-                            var id = await _orderRepository.AddAsync(order,HttpContext.RequestAborted);
+                            var id = await _orderRepository.AddAsync(order, HttpContext.RequestAborted);
                             if (!string.IsNullOrEmpty(id))
                             {
                                 successCount++;
@@ -3777,9 +3788,9 @@ public class OrderController : BaseController
                         else
                         {
                             _mapper.Map(item, order);
-                            await _orderRepository.UpdateAsync(order,HttpContext.RequestAborted);
+                            await _orderRepository.UpdateAsync(order, HttpContext.RequestAborted);
                         }
-                        
+
                     }
                     catch
                     {

+ 0 - 0
src/Hotline.Api/模板.xlsx


+ 6 - 5
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -141,15 +141,16 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         }
 
         var workflow = await _workflowDomainService.CreateWorkflowAsync(wfModule, dto.Title,
-            _sessionContext.RequiredUserId, _sessionContext.RequiredOrgId, externalId, expiredTimeConfig?.TimeText,
-            expiredTimeConfig?.Count, expiredTimeConfig?.TimeType, expiredTimeConfig?.ExpiredTime, expiredTimeConfig?.NearlyExpiredTime, cancellationToken);
+            _sessionContext.RequiredUserId, _sessionContext.RequiredOrgId, 
+            externalId, expiredTimeConfig?.TimeText,
+            expiredTimeConfig?.Count, expiredTimeConfig?.TimeType, 
+            expiredTimeConfig?.ExpiredTime, expiredTimeConfig?.NearlyExpiredTime, cancellationToken);
 
         var startStep = _workflowDomainService.CreateStartStep(workflow, startStepDefine, dto,
             new List<Kv> { new(_sessionContext.RequiredUserId, _sessionContext.UserName) });
 
         if (dto.Files.Any())
-            startStep.FileJson =
-                await _fileRepository.AddFileAsync(dto.Files, workflow.ExternalId, startStep.Id, cancellationToken);
+            startStep.FileJson = await _fileRepository.AddFileAsync(dto.Files, workflow.ExternalId, startStep.Id, cancellationToken);
 
         await _workflowStepRepository.AddAsync(startStep, cancellationToken);
         workflow.Steps.Add(startStep);
@@ -589,7 +590,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         var originSteps = workflow.Steps.Where(d => d.StepType != EStepType.End && d.IsOrigin).ToList(); //todo 恢复到可撤回至发起人节点
         var stepCodes = originSteps.Select(d => d.Code).ToList();
         var stepDefines = workflow.WorkflowDefinition.FindStepDefines(stepCodes);
-        var currentStep = workflow.Steps.FirstOrDefault(d => d.Id == workflow.CurrentStepId);
+        var currentStep = workflow.Steps.FirstOrDefault(d => d.Id == workflow.ActualHandleStepId);
         if (currentStep is null)
             throw new UserFriendlyException("无效当前节点编号");
 

+ 2 - 2
src/Hotline.Application/Handlers/FlowEngine/WorkflowNextHandler.cs

@@ -67,8 +67,8 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
     /// <param name="cancellationToken">Cancellation token</param>
     public async Task Handle(NextStepNotify notification, CancellationToken cancellationToken)
     {
-        _logger.LogInformation(
-            $"收到{nameof(NextStepNotify)}, notification: {JsonConvert.SerializeObject(notification)}");
+        //_logger.LogInformation(
+        //    $"收到{nameof(NextStepNotify)}, notification: {JsonConvert.SerializeObject(notification)}");
         var workflow = notification.Workflow;
         var data = notification.Dto;
         var assignInfo = notification.FlowAssignInfo;

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

@@ -67,7 +67,7 @@ public class OrderMapperConfigs : IRegister
 
         config.ForType<OrderDelay, OrderDelayDto>()
             //.Inherits<Order, OrderDto>()
-            .Map(d=>d.CurrentStepName,s=>s.Workflow.CurrentStepName)
+            .Map(d=>d.CurrentStepName,s=>s.Workflow.ActualHandleStepName)
             .Map(d=>d.ActualHandlerName,s=>s.Workflow.ActualHandlerName)
             .IgnoreIf((s, d) => s.Workflow == null, d => d.CurrentStepName)
             .IgnoreIf((s, d) => s.Workflow == null, d => d.ActualHandlerName);

+ 3 - 3
src/Hotline.Repository.SqlSugar/Orders/OrderRepository.cs

@@ -103,16 +103,16 @@ namespace Hotline.Repository.SqlSugar.Orders
             foreach (var item in hotSpotList)
             {
                 var table = await Db.Queryable<Order>()
-                    .LeftJoin<SystemOrganize>((it, o) => it.CurrentHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
+                    .LeftJoin<SystemOrganize>((it, o) => it.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
                     .Where((it, o) => it.StartTime >= StartTime && it.StartTime <= EndTime)
                     .GroupBy((it, o) => new
                     {
-                        CurrentHandleOrgCode = (it.CurrentHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
+                        CurrentHandleOrgCode = (it.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
                         o.Name
                     })
                     .Select((it, o) => new
                     {
-                        OrgCode = it.CurrentHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
+                        OrgCode = it.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                         Count = SqlFunc.AggregateSum(SqlFunc.IIF(it.HotspotId.Substring(0, 2) == item.Id, 1, 0)),
                         Key = item.Id,
                         OrgName = o.Name,

+ 214 - 95
src/Hotline/FlowEngine/Workflows/Workflow.cs

@@ -137,6 +137,14 @@ public partial class Workflow : CreationEntity
     /// </summary>
     public string? ActualHandleOrgAreaName { get; set; }
 
+    /// <summary>
+    /// 实际办理对象(会签停留在顶级发起节点)
+    /// 办理时选择的办理对象,可能是部门也可能是用户
+    /// </summary>
+    public string? ActualHandlerValue { get; set; }
+    public string? ActualHandlerKey { get; set; }
+    public EHandlerType? ActualHandlerType { get; set; }
+
     /// <summary>
     /// 实际办理意见(办理中...or 最终办理意见)
     /// </summary>
@@ -182,65 +190,65 @@ public partial class Workflow : CreationEntity
 
     #region 当前办理节点信息
 
-    /// <summary>
-    /// 当前办理节点code(非会签:当前被指派节点,会签:会签发起节点)
-    /// </summary>
-    public string? CurrentStepCode { get; set; }
+    ///// <summary>
+    ///// 当前办理节点code(非会签:当前被指派节点,会签:会签发起节点)
+    ///// </summary>
+    //public string? CurrentStepCode { get; set; }
 
-    /// <summary>
-    /// 当前节点名称
-    /// </summary>
-    public string? CurrentStepName { get; set; }
+    ///// <summary>
+    ///// 当前节点名称
+    ///// </summary>
+    //public string? CurrentStepName { get; set; }
 
-    /// <summary>
-    /// 当前节点id
-    /// </summary>
-    public string? CurrentStepId { get; set; }
+    ///// <summary>
+    ///// 当前节点id
+    ///// </summary>
+    //public string? CurrentStepId { get; set; }
 
-    /// <summary>
-    /// 到达当前节点时间(stepBox创建时间)
-    /// </summary>
-    public DateTime? CurrentStepCreateTime { get; set; }
+    ///// <summary>
+    ///// 到达当前节点时间(stepBox创建时间)
+    ///// </summary>
+    //public DateTime? CurrentStepCreateTime { get; set; }
 
-    /// <summary>
-    /// 实际办理节点签收时间
-    /// </summary>
-    public DateTime? CurrentHandleStepAcceptTime { get; set; }
+    ///// <summary>
+    ///// 当前办理节点签收时间
+    ///// </summary>
+    //public DateTime? CurrentHandleStepAcceptTime { get; set; }
 
-    /// <summary>
-    /// 实际办理时间
-    /// </summary>
-    public DateTime? CurrentHandleTime { get; set; }
+    ///// <summary>
+    ///// 当前办理时间
+    ///// </summary>
+    //public DateTime? CurrentHandleTime { get; set; }
 
-    /// <summary>
-    /// 实际办理人id
-    /// </summary>
-    public string? CurrentHandlerId { get; set; }
+    ///// <summary>
+    ///// 当前办理人id
+    ///// </summary>
+    //public string? CurrentHandlerId { get; set; }
 
-    /// <summary>
-    /// 实际办理人名称
-    /// </summary>
-    public string? CurrentHandlerName { get; set; }
+    ///// <summary>
+    ///// 当前办理人名称
+    ///// </summary>
+    //public string? CurrentHandlerName { get; set; }
 
-    /// <summary>
-    /// 实际办理部门名称
-    /// </summary>
-    public string? CurrentHandleOrgName { get; set; }
+    ///// <summary>
+    ///// 当前办理部门名称
+    ///// </summary>
+    //public string? CurrentHandleOrgName { get; set; }
 
-    /// <summary>
-    /// 实际办理部门编码
-    /// </summary>
-    public string? CurrentHandleOrgCode { get; set; }
+    ///// <summary>
+    ///// 当前办理部门编码
+    ///// </summary>
+    //public string? CurrentHandleOrgCode { get; set; }
 
-    /// <summary>
-    /// 实际办理部门行政区划编码
-    /// </summary>
-    public string? CurrentHandleOrgAreaCode { get; set; }
+    ///// <summary>
+    ///// 当前办理部门行政区划编码
+    ///// </summary>
+    //public string? CurrentHandleOrgAreaCode { get; set; }
 
-    /// <summary>
-    /// 实际办理部门行政区划名称
-    /// </summary>
-    public string? CurrentHandleOrgAreaName { get; set; }
+    ///// <summary>
+    ///// 当前办理部门行政区划名称
+    ///// </summary>
+    //public string? CurrentHandleOrgAreaName { get; set; }
 
     #endregion
 
@@ -470,7 +478,7 @@ public partial class Workflow
         ActualHandleStepName = currentStep.Name;
         ActualHandleStepId = currentStep.Id;
         ActualHandleStepCreateTime = currentStep.CreationTime;
-        
+
         ActualHandleStepAcceptTime = currentStep.AcceptTime;
         ActualHandleTime = DateTime.Now;
         ActualHandlerId = actualHandlerId;
@@ -535,61 +543,172 @@ public partial class Workflow
     }
 
     /// <summary>
-    /// 更新当前办理节点信息
+    /// 指派、未办理时调用
     /// </summary>
-    public void UpdateWorkflowCurrentStepInfo(
-        bool isStartCountersign,
-        string? handlerId,
-        string? handlerName,
-        string? handleOrgCode,
-        string? handleOrgName,
-        string? handleOrgAreaCode,
-        string? handleOrgAreaName,
-        WorkflowStep? currentStep = null,
-        WorkflowStep? nextStep = null)
+    public void UpdateActualStepWhenAssign(WorkflowStep nextStep, Kv handler, EHandlerType handlerType)
     {
-        //非会签:指当前被指派节点,会签:会签发起节点
-        if (IsInCountersign) return;
-
-        if (isStartCountersign && currentStep is null)
-            throw new UserFriendlyException("开启会签时,会签发起节点不能为空");
-
-        if (!isStartCountersign && nextStep is null)
-            throw new UserFriendlyException("未开启会签时,被指派节点不能为空");
-
-        CurrentHandle(
-            isStartCountersign ? currentStep : nextStep,
-            handlerId,
-            handlerName,
-            handleOrgCode,
-            handleOrgName,
-            handleOrgAreaCode,
-            handleOrgAreaName
-        );
+        ResetActualStepInfo();
+        ActualHandleStepCode = nextStep.Code;
+        ActualHandleStepName = nextStep.Name;
+        ActualHandleStepId = nextStep.Id;
+        ActualHandleStepCreateTime = nextStep.CreationTime;
+        ActualHandlerKey = handler.Key;
+        ActualHandlerValue = handler.Value;
+        ActualHandlerType = handlerType;
     }
 
-    public void CurrentHandle(
+    /// <summary>
+    /// 办理时调用
+    /// </summary>
+    public void UpdateActualStepWhenHandle(
         WorkflowStep step,
-        string? handlerId,
+        string handlerId,
         string? handlerName,
-        string? handleOrgCode,
+        string handleOrgId,
         string? handleOrgName,
         string? handleOrgAreaCode,
-        string? handleOrgAreaName)
+        string? handleOrgAreaName,
+        int handlerOrgLevel)
+    {
+        ActualHandleStepCode = step.Code;
+        ActualHandleStepName = step.Name;
+        ActualHandleStepId = step.Id;
+        ActualHandleStepCreateTime = step.CreationTime;
+        ActualHandleStepAcceptTime = step.AcceptTime;
+        ActualHandleTime = step.HandleTime;
+        ActualHandlerId = handlerId;
+        ActualHandlerName = handlerName;
+        ActualHandleOrgCode = handleOrgId;
+        ActualHandleOrgName = handleOrgName;
+        ActualHandleOrgAreaCode = handleOrgAreaCode;
+        ActualHandleOrgAreaName = handleOrgAreaName;
+
+        //实际办理部门为一级部门时记录
+        if (handlerOrgLevel == 1)
+            UpdateLevelOneOrg(handleOrgId, handleOrgName);
+    }
+
+    ///// <summary>
+    ///// 更新当前办理节点信息
+    ///// </summary>
+    //public void UpdateWorkflowCurrentStepInfo1(
+    //    bool isStartCountersign,
+    //    string? handlerId,
+    //    string? handlerName,
+    //    string? handleOrgCode,
+    //    string? handleOrgName,
+    //    string? handleOrgAreaCode,
+    //    string? handleOrgAreaName,
+    //    WorkflowStep? currentStep = null,
+    //    WorkflowStep? nextStep = null)
+    //{
+    //    //非会签:指当前被指派节点,会签:会签发起节点
+    //    if (IsInCountersign) return;
+
+    //    if (isStartCountersign && currentStep is null)
+    //        throw new UserFriendlyException("开启会签时,会签发起节点不能为空");
+
+    //    if (!isStartCountersign && nextStep is null)
+    //        throw new UserFriendlyException("未开启会签时,被指派节点不能为空");
+
+    //    CurrentHandle(
+    //        isStartCountersign ? currentStep : nextStep,
+    //        handlerId,
+    //        handlerName,
+    //        handleOrgCode,
+    //        handleOrgName,
+    //        handleOrgAreaCode,
+    //        handleOrgAreaName
+    //    );
+    //}
+
+    //public void CurrentHandle(
+    //    WorkflowStep step,
+    //    string? handlerId,
+    //    string? handlerName,
+    //    string? handleOrgCode,
+    //    string? handleOrgName,
+    //    string? handleOrgAreaCode,
+    //    string? handleOrgAreaName)
+    //{
+    //    CurrentStepCode = step.Code;
+    //    CurrentStepName = step.Name;
+    //    CurrentStepId = step.Id;
+    //    CurrentStepCreateTime = step.CreationTime;
+
+    //    CurrentHandleStepAcceptTime = step.AcceptTime;
+    //    CurrentHandleTime = DateTime.Now;
+    //    CurrentHandlerId = handlerId;
+    //    CurrentHandlerName = handlerName;
+    //    CurrentHandleOrgCode = handleOrgCode;
+    //    CurrentHandleOrgName = handleOrgName;
+    //    CurrentHandleOrgAreaCode = handleOrgAreaCode;
+    //    CurrentHandleOrgAreaName = handleOrgAreaName;
+    //}
+
+    ///// <summary>
+    ///// 指派、未办理时调用
+    ///// </summary>
+    //public void UpdateWorkflowCurrentStepInfo(WorkflowStep nextStep, Kv handler, EHandlerType handlerType)
+    //{
+    //    ResetCurrentStepInfo();
+    //    CurrentStepCode = nextStep.Code;
+    //    CurrentStepName = nextStep.Name;
+    //    CurrentStepId = nextStep.Id;
+    //    CurrentStepCreateTime = nextStep.CreationTime;
+    //    CurrentHandlerKey = handler.Key;
+    //    CurrentHandlerValue = handler.Value;
+    //    CurrentHandlerType = handlerType;
+    //}
+
+    ///// <summary>
+    ///// 办理时调用
+    ///// </summary>
+    //public void UpdateWorkflowCurrentStepInfo(
+    //    WorkflowStep currentStep,
+    //    string handlerId,
+    //    string? handlerName,
+    //    string handleOrgId,
+    //    string? handleOrgName,
+    //    string? handleOrgAreaCode,
+    //    string? handleOrgAreaName)
+    //{
+    //    CurrentStepCode = currentStep.Code;
+    //    CurrentStepName = currentStep.Name;
+    //    CurrentStepId = currentStep.Id;
+    //    CurrentStepCreateTime = currentStep.CreationTime;
+    //    CurrentHandleStepAcceptTime = currentStep.AcceptTime;
+    //    CurrentHandleTime = currentStep.HandleTime;
+    //    CurrentHandlerId = handlerId;
+    //    CurrentHandlerName = handlerName;
+    //    CurrentHandleOrgCode = handleOrgId;
+    //    CurrentHandleOrgName = handleOrgName;
+    //    CurrentHandleOrgAreaCode = handleOrgAreaCode;
+    //    CurrentHandleOrgAreaName = handleOrgAreaName;
+    //}
+
+    //private void ResetCurrentStepInfo()
+    //{
+    //    CurrentHandleStepAcceptTime = null;
+    //    CurrentHandleTime = null;
+    //    CurrentHandlerId = null;
+    //    CurrentHandlerName = null;
+    //    CurrentHandleOrgCode = null;
+    //    CurrentHandleOrgName = null;
+    //    CurrentHandleOrgAreaCode = null;
+    //    CurrentHandleOrgAreaName = null;
+    //}
+
+    private void ResetActualStepInfo()
     {
-        CurrentStepCode = step.Code;
-        CurrentStepName = step.Name;
-        CurrentStepId = step.Id;
-        CurrentStepCreateTime = step.CreationTime;
-
-        CurrentHandleStepAcceptTime = step.AcceptTime;
-        CurrentHandleTime = DateTime.Now;
-        CurrentHandlerId = handlerId;
-        CurrentHandlerName = handlerName;
-        CurrentHandleOrgCode = handleOrgCode;
-        CurrentHandleOrgName = handleOrgName;
-        CurrentHandleOrgAreaCode = handleOrgAreaCode;
-        CurrentHandleOrgAreaName = handleOrgAreaName;
+        ActualHandleStepAcceptTime = null;
+        ActualHandleTime = null;
+        ActualHandlerId = null;
+        ActualHandlerName = null;
+        ActualHandleOrgCode = null;
+        ActualHandleOrgName = null;
+        ActualHandleOrgAreaCode = null;
+        ActualHandleOrgAreaName = null;
     }
 
     /// <summary>

+ 86 - 45
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -104,8 +104,19 @@ namespace Hotline.FlowEngine.Workflows
         {
             //1. 创建first节点 (和trace)2.办理开始节点 
 
+
             if (firstStepDefine.StepType is EStepType.End)
             {
+                //firstStep是否为end,t: 实际办理节点为startStep, 并且handlerId赋值 f: 实际办理节点为firstStep, handlerId未赋值
+                workflow.UpdateActualStepWhenHandle(startStep,
+                    _sessionContext.RequiredUserId, _sessionContext.UserName,
+                    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+                    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+                    _sessionContext.OrgLevel);
+                workflow.ActualHandlerKey = _sessionContext.RequiredUserId;
+                workflow.ActualHandlerValue = _sessionContext.UserName;
+                workflow.ActualHandlerType = EHandlerType.AssignedUser;
+
                 var endTrace = await EndAsync(workflow, dto, firstStepDefine, startStep, cancellationToken: cancellationToken);
                 return;
             }
@@ -119,6 +130,7 @@ namespace Hotline.FlowEngine.Workflows
             var counterSignType = GetCounterSignType(startStep.BusinessType);
             await HandleStepAsync(startStep, workflow, dto, flowAssignInfo.FlowAssignType, counterSignType,
                 cancellationToken);
+
             //赋值当前节点的下级办理节点
             if (dto.IsStartCountersign)
                 startStep.CreateCountersignSteps(firstSteps);
@@ -130,23 +142,30 @@ namespace Hotline.FlowEngine.Workflows
 
             //todo 计算办理工作时长
 
-            //更新当前办理节点信息
-            workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
-                _sessionContext.RequiredUserId, _sessionContext.UserName,
-                _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                startStep, firstSteps.First());
+            ////更新当前办理节点信息
+            //workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
+            //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+            //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+            //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+            //    startStep, firstSteps.First());
+
+            //指派实际办理节点
+            if (!workflow.IsInCountersign &&
+                firstStepDefine.StepType != EStepType.Summary &&
+                firstStepDefine.StepType != EStepType.End)
+                workflow.UpdateActualStepWhenAssign(firstSteps.First(), dto.NextHandlers.First(), dto.HandlerType);
+
 
             //发起会签时记录顶层会签节点(必须在update currentStep之后)
             if (dto.IsStartCountersign && !workflow.IsInCountersign)
                 workflow.StartCountersign(startStep.Id, counterSignType);
 
-            //更新实际办理节点信息
-            workflow.UpdateWorkflowActualHandleInfo(startStep,
-                _sessionContext.RequiredUserId, _sessionContext.UserName,
-                _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                _sessionContext.OrgLevel);
+            ////更新实际办理节点信息
+            //workflow.UpdateWorkflowActualHandleInfo(startStep,
+            //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+            //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+            //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+            //    _sessionContext.OrgLevel);
 
             //更新受理人信息
             workflow.UpdateAcceptor(
@@ -400,12 +419,21 @@ namespace Hotline.FlowEngine.Workflows
                     workflow.EndCountersign();
             }
 
-            //更新实际办理节点信息
-            workflow.UpdateWorkflowActualHandleInfo(currentStep,
-                _sessionContext.RequiredUserId, _sessionContext.UserName,
-                _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                _sessionContext.OrgLevel);
+            if (workflow.ActualHandleStepId == currentStep.Id)
+            {
+                workflow.UpdateActualStepWhenHandle(currentStep,
+                    _sessionContext.RequiredUserId, _sessionContext.UserName,
+                    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+                    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+                    _sessionContext.OrgLevel);
+            }
+
+            ////更新实际办理节点信息
+            //workflow.UpdateWorkflowActualHandleInfo(currentStep,
+            //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+            //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+            //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+            //    _sessionContext.OrgLevel);
 
             //检查是否流转到流程终点
             if (nextStepDefine.StepType is EStepType.End)
@@ -440,12 +468,22 @@ namespace Hotline.FlowEngine.Workflows
 
             //todo 计算办理工作时长
 
-            //更新当前办理节点信息
-            workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
-                _sessionContext.RequiredUserId, _sessionContext.UserName,
-                _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                currentStep, nextSteps?.FirstOrDefault());
+            ////更新当前办理节点信息
+            //if (!workflow.IsInCountersign)
+            //    workflow.UpdateWorkflowCurrentStepInfo(nextSteps.First(), dto.NextHandlers.First(), dto.HandlerType);
+
+            ////更新当前办理节点信息
+            //workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
+            //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+            //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+            //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+            //    currentStep, nextSteps?.FirstOrDefault());
+
+            //指派实际办理节点
+            if (!workflow.IsInCountersign &&
+                nextStepDefine.StepType != EStepType.Summary &&
+                nextStepDefine.StepType != EStepType.End)
+                workflow.UpdateActualStepWhenAssign(nextSteps.First(), dto.NextHandlers.First(), dto.HandlerType);
 
             //发起会签时记录顶层会签节点
             if (dto.IsStartCountersign && !workflow.IsInCountersign)
@@ -511,11 +549,12 @@ namespace Hotline.FlowEngine.Workflows
                 workflow.SetStatusRunnable();
 
             //更新当前办理节点信息
-            workflow.UpdateWorkflowCurrentStepInfo(false,
-                operater.Id, operater.Name,
-                operater.OrgId, operater.Organization.Name,
-                operater.Organization.AreaCode, operater.Organization.AreaName,
-                nextStep: newPrevStep);
+            //workflow.UpdateWorkflowCurrentStepInfo(false,
+            //    operater.Id, operater.Name,
+            //    operater.OrgId, operater.Organization.Name,
+            //    operater.Organization.AreaCode, operater.Organization.AreaName,
+            //    nextStep: newPrevStep);
+            workflow.UpdateActualStepWhenAssign(newPrevStep, prevStep.Handlers.First(), prevStep.HandlerType);
 
             //更新流程可办理对象
             workflow.UpdatePreviousHandlers(operater.Id, operater.OrgId, newPrevStep);
@@ -574,11 +613,12 @@ namespace Hotline.FlowEngine.Workflows
             var newStartStep = await DuplicateStepWithTraceAsync(workflow, startStep, EWorkflowTraceStatus.Recall, cancellationToken);
 
             //更新当前办理节点信息
-            workflow.UpdateWorkflowCurrentStepInfo(false,
-                _sessionContext.RequiredUserId, _sessionContext.UserName,
-                _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                nextStep: newStartStep);
+            //workflow.UpdateWorkflowCurrentStepInfo(false,
+            //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+            //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+            //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+            //    nextStep: newStartStep);
+            workflow.UpdateActualStepWhenAssign(startStep, startStep.Handlers.First(), startStep.HandlerType);
 
             var isOrgToCenter = CheckIfFlowFromOrgToCenter(workflow, startStep);
 
@@ -623,12 +663,12 @@ namespace Hotline.FlowEngine.Workflows
                 workflow.EndCountersign();
                 workflow.ResetOption();
 
-                //更新当前办理节点信息
-                workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
-                    _sessionContext.RequiredUserId, _sessionContext.UserName,
-                    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                    nextStep: targetStep);
+                ////更新当前办理节点信息
+                //workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
+                //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+                //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+                //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+                //    nextStep: targetStep);
 
                 //calc workflow expired time
                 isCenterToOrg = CheckIfFlowFromCenterToOrg(workflow, targetStep);
@@ -1508,11 +1548,12 @@ namespace Hotline.FlowEngine.Workflows
 
 
             //更新当前办理节点信息
-            workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
-                _sessionContext.RequiredUserId, _sessionContext.UserName,
-                _sessionContext.RequiredOrgId, _sessionContext.OrgName,
-                _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
-                nextStep: targetStepNew);
+            //workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign,
+            //    _sessionContext.RequiredUserId, _sessionContext.UserName,
+            //    _sessionContext.RequiredOrgId, _sessionContext.OrgName,
+            //    _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
+            //    nextStep: targetStepNew);
+            workflow.UpdateActualStepWhenAssign(targetStepNew, targetStep.Handlers.First(), targetStep.HandlerType);
 
             //calc workflow expired time
             var isOrgToCenter = CheckIfFlowFromOrgToCenter(workflow, targetStep);

+ 52 - 44
src/Hotline/Orders/Order.cs

@@ -411,6 +411,14 @@ namespace Hotline.Orders
         /// </summary>
         public string? ActualHandleOrgAreaName { get; set; }
 
+        /// <summary>
+        /// 实际办理对象(会签停留在顶级发起节点)
+        /// 办理时选择的办理对象,可能是部门也可能是用户
+        /// </summary>
+        public string? ActualHandlerValue { get; set; }
+        public string? ActualHandlerKey { get; set; }
+        public EHandlerType? ActualHandlerType { get; set; }
+
         /// <summary>
         /// 实际办理意见(办理中...or 最终办理意见)
         /// </summary>
@@ -456,60 +464,60 @@ namespace Hotline.Orders
 
         #region 当前办理节点信息
 
-        /// <summary>
-        /// 当前办理节点code(非会签:当前被指派节点,会签:会签发起节点)
-        /// </summary>
-        public string? CurrentStepCode { get; set; }
+        ///// <summary>
+        ///// 当前办理节点code(非会签:当前被指派节点,会签:会签发起节点)
+        ///// </summary>
+        //public string? CurrentStepCode { get; set; }
 
-        /// <summary>
-        /// 当前节点名称
-        /// </summary>
-        public string? CurrentStepName { get; set; }
+        ///// <summary>
+        ///// 当前节点名称
+        ///// </summary>
+        //public string? CurrentStepName { get; set; }
 
-        /// <summary>
-        /// 到达当前节点时间
-        /// </summary>
-        public DateTime? CurrentStepCreateTime { get; set; }
+        ///// <summary>
+        ///// 到达当前节点时间
+        ///// </summary>
+        //public DateTime? CurrentStepCreateTime { get; set; }
 
-        /// <summary>
-        /// 当前办理节点签收时间
-        /// </summary>
-        public DateTime? CurrentHandleStepAcceptTime { get; set; }
+        ///// <summary>
+        ///// 当前办理节点签收时间
+        ///// </summary>
+        //public DateTime? CurrentHandleStepAcceptTime { get; set; }
 
-        /// <summary>
-        /// 当前办理时间
-        /// </summary>
-        public DateTime? CurrentHandleTime { get; set; }
+        ///// <summary>
+        ///// 当前办理时间
+        ///// </summary>
+        //public DateTime? CurrentHandleTime { get; set; }
 
-        /// <summary>
-        /// 当前办理人id
-        /// </summary>
-        public string? CurrentHandlerId { get; set; }
+        ///// <summary>
+        ///// 当前办理人id
+        ///// </summary>
+        //public string? CurrentHandlerId { get; set; }
 
-        /// <summary>
-        /// 当前办理人名称
-        /// </summary>
-        public string? CurrentHandlerName { get; set; }
+        ///// <summary>
+        ///// 当前办理人名称
+        ///// </summary>
+        //public string? CurrentHandlerName { get; set; }
 
-        /// <summary>
-        /// 当前办理部门名称
-        /// </summary>
-        public string? CurrentHandleOrgName { get; set; }
+        ///// <summary>
+        ///// 当前办理部门名称
+        ///// </summary>
+        //public string? CurrentHandleOrgName { get; set; }
 
-        /// <summary>
-        /// 当前办理部门编码
-        /// </summary>
-        public string? CurrentHandleOrgCode { get; set; }
+        ///// <summary>
+        ///// 当前办理部门编码
+        ///// </summary>
+        //public string? CurrentHandleOrgCode { get; set; }
 
-        /// <summary>
-        /// 当前办理部门行政区划编码
-        /// </summary>
-        public string? CurrentHandleOrgAreaCode { get; set; }
+        ///// <summary>
+        ///// 当前办理部门行政区划编码
+        ///// </summary>
+        //public string? CurrentHandleOrgAreaCode { get; set; }
 
-        /// <summary>
-        /// 当前办理部门行政区划名称
-        /// </summary>
-        public string? CurrentHandleOrgAreaName { get; set; }
+        ///// <summary>
+        ///// 当前办理部门行政区划名称
+        ///// </summary>
+        //public string? CurrentHandleOrgAreaName { get; set; }
 
         #endregion