# `Sp_PC_FirstInspection` (procedure) > @author:zhucx @date:20211108 封存 @describe: PC 质量管理-过程检验PQC-首检任务列表/ 移动端 - 过程首检 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `iState` | `int` | | 2 | IN | `sLoginId` | `varchar(100)` | | 3 | IN | `sMachineId_s` | `varchar(100)` | | 4 | IN | `sProceeAllMachine` | `varchar(10)` | | 5 | IN | `sSuId` | `varchar(100)` | | 6 | IN | `sBrId` | `varchar(100)` | | 7 | IN | `bFilter` | `longtext` | | 8 | IN | `sUnTaskFormId` | `varchar(100)` | | 9 | IN | `pageNum` | `int` | | 10 | IN | `pageSize` | `int` | | 11 | OUT | `totalCount` | `int` | | 12 | IN | `countCloumn` | `varchar(5000)` | | 13 | OUT | `countMapJson` | `longtext` | | 14 | IN | `sFilterOrderBy` | `varchar(5000)` | | 15 | IN | `sGroupby_select_sql` | `varchar(5000)` | | 16 | IN | `sGroupby_group_sql` | `varchar(5000)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_PC_FirstInspection`'`._ ## Narrative **Business context:** 质量管理 → 过程质量控制(PQC) → 首检任务列表 and 移动端管理 → 现场 → 功能操作 → 过程首检 / 印刷大检 — paged data source for the 首检 (first-article inspection) task list, both desktop and mobile. The body COMMENT marks the routine `20211108 封存` (sealed) — surviving in DB to back legacy form bindings but flagged for retirement. **What it does:** Builds `p_Tmp_ProductionReport` with the work-order/process/machine/customer/product columns plus the three 首检 timestamps (`tFirst1/2/3Inspection`). Reads `SysSystemSettings.CkxProcessFilter` and, when active and `sLoginId` is not sysadmin, calls `Fun_GetLookProcess` to scope to the user's allowed processes. Restricts to `mftProductionPlanSlave A WHERE A.dProcessQty - A.dProductionReportQty > 0 AND A.sState = 2 AND A.bFirst3Inspection = 0` and to processes that own a 首检 test-standard (`EleTestStandard.sFormId='12012615914116370215408310'`). Computes `tFirstInspectionTime` as the latest non-empty first-inspection timestamp via nested `CASE WHEN TIMESTAMPDIFF(MINUTE,...) > 0`. Enriches with `eleprocess.sProcessName` and the matching `EleTestStandard.sTestName`/`sId`, then orders by `iSort,iOrder` and pages with `LIMIT 0,pageSize`. **Invocation:** Bound as the data-source of three forms via `gdsconfigformmaster.sSqlStr` — 首检任务列表 `gfm.sId=12012615914116372413380860` under 过程质量控制(PQC) → 质量管理, plus 过程首检 `12012615914116373903372280` and 印刷大检 `101801153119616509369924030` under 移动端管理 → 现场 → 功能操作. Install scripts: `script/标版/30100101/Sp_PC_FirstInspection.sql` and a perf patch at `script/标版/20210323/optimizeprocedure.sql`. Status caveat: header `封存` flag — verify whether the active forms still resolve to this proc or to a successor before relying on changes.