# `Sp_WorkOrder_GtChar` (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 | `sWorkOrderGuid` | `varchar(100)` |
| 5 | IN | `bFilter` | `varchar(5000)` |
| 6 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 7 | OUT | `sCode` | `int` |
| 8 | OUT | `sReturn` | `longtext` |

## Body

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

## Narrative

**Business context:** 制造 → 工单 — 工单甘特图 (`COMMENT '工单甘特图'`): builds the Gantt-chart payload for a single 工单, returning a JSON `{data, links}` shape that the front-end Gantt widget (dhtmlx-style) consumes — control rows (`mftworkordercontrol`) as parents, process rows (`mftworkorderprocess`) as children, with `tStartDate`/`tEndDate` joined from `mftproductionplanslave` and a derived `sProcessState` ("已完成"/"已排程"/"未排程"/"发外加工"/"偏离APS规则转人工排程"…).

**What it does:** Validates `sWorkOrderGuid`, reads `syssystemsettings.CkxXd` for the brand to switch the "已下达/已排程" label, builds two temp tables `tmp_gt_WorkControl` and `tmp_gt_WorkProcess`, populates them from `mftworkordercontrol` / `mftworkorderprocess` + `eleprocess` joins, then cursors over them concatenating `JSON_OBJECT(...)` rows into `p_dataArray` and `p_linkArray` (parent/child linkage via `iOrder`). Final output: `sReturn=JSON_OBJECT('data',p_dataArray,'links',p_linkArray)`, `sCode=1`. No INSERT/UPDATE/DELETE to real tables.

**Invocation:** Status: appears orphaned. No `gdsconfigformmaster` binding, no `gdsmodule` hook, no other DB routine calls it. The only xly-src reference is the install script `script/标版/30100101/Sp_WorkOrder_GtChar.sql` — no Java caller, no MyBatis mapper. Either dispatched dynamically through a name not yet grep-able, or unused; candidate for maintainer audit.
