Browse Source

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

Dun.Jason 9 months ago
parent
commit
05bb21f549

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

@@ -5837,7 +5837,10 @@ public class OrderController : BaseController
     [HttpPost("change-handler")]
     public async Task ChangeHandler([FromBody] ChangeHandlerDto dto)
     {
-        if (string.IsNullOrEmpty(dto.StepId))
+        var special = await _orderSpecialRepository.Queryable().Where(x => x.OrderId == dto.OrderId && x.State == 0).AnyAsync();
+        if (special)
+	        throw  UserFriendlyException.SameMessage("当前工单特提审批中,请审批后再操作!");
+		if (string.IsNullOrEmpty(dto.StepId))
         {
             await _orderRepository.Updateable().SetColumns(o => new Orders.Order() { SignerId = dto.Handler.UserId, SignerName = dto.Handler.Username })
                 .Where(o => o.Id == dto.OrderId).ExecuteCommandAsync(HttpContext.RequestAborted);

+ 31 - 20
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -147,22 +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 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
-            }, 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);
@@ -738,6 +741,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                 var summaryTargetStep = workflow.Steps.FirstOrDefault(d =>
                     d.StepType == EStepType.Normal &&
                     d.Code == stepDefine.SummaryTargetCode &&
+                    d.Status == EWorkflowStepStatus.Handled &&
                     d.IsOrigin);
                 if (summaryTargetStep is null)
                     throw UserFriendlyException.SameMessage("未查询到汇总对象节点");
@@ -750,7 +754,11 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     Key = summaryTargetStep.HandlerId,
                     Value = summaryTargetStep.HandlerName,
                     UserId = summaryTargetStep.HandlerId,
-                    Username = summaryTargetStep.HandlerName
+                    Username = summaryTargetStep.HandlerName,
+                    OrgId = summaryTargetStep.HandlerOrgId,
+                    OrgName = summaryTargetStep.HandlerOrgName,
+                    RoleId = summaryTargetStep.RoleId,
+                    RoleName = summaryTargetStep.RoleName
                 };
 
                 nextStepOption = new NextStepOption
@@ -845,8 +853,9 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                 if (flowType is EFlowType.Handle
                     && (stepDefine.StepType != EStepType.Summary && stepDefine.BusinessType != EBusinessType.Center))
                     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,
@@ -854,8 +863,10 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                         UserId = d.Id,
                         Username = d.Name,
                         OrgId = d.OrgId,
-                        OrgName = d.Organization.Name
-                    })
+                        OrgName = d.Organization.Name,
+                        RoleId = defineTypeItem.Key,
+                        RoleName = defineTypeItem.Value
+					})
                     .ToList();
                 break;
             case EHandlerType.OrgLevel:

+ 5 - 2
src/Hotline.Application/Orders/OrderApplication.cs

@@ -204,7 +204,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
 		//stTime = _timeLimitDomainService.WorkDay(stTime);
 		//DateTime stTime2 = _timeLimitDomainService.WorkDay(DateTime.Now);
 		DateTime? dateTime = DateTime.Now;
-		return _orderRepository.Queryable(canView: true).Includes(d => d.OrderDelays)
+		var IsCenter = _sessionContext.OrgIsCenter;
+
+		return _orderRepository.Queryable(canView: !IsCenter).Includes(d => d.OrderDelays)
             .WhereIF(dto.IsProvince.HasValue, d => d.IsProvince == dto.IsProvince)
             .WhereIF(!string.IsNullOrEmpty(dto.No), d => d.No.Contains(dto.No!))
             .WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Title.Contains(dto.Title!))
