# `Sp_Split_sWod` (procedure)

> 研发工单拆分


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sTableName` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `iFlag` | `int` |

## Body

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

## Narrative

**Business context:** 生产管理 → 生产工单 (`mftworkordermaster` / 研发工单) — work-order equivalent of `Sp_Split_sMpt`. Splits a multi-line work-order master into individual one-line work-orders so each printable product has its own 工单 number, scheduling row, and downstream report chain.

**What it does:** Counts `mftworkorderslave WHERE sParentId=sGuid`; iterates each slave with a cursor; for each iteration skips when another slave already references the same `sProductId` (dedup), then calls `SP_Sis_GetMaxNo('mftworkordermaster', …)` for a fresh `sBillNo`, generates new IDs via `newId()`, and `INSERT INTO mftworkordermaster ... SELECT ... FROM mftworkordermaster WHERE sId=sGuid` (cloning every master column including the production-stage money fields `dPrintBeforeMoney`/`dPrintMoney`/`dPackMoney`/`dTransportMoney`, completion flags `bBillComplete`/`bSealingComplete`, plate fields, etc.) followed by `INSERT INTO mftworkorderslave ... SELECT ...` for that single slave (full column list including process flags `bDeliverComplete`/`bOutsideProcessComplete`/`bCheckingComplete`, transferred-matter fields, etc.).

**Invocation:** Install script: `script/标版/30100101/Sp_Split_sWod.sql`. No form-master binding, no `gdsmodule` hook, no other DB caller, no xly-src reference. Status: appears orphaned — DBA-side helper. Caveat: cloned column list is hard-coded; any schema additions to `mftworkordermaster`/`mftworkorderslave` need to be reflected here, otherwise clones drop those columns silently.
