Fun_GetAuxiliaryQtyUnit.md 2.23 KB

Fun_GetAuxiliaryQtyUnit (function)

  • Type: FUNCTION
  • Returns: varchar(100)
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sMaterialsGuid varchar(100)
2 IN sMaterialsStyle varchar(100)
3 IN dAuxiliaryQty decimal(18,6)
4 IN iType int
5 IN sBrId varchar(100)
6 IN sSuId varchar(100)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTIONFunGetAuxiliaryQtyUnit'._

Narrative

Business context: Inverse of Fun_GetMaterialsQtyUnit — given an auxiliary quantity (the purchasing/storage unit, e.g. 张/PCS/m) plus a material spec, returns either the equivalent stocking-unit quantity (when iType=0) or the auxiliary-unit name (when iType=1). Used during reverse formula calculation: sFormulaIdType = sReComputeId.

What it does: reads the material's EleMaterials row (sMaterialsUnit, sAuxiliaryUnit, dGramWeight, sConversionUnit, bReel, dCoefficient, bInverse) plus tenant system settings CbxMaterialsUnit (MM/CM/INCH), NetSquareM (m² rounding decimals), NetConversionRate (inch conversion). Branches by spec format (W*L, W*L*H, plain numeric, blank) × unit family (Ton/吨/噸, KG, M2, M3, m, reel) × MM/CM/INCH dimension base. Each branch derives dMaterialsQty from dAuxiliaryQty using gram-weight or sheet-area math, picks a default sAuxiliaryUnit (//PCS/m), and finally rounds: 张/PCS → CEILING; m → ROUND(qty, NetSquareM) (or CEILING if NetSquareM=0). Returns the quantity (iType=0) or unit string (iType=1).

Invocation: invoked by ReplaceFieldServiceImpl.getReplaceFieldReslut() when the formula type is sReComputeId — the Java service synthesizes SELECT Fun_GetAuxiliaryQtyUnit(...) from material + slave-row context and runs it through businessBaseDao.getByMap. Also referenced by the bill-check family (Sp_Check_sCmt, sLok, sMpa, sOis, sOpc, sOpi, sOpkg, sOpn, sOpn1, sOpp, sPca, sPca1, sPis, sPkg, sPmd, sPod, sPpa) and inventory in/out procs (SP_Inventory_InOutWarehouse, _All, _220709, _221111).