# `Sp_chart_Bottleneck` (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_chart_Bottleneck`'`._

## Narrative

**Business context:** 制造管理 / 仪表盘 — 瓶颈工序表 (bottleneck-process chart). Computes a per-machine "delay days" series for an executive home-screen dashboard: cursors active production-plan processes, flags machines whose next process starts more than 2 days after the prior process ends (or before), and renders the top-2 bottleneck machines' upcoming-day load as a JSON payload.

**What it does:** Cursors `mftworkorderprocess` rows joined to `mftproductionplan` (state=3) ordered by parent / control / type / order. For each row pulls the corresponding `mftproductionplanslave.tStartDate`/`tEndDate`/`sMachineId`, diffs against the previous process's end, and inserts a `(sMachineId, iDiffDay)` record into `Bottleneck_Tmp` when the gap is negative (machine running early) or > 2 days. Picks the top-2 machines by occurrence (`TMP_Machine1` → `TMP_Machine`), reads their planned hours per day from `mftproductionplanslave`/`elemachine` (`TMP_Date`), and builds a `{"data": [...], "day": [...], "sMachines": [...]}` string — but never assigns to a return OUT param.

**Invocation:** Status: appears orphaned. No form-master, gdsmodule hook, other-routine caller, or xly-src caller. No install script either (not even in `script/标版/`) — body is only resident in the live DB. The chart-string is computed but never returned: `sReturn` and `sCode` are declared OUT but the proc leaves them unset, which suggests dead code. Candidate for maintainer audit / removal.
