# `Sp_plc_implementation` (procedure)

> 机器运行情况


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sMachineId` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `tStartDate` | `varchar(100)` |
| 5 | IN | `tEndDate` | `varchar(100)` |
| 6 | IN | `pageNum` | `int` |
| 7 | IN | `pageSize` | `int` |
| 8 | OUT | `totalCount` | `int` |
| 9 | IN | `countCloumn` | `varchar(5000)` |
| 10 | OUT | `countMapJson` | `longtext` |
| 11 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 12 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 13 | IN | `sGroupby_group_sql` | `varchar(5000)` |
| 14 | OUT | `sCode` | `int` |
| 15 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 设备 / PLC 信号采集 — paged equipment-running-status report (proc COMMENT: "机器运行情况"). Reads the raw PLC log table `sysdoplclog`, decodes the pipe/comma-delimited `sValues` payload via `Fn_split_string`, and explodes one row per machine into 31 typed metric columns (合格数/不合格数/PH/电导率/工单号/班组/警报灯/原纸放卷计数 …) ready for a grid. Restricted to `iPlcNo < 3` machines (first signal-group only) — companion `Sp_plc_implementation1` handles `iPlcNo > 2`.

**What it does:** Builds two temp tables (`Sp_plc_implementation` for output, `p_elemachine` for the machine slice), populates `p_elemachine` from `elemachine` filtered by `sMachineId` or `iPlcNo < 3 AND iPlcNo > 0`, then cursors each machine reading the top-N rows of `sysdoplclog WHERE iSemens=p_iSemens AND sTaskRes<>''` paged by `LIMIT p_index,pageSize`. For each row, computes `p_iVz = MOD(iPlcNo,14)` and uses `Fn_split_string(sValues,'|',p_iVz)` to pick this machine's slot inside the merged payload, then splits that slot by `,` to produce 23 typed metrics including `sQty10` 调机/生产 phase flag and 警报灯 colour decode.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName` binding, no `gdsconfigformmaster` sSqlStr/sConfigSqlStr reference, no `gdsconfigcharmaster.sProcedureName` chart binding, no other-routine caller, no Java/MyBatis reference. Only install script `xly-src/script/标版/30100101/Sp_plc_implementation.sql` ships it. The signature matches the paged-report calling convention (pageNum/pageSize/totalCount/countMapJson/bFilter-style), so likely a former report data-source whose form-master was deprovisioned — candidate for maintainer audit.
