# `sp_Qlyoutsideproducttest_calculate` (procedure)

> 发外检验单据计算过程split，前台传入数据源，经过运算处理后返回前台渲染


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sDropTableSql` | `longtext` |
| 2 | IN | `sCreateTableSql` | `longtext` |
| 3 | IN | `insertSql` | `longtext` |
| 4 | IN | `selectSql` | `longtext` |
| 5 | IN | `sFormGuid` | `varchar(100)` |
| 6 | IN | `sLoginId` | `varchar(100)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |
| 10 | OUT | `sReturn` | `longtext` |

## Body

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

## Narrative

**Business context:** 质量管理 / 发外检验 — front-end-driven "split calc" hook for the 发外检验 form. The UI hands the proc four pieces of dynamic SQL (drop / create / insert / select temp tables) plus the form id, and the proc executes them in order around a fixed business block that re-fills sample/accept/reject quantities on `*_calc_tmp` temp tables before the result is rendered back to the grid. Standard signature for the `sysbtncalctable`-style calculate hook (see `sysbtncalctable.sId / sDropTableSql / sCreateTableSql / selectSql`).

**What it does:** For each of `sDropTableSql`, `sCreateTableSql`, `insertSql`: splits the input on `;`, then `PREPARE / EXECUTE / DEALLOCATE` each statement in sequence — so the front-end can throw any temp-table DDL at it. Between insert and select, the business block populates a temp `A1(sid, iSample, iAccept, iReject, iAccept2, iReject2)` by joining `QlyOutSideProductTestSlave_calc_tmp` to `Qlyoutsideproducttestmaster_calc_tmp` and `EleTestStandardItem` where `A.dArrAuxiliaryQty BETWEEN c.iQuantityFrom AND c.iQuantityTo`; then `UPDATE QlyOutSideProductTestSlave_calc_tmp` with the matched sample/AC/RE values and `handleType='update'`. Finally executes `selectSql` (semicolon-split) and the second `sDropTableSql` to clean up.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep across all extensions). Signature matches `sysbtncalctable` calculate-hook usage where the front-end stores the per-form SQL bundle and posts the parameters via a generic action endpoint — likely invoked dynamically from Java code that reads `sysbtncalctable` by name, not present in the surveyed xly-src; candidate for maintainer audit.
