# `Sp_MacRepClaim_BtnEventClaim` (procedure)

> 设备维修任务认领


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 设备管理 → 设备维修 — 设备维修任务认领 button on the 设备报修 grid. A 维修员 claims an open 报修 task; once claimed it can't be re-claimed until released.

**What it does:** Parses `$.params[0].value[*].sId` from `sProInParam`. For each id, reads `EptMachineRepairFixMaster.bClaimed` — if already 1, returns `sCode=-1` with `sTaskClaimed` ("该任务已被认领") via `Fun_Sis_GetConst` and exits. Otherwise `UPDATE EptMachineRepairFixMaster` sets `bClaimed=1`, `sClaimPerson=sMakePerson`, `tClaimDate=NOW()`, `sClaimPersonId=(SELECT sEmployeeId FROM sftlogininfo WHERE sUserName=sMakePerson)` for each selected row.

**Invocation:** Dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — the 设备报修 grid's 认领 toolbar button names this proc by string. Inverse: `Sp_MacRepClaimCancel_BtnEventClaimCancel`. Re-assignment variant: `Sp_MacRepClaim_BtnEventClaimZP` (指派, the dispatcher reassigns to a chosen 维修员 instead of self-claim).
