# `Sp_Task_GrossProfitSmallai` (procedure)

> 小ai保驾护航-企业即时毛利分析报告


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | OUT | `cardTitle` | `varchar(255)` |
| 2 | OUT | `title` | `varchar(255)` |
| 3 | OUT | `sAbstract` | `varchar(255)` |
| 4 | OUT | `cardDate` | `varchar(255)` |
| 5 | OUT | `itemMemo` | `varchar(255)` |
| 6 | OUT | `sCode` | `int` |
| 7 | OUT | `sReturn` | `longtext` |
| 8 | OUT | `sUserList` | `longtext` |
| 9 | OUT | `sUserData` | `longtext` |

## Body

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

## Narrative

**Business context:** 小ai保驾护航 — scheduled push of the daily 毛利分析 (gross-margin) digest. Member of the `Sp_Task_*` quartz-scheduled message family.

**What it does:** Defaults `sBrId/sSuId/sCode`, sets `title='今日毛利…'`, queries `Viw_MftWorkOrder` join `elecustomer` + `eleproduct` (filtered to `bCheck=1` and today's `tCreateDate`) to total `dProductMoney` / `dAllMoney` / `dSaleProfit` plus the cost breakdown (`dMasterMaterialsMoney`, `dAuxiliaryMaterialsMoney`, `dPrintBeforeMoney`, `dPrintMoney`, `dPrintAfterMoney + dPrintProductMoney`). Builds one card-list row per 工单 in the shared `Sp_Task_doTestMsg` temp table for the message template to render.

**Invocation:** Dispatched by the Quartz scheduler — `QuartzTask` (xlyFlow) calls `TaskServiceImpl.doProOne()` which executes the procedure named in the scheduler-job config, then `sendMsgDoNew(...)` pipes the OUT params + result set to the configured `sMestemplateId`. Install script `script/标版/30100101/Sp_Task_GrossProfitSmallai.sql`; no `gdsmodule`/form-master binding.
