# `Sp_DailyStatisticalSalary` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sProInParam` | `varchar(10000)` | | 2 | IN | `sLoginId` | `varchar(100)` | | 3 | IN | `sBrId` | `varchar(100)` | | 4 | IN | `sSuId` | `varchar(100)` | | 5 | OUT | `sReturn` | `varchar(1000)` | | 6 | OUT | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_DailyStatisticalSalary`'`._ ## Narrative **Business context:** 生产管理 → 工资结算 / 计件工资 — month-scope salary computation driver. For the chosen 年月 (`tYearMonth`), walks every active 日统计 row in `sissalarystructureplan` (`sCycle='1'`) and applies its `sFormulaId` to roll wage figures from `mftproductionreportslave` (and its employee split table) into per-row `dWageMoney` columns, materialising a snapshot in `mftpayrollstatementcalc` and back-writing into `mftDaySumReport`. **What it does:** Validates `sProInParam`, parses `tYearMonth` from `$.changeValue[0].tYearMonth`. Cursors `sissalarystructureplan` rows for the tenant where `sCycle='1'` ordered by `iOrder`; for each plan: 1. If `bCalcType=0` (per-team), inserts a grouped snapshot into `mftpayrollstatementcalc` from `mftproductionreportslave` for the year-month, decorates with machine/team names, then cursors back through and for each row calls `Sp_System_ReplaceField(sId, 'mftpayrollstatementcalc', 'billSlave', p_sFormulaId, @awardMoney, …)` to evaluate the formula. The dynamic UPDATE then writes the resulting money into `mftProductionReportSlave.dWageMoney` proportional to `dProcessQty`, splits it to `mftproductionreportemployee.dWageMoney` by `dProportion`, and finally rolls a per-employee total into `mftDaySumReport.dWageMoney`. 2. If `bCalcType=1` (per-employee/direct), copies the rows from `mftDaySumReport` straight into `mftpayrollstatementcalc` and updates `mftDaySumReport.dWageMoney` directly with the formula output. Any `Sp_System_ReplaceField` failure aborts via `LEAVE top` with `sCode=-1`. **Invocation:** Status: appears orphaned in production hooks. No caller in any channel — no form-master, no `gdsmodule` hook, no other routine. xly-src has install scripts at `script/标版/30100101/Sp_DailyStatisticalSalary.sql`, the doubled-name `Sp_Sp_DailyStatisticalSalary.sql`, and a customer override `script/客户/金九/Sp_DailyStatisticalSalary.sql` — confirming it has a customer-side use history (金九 印务) but no live button binding in the standard 30100101 deployment. The JSON `$.changeValue[0].tYearMonth` shape is sp_btn_action-style, so binding probably lived on a removed wage-calc button. Candidate for maintainer audit.