# `sp_OEE_adjustmentend` (procedure)

> OEE 调机结束


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sMachineId` | `varchar(100)` |
| 2 | IN | `sTeamId` | `varchar(100)` |
| 3 | IN | `sBillNo` | `varchar(100)` |
| 4 | IN | `sPlanslaveId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | OUT | `sReturn` | `varchar(1000)` |
| 8 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** OEE管理 — "调机结束" (end-of-machine-setup) hook on a machine workstation. Fires when the OEE shop-floor app signals that setup/adjustment for the current 工序 (process step) is finished and production proper is about to begin. In practice the deployed body is a hard gate: it always returns `sCode=-1, sReturn='是否做首检、做清场检，如果没有做，不允许结束'` — i.e. it refuses to close the setup stage until the 首检 (first-piece) and 清场 (clearance) checks are recorded, so callers treat it as a precondition validator.

**What it does:** `IFNULL`-defaults the inbound args, then unconditionally writes the refusal message and sets `sCode=-1` before `LEAVE top` — leaving the actual end-of-setup state changes to whatever bypasses or post-processes the result on the Java side.

**Invocation:** Called by `PlcXmzServiceImpl.sp_OEE_adjustmentend(...)` and the 2022/Old PLC variants `PlcXmz2022ServiceImpl` / `PlcXmzServiceImplOld`, each forwarding to the proc through the shared `doOeePro(... "sp_OEE_adjustmentend", ...)` `{CALL …}` template. The Java method is itself called by `OeeHandleServiceImpl` while reacting to PLC `sMachineId` data — the OEE PLC dispatch path.
