# `Fun_GetBookStickQty` (function)


- **Type:** FUNCTION
- **Returns:** `decimal(18,6)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `dQty` | `decimal(18,6)` |

## Body

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

## Narrative

**Business context:** Book-binding glue-allocation rounding rule. In book manufacturing, glue/`贴` is dispensed in quarter-unit increments; the planning system rounds fractional sticker quantities to the discrete pour size before charging materials.

**What it does:** lookup table on `dQty`: 0.125 → 0.125; 0.25 → 0.25; 0.375 → 0.25; 0.5/0.625/0.75/0.875 → 0.5; all other values pass through unchanged. Returns 0 if NULL.

**Invocation:** called from `Sp_Manufacture_InsertMftPlanBook` (book-style manufacturing plan generator) and the formula-engine replace-field family `Sp_System_ReplaceField`, `Sp_System_ReplaceFieldNew`, `Sp_System_ReplaceField_Detail`, `Sp_System_ReplaceField_NEW`, `Sp_System_ReplaceField_NEW_ACT` — those procs in turn are driven by `BtnCalculationServiceImpl` (`doSetTimeCalcMachineHour`) via the cost-formula module `成本公式`.
