# `Sp_EquipmentOutput_Machine` (procedure)

> 印刷机台汇总达成统计


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `varchar(100)` |
| 2 | IN | `tEndDate` | `varchar(100)` |
| 3 | IN | `sMachineName` | `varchar(100)` |
| 4 | IN | `sAttribute` | `varchar(100)` |
| 5 | IN | `sSearchType` | `varchar(100)` |
| 6 | IN | `sLoginId` | `varchar(100)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | IN | `bFilter` | `varchar(5000)` |
| 10 | IN | `pageNum` | `int` |
| 11 | IN | `pageSize` | `int` |
| 12 | OUT | `totalCount` | `int` |
| 13 | IN | `countCloumn` | `varchar(5000)` |
| 14 | OUT | `countMapJson` | `longtext` |
| 15 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 16 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 17 | IN | `sGroupby_group_sql` | `varchar(5000)` |
| 18 | OUT | `sColumnNameConfig` | `longtext` |

## Body

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

## Narrative

**Business context:** 生产管理 → 生产运营报表 → 印刷产量达标率 — 印刷机台汇总达成统计. Per-printing-machine shift-by-shift report comparing planned vs actual production output across `mftworkorderslave` planning, `mftworkordercontrolslave` 排程, and `mftproductionreportslave` actuals over a date window. The companion `Sp_EquipmentOutput_Machine_YH` runs the same logic for 印后 (post-press) machines.

**What it does:** Defaults `tStartDate` to NOW-2 days and `tEndDate` to NOW. Builds temp table `Sp_EquipmentOutput_Machine_Table` populated from `elemachine WHERE sMachineType=1` (印刷机) split by `sWorkType` (1=single-shift 白班, 2=two-shift 白班+晚班), filtered by `sMachineName`/`sAttribute` LIKE. Builds `Sp_EquipmentOutput_Plan_Table` aggregating `dPlanQty` and `dProcessQty` per machine/shift from the planning slave tables. Assembles dynamic column-config strings via `Fun_get_show_config_hb` / `Fun_get_show_config_ys40` (paints the "合计" row pink-on-green). Per-day expands across the date range so each column is `<date>_白班/<date>_晚班`. Final paginated rowset is delivered through `CALL Sp_Outstanding_Query` / `Sp_Do_UpdateByPageSizeBefore` and the column metadata is returned via OUT `sColumnNameConfig`.

**Invocation:** Bound as the data source of the 印刷产量达标率 form (sId `1921168137117916508517550840`) under module 生产管理 → 生产运营报表 → 印刷产量达标率 (gdsmodule sId `1921168137117916508517546250`). Loaded when the user opens the report; the form-binding dispatcher reads the proc name from `gdsconfigformmaster`. Other DB callers: `Sp_CostAccount_WorkCenterToOperation` reuses the temp-table shape, and `Sp_EquipmentOutput_Machine_YH` is the 印后 counterpart. xly-src ships `script/标版/30100101/schedule/Sp_EquipmentOutput_Machine.sql` (alongside its `_YH` and `Sp_CostAccount_WorkCenterToOperation.sql` peers in the same `schedule/` directory).
