# `Sp_OEE_ScanInsertToERP` (procedure)

> @author:zhucx 
					@date:20210817 封存 
					@describe:PLC服务器调用


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sBrId` | `varchar(100)` |
| 2 | IN | `sSuId` | `varchar(100)` |
| 3 | IN | `sPlcAddr` | `longtext` |
| 4 | IN | `sValues` | `longtext` |
| 5 | IN | `p_doDate` | `varchar(100)` |
| 6 | IN | `sDosIds` | `longtext` |

## Body

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

## Narrative

**Business context:** OEE / PLC integration — sealed (封存) PLC-to-ERP scan ingester. The procedure's own COMMENT marks it `20210817 封存`; production traffic now flows through `Sp_OEE_ScanInsertToERP2013`, which is the procedure that calls this one. Historically: parses PLC address/value pair strings (`sPlcAddr`, `sValues`) into machine + counter readings and writes them back to ERP production tables.

**What it does:** Accepts `sPlcAddr` and `sValues` blobs from the xlyPlc Java service (Siemens PLC reader), tokenises the per-channel values, locates the matching `elemachine`/work-order rows, and inserts/updates ERP-side counters and event rows. Sealed body is preserved for back-compat but the `2013` variant supersedes it.

**Invocation:** Called by Java `PlcToErpServiceImpl` in `xlyPlc` (assigns `String splc = "Sp_OEE_ScanInsertToERP";` then `call splc(...)`) — Siemens S7 scheduler reads PLC blocks then synchronously executes the proc per machine. Also referenced as a dispatched-call literal by `Sp_OEE_ScanInsertToERP2013`. Install scripts: `script/标版/30100101/schedule/Sp_OEE_ScanInsertToERP.sql` and the PLC variant under `plcNew/`.

Status caveat: marked sealed in body COMMENT — current deployments may route through the `2013` successor instead.
