# `Sp_productionPlanInfo_BtnEventOutProcessing` (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_productionPlanInfo_BtnEventOutProcessing`'`._

## Narrative

**Business context:** 生产管理 → 生产计划管理 → 生产排程 — toolbar handler "机台计划：工序发外加工" (send remaining qty out for sub-contracting). Triggered when a process can't be finished in-house: the residual qty is pushed to the work-order's outside-processing leg, the in-house schedule row is shrunk to what's already reported, and the leftover slave row is removed if it has no production-report dependency.

**What it does:** Per slave `sId` (dash-split): (1) `UPDATE MftWorkOrderProcess A INNER JOIN mftproductionplanslave B ON A.sId=B.sSrcSlaveId SET bOutside=1, dOutsideQty=IFNULL(B.dProcessQty,0)-IFNULL(B.dProductionReportQty,0)+A.dOutsideQty, bExamine=0, tPlanDate=NOW(), bNewOld=0` where outstanding qty > 0. (2) `UPDATE mftproductionplanslave SET dProcessQty=IFNULL(dProductionReportQty,0)` (shrink the in-house row). (3) For 胶印 (`sProcessId='1691254111216986535514820'`): hide the iOrder=1 切纸 row via `bHide=1`. (4) Freeze the slave if it has any reported qty or `bPublishComplete=1`. (5) `DELETE FROM mftproductionplanslave WHERE sId=p_sIdOne AND sId NOT IN (SELECT sSrcSlaveId FROM MftProductionReportSlave)`. (6) Logs 发外加工 to `syslog` with `sFormId='101251240115016110217762400'`.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 生产排程 form's "工序发外加工" button. xly-src ships `script/标版/30100101/schedule/Sp_productionPlanInfo_BtnEventOutProcessing.sql`.
