# `Sp_Bd_bi18` (procedure)

> @author:zhucx
							@date:20211224 
							@describe: 印刷车间


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iFlag` | `int` |
| 2 | IN | `iTmpCheck` | `int` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sGuid` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(4000)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 印刷车间 workshop dashboard (kanban) — board procedure for the 印刷 (printing) workshop in the `Sp_Bd_bi<n>` workshop-board family. Returns the per-machine current-shift status block consumed by the 看板/dashboard page. MES-integrated variant — reads MES-system tables in addition to xly's own.

**What it does:** Same shape as siblings `Sp_Bd_bi16`/`Sp_Bd_bi17` — seeds `p_Bd_PlcNo_No` with the 印刷 machine PLC numbers (`23,12,1,2,13`), cursor-iterates per machine, reads current 工单 / 班组 / 设备状态 via `viw_plc_machine`, joins `mftworkordermaster`+`mftworkorderprocess`, computes 实际/标准/偏差 调机时间 + 当前色号 + 完成版数/模数 from `plc_machinedata`, aggregates into `p_Bd_workshop5` and emits a `{"data":[...]}` JSON. Reads MES counter columns via the `MEStt` join (replaced by xly's own counter in the `_nomes` sibling).

**Invocation:** Installed by `xly-src/script/标版/30100101/kanban/Sp_Bd_bi18-印刷.sql`. No form-master sSqlStr, no `gdsmodule` hook, no other-routine caller (other than appearing as a comment string in `Sp_Bd_bi18_nomes`), no Java caller. Status: appears reachable only via an external dashboard HTTP endpoint that invokes the proc by name. Per wiki scope, kanban dashboard procs sit outside the routine call-graph wiring tracked in this catalog.

Tenant note: `iPlcNo` literals (`23,12,1,2,13`) are deployment-specific.