@@ -253,8 +255,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     public ISugarQueryable<Order> GetToExpireAsync(AboutToExpireListDto dto)
     {
         DateTime stTime = _timeLimitDomainService.WorkDay(DateTime.Now);
+        var IsCenter = _sessionContext.OrgIsCenter;
 
-        return _orderRepository.Queryable(canView: true).Includes(d => d.OrderDelays)
+		return _orderRepository.Queryable(canView: !IsCenter).Includes(d => d.OrderDelays)
             .WhereIF(dto.IsProvince.HasValue, d => d.IsProvince == dto.IsProvince)
             //.WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Title.Contains(dto.Keyword!) || d.No.Contains(dto.Keyword!))
             .WhereIF(!string.IsNullOrEmpty(dto.No), x => x.No.Contains(dto.No))

+ 62 - 62
src/Hotline.Application/StatisticalReport/OrderReportApplication.cs

@@ -156,8 +156,8 @@ FROM (
 		select  ""HandlerOrgId"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""YbOrderCountNum"",0 ""ZbOrderCountNum"",0 ""YbOverdue"",0 ""ZbOverdue"",0 ""HqybOverdue"",0 ""HqzbOverdue"",0 ""DelayEnd"",0 ""DelayWait"",0""Archived"" ,0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"" ,0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"",0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2   {2} --and ""t"".""CountersignPosition""<=1 
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10  and ""t"".""Status"">=2   {2} --and ""t"".""CountersignPosition""<=1 
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -166,7 +166,7 @@ FROM (
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2  {2} --and ""t"".""CountersignPosition""<=1 
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -174,8 +174,8 @@ FROM (
 		select  ""HandlerOrgId"",0 ""YbOrderCountNum"",0 ""ZbOrderCountNum"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""YbOverdue"" ,0 ""ZbOverdue"",0 ""HqybOverdue"",0 ""HqzbOverdue"",0 ""DelayEnd"",0 ""DelayWait"",0""Archived"",0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"",0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"" ,0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""t"".""CountersignPosition""=0   {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""t"".""CountersignPosition""=0   {2}
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -184,7 +184,7 @@ FROM (
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2 and (SELECT NOW())>""StepExpiredTime"" and ""t"".""CountersignPosition""=0   {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -192,8 +192,8 @@ FROM (
 		select  ""HandlerOrgId"",0 ""YbOrderCountNum"",0 ""ZbOrderCountNum"",0 ""YbOverdue"" ,0 ""ZbOverdue"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""HqybOverdue"",0 ""HqzbOverdue"",0 ""DelayEnd"",0 ""DelayWait"",0""Archived"",0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"",0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"" ,0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""CountersignPosition"">0  {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""CountersignPosition"">0  {2}
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -203,7 +203,7 @@ FROM (
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2 and (SELECT NOW())>""StepExpiredTime"" 
 			and   ""CountersignPosition"">0  {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -211,8 +211,8 @@ FROM (
 		select  ""HandlerOrgId"",0 ""YbOrderCountNum"",0 ""ZbOrderCountNum"",0 ""YbOverdue"" ,0 ""ZbOverdue"",0 ""HqybOverdue"",0 ""HqzbOverdue"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""DelayEnd"",0 ""DelayWait"" ,0""Archived"",0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"",0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"" ,0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2 and ""CountersignPosition"">0 {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2 and ""CountersignPosition"">0 {2}
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -221,7 +221,7 @@ FROM (
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2 and ""CountersignPosition"">0 {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL  {4}
 		GROUP BY ""HandlerOrgId""
 		UNION ALL
@@ -354,8 +354,8 @@ FROM (
 		select  ""HandlerOrgId"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""YbOrderCountNum"",0 ""ZbOrderCountNum"",0 ""YbOverdue"",0 ""ZbOverdue"",0 ""HqybOverdue"",0 ""HqzbOverdue"",0 ""DelayEnd"",0 ""DelayWait"",0""Archived"" ,0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"" ,0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"",0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2   {2} --and ""t"".""CountersignPosition""<=1 
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2   {2} --and ""t"".""CountersignPosition""<=1 
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -364,7 +364,7 @@ FROM (
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2  {2} --and ""t"".""CountersignPosition""<=1 
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -372,8 +372,8 @@ FROM (
 		select  ""HandlerOrgId"",0 ""YbOrderCountNum"",0 ""ZbOrderCountNum"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""YbOverdue"" ,0 ""ZbOverdue"",0 ""HqybOverdue"",0 ""HqzbOverdue"",0 ""DelayEnd"",0 ""DelayWait"",0""Archived"",0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"",0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"" ,0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""t"".""CountersignPosition""=0   {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""t"".""CountersignPosition""=0   {2}
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -382,7 +382,7 @@ FROM (
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2 and (SELECT NOW())>""StepExpiredTime"" and ""t"".""CountersignPosition""=0   {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -390,8 +390,8 @@ FROM (
 		select  ""HandlerOrgId"",0 ""YbOrderCountNum"",0 ""ZbOrderCountNum"",0 ""YbOverdue"" ,0 ""ZbOverdue"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""HqybOverdue"",0 ""HqzbOverdue"",0 ""DelayEnd"",0 ""DelayWait"",0""Archived"",0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"",0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"" ,0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""CountersignPosition"">0  {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2 and ""HandleTime"">""StepExpiredTime"" and ""CountersignPosition"">0  {2}
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -401,7 +401,7 @@ FROM (
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2 and (SELECT NOW())>""StepExpiredTime"" 
 			and   ""CountersignPosition"">0  {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -409,8 +409,8 @@ FROM (
 		select  ""HandlerOrgId"",0 ""YbOrderCountNum"",0 ""ZbOrderCountNum"",0 ""YbOverdue"" ,0 ""ZbOverdue"",0 ""HqybOverdue"",0 ""HqzbOverdue"",SUM(( CASE  WHEN ( ""HandlerOrgId"" IS NOT NULL ) THEN 1  ELSE 0 END )) AS ""DelayEnd"",0 ""DelayWait"" ,0""Archived"",0 ""ToBeArchived"",0 ""WaitPublished"",0 ""PublishedOpen"",0 ""PublishedNoOpen"",0 ""OrderDelayCount"",0 ""ScreenCount"",0 ""ScreenApproval"", 0 ""ScreenPass"" , 0 ""ScreenNotPass"" ,0 ""SatisfactionCount"", 0 ""NotSatisfactionCount"" from(
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
-			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status"">=2 and ""CountersignPosition"">0 {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""TraceState"" !=10 and ""t"".""Status"">=2 and ""CountersignPosition"">0 {2}
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL {4}
 		GROUP BY ""HandlerOrgId""
 		union ALL
@@ -419,7 +419,7 @@ FROM (
 		 select ""o"".""Id"",SUBSTRING(""t"".""HandlerOrgId"",1,{3}) ""HandlerOrgId"" from ""workflow_trace"" ""t""
 			left join ""order"" ""o"" on ""o"".""Id""=""t"".""ExternalId""
 			where ""o"".""CreationTime"">='{0}' and ""o"".""CreationTime""<='{1}'  and ""t"".""ModuleCode""='OrderHandle' and ""t"".""Status""<2 and ""CountersignPosition"">0 {2}
-			GROUP BY ""HandlerOrgId"",""o"".""Id""
+			GROUP BY SUBSTRING(""t"".""HandlerOrgId"",1,{3}),""o"".""Id""
 		)""s"" where ""HandlerOrgId"" IS not NULL  {4}
 		GROUP BY ""HandlerOrgId""
 		UNION ALL
@@ -504,7 +504,7 @@ order by ""su"".""OrgCode""";
                     query = _workflowTraceRepository.Queryable()
                         .LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
                          .Where((t, o) => t.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime
-                         && t.Status >= EWorkflowStepStatus.Handled)
+                         && t.Status >= EWorkflowStepStatus.Handled && t.TraceState != EWorkflowTraceState.StepRemoveByPrevious)
                          .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
                          .WhereIF(dto.OrgCode == "001", (t, o) => t.HandlerOrgId == dto.OrgCode)
                          .WhereIF(dto.OrgCode != "001", (t, o) => t.HandlerOrgId.StartsWith(dto.OrgCode))
@@ -526,20 +526,20 @@ order by ""su"".""OrgCode""";
                     break;
                 case EStatisticsType.OrderDelayCount://延期次数
                     query = _orderDelayRepository.Queryable()
-                        .Includes(x => x.Order)
-                        .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime && x.DelayState == EDelayState.Pass)
-                        .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
-                        .WhereIF(dto.OrgCode == "001", x => x.ApplyOrgCode == dto.OrgCode)
-                        .WhereIF(dto.OrgCode != "001", x => x.ApplyOrgCode.StartsWith(dto.OrgCode))
-                        .OrderByDescending(x => x.Order.CreationTime)
-                        .Select(x => new SelectOrderId { Id = x.Order.Id })
+                          .LeftJoin<Order>((d, o) => d.OrderId == o.Id)
+                        .Where((d, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && d.DelayState == EDelayState.Pass)
+                        .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (d, o) => o.Source == ESource.ProvinceStraight)
+                        .WhereIF(dto.OrgCode == "001", (d, o) => d.ApplyOrgCode == dto.OrgCode)
+                        .WhereIF(dto.OrgCode != "001", (d, o) => d.ApplyOrgCode.StartsWith(dto.OrgCode))
+                        .OrderByDescending((d, o) => o.CreationTime)
+                        .Select((d, o) => new SelectOrderId { Id = o.Id })
                        .MergeTable();
                     break;
                 case EStatisticsType.YBOverdue://已办超期
                     query = _workflowTraceRepository.Queryable()
                         .LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
                          .Where((t, o) => t.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime
-                         && t.Status >= EWorkflowStepStatus.Handled && t.HandleTime > t.StepExpiredTime && t.CountersignPosition == ECountersignPosition.None)
+                         && t.Status >= EWorkflowStepStatus.Handled && t.HandleTime > t.StepExpiredTime && t.CountersignPosition == ECountersignPosition.None && t.TraceState != EWorkflowTraceState.StepRemoveByPrevious)
                          .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
                          .WhereIF(dto.OrgCode == "001", (t, o) => t.HandlerOrgId == dto.OrgCode)
                          .WhereIF(dto.OrgCode != "001", (t, o) => t.HandlerOrgId.StartsWith(dto.OrgCode))
@@ -563,7 +563,7 @@ order by ""su"".""OrgCode""";
                     query = _workflowTraceRepository.Queryable()
                         .LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
                          .Where((t, o) => t.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime
-                         && t.Status >= EWorkflowStepStatus.Handled && t.HandleTime > t.StepExpiredTime && t.CountersignPosition > ECountersignPosition.None)
+                         && t.Status >= EWorkflowStepStatus.Handled && t.HandleTime > t.StepExpiredTime && t.CountersignPosition > ECountersignPosition.None && t.TraceState != EWorkflowTraceState.StepRemoveByPrevious)
                          .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
                          .WhereIF(dto.OrgCode == "001", (t, o) => t.HandlerOrgId == dto.OrgCode)
                          .WhereIF(dto.OrgCode != "001", (t, o) => t.HandlerOrgId.StartsWith(dto.OrgCode))
@@ -587,7 +587,7 @@ order by ""su"".""OrgCode""";
                     var cqybquery = _workflowTraceRepository.Queryable()
                            .LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
                             .Where((t, o) => t.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime
-                            && t.Status >= EWorkflowStepStatus.Handled && t.HandleTime > t.StepExpiredTime && t.CountersignPosition >= ECountersignPosition.None)
+                            && t.Status >= EWorkflowStepStatus.Handled && t.HandleTime > t.StepExpiredTime && t.CountersignPosition >= ECountersignPosition.None && t.TraceState != EWorkflowTraceState.StepRemoveByPrevious)
                             .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
                             .WhereIF(dto.OrgCode == "001", (t, o) => t.HandlerOrgId == dto.OrgCode)
                             .WhereIF(dto.OrgCode != "001", (t, o) => t.HandlerOrgId.StartsWith(dto.OrgCode))
@@ -610,7 +610,7 @@ order by ""su"".""OrgCode""";
                     query = _workflowTraceRepository.Queryable()
                            .LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
                             .Where((t, o) => t.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime
-                            && t.Status >= EWorkflowStepStatus.Handled && t.CountersignPosition > ECountersignPosition.None)
+                            && t.Status >= EWorkflowStepStatus.Handled && t.CountersignPosition > ECountersignPosition.None && t.TraceState != EWorkflowTraceState.StepRemoveByPrevious)
                             .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
                             .WhereIF(dto.OrgCode == "001", (t, o) => t.HandlerOrgId == dto.OrgCode)
                             .WhereIF(dto.OrgCode != "001", (t, o) => t.HandlerOrgId.StartsWith(dto.OrgCode))
@@ -677,44 +677,44 @@ order by ""su"".""OrgCode""";
                     break;
                 case EStatisticsType.ScreenCount://甄别总量
                     query = _orderScreenRepository.Queryable()
-                        .Includes(x => x.Order)
-                       .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime && x.Order.Id != null)
-                       .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
-                       .WhereIF(dto.OrgCode == "001", x => x.CreatorOrgId == dto.OrgCode)
-                       .WhereIF(dto.OrgCode != "001", x => x.CreatorOrgId.StartsWith(dto.OrgCode))
-                        .Select(x => new SelectOrderId { Id = x.Order.Id })
+                        .LeftJoin<Order>((d, o) => d.OrderId == o.Id)
+                       .Where((d, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null)
+                       .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (d, o) => o.Source == ESource.ProvinceStraight)
+                       .WhereIF(dto.OrgCode == "001", (d, o) => d.CreatorOrgId == dto.OrgCode)
+                       .WhereIF(dto.OrgCode != "001", (d, o) => d.CreatorOrgId.StartsWith(dto.OrgCode))
+                        .Select((d, o) => new SelectOrderId { Id = o.Id })
                        .MergeTable();
                     break;
                 case EStatisticsType.ScreenApproval://带甄别
                     query = _orderScreenRepository.Queryable()
-                        .Includes(x => x.Order)
-                       .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime && x.Order.Id != null
-                       && (x.Status == EScreenStatus.Approval || x.Status == EScreenStatus.Apply))
-                       .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
-                       .WhereIF(dto.OrgCode == "001", x => x.CreatorOrgId == dto.OrgCode)
-                       .WhereIF(dto.OrgCode != "001", x => x.CreatorOrgId.StartsWith(dto.OrgCode))
-                        .Select(x => new SelectOrderId { Id = x.Order.Id })
+                       .LeftJoin<Order>((d, o) => d.OrderId == o.Id)
+                       .Where((d, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null
+                       && (d.Status == EScreenStatus.Approval || d.Status == EScreenStatus.Apply))
+                       .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (d, o) => o.Source == ESource.ProvinceStraight)
+                       .WhereIF(dto.OrgCode == "001", (d, o) => d.CreatorOrgId == dto.OrgCode)
+                       .WhereIF(dto.OrgCode != "001", (d, o) => d.CreatorOrgId.StartsWith(dto.OrgCode))
+                        .Select((d, o) => new SelectOrderId { Id = o.Id })
                        .MergeTable();
                     break;
                 case EStatisticsType.ScreenPass://甄别通过
                     query = _orderScreenRepository.Queryable()
-                        .Includes(x => x.Order)
-                       .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime && x.Order.Id != null && x.Status == EScreenStatus.End)
-                       .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
-                       .WhereIF(dto.OrgCode == "001", x => x.CreatorOrgId == dto.OrgCode)
-                       .WhereIF(dto.OrgCode != "001", x => x.CreatorOrgId.StartsWith(dto.OrgCode))
-                        .Select(x => new SelectOrderId { Id = x.Order.Id })
+                       .LeftJoin<Order>((d, o) => d.OrderId == o.Id)
+                       .Where((d, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null && d.Status == EScreenStatus.End)
+                       .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (d, o) => o.Source == ESource.ProvinceStraight)
+                       .WhereIF(dto.OrgCode == "001", (d, o) => d.CreatorOrgId == dto.OrgCode)
+                       .WhereIF(dto.OrgCode != "001", (d, o) => d.CreatorOrgId.StartsWith(dto.OrgCode))
+                        .Select((d, o) => new SelectOrderId { Id = o.Id })
                        .MergeTable();
                     break;
                 case EStatisticsType.ScreenNotPass://甄别不通过
                     query = _orderScreenRepository.Queryable()
-                       .Includes(x => x.Order)
-                      .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime && x.Order.Id != null && x.Status == EScreenStatus.Refuse)
-                      .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
-                      .WhereIF(dto.OrgCode == "001", x => x.CreatorOrgId == dto.OrgCode)
-                      .WhereIF(dto.OrgCode != "001", x => x.CreatorOrgId.StartsWith(dto.OrgCode))
-                       .Select(x => new SelectOrderId { Id = x.Order.Id })
-                      .MergeTable();
+                      .LeftJoin<Order>((d, o) => d.OrderId == o.Id)
+                      .Where((d, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null && d.Status == EScreenStatus.Refuse)
+                      .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (d, o) => o.Source == ESource.ProvinceStraight)
+                      .WhereIF(dto.OrgCode == "001", (d, o) => d.CreatorOrgId == dto.OrgCode)
+                       .WhereIF(dto.OrgCode != "001", (d, o) => d.CreatorOrgId.StartsWith(dto.OrgCode))
+                        .Select((d, o) => new SelectOrderId { Id = o.Id })
+                       .MergeTable();
                     break;
                 default:
                     break;

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

@@ -490,8 +490,10 @@ public abstract class StepBasicEntity : CreationEntity
                     UserId = HandlerId,
                     Username = HandlerName,
                     OrgId = HandlerOrgId,
-                    OrgName = HandlerOrgName
-                };
+                    OrgName = HandlerOrgName,
+                    RoleId = RoleId,
+                    RoleName = RoleName
+				};
             case EFlowAssignType.Role:
                 return new FlowStepHandler
                 {

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

@@ -329,8 +329,8 @@ namespace Hotline.FlowEngine.Workflows
             StepDefine nextStepDefine, bool isNextDynamic, FlowAssignInfo flowAssignInfo,
             DateTime? expiredTime, ISessionContext current, CancellationToken cancellationToken)
         {
-            ValidatePermission(workflow, current.RequiredOrgId, current.RequiredUserId, current.Roles);
-            //CheckWhetherRunnable(workflow.Status);
+            //ValidatePermission(workflow, current.RequiredOrgId, current.RequiredUserId, current.Roles);
+            CheckWhetherRunnable(workflow.Status);
 
             #region 办理当前节点
 
@@ -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
-                if (!step.HandlerOrgIsCenter!.Value) 
-                    newStep.FlowAssignType = EFlowAssignType.Org;
-                newStep.Assign(step.HandlerId, step.HandlerName, step.HandlerOrgId, step.HandlerOrgName);
+                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);
             }
 
             await _workflowStepRepository.AddAsync(newStep, cancellationToken);