# `Sp_QlyTestWorkOrder` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sWorkOrderGuid` | `varchar(100)` |
| 2 | IN | `sSuId` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `bFilter` | `longtext` |
| 5 | IN | `sUnTaskFormId` | `varchar(100)` |
| 6 | IN | `pageNum` | `int` |
| 7 | IN | `pageSize` | `int` |
| 8 | OUT | `totalCount` | `int` |
| 9 | IN | `countCloumn` | `varchar(5000)` |
| 10 | OUT | `countMapJson` | `longtext` |
| 11 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 12 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 13 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 质量管理 — would serve a master quality-test summary keyed by 生产工单, with one row per `viw_mftworkorder` showing five inspection-pass-rate pairs (材料/发外/工序/首检/成品 = inspection count + qualified count). Master of the drill-down handled by `Sp_QlyTest`.

**What it does:** Splices `bFilter` JSON via `Fun_bFilter_toWhere`, rewrites alias prefixes on `sCustomerName`/`sProductName`, then builds dynamic-SQL `INSERT INTO P_QlyTestWorkOrder` from `viw_mftworkorder` joined to `elecustomer` and `eleproduct` (`bCheck=1 AND bInvalid=0`, grouped by `sId`). After populating the work-order rows it fans out ten correlated `UPDATE` joins, each counting matching test-master rows on `bCheck=1 AND bInvalid=0` and (for the "Result" columns) `iTestResult=0`: materials from `QlyComeMaterialsTestMaster` linked through `purpurchaseorderslave`/`purpurchaseorderDetail.sWorkOrderId`; outside-product from `Qlyoutsideproducttestmaster`; first/process inspections from `QlyProcessTestMaster` filtered by 首检 vs 工序检验 form-ids; final-product from `QlyProductTestMaster`.

**Invocation:** No `gdsconfigformmaster.sSqlStr` binding, no `gdsmodule` hook, no other routine references it, and `grep -rln` on xly-src returns nothing. Same form-report signature as `Sp_QlyTest`. Status: appears orphaned; candidate for maintainer audit.
