Sp_Check_sPod.md 2.76 KB

Sp_Check_sPod (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_sPod'._

Narrative

Business context: 采购管理 → 物料采购流程 → 采购订单 — post-save validator on purpurchaseordermaster/purpurchaseorderslave/purpurchaseorderdetail. Recomputes 正算/反算 material quantities from the source 采购申请/工单 lines, enforces the 反算公式物料 rule, and prevents a single PO row from pulling from material plans that span different work-orders. Calls a dedicated checker Sp_PurpurchaseOrder_CheckUpdate for the heavy module-specific rules.

What it does: Sets sCode=1, iFlag=0, clears sReturn. Reads NetMoney/NetPrice precisions. First barrier: for slave rows with iHandIn=1 whose eleproduct.bInverse=0, abort with sMaterialNotFsgs ("物料不是反算公式物料,请输入采购数量进行计算"). Opens nested cursors over purpurchaseorderslave × purpurchaseorderdetail joined to source apply/work-order rows, dispatches to forward (Sp_System_ReplaceField, iComputeType=0) or reverse formula based on eleformula.sComputeId/sReComputeId, recomputes dMaterialsQty/dAuxiliaryQty and the derived money columns, and updates the slave/detail rows. On per-row overruns vs. material need or vs. source plan, raises sCgQtyUpMaterialNeed/sCgJjQtyUpMaterialNeed/sJjQtyUpMaterialNeed/sPcaCgQtyUpCg/sPcaCgJjQtyUpCg/sPcaJjQtyUpCg/sPcaMaterialInOrder/sPcaMaterialInCgOrder. Enforces sMaterialNoSameWorkOrder/sQtyNoSameWorkOrder (one slave row cannot mix work-orders / qty must match work-order qty). Then CALL Sp_PurpurchaseOrder_CheckUpdate(sGuid, sFormGuid, sLoginId, sBrId, sSuId, @sCode, @sReturn) for the module-specific extra rules. Finally calls Sp_afterSave_sPod. Old-system 旧采购订单号 rule is commented out.

Invocation: Bound to gdsmodule.sSaveProName on 采购订单 (192116810113315217757747140) — 采购管理 → 物料采购流程 (KPI流程操作菜单). Dispatched by BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName") after the save batch commits. Pre-save peer is Sp_beforeSave_sPod. xly-src ships script/标版/30100101/Sp_Check_sPod.sql as the install body.