# `Sp_Productionplan_sColumnarStack_Char` (procedure)

> 生成计划:叠状柱形图


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sLoginId` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `bFilter` | `varchar(5000)` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `longtext` |

## Body

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

## Narrative

**Business context:** 生产计划管理 → 生管主计划 — 生成计划:叠状柱形图 (per the COMMENT). Dashboard data-source for the stacked-column chart showing each 机台 / 工作中心's planned-hour load split by state (已下达 / 已排程 / 已暂停 / 未排程). Handles a special "0000000000" filter token to switch to a 发外 (outsourced) view sourced from `opsoutsideprocessslave`.

**What it does:** Builds `Productionplan_sColumnarStack_Char_Tmp` (sMachineId, sFormId, sMachineName, dHourSum, sState, sStateName, iOrder). If `bFilter` contains `0000000000`: inserts a single 发外 series from `opsoutsideprocessslave O JOIN eleprocess P JOIN sisworkcenter W` grouped by `P.sWorkCenterId`. Otherwise resolves a 未排程机台 sFormId by joining `eleprocess`/`sisprocessclassify`/`sisworkcenter`/`eleprocessmachine`/`elemachine`, then inserts the 未排程 series from `mftproductionplanslave WHERE sState=0 AND sMachineId=''` and the 已排程/已下达/已暂停 series grouped by `(PL.sMachineId, PL.sState)`. Applies the machine's standard work-hour basis (`b.dWeek * sWorkType`) to normalise dHourSum, then iterates the state cursor (5/4/3/1) to compose the JSON `{ data:[{name, sState, <machineName>, sMachineId<name>}], fields:[...], xName:'机台名称', yName:'总时间' }`.

**Invocation:** Not bound in `gdsconfigcharmaster`/`gdsconfigcharmaster0302`; only the install script in xly-src — Status: appears orphaned. Superseded by `Sp_Productionplan_sColumnarStack_Char_V10.1` which is also unbound. Candidate for maintainer audit.
