未办结关于驳回重走流程去重

main
陈伟 2026-02-11 16:53:27 +08:00
parent c02e0bb6fd
commit f27e45c0be
1 changed files with 22 additions and 9 deletions

View File

@ -588,26 +588,39 @@ public class WorkflowEngineApp : SqlSugarBaseApp<SysCategoryType, SugarDbContext
var pageIndex = pageQueryDto.page < 1 ? 1 : pageQueryDto.page;
var pageSize = pageQueryDto.limit < 1 ? 10 : pageQueryDto.limit;
var maxWorkitemSubQuery = _sqlSugar.Queryable<ZyFlowWorkitem>()
.GroupBy(w => w.InstanceId)
.GroupBy(w => w.HandlerId)
.Select(w => new
{
w.InstanceId,
MaxWorkitemId = SqlFunc.AggregateMax(w.WorkitemId)
});
// 未办结逻辑:
// 1. 当前用户参与过(处理过/待处理)
// 2. 流程状态不是"Completed"(未完成)
// Draft拟办、Submitted已提交、Forwarded已转发、Auditing审核中、Summarized已汇总、Completed已完成、Rejected已驳回
var doneInstanceIds = _sqlSugar
.Queryable<ZyFlowWorkitem>()
.LeftJoin<ZyFlowNode>((w, n) => w.NodeId == n.NodeId)
.LeftJoin<ZyFlowInstance>((w, n, i)
.InnerJoin(maxWorkitemSubQuery,
(w, sub)
=> w.InstanceId == sub.InstanceId
&& w.WorkitemId == sub.MaxWorkitemId)
// 原有多表关联逻辑(顺序
.LeftJoin<ZyFlowNode>((w, sub, n) => w.NodeId == n.NodeId)
.LeftJoin<ZyFlowInstance>((w, sub, n, i)
=> w.InstanceId == i.InstanceId)
.LeftJoin<IllegalConstructionAssessment>((w, n, i, t)
.LeftJoin<IllegalConstructionAssessment>((w, sub, n, i, t)
=> i.BusinessNo == t.BusinessNumber)
.WhereIF(!string.IsNullOrEmpty(pageQueryDto.key), (w, n, i, t)
.WhereIF(!string.IsNullOrEmpty(pageQueryDto.key), (w, sub, n, i, t)
=> t.BusinessNumber.Contains(pageQueryDto.key))
.Where((w, n, i, t)
.Where((w, sub, n, i, t)
=> w.Status == "Done" && i.Status != "Completed")
.Where((w, n, i, t)
.Where((w, sub, n, i, t)
=> w.HandlerId == userId)
.OrderByDescending((w, n, i, t) =>
t.CreateTime)
.Select((w, n, i, t)
.OrderByDescending((w, sub, n, i, t)
=> t.CreateTime)
.Select((w, sub, n, i, t)
=> new FlowQuerySingleResultDto
{
workitemId = w.WorkitemId,