# `sp_get_unTodo_Apply` (procedure)

> 待办事项


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sLoginId` | `varchar(50)` |
| 2 | IN | `sBrId` | `varchar(50)` |
| 3 | IN | `sSuId` | `varchar(50)` |
| 4 | IN | `isHandle` | `int` |
| 5 | IN | `bFilter` | `longtext` |
| 6 | IN | `pageNum` | `int` |
| 7 | IN | `pageSize` | `int` |
| 8 | OUT | `totalCount` | `int` |
| 9 | IN | `countCloumn` | `longtext` |
| 10 | OUT | `countMapJson` | `longtext` |
| 11 | IN | `sFilterOrderBy` | `longtext` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `sp_get_unTodo_Apply`'`._

## Narrative

**Business context:** "我发起的" view companion to `sp_get_unTodo` — lists the workflow instances the current user kicked off (`biz_flow.apply_user`) rather than tasks waiting on them. Reads from `biz_flow` with a correlated subquery into `biz_todo_item` to resurrect the current step's `task_id` and `instance_id`.

**What it does:** Sets `pageNum, pageSize` defaults (1 / 20). Uses `sLoginId` directly as `p_sLoginName`. Builds dynamic SQL selecting from `biz_flow B` with two LIMIT 1 sub-SELECTs into `biz_todo_item` to pick the current step's `id` (returned as `sId`) and `task_id` (as `sTaskId`); other columns return the application metadata as: `sTypeName ← sSrcNo`, `title ← create_time`, `reason`, `apply_user`, `apply_time`, `sSrcNo ← sTypeName` (the SELECT deliberately swaps `title` and `sTypeName` for the UI), `create_by/update_by/update_time`, plus `instance_id AS sInstanceId`. Filters `WHERE apply_user = p_sLoginName` ordered by `id DESC` and paged. A second COUNT(1) on `biz_flow` populates `@totalCount`. The "mark-as-read" `UPDATE biz_todo_item` is commented out (this is the "我发起" view, not the inbox).

**Invocation:** Status: appears orphaned via static scan. No `gdsmodule` hook, no `gdsconfigformmaster` reference, no other proc CALLs it, no xly-src grep hit. Wired dynamically by the front-end Todo widget's "我发起" tab, alongside `sp_get_unTodo`. The proc name signals that intent (`_Apply` = 我申请的/我发起的).
