# `Sp_Manufacture_BtnRepairExplain` (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_Manufacture_BtnRepairExplain`'`._

## Narrative

**Business context:** 生产管理 → 生产计划 / 产量上报 — 偏离原因 button (despite the `Repair` token, the install-script comment is 偏离原因 / deviation reason). A 主管 confirms an adjusted plan qty / hours against the actual 产量上报 row and records a free-text deviation memo against the locked 机台计划 slave.

**What it does:** Parses `$.params[*].value[*].sId` plus `$.changeValue.dAjustReportPlanQty` (主管确认数量), `$.changeValue.sAjustReportPlanHour` (主管确认工时), and `$.changeValue.textareaValue` (memo) from `sProInParam`. For each plan-slave id, looks up the corresponding `mftproductionreportslave.sId` by `sSrcSlaveId`, and when found, `UPDATE mftproductionreportslave` writes `dAjustReportPlanQty`, `dAjustReportPlanHour` (only overwriting when override is non-blank) and sets `bAffirm=1`; then `UPDATE mftproductionplanslavelock.sPlannerMemo` with the textarea memo.

**Invocation:** Dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — the 机台计划 / 产量上报 grid's 偏离原因 toolbar button names this proc by string. Install script: `script/标版/30100101/schedule/Sp_Manufacture_BtnRepairExplain.sql` (comment: 偏离原因).
