# `Sp_bd_MachinePlanTemplate_2` (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_2`'`._

## Narrative

**Business context:** 看板管理 / 单机设备看板(1屏) (front-end template `commonAuto/QCZH1`). The "本班数据-本月展示" tile of the layout — month-to-date production aggregate for the same machine that the `_1` sibling reports on as current-shift. Author tagged `封存` 2021-06-21.

**What it does:** Same machine-resolution preamble as `_1` (reads `elemachine` + `viw_plc_machine` by `iPlcNo=sPlcNo`), but widens the `plc_machinedata` aggregation window to the current calendar month for plan-quantity / report-quantity / 时间稼动率 / 速度稼动率 / 总稼动率 metrics. Writes rows into `p_bd_MachinePlanTemplate2(sName,iOrder,sValue)` and emits the rows ordered by `iOrder` as the kanban JSON envelope.

**Invocation:** No install script for this exact name. The three `Sp_mes_TimeActivation_*` procs reference the name only in a `-- call Sp_bd_MachinePlanTemplate_2(...)` debug comment and via a same-named temporary table `p_bd_MachinePlanTemplate2` (name collision, not a real call). No form-master sSqlStr, no `gdsmodule` hook, no Java caller. Status: appears orphaned. No caller found in any channel — candidate for maintainer audit. Marked `封存` (sealed) 2021-06-21.

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