# Business Logic — JBSbatKKBndWdtOvrSendMl.getMltNinshoId()

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKBndWdtOvrSendMl` |
| Layer | Service (Batch Service Component) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKBndWdtOvrSendMl.getMltNinshoId()

This method retrieves the **multi-session authentication ID** (`MLTISE_NINSHO_ID`) from the **Operation Service Contract** table (`KK_T_OP_SVC_KEI`) for a given service contract number. It is a private utility method used during the FTTH communication volume excess notification batch processing flow, specifically within `updateFtthTsrckJsk()`, which handles both immediate notifications (`SEND_KBN_JISHI`) and warning notifications (`SEND_KBN_YOKOKU`).

The method follows a **query-and-extract** pattern: it prepares a parameter set containing the service contract number, operation date, and a fixed service code (`"B015"`), delegates the database query to `executeKK_T_OP_SVC_KEI_KK_SELECT_054()`, fetches the resulting row via `selectNext()`, and extracts the multi-session authentication ID. If no matching record is found, it safely returns an empty string rather than throwing an exception, making it a defensive query utility.

The multi-session authentication ID is a telecom-domain credential used to identify and authorize operations associated with a specific service contract across multiple concurrent sessions. This is distinct from the standard ISP authentication ID (`ISP_NINSHO_ID`), which is obtained by the companion method `getNinshoId()`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getMltNinshoId(svcKeiNo)"])
    CREATE_PARAM["Create JBSbatCommonDBInterface param"]
    RESET_PARAM["Reset param = new JBSbatCommonDBInterface()"]
    SET_SVC_KEI_NO["Set svcKeiNo value"]
    SET_OPE_DATE_1["Set super.opeDate value"]
    SET_SVC_CD["Set svcKeiCd = B015"]
    SET_OPE_DATE_2["Set super.opeDate value"]
    EXEC_SELECT["executeKK_T_OP_SVC_KEI_KK_SELECT_054()"]
    FETCH_ROW["db_KK_T_OP_SVC_KEI.selectNext()"]
    CHECK_RESULT{"opSvcKeiInfo != null?"}
    INIT_MLT["mltiNinshoId = empty string"]
    GET_MLT_ID["mltiNinshoId = opSvcKeiInfo.getString(MLTISE_NINSHO_ID)"]
    RETURN_MLT["Return mltiNinshoId"]

    START --> CREATE_PARAM --> RESET_PARAM --> SET_SVC_KEI_NO --> SET_OPE_DATE_1 --> SET_SVC_CD --> SET_OPE_DATE_2 --> EXEC_SELECT --> FETCH_ROW --> CHECK_RESULT
    CHECK_RESULT -->|"true"| GET_MLT_ID --> RETURN_MLT
    CHECK_RESULT -->|"false"| RETURN_MLT
    INIT_MLT --> CHECK_RESULT
```

**CRITICAL — Constant Resolution:**
- `KK_T_OP_SVC_KEI_KK_SELECT_054` = `"KK_SELECT_054"` (SQL define name for the service contract query) `[-> KK_T_OP_SVC_KEI_KK_SELECT_054="KK_SELECT_054" (JBSbatKKBndWdtOvrSendMl.java:82)]`
- `D_TBL_NAME_KK_T_OP_SVC_KEI` = `"KK_T_OP_SVC_KEI"` (database table name) `[-> D_TBL_NAME_KK_T_OP_SVC_KEI="KK_T_OP_SVC_KEI" (JBSbatKKBndWdtOvrSendMl.java:70)]`
- `MLTISE_NINSHO_ID` = `"MLTISE_NINSHO_ID"` (multi-session authentication ID column) `[-> MLTISE_NINSHO_ID="MLTISE_NINSHO_ID" (JBSbatKK_T_OPSVKEI_ISP.java:55)]`
- Service code `"B015"` is a literal string representing the operation service code for multi-session authentication ID queries.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcKeiNo` | `String` | **Service contract number** — the unique identifier for a customer's service contract line item. Used as the primary lookup key to retrieve the associated operation service contract record from the `KK_T_OP_SVC_KEI` table. |

**External/instance state read by this method:**

| Source | Type | Business Description |
|--------|------|---------------------|
| `super.opeDate` | `String` (inherited field) | **Operation date** — the batch processing execution date used as a query condition to retrieve the correct service contract record for the current batch run. |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKBndWdtOvrSendMl.executeKK_T_OP_SVC_KEI_KK_SELECT_054` | KK_T_OP_SVC_KEI_KK_SELECT_054 | `KK_T_OP_SVC_KEI` | Executes the KK_SELECT_054 SQL define to query the Operation Service Contract table by service contract number, operation date, service code, and operation date. |

**CRUD Classification Detail:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `executeKK_T_OP_SVC_KEI_KK_SELECT_054` | KK_T_OP_SVC_KEI_KK_SELECT_054 | `KK_T_OP_SVC_KEI` | Queries the Operation Service Contract table to retrieve the record matching the given service contract number, operation date, and service code "B015". Uses `selectBySqlDefine()` with `KK_SELECT_054` SQL template. |
| R | `db_KK_T_OP_SVC_KEI.selectNext()` | - | `KK_T_OP_SVC_KEI` | Fetches the next row from the pre-executed SELECT query result set into a `JBSbatCommonDBInterface` object. |

**SC Code derivation:**
- The method `executeKK_T_OP_SVC_KEI_KK_SELECT_054` maps to the SQL define name `KK_SELECT_054` and targets the table `KK_T_OP_SVC_KEI`.
- This is an internal SELECT method — no external SC (Service Component) code is used; it directly calls `db_KK_T_OP_SVC_KEI.selectBySqlDefine()`.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `updateFtthTsrckJsk` | `JBSbatKKBndWdtOvrSendMl.updateFtthTsrckJsk()` → `getMltNinshoId(svcKeiNo)` | `executeKK_T_OP_SVC_KEI_KK_SELECT_054 [R] KK_T_OP_SVC_KEI` |

**Call chain detail:**
1. `updateFtthTsrckJsk(String svcKeiNo, String sendKbn)` — When `sendKbn` equals `"1"` (immediate notification, `SEND_KBN_JISHI`), this method retrieves both the standard ISP authentication ID and the multi-session authentication ID, then sets both into the `setMap` for updating the FTTH communication volume excess record (`KK_T_FTTH_TSRCK_JSK`). The call occurs at: `getMltNinshoId(svcKeiNo)`.

**Terminal operations reached from this method:**
- `executeKK_T_OP_SVC_KEI_KK_SELECT_054 [R] KK_T_OP_SVC_KEI` — reads the operation service contract record.
- `db_KK_T_OP_SVC_KEI.selectNext() [R] KK_T_OP_SVC_KEI` — retrieves the result row.
- `JBSbatCommonDBInterface.getString() [R]` — extracts `MLTISE_NINSHO_ID` from the result.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET / INITIALIZATION] `(parameter setup)` (L~1140)

> Initializes the parameter container for the database query. The first `param` creation is immediately discarded and recreated — this is a redundant initialization that should be cleaned up.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param = new JBSbatCommonDBInterface();` // redundant initial allocation (later discarded) |
| 2 | EXEC | `// Comment: アクションサービス契約からマルチセッション用認証IDを取得する` ("Retrieve multi-session authentication ID from the operation service contract") [-> Javadoc] |
| 3 | SET | `param = new JBSbatCommonDBInterface();` // actual parameter object for query |
| 4 | EXEC | `param.setValue(svcKeiNo);` // Set service contract number [-> Parameter svcKeiNo] |
| 5 | EXEC | `param.setValue(super.opeDate);` // Set operation date [-> Instance field super.opeDate] |
| 6 | EXEC | `param.setValue("B015");` // Set operation service code B015 [-> Literal string "B015"] |
| 7 | EXEC | `param.setValue(super.opeDate);` // Set operation date again [-> Instance field super.opeDate] |

**Block 2** — [CALL] `(database query execution)` (L~1146)

> Delegates the actual SQL SELECT to the private execute method, which internally builds a parameter list and calls `selectBySqlDefine()` on the `db_KK_T_OP_SVC_KEI` SQL access object.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_OP_SVC_KEI_KK_SELECT_054(param.getList().toArray());` // Invokes KK_SELECT_054 SQL on KK_T_OP_SVC_KEI table [-> KK_T_OP_SVC_KEI_KK_SELECT_054="KK_SELECT_054" (JBSbatKKBndWdtOvrSendMl.java:82), -> D_TBL_NAME_KK_T_OP_SVC_KEI="KK_T_OP_SVC_KEI" (JBSbatKKBndWdtOvrSendMl.java:70)] |

**Block 3** — [SET / FETCH] `(retrieve result row)` (L~1148)

> Fetches the next row from the pre-executed query result set.

| # | Type | Code |
|---|------|------|
| 1 | SET | `opSvcKeiInfo = db_KK_T_OP_SVC_KEI.selectNext();` // Retrieves next row into JBSbatCommonDBInterface [-> db_KK_T_OP_SVC_KEI (JBSbatKKBndWdtOvrSendMl.java:96)] |

**Block 4** — [SET / INITIALIZE] `(return variable)` (L~1150)

> Initializes the return variable with a default empty string to handle the null-result case.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mltiNinshoId = "";` // Default empty string when no matching record |

**Block 5** — [IF / CONDITIONAL] `(null check on result)` (L~1151)

> Checks whether the database query returned a valid record. If a record exists, extracts the multi-session authentication ID; otherwise, the empty string default is returned.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (null != opSvcKeiInfo)` [-> Condition: result row is non-null] |

**Block 5.1** — [ELSE-IF / NESTED] `(extract ID from result)` (L~1153)

> Extracts the multi-session authentication ID field from the query result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mltiNinshoId = opSvcKeiInfo.getString(JBSbatKK_T_OPSVKEI_ISP.MLTISE_NINSHO_ID);` // Extract multi-session authentication ID [-> MLTISE_NINSHO_ID="MLTISE_NINSHO_ID" (JBSbatKK_T_OPSVKEI_ISP.java:55)] |

**Block 6** — [RETURN] `(return to caller)` (L~1156)

> Returns the multi-session authentication ID — either the extracted value or the empty string default.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return mltiNinshoId;` // Returns multi-session authentication ID or empty string |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiNo` | Field | Service contract number — the unique identifier for a customer's service contract line item in the telecom billing system. |
| `MLTISE_NINSHO_ID` | Field | Multi-session authentication ID — a credential used to authorize operations across multiple concurrent sessions for a given service contract. Stored in the `KK_T_OP_SVC_KEI` table. |
| `ISP_NINSHO_ID` | Field | ISP authentication ID — the standard (single-session) authentication ID for a service contract, obtained by the companion method `getNinshoId()`. |
| `opeDate` | Field | Operation date — the batch processing execution date, inherited from the parent class. Used as a query condition to retrieve records for the current batch run. |
| `KK_T_OP_SVC_KEI` | Table | Operation Service Contract table — stores operational data for service contracts, including authentication IDs used during batch notifications. |
| `KK_T_FTTH_TSRCK_JSK` | Table | FTTH Communication Volume Excess Record table — stores FTTH over-usage records, including both ISP and multi-session authentication IDs for notification processing. |
| `KK_SELECT_054` | SQL Define | SQL query template (define name) for selecting an Operation Service Contract record by service contract number, operation date, and service code. |
| `"B015"` | Constant | Service code literal — identifies the operation service type for multi-session authentication ID retrieval in the `KK_T_OP_SVC_KEI` table. |
| `SEND_KBN_JISHI` | Constant | Immediate notification kind code — when the FTTH excess notification is sent immediately (actual/immediate dispatch). |
| `SEND_KBN_YOKOKU` | Constant | Warning notification kind code — when the FTTH excess notification is sent as a warning/advance notice. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service. The batch processing monitors communication volume against limits. |
| `KK_T_SVC_KEI` | Table | Service Contract table — base table storing primary service contract data including pricing code (`PCRS_CD`) and pricing plan code (`PPLAN_CD`). |
| `JBSbatCommonDBInterface` | Class | Common database interface — a parameter/result container used throughout the batch framework for building query parameter lists and holding SELECT results. |
| `JBSbatSQLAccess` | Class | SQL access wrapper — provides `selectBySqlDefine()` and `selectNext()` methods for executing parameterized SQL queries against KK-prefixed database tables. |
| Multi-session authentication | Business term | A telecom authentication mechanism that allows a single service contract to be referenced across multiple concurrent sessions, used in FTTH excess notification batch processing. |
| `svcKeiUcwkNo` | Field | Service detail work number — an internal tracking identifier for service contract line items. |

---
