# `Sp_Sis_GetEleProductNo` (procedure)

> 获取产品的品牌 系列


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sBillType` | `varchar(100)` |
| 2 | OUT | `sReturn` | `varchar(100)` |
| 3 | IN | `sClassNo` | `longtext` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |

## Body

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

## Narrative

**Business context:** 基础资料 → 印品资料 (eleproduct) — auto-generates the next 印品编号 (品牌+系列+sequence) for a new product master row, using the customer / reserve-code prefix plus a per-prefix incrementing tail. Specifically targets `sProductNo LIKE 'KH%'` (客户款式) and supports two width modes — 5-digit tail when `sDemandItemCode=0`, 3-digit tail otherwise — driven by `sBillType` (`sMReserve5` / `sProductNo` / default `sMReserve6`).

**What it does:** Parses `sClassNo` as JSON (`sCustomerId, sCustomerNo, sNo, sMReserve1..6, sDemandItemCode, sProductName, sId`); if `sId` is supplied and an existing `KH%` row already exists for that product, returns the existing `sProductNo` (idempotency); otherwise composes a dynamic `SELECT MAX(CONVERT(<column>,UNSIGNED))` over `eleproduct` with the assembled `WHERE` (brand/subsidiary + customer + reserve fields + optional product-name) restricted to `sProductNo LIKE 'KH%'`, adds 1, left-pads to the configured width, and concatenates with the title prefix for the `sProductNo` mode (or returns just the tail for the reserve-column modes).

**Invocation:** Called by Java `BusinessCharacterFormatServiceImpl.getEleProductNo(sBillType, sClassNo, sBrandsId, sSubsidiaryId)` through `procedureService.getCallProByMap(...)` — the character-format pipeline that fills auto-generated codes on the product master form during save/draft. Install script: `script/标版/30100101/Sp_Sis_GetEleProductNo.sql`.
