# `Sp_Calc_sAcc_YC` (procedure)

> 质量事故报告


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iFlag` | `int` |
| 2 | IN | `iTmpCheck` | `int` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sGuid` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(5000)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 生产管理 → 生产单据 → 质量事故报告 (equipment variant) — equipment-specific quality-accident report check / uncheck. Targets `mftqualityaccidenteqpmaster` (note the `eqp` table suffix), distinct from the general `mftqualityaccidentmaster` handled by sibling `Sp_Calc_sAcc`.

**What it does:** Validates `sGuid`. Reads master `bInvalid, tCreateDate`. Refuses if `bInvalid=1`. Period-locking via `SysSystemSettings.CkxIntervalMonthModifyBill=0 → sysaccountperiod.bFrozen` (same as sibling). With `iFlag=1`: refuses if already checked; counts attached `filfilemanage` images for the bill (the count is stored in `p_iImageCount` but never read — preparatory hook for an image-required guard); then sets master `bCheck=1, sStatus=1, sCheckPerson=sLoginId, tCheckDate=NOW()`. With `iFlag=0`: symmetric uncheck guarded on `bCheck=0` (returns `sNoCanCheckBybUnCheck`).

**Invocation:** Status: appears orphaned in this DB instance. No `gdsmodule.sProcName/sCalcProName`, form-master, routine, or xly-src caller. The matching `设备异常单` module (sId `101251240115016045682733390`) is bound to `Sp_Calc_sAcc` instead — `Sp_Calc_sAcc_YC` looks intended for that module but is not currently wired up. Candidate for maintainer audit.

Flag: image-count read with no consuming branch — dead-code or unfinished image-requirement gate.
