# `Sp_ProductionReport_BtnEventComplete` (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 | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 移动端管理 → 现场 → 功能操作 → 内部报工 (and 发外报工) — "强制完工" (force-complete) toolbar handler on production-report rows. Lets a supervisor close a `mftworkorderprocess` or `mftproductionplanslave` row when the operator hasn't (or can't) submit further `mftproductionreport*` qty, with a permanent `syscomplete` audit row recording who, when, and why.

**What it does:** Walks `sProInParam.params[*].value[*].sSlaveId`. Reads `SysSystemSettings.CbxProductionReport` into `@p_sType`. Branch (a) — if `'workorder'` (生产工单 mode): `Update mftworkorderprocess SET bProductionReportComplete=1` for the slave id and `INSERT INTO syscomplete(... 'mftworkorderprocess','bProductionReportComplete')` via `viw_mftworkorderprocess`. Branch (b) — otherwise (生产排程 mode): updates `mftproductionplanslave SET bProductionReportComplete=1, tProductionReportDate=NOW(), sProductionReportPerson=sMakePerson`, propagates the same flag to `mftworkorderprocess` via `sSrcSlaveId`, and writes two `syscomplete` rows (plan-slave and work-order-process) keyed by `Fun_Sis_GetConstNew(...,'sForceComplete',...)` operation type.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 报工 form's "强制完工" button names this proc as `sproName`. xly-src ships `script/标版/30100101/Sp_ProductionReport_BtnEventComplete.sql`. The sample JSON `{"sproName":"Sp_ProductionReport_BtnEventComplete","inMap":"slave.sSlaveId","orderBy":"{'gdsconfigformslave':'ORDER BY iOrder ASC '}"}` appears as a doc-comment in `CalcProcedureServiceImpl.getAddSql()` illustrating the button-param shape.
