# `Sp_Apply_Flow_QualityaccidentCL` (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_QualityaccidentCL`'`._

## Narrative

**Business context:** 质量事故 (material-loss variant — 流程启动前调用-质量事故报告材料) — workflow-apply data builder for the material-related quality-accident approval flow on `mftqualityaccidentmaster`. Builds an eight-tier approver roster plus two loss-threshold flags driving routing.

**What it does:** Resolves tiers from `eleemployee.iPosition`: 18=品质经理, 6=物控经理, 5=供应链部长, 11=财务经理, 1=总经理, 38=副董执行董事, 34=国内事业副总, 39=董事长. Reads `dLoseMoney` from `mftqualityaccidentmaster`: `p_iOut=1` when loss>0, `p_iOut1=1` when loss>5000 (5k-CNY senior-review threshold). Renders `sReprint` (处理方式) into 特采/退货补送/退货完成/报废 labels and emits supply/material display labels plus `iCigPack` (烟包 indicator) into `sTableParamsValue`.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB — workflow configs tenant-provisioned per deployment).

Flag: 烟包 (`p_iCigPack`) declaration + lookup commented out — `iCigPack` is emitted directly from master column `A.iCigPack` instead. Loose stub.
