# `Sp_chart_MonthProfit` (procedure)

> PLC数据同步


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sLoginId` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `bFilter` | `varchar(5000)` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 财务图表分析 → 图表分析 → 决策支持 — the dashboard card 销售VS标准成本 月度趋势分析 plots, per month, the brand's checked work-order sales revenue against summed standard cost so finance can spot margin drift over time.

**What it does:** Joins `mftworkordermaster` (filtered to `bCheck = 1` for the current `sBrandsId`/`sSubsidiaryId`) to a `mftworkorderslave` aggregate of `dProductMoney`, groups by `date_format(tCreateDate,'%Y%m')`, scales totals by 0.001 (千元), and emits a JSON payload with two series — `销售额` and `标准成本` — in the chart-renderer's `{data, xUnit, yUnit}` shape.

**Invocation:** Bound to `gdsconfigcharmaster` row `15934049720005097053483739309000` (sCharType `sBrokenLine`) under module 财务图表分析; the chart-rendering layer calls procedures listed in `sProcedureName` to populate dashboard cards. Despite the routine's `COMMENT 'PLC数据同步'`, the body is unrelated to PLC sync — the comment is a leftover copy/paste.
