# `Fun_Getcolorcount_CalcQty1` (function)


- **Type:** FUNCTION
- **Returns:** `int`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sJson` | `longtext` |

## Body

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

## Narrative

**Business context:** CMYK ink-count summer for the printing planner. Each plate-color JSON entry carries `sName` (C/M/Y/K or a spot-color name) and `dColor` (ink-station count). This variant counts only the CMYK process colors (`sName ∈ {C, M, Y, K, "C+M+Y+K"}`).

**What it does:** walks the JSON array; per entry, if `sName` is one of the CMYK process names, accumulates `dColor`; non-process (spot) colors contribute 0. Returns the running sum. `Fun_Getcolorcount_CalcQty2` is the inverse — it sums spot colors only.

**Invocation:** called from `Sp_Manufacture_InsertMftPlanSlave` (轮转工单 / 合版工单 manufacturing-plan slave inserter), where it splits the color/ink JSON into process-ink stations vs. spot-ink stations for the per-plate quantity bookkeeping.
