Sp_OpsOutsideprocess_CheckUpdate (procedure)
成品外购保存校验
- Type: PROCEDURE
- Deterministic: NO
- SQL data access: CONTAINS SQL
Parameters
| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | sGuid |
varchar(100) |
| 2 | IN | sFormGuid |
varchar(100) |
| 3 | IN | sLoginId |
varchar(100) |
| 4 | IN | sBrId |
varchar(100) |
| 5 | IN | sSuId |
varchar(100) |
| 6 | OUT | sCode |
int |
| 7 | OUT | sReturn |
varchar(4000) |
Body
Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpOpsOutsideprocess_CheckUpdate'._
Narrative
Business context: 外协管理 / 工序发外 (variant: 成品外购) — pre-save validator/recompute for the 成品外购 master record. Aggregates 其它费用 onto each product line, recomputes 单价/金额 and tax-decomposition columns, and refuses to save when the same product appears at multiple prices on one master.
What it does: For the master sGuid: zeros dOldMaterialsPrice on rows where dMaterialsPrice=0, snapshots dMaterialsPrice → dOldMaterialsPrice, recomputes dOldMaterialsMoney. If any slaves exist on the master, aggregates per (sParentId,sProductId,sId) summing dOldMaterialsMoney + dOtherMoney into a new dMaterialsMoney, then derives dMaterialsPrice = ROUND(dMaterialsMoney/dMaterialsQty,6). Joins sistax to refresh dMaterialsNoTaxPrice/dMaterialsNoTaxMoney/dMaterialsTaxMoney. Aborts with sCode=-1 and '该订单存在相同产品,单价不一致数据,请检查修改后重新保存!' when the same sProductId ends up with multiple distinct dMaterialsPrice values. Finally clears the dOld* snapshot columns when iCheckCount=0.
Invocation: Called by sibling check-routines Sp_Check_sOpc and Sp_Check_sOpp — i.e. wired into the pre-save validator chain (gdsmodule.sSaveProName/sSaveProNameBefore) of the 成品外购 / 工序发外 forms, dispatched by BusinessBaseServiceImpl during the save flow.