# `Sp_System_ReCostStructure_new` (procedure)

> @author:杨恒林
							@date:20210616 封存
							@describe: 成本结构发生变化时,需要保存当前的数据到备份表，CotOrderCostAnalysis+时分秒


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(100)` |
| 2 | IN | `sMakePerson` | `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_System_ReCostStructure_new`'`._

## Narrative

**Business context:** 成本管理 → 成本结构维护 — snapshot the active cost-analysis table when 成本结构 schema changes. Header comment (@author:杨恒林 @date:20210616 封存) says: when 成本结构 (cost framework) changes, save current data into a timestamped backup table `cotordercostanalysis<YYYYMMDDHHmmss>`. `_new` variant differs from `Sp_System_ReCostStructure` only in checking/renaming `accordercostanalysis` (not the legacy `cotordercostanalysis`) and in skipping the trailing `Sp_System_InitCurrentPeriodCost` re-initialisation call.

**What it does:** Hard-codes `p_sDbName='xlyweberp'` (one-tenant assumption) and `p_sTableName='cotordercostanalysis'+DATE_FORMAT(NOW(),'%Y%m%d%H%i%s')`. Checks `information_schema.tables` for `accordercostanalysis`; if present, executes a dynamic `ALTER TABLE accordercostanalysis rename to <p_sTableName>` via PREPARE/EXECUTE. Then re-checks and `DROP TABLE cotordercostanalysis` if it (still) exists. The post-rename `Sp_System_InitCurrentPeriodCost('2000-01-01',…)` call is commented out — leaves the schema empty.

**Invocation:** Status: appears orphaned. No `gdsmodule` binding, no form-master, no other-proc, no xly-src match. `_new` suffix and `封存` author tag mark this as a developer staging copy of `Sp_System_ReCostStructure` — likely never deployed (the hard-coded `xlyweberp` database name would fail in multi-tenant SaaS). Candidate for cleanup.
