# `Sp_Productionplan_Pie_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` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 生产计划管理 → 生管主计划 — 生成计划:卡片图 (per the COMMENT). Dashboard data-source for the per-工作中心 load-card chart on the 生产计划 page: each 工作中心 returns its planned-quantity sum, current hours, next-day hours, capacity baseline, and a normalised load ratio used to colour the card.

**What it does:** Resolves `SysSystemSettings.CkxProcessFilter` and (if enabled) the user's `Fun_GetLookProcess(...)` 工序 whitelist via `SftLoginInfo`. Builds `Productionplan_Pie_Char_Tmp` (sWorkCenterId, iPlanSum, dHourSum, d2HourSum, dStdWorkCenterHour, sLimitDate, iLimitColor, dRate). Composes a dynamic INSERT from `mftproductionplanslave P` with the active-state and frozen filters, GROUPed by `P.sWorkCenterId`. Then joins `elemachine` + `sisworkcenter` to derive each 工作中心's standard `dStdWorkCenterHour`, computes `sLimitDate` via `DATE_ADD(SYSDATE, INTERVAL dHourSum/std DAY)` and `dRate = d2HourSum / std`. Picks the highest-load 工作中心 as the warning row (`iLimitColor=1`) and returns JSON `{ data: [...], subTitle, yUnit }` in `sReturn`.

**Invocation:** No live `gdsconfigcharmaster` binding for this name and only the install-script reference in xly-src — Status: appears orphaned. Currently superseded by `Sp_Productionplan_Pie_Char_V10.1` (same purpose, refactored body) which itself is also unbound in the live config tables. Both candidates for maintainer audit.
