# `Sp_plc_implementation2` (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_implementation2`'`._ ## Narrative **Business context:** 设备 / PLC 信号采集 — latest-snapshot variant of the `Sp_plc_implementation*` family (proc COMMENT: "机器运行情况(全部机器最新一条)"). Returns the most recent decoded PLC reading per machine (one row each) rather than paging through history — used for a live monitoring grid where every device shows its current state. **What it does:** Builds `Sp_plc_implementation` and `p_elemachine` temp tables the same way as the history variants; for every `elemachine WHERE iPlcNo > 0` (or the single `sMachineId` if supplied), cursors machines and pulls `LIMIT 1` from `sysdoplclog ORDER BY iIncrement DESC`, decodes the pipe slot via `Fn_split_string(sValues,'|',MOD(iPlcNo,14))`, splits by `,` into 23 metric columns including 警报灯 colour decode, 调机/生产 phase, 电表读数 (with `if(...=0,'断电',...)`), and per-stage 计数 fields. **Invocation:** Status: appears orphaned. No `gdsmodule.sProcName` binding, no form-master sSqlStr reference, no `gdsconfigcharmaster.sProcedureName` chart binding, no other-routine caller, no xly-src reference. Signature matches the paged-report calling convention but no caller wires it — candidate for maintainer audit. See `Sp_plc_implementation2_new` for the 2024-12-07 rewrite.