# `Sp_ProductionOrder_OutSide` (procedure)

> @author:zhucx 
		     @date: 2022/12/02
				 @describe: 销售订单-生产订单，发外加工按钮


- **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_ProductionOrder_OutSide`'`._

## Narrative

**Business context:** 生产管理 → 订单生产流程 → 销售订单->生产工单 — 发外加工 toolbar action. Flags a sales-order slave row for outsourced production (whole-bill outsourcing, not per-process), which lets the downstream 发外加工流程 pick it up instead of generating an in-house 生产工单.

**What it does:** Walks `$.params[*].value[*].sSlaveId`/`dRequiredQty`. For each `salsalesorderslave.sId`, `UPDATE salsalesorderslave SET bOutside=1, bProductionOrder=1, tProductionOrder=SYSDATE(), sProductionOrder=sMakePerson, dAuxiliaryQty=p_dRequireQty, dReleaseQty=dProductQty WHERE sId=p_sId`. (The commented-out block earlier in the body — checking 生产工单已经生成 — is disabled, so it does NOT refuse when a work order already exists.)

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 发外加工 toolbar button on 销售订单->生产工单. Inverse: `Sp_ProductionOrder_ReturnOutSide`. No xly-src install script under this name; DB-only — candidate for maintainer audit.
