|
|
@@ -185,36 +185,45 @@ public class S8TaskFlowService : ITransient
|
|
|
|
|
|
// 双线合一:开始处理 = TB001 异常提报审批通过。
|
|
|
// 当前用户必须是 TB001 task 的 AssigneeId,FlowEngine 强校验。
|
|
|
- await TryApproveIntakeOnStartProgressAsync(e.Id, currentUserId);
|
|
|
+ await TryApproveIntakeOnStartProgressAsync(e, currentUserId);
|
|
|
|
|
|
return e;
|
|
|
}
|
|
|
|
|
|
- private async Task TryApproveIntakeOnStartProgressAsync(long exceptionId, long currentUserId)
|
|
|
+ private async Task TryApproveIntakeOnStartProgressAsync(AdoS8Exception e, long currentUserId)
|
|
|
{
|
|
|
+ long? instanceId = null, taskId = null;
|
|
|
try
|
|
|
{
|
|
|
+ // S8-S1-EXCEPTION-FLOW-SYNC-FIX-1:实例/任务查询同样清数据范围过滤(ApprovalFlowInstance/Task 继承 EntityBaseOrg)。
|
|
|
+ // 非超管用户在 DataScope=Self 时被「CreateUserId==当前用户」过滤、Dept/DeptChild 时被 OrgId 过滤,会查不到
|
|
|
+ // 由他人(或系统)创建的 flow,双线合一静默失效。ClearFilter() 清全部数据范围过滤;BizType+BizId+assignee 已限定,
|
|
|
+ // 无跨 BizType 误伤;ApprovalFlowInstance/Task 无软删与租户过滤。
|
|
|
var instance = await _flowInstanceRep.AsQueryable()
|
|
|
+ .ClearFilter()
|
|
|
.Where(x => x.BizType == "EXCEPTION_REPORT"
|
|
|
- && x.BizId == exceptionId
|
|
|
+ && x.BizId == e.Id
|
|
|
&& x.Status == FlowInstanceStatusEnum.Running)
|
|
|
.FirstAsync();
|
|
|
if (instance == null) return;
|
|
|
+ instanceId = instance.Id;
|
|
|
|
|
|
var task = await _flowTaskRep.AsQueryable()
|
|
|
+ .ClearFilter()
|
|
|
.Where(x => x.InstanceId == instance.Id
|
|
|
&& x.AssigneeId == currentUserId
|
|
|
&& x.Status == FlowTaskStatusEnum.Pending)
|
|
|
.FirstAsync();
|
|
|
if (task == null) return;
|
|
|
+ taskId = task.Id;
|
|
|
|
|
|
await _flowEngine.Approve(task.Id, "S8 已开始处理(双线合一自动同意)");
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogWarning(ex,
|
|
|
- "S8 开始处理时自动同意 TB001 任务失败 exceptionId={Id} userId={UserId}",
|
|
|
- exceptionId, currentUserId);
|
|
|
+ "S8 开始处理时自动同意 TB001 任务失败 exceptionId={Id} exceptionCode={Code} userId={UserId} assigneeId={Assignee} status={Status} instanceId={InstanceId} taskId={TaskId} err={Err}",
|
|
|
+ e.Id, e.ExceptionCode, currentUserId, e.AssigneeId, e.Status, instanceId, taskId, ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -263,37 +272,46 @@ public class S8TaskFlowService : ITransient
|
|
|
}, ex => throw ex);
|
|
|
|
|
|
// 双线合一:S8 驳回 = TB001 流程整体拒绝(取消所有 pending 任务、Instance 终止)。
|
|
|
- await TryRejectIntakeOnRejectAsync(e.Id, remark);
|
|
|
+ await TryRejectIntakeOnRejectAsync(e, remark);
|
|
|
|
|
|
return e;
|
|
|
}
|
|
|
|
|
|
- private async Task TryRejectIntakeOnRejectAsync(long exceptionId, string? remark)
|
|
|
+ private async Task TryRejectIntakeOnRejectAsync(AdoS8Exception e, string? remark)
|
|
|
{
|
|
|
+ var currentUserId = _userManager.UserId;
|
|
|
+ long? instanceId = null, taskId = null;
|
|
|
try
|
|
|
{
|
|
|
+ // S8-S1-EXCEPTION-FLOW-SYNC-FIX-1:实例/任务查询同样清数据范围过滤(ApprovalFlowInstance/Task 继承 EntityBaseOrg)。
|
|
|
+ // 非超管用户在 DataScope=Self 时被「CreateUserId==当前用户」过滤、Dept/DeptChild 时被 OrgId 过滤,会查不到
|
|
|
+ // 由他人(或系统)创建的 flow,双线合一静默失效。ClearFilter() 清全部数据范围过滤;BizType+BizId+assignee 已限定,
|
|
|
+ // 无跨 BizType 误伤;ApprovalFlowInstance/Task 无软删与租户过滤。
|
|
|
var instance = await _flowInstanceRep.AsQueryable()
|
|
|
+ .ClearFilter()
|
|
|
.Where(x => x.BizType == "EXCEPTION_REPORT"
|
|
|
- && x.BizId == exceptionId
|
|
|
+ && x.BizId == e.Id
|
|
|
&& x.Status == FlowInstanceStatusEnum.Running)
|
|
|
.FirstAsync();
|
|
|
if (instance == null) return;
|
|
|
+ instanceId = instance.Id;
|
|
|
|
|
|
- var currentUserId = _userManager.UserId;
|
|
|
var task = await _flowTaskRep.AsQueryable()
|
|
|
+ .ClearFilter()
|
|
|
.Where(x => x.InstanceId == instance.Id
|
|
|
&& x.AssigneeId == currentUserId
|
|
|
&& x.Status == FlowTaskStatusEnum.Pending)
|
|
|
.FirstAsync();
|
|
|
if (task == null) return;
|
|
|
+ taskId = task.Id;
|
|
|
|
|
|
await _flowEngine.Reject(task.Id, remark ?? "S8 已驳回(双线合一自动拒绝)");
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogWarning(ex,
|
|
|
- "S8 驳回时自动拒绝 TB001 流程失败 exceptionId={Id}",
|
|
|
- exceptionId);
|
|
|
+ "S8 驳回时自动拒绝 TB001 流程失败 exceptionId={Id} exceptionCode={Code} userId={UserId} assigneeId={Assignee} status={Status} instanceId={InstanceId} taskId={TaskId} err={Err}",
|
|
|
+ e.Id, e.ExceptionCode, currentUserId, e.AssigneeId, e.Status, instanceId, taskId, ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|