# `Sp_BtnEvent_WorkUnComplete` (procedure)

> 取消工单完工


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sUserId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(1000)` |
| 7 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 生产工单 — toolbar handler that reverses 工单完工 (work-order-complete). Lets the shop floor un-complete a finished `mftworkordermaster` so further reports/postings can be made; the original completion timestamp is overwritten with the cancel timestamp and `sCompletePerson` records who cancelled.

**What it does:** Parses `$.params[*].value[*].sId` from `sProInParam`. For each master id, sets `mftworkordermaster.bBillComplete=0, tBillCompleteDate=NOW(), sCompletePerson=CONCAT(sMakePerson,'取消完工')`. Returns `sCode=-1, paramsErro` on missing input.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — 生产工单 grid's 取消完工 toolbar button names this proc as its action. Inverse of the `bBillComplete=1` setter on the same table.

Flag: the timestamp column is reused for both completion and cancellation, so the audit trail loses the original completion time on cancel.
