Sp_Check_sPtr (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 |
| 8 | OUT | sCode |
int |
| 9 | OUT | sReturn |
varchar(4000) |
Body
Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpCheck_sPtr'._
Narrative
Business context: 库存管理 → 成品库存 → 出库管理 → 成品领用单据 — post-save validator on pitproductrejectmaster/pitproductrejectslave (sPtr = product-takeout/reject). Despite the name, the proc backs the 成品领用 (and report-scrap) flow: ensures 红冲 records don't double-submit and that the out-store qty per row does not exceed either the source 计划 qty or the 质量事故 报废 qty.
What it does: Sets sCode=1, iFlag=0, clears sReturn. Reads pitproductrejectmaster.sMinusSrcId; if set, counts pitproductrejectslave rows whose original dProductQty plus summed reverse-charge dProductQty is non-zero — if any, aborts with sCcprkHaveRedData ("已存在红冲数据,不允许重复提交"). The commented 余数仓库 enforcement block is preserved. With a non-empty sFormGuid, opens a cursor over pitproductrejectslave and for each sSrcSlaveId checks two channels: (1) mftproductionplanbillslave.dProcessQty - SUM(pitproductrejectslave.dProductQty) and (2) mftqualityaccidentmaster.dScarpQty - SUM(...). On negative result, concatenates either sOdtInOrder (same bill) or sDataInScrapOrDispatch (other bill numbers) with sOutStockExceed ("出库数量已超量"). Aborts with sCode=-1 if sReturn is non-empty, otherwise calls Sp_afterSave_sPtr.
Invocation: Bound to gdsmodule.sSaveProName on 成品领用单据 (101251240115015920999005840) — 库存管理 → 成品库存 → 出库管理. Dispatched by BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName") after the save batch commits. No sSaveProNameBefore peer on this module. xly-src ships script/标版/30100101/Sp_Check_sPtr.sql as the install body.