# `Sp_ImportSubjectAssociate_Customer` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 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_ImportSubjectAssociate_Customer`'`._

## Narrative

**Business context:** 财务 → 凭证 → 辅助核算 (sissubject) seeding — back-populates the `sissubject` accounting-subject table with one row per `elecustomer` row that doesn't yet have an associated subject. `sFormId='1'` is the subject-type code for 客户 (customer) within `sissubject`. Part of the 凭证生成 (voucher-generation) installation bundle.

**What it does:** Reads the current `MAX(iOrder)` for `sFormId='1'` scoped to brand/subsidiary, then INSERTs into `sissubject` (`sId=newId()`, `sSrcId=E.sId`, `sFormId='1'`, monotonically-incremented `iOrder`, `sThirdNo=E.sCustomerNo`) for every `elecustomer` row whose `sId` is not already linked. Idempotent — repeated runs add only newly-created customers.

**Invocation:** Status: appears orphaned in production runtime. Defined in install scripts `xly-src/script/标版/upgrade/20211115生成凭证/Sp_ImportSubjectAssociate_Customer.sql` and `xly-src/script/标版/30100101/Sp_ImportSubjectAssociate_Customer.sql` — a one-shot 凭证生成 DBA seeding bundle that's run during tenant provisioning, not wired to any form/button/gdsmodule hook or Java service. Family siblings (`_depart` sFormId=7, `_materials` sFormId=6, `_materialsclassify` sFormId=5, `_Supply` sFormId=4, `_Product` sFormId=3, `_ProductClassify` sFormId=2, `_WareHouse`) follow the same pattern.
