# `Sp_bd_TmComplianceRate` (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_bd_TmComplianceRate`'`._

## Narrative

**Business context:** 看板管理 / 产量达标率 — per-machine, per-shift output compliance ratio for the rotary-press group (PLC numbers 1-12). Compares each machine's `dQty + dPlateQty` against the team's target `eleteam.dPrintQty` (default 36000) across four shift buckets: 昨日白班 / 昨日晚班 / 今日白班 / 今日晚班.

**What it does:** Loads yesterday-to-now machine output from `plc_machinedata` (filtered to `elemachine.iPlcNo` 1-12) into temp `p_machinedata`, then per-(sMachineId,sTeamId,iOrder) collapses adjustable-quantity sequences via `Fun_GetHumpDiff(GROUP_CONCAT(...))` plus `SUM(dPlateQty)` into `p_bd_TmComplianceRate`. Joins `eleteam` for team name & target `dPrintQty`, joins `elemachine` for machine name and `sShiftsWork`/`sOffwork` shift-cutover times. Classifies each row's `tCreateDate` into one of the four `sType` shift buckets using the machine's per-machine shift times (defaults `17:30` for `sShiftsWork`, `08:30` for `sOffwork`). Backfills zero rows for any machine not reporting in a bucket. Emits JSON `{data:[{type,y:100*y/dPrintQty,x}],xUnit:"",yUnit:"%"}`.

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_bd_TmComplianceRate.sql`. No form-master sSqlStr, no `gdsmodule` hook, no other-routine caller, no Java caller — reachable only via an external dashboard HTTP endpoint that invokes the proc by name. `Sp_bd_TmComplianceRate2` and `Sp_bd_TmComplianceRate3` cover PLC ranges 15-26 and 29-40.
