public virtual ReturnInfo <PagingInfo <WorkflowInfo> > QueryCurrUserWaitHandlePage(int pageIndex, int pageSize, WaitHandleFilterInfo filter, string connectionId = null) { if (filter == null) { filter = new WaitHandleFilterInfo(); } filter.HandlerId = UserTool.CurrUser.Id; filter.EndCreateTime = filter.EndCreateTime.AddThisDayLastTime(); return(ExecReturnFuncAndConnectionId <PagingInfo <WorkflowInfo> >((reInfo, connId) => { return Persistence.SelectWaitHandlePage(pageIndex, pageSize, filter, connId); }, null, connectionId, AccessMode.SLAVE)); }
/// <summary> /// 查询待办的工作流列表并分页 /// </summary> /// <param name="pageIndex">页码</param> /// <param name="pageSize">每页记录数</param> /// <param name="filter">筛选</param> /// <param name="connectionId">连接ID</param> /// <returns>分页信息</returns> public PagingInfo <WorkflowInfo> SelectWaitHandlePage(int pageIndex, int pageSize, WaitHandleFilterInfo filter, string connectionId = null) { PagingInfo <WorkflowInfo> result = null; DynamicParameters parameters; StringBuilder whereSql = MergeWhereSql(filter, out parameters); whereSql.Append(" AND wh.handler_id=@HandlerId AND flow_status!=@NotFlowStatus AND ((wh.handle_status=@HandleStatus && handle_type=@HandleType1) || (is_readed=@IsReaded && handle_type=@HandleType2))"); parameters.Add("HandlerId", filter.HandlerId); parameters.Add("NotFlowStatus", (byte)FlowStatusEnum.DRAFT); parameters.Add("HandleStatus", (byte)HandleStatusEnum.UN_HANDLE); parameters.Add("HandleType1", (byte)HandleTypeEnum.AUDIT); parameters.Add("HandleType2", (byte)HandleTypeEnum.NOTIFY); parameters.Add("IsReaded", false); if (filter.HandleType != null) { whereSql.Append(" AND wh.handle_type=@HandleType"); parameters.Add("HandleType", filter.HandleType); } if (filter.IsReaded != null) { whereSql.Append(" AND wh.is_readed=@IsReaded"); parameters.Add("IsReaded", filter.IsReaded); } string sortSql = GetSelectPageSortSql(filter, GetSelectSortNamePfx(filter)); if (string.IsNullOrWhiteSpace(sortSql)) { sortSql = $" ORDER BY wh.is_readed,wh.create_time DESC"; } string formatSql = $"SELECT {{0}} FROM {Table}" + $" INNER JOIN workflow_handle wh ON {Table}.`id`=wh.`workflow_id`" + whereSql.ToString(); string countSql = string.Format(formatSql, "COUNT(*)"); string pageSql = string.Format(formatSql, $"{JoinSelectPropMapFields(pfx: Table + ".")},wh.`id`,wh.`is_readed` IsReaded,wh.`handle_type` HandleType,wh.`handle_status` HandleStatus") + " " + sortSql + " " + GetPartPageSql(pageIndex, pageSize); var source = this.GetType().Name; DbConnectionManager.BrainpowerExecute(connectionId, this, (connId, dbConn) => { result = PagingUtil.ExecPage <WorkflowInfo>(pageIndex, pageSize, () => { Log.TraceAsync(countSql, source: source, tags: "SelectWaitHandlePage"); return(dbConn.ExecuteScalar <int>(countSql, parameters, GetDbTransaction(connId))); }, () => { Log.TraceAsync(pageSql, source: source, tags: "SelectWaitHandlePage"); return(dbConn.Query <WorkflowInfo, WorkflowHandleInfo, WorkflowInfo>(pageSql, (wf, wh) => { if (wf.Handles == null) { wf.Handles = new List <WorkflowHandleInfo>() { wh }; } return wf; }, parameters, GetDbTransaction(connId), splitOn: "id").AsList()); }); }, AccessMode.SLAVE); return(result); }