# `Fun_Getcolorcount` (function)

> 根据 + 分隔符，确定颜色数


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iFace` | `int` |
| 2 | IN | `iColorOrder` | `int` |
| 3 | IN | `splitstr` | `varchar(1000)` |

## Body

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

## Narrative

**Business context:** Plate color/ink counter — header `根据 + 分隔符，确定颜色数`. Operates on a JSON color-list string with optional face-doubling and process/spot color filter. Used by the work-order/quotation calc procs for paperboard/box products to estimate ink-station usage per face.

**What it does:** upper-cases the input; counts how many `"SNAME":"C"`, `"M"`, `"Y"`, `"K"` substrings appear (CMYK process colors) and the total number of `}` (one per color entry). Then branches: `iFace=2` doubles the result (two-sided print); `iColorOrder=1` returns CMYK process count, `iColorOrder=2` returns the spot-color complement `(total - CMYK)`. Returns 0 for any other combination.

**Invocation:** invoked by `Sp_Manufacture_InsertMftPlanSlave` (轮转/合版 manufacturing-plan slave), `Sp_Quotation_CalcDataPackProductStd` (paperboard quotation calc), and `Sp_WorkOrder_CalcDataBsProductStd` (paperboard work-order calc) — together with the customer-override copies in `script/客户/{千彩,快马,金宣发,上海亚峰}` indicating site-specific tweaks against this same routine.
