/// <summary> /// 获取等审核信息 /// </summary> /// <param name="userId">用户主键</param> /// <param name="categoryCode">分类代码</param> /// <param name="searchValue">查询字符串</param> /// <param name="showAuditReject">显示退回的</param> /// <returns>数据表</returns> public DataTable GetWaitForAudit(string userId = null, string categoryCode = null, string categorybillFullName = null, string searchValue = null, bool showAuditReject = true) { if (string.IsNullOrEmpty(userId)) { userId = this.UserInfo.Id; } string sqlQuery = " SELECT * " + " FROM " + BaseWorkFlowCurrentEntity.TableName // 未被删除的,有效的数据,还没能审核结束的 + " WHERE (" + BaseWorkFlowCurrentEntity.FieldDeletionStateCode + " = 0) " // Enabled 0 表示,审核还没结束 + " AND (" + BaseWorkFlowCurrentEntity.FieldEnabled + " = 0) "; if (!showAuditReject) { sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldAuditStatus + " != 'AuditReject') "; } if (!string.IsNullOrEmpty(userId)) { // 待审核的工作流(指向用户的) switch (BaseSystemInfo.UserCenterDbType) { case DbTypes.Access: sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldToUserId + "= '" + userId + "' "; break; default: sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldToUserId + "=" + userId + " "; break; } //(指向角色的) BaseUserManager userManager = new BaseUserManager(this.UserInfo); string[] roleIds = userManager.GetAllRoleIds(userId); if (roleIds != null && roleIds.Length > 0) { sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToRoleId + " IN (" + StringUtil.ArrayToList(roleIds) + ")"; } //(指向部门的) string[] organizeIds = userManager.GetAllOrganizeIds(userId); if (organizeIds != null && organizeIds.Length > 0) { sqlQuery += " OR (" + BaseWorkFlowCurrentEntity.FieldToUserId + " IS NULL AND + " + BaseWorkFlowCurrentEntity.FieldToDepartmentId + " IN (" + StringUtil.ArrayToList(organizeIds) + "))"; } sqlQuery += " ) "; } if (!string.IsNullOrEmpty(categoryCode)) { BaseWorkFlowBillTemplateManager templateManager = new BaseWorkFlowBillTemplateManager(this.DbHelper, this.UserInfo); DataTable dataTable = templateManager.Search(string.Empty, categoryCode, string.Empty, null, false); string categoryCodes = BaseBusinessLogic.FieldToList(dataTable, BaseWorkFlowBillTemplateEntity.FieldCode); if (!string.IsNullOrEmpty(categoryCodes)) { sqlQuery += " AND (BaseWorkFlowCurrent.CategoryCode IN (" + categoryCodes + ")) "; } } if (!string.IsNullOrEmpty(categorybillFullName)) { sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.TableName + "." + BaseWorkFlowCurrentEntity.FieldCategoryFullName + " ='" + categorybillFullName + "') "; } List<IDbDataParameter> dbParameters = new List<IDbDataParameter>(); if (!String.IsNullOrEmpty(searchValue)) { searchValue = searchValue.Trim(); sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldObjectFullName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldObjectFullName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditUserRealName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditUserRealName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditIdea + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditIdea); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditStatusName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditStatusName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToDepartmentName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldToDepartmentName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToUserRealName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldToUserRealName) + ")"; if (searchValue.IndexOf("%") < 0) { searchValue = "%" + searchValue + "%"; } dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldObjectFullName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditUserRealName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditIdea, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditStatusName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldToDepartmentName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldToUserRealName, searchValue)); } // 排序字段 sqlQuery += " ORDER BY " + BaseWorkFlowCurrentEntity.FieldSendDate; return DbHelper.Fill(sqlQuery, dbParameters.ToArray()); }