# `Sp_Manufacture_MftWorkOrderAround` (procedure)

> 订单(工单)执行情况


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iType` | `int` |
| 2 | IN | `sStatistics` | `varchar(100)` |
| 3 | IN | `tStartDate` | `datetime` |
| 4 | IN | `tEndDate` | `datetime` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `sLoginId` | `varchar(100)` |
| 8 | IN | `bFilter` | `varchar(5000)` |
| 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_Manufacture_MftWorkOrderAround`'`._

## Narrative

**Business context:** 生产管理 — 订单(工单)执行情况 cross-document tracking report. One row per work-order (or related sales-order, per `iType` / `sStatistics`), with companion columns showing what has happened around it: quotation, sales order, production report, semi-good in-store, delivery notify, delivery, reject, sales-checking, invoice, receipt. Lets planners see, for a 工单, whether the order has been quoted, reported, delivered, billed and paid.

**What it does:** Allocates temp table `p_Tmp_Viw_MftWorkOrderRound`, then `INSERT INTO` it from `Viw_MftWorkOrder` (the base work-order list) filtered by `tStartDate..tEndDate` and `sLoginId` permissions. For each row it left-joins / updates the cross-flow totals using `MftProductionPlanSlave`, `Viw_MftProductionReport`, `Viw_PitProductInStore`/`PitProductInStoreSlave`, `SalDeliverNotifySlave`, `SalDeliverGoodsSlave`, `SalRejectGoodsSlave`, `Viw_SalSalesChecking`/`SalSalesCheckingSlave`, `Viw_SalSalesInvoice`/`SalSalesInvoiceSlave`, `CahReceiptSlave`, `QuoQuotationMaster`, `Viw_SalSalesOrder`. `iType` switches the document axis. Pages out via `CALL Sp_Outstanding_Query` with `bFilter`/`pageNum`/`pageSize`/`countCloumn`/`sGroupby_*`.

**Invocation:** Standard form-master report-proc signature, but no `gdsconfigformmaster.sSqlStr` row in the live DB currently binds it. Install script is `xly-src/script/标版/30100101/Sp_Manufacture_MftWorkOrderAround.sql` plus a customer-override `xly-src/script/客户/千彩/Sp_Manufacture_MftWorkOrderAround.sql`. Likely loaded by a 订单(工单)执行情况 report form whose sSqlStr was migrated out — verify the matching form's binding before assuming the proc is dead.
