# `Sp_Apply_Flow_MachineFix` (procedure)

> 流程启动前调用-设备维修申请


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sFormGuid` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sSrcNo` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sTableParams` | `longtext` |
| 6 | OUT | `sSrcReportData` | `longtext` |
| 7 | OUT | `sTableParamsValue` | `longtext` |
| 8 | OUT | `sReturn` | `varchar(4000)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 设备维修 → 设备管理 (catalog header: "流程启动前调用-设备维修申请") — per-form workflow-apply data builder backing the 维修申请 / 设备报修 单据 (form `192116811124916389453432110` / `101251240115016076506222750` referenced in the commented-out report-payload block). One of the per-form `Sp_Apply_Flow_<Form>` procs that the workflow engine invokes before kicking off the maintenance-approval chain.

**What it does:** Resolves the制单人's 二级部门 (department-head) name list by chaining `eptmachinerepairfixmaster.sMakePerson` → `eleemployee.sDepartId` → `sisdepart.sEmployeeId` → `eleemployee.sEmployeeName`, into `p_OneFlow`. Builds `p_sShowMemo` by aggregating `eptmachinerepairfixslave` rows into `'故障类别:{sMaintenanceCycle}➜故障描述:{sMaintainContent}'` joined by newline. Emits `sTableParams` (column-label JSON for 维修申请单/设备名称/报修申请人/报修部门/故障明细/故障描述) and `sTableParamsValue` (JSON of master values joined across `eptmachinerepairfixmaster`/`eleemployee`/`sisdepart`/`elemachine` + `OneFlow` + `iOut` flag — `iOut=0` when `sMachineId='17030614920003057848750279902700'`, else `1`, hardcoded machine sId).

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` where `sApplyProName` is read from `gdsmoduleflow.sApplyProName` on the 维修申请 workflow config row. `gdsmoduleflow` is empty in this database — workflow configs are tenant-provisioned per deployment.

Flags: `iOut` machine-sId branch hardcodes a tenant-specific 设备 GUID (`17030614920003057848750279902700`) — if cloned to another deployment the predicate becomes a no-op. The output JSON sets the `"sDeptName"` key twice (second overwrites the first — likely paste error).
