# `Sp_bd_MachinePlanTemplate_1` (procedure)

> @author:zhucx
							@date:20210621 封存
							@describe: 看板管理-单机设备看板(1屏) 对应commonAuto/QCZH1 下 本班数据展示


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 看板管理 / 单机设备看板(1屏) — single-machine dashboard rendered by front-end template `commonAuto/QCZH1`. This is the "本班数据" tile of the layout — current-shift production aggregate for one PLC machine. Author tagged `封存` 2021-06-21.

**What it does:** Resolves machine + team from `elemachine` and `viw_plc_machine` by `iPlcNo=sPlcNo` (tenant-scoped), derives current `sWorkType` by comparing `NOW()` against `sOffWork`/`sShiftsWork`, then aggregates plan/report quantities, 时间稼动率, 速度稼动率, 总稼动率 across this shift's `plc_machinedata` window into `p_bd_MachinePlanTemplate1(sName,iOrder,sValue)`. Final SELECT emits the rows ordered by `iOrder` as a JSON envelope for the front-end.

**Invocation:** No install script (the family base `xly-src/script/标版/30100101/Sp_bd_MachinePlanTemplate.sql` ships only the unnumbered version). No form-master sSqlStr, no `gdsmodule` hook, no other-routine caller, no Java caller. Status: appears orphaned. No caller found in any channel — candidate for maintainer audit. Marked `封存` (sealed) 2021-06-21; reachable only by a tenant-baked external dashboard endpoint that invokes the proc by name.

Hardcoded defaults `dDayPlanQty=8000`/`dMonthPlanQty=240000` — re-mapping needed for tenants with different shift targets.
