# Business Logic — JBSbatKKBndWdtOvrSendPstCrd.getNinshoId() [30 LOC]

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

## 1. Role

### JBSbatKKBndWdtOvrSendPstCrd.getNinshoId()

This method retrieves the authentication ID (認証ID, *ninsho-ID*) associated with a given service contract number from the database. Specifically, it queries the **Service Contract Detail (eo Optical Network)** table (`KK_T_SVKEIUW_EOH_NET`) by service contract number (`SVC_KEI_UCWK_NO`) and operational date to fetch the ISP authentication ID (`ISP_NINSHO_ID`) stored on the contract line item. The authentication ID is a credential used to authenticate with the service provider's infrastructure for tasks such as fiber-to-the-home (FTTH) provisioning, service changes, and termination processing. This method acts as a **shared utility** within the batch service layer — it is called by `updateFtthTsrckJsk()` to obtain the authentication ID required when updating FTTH communication volume overage records, and follows a standard database-read pattern: build a parameter list, execute a SQL-defined select, and extract a single field from the returned entity.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getNinshoId(svcKeiNo)"])
    STEP1["Create JBSbatCommonDBInterface param"]
    STEP2["param.setValue(svcKeiNo)"]
    STEP3["param.setValue(opeDate) x 6"]
    STEP4["executeKK_T_SVC_KEI_UCWK_KK_SELECT_069(param)"]
    STEP5["db_KK_T_SVC_KEI_UCWK.selectNext()"]
    COND{svcKeiUcwkInfo != null?}
    STEP6["ninshoId = svcKeiUcwkInfo.getString(ISP_NINSHO_ID)"]
    STEP7["ninshoId = \"\""]
    RETURN(["Return ninshoId"])

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> COND
    COND -- true --> STEP6 --> RETURN
    COND -- false --> STEP7 --> RETURN
```

**CRITICAL — Constant Resolution:**
- `JBSbatKK_T_SVKEIUW_EOH_NET.ISP_NINSHO_ID` = `"ISP_NINSHO_ID"` — the column name for the ISP authentication ID field in the `KK_T_SVKEIUW_EOH_NET` table.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcKeiNo` | `String` | Service contract number — the unique identifier for a service contract line item. Used as the primary lookup key to find the corresponding record in the Service Contract Detail (eo Optical Network) table. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.opeDate` | (inherited) | Operational date — the batch processing date used as a query parameter to scope the database select to the correct operational period. |
| `db_KK_T_SVC_KEI_UCWK` | DB entity manager | Database accessor for the `KK_T_SVC_KEI_UCWK` table — the in-memory entity manager that holds the result of the SQL select query. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKBndWdtOvrSendPstCrd.executeKK_T_SVC_KEI_UCWK_KK_SELECT_069` | - | `KK_T_SVKEIUW_EOH_NET` | Executes SQL-defined select (KK_SELECT_069) to query the service contract detail (eo optical network) table using service contract number and operational date as filter parameters. |
| R | `db_KK_T_SVC_KEI_UCWK.selectNext` | - | `KK_T_SVKEIUW_EOH_NET` | Retrieves the next row from the result set of the executed SQL select, returning a `JBSbatCommonDBInterface` containing the matched record. |
| R | `JBSbatCommonDBInterface.getString` | - | `ISP_NINSHO_ID` field | Extracts the ISP authentication ID string value from the returned entity record. |
| - | `JBSbatCommonDBInterface.setValue` | - | - | Builds the parameter list with service contract number and operational date (6 entries total). |
| - | `JBSbatCommonDBInterface.toArray` | - | - | Converts the parameter list to an object array for passing to the SQL execution method. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKBndWdtOvrSendPstCrd.updateFtthTsrckJsk | `updateFtthTsrckJsk(svcKeiNo, sendKbn)` -> `getNinshoId(svcKeiNo)` | `getString [R] KK_T_SVKEIUW_EOH_NET.ISP_NINSHO_ID`, `selectNext [R] KK_T_SVKEIUW_EOH_NET`, `executeKK_T_SVC_KEI_UCWK_KK_SELECT_069 [-] KK_T_SVKEIUW_EOH_NET` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/INIT] (L699)

> Initializes the parameter object for the database query. All parameters are set as key-value pairs in order.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param = new JBSbatCommonDBInterface()` |
| 2 | CALL | `param.setValue(svcKeiNo)` // Service contract number |
| 3 | CALL | `param.setValue(super.opeDate)` // Operational date |
| 4 | CALL | `param.setValue(super.opeDate)` // Operational date (duplicate) |
| 5 | CALL | `param.setValue(svcKeiNo)` // Service contract number (duplicate) |
| 6 | CALL | `param.setValue(super.opeDate)` // Operational date (duplicate) |
| 7 | CALL | `param.setValue(super.opeDate)` // Operational date (duplicate) |

**Block 2** — [EXEC/DB SELECT] (L716)

> Executes the SQL-defined select to query the service contract detail table. The parameter array is passed to the select method.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_069(param.getList().toArray())` // Executes SQL select on KK_T_SVKEIUW_EOH_NET |

**Block 3** — [SET/RESULT FETCH] (L718)

> Retrieves the next record from the query result set into an entity interface.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkInfo = db_KK_T_SVC_KEI_UCWK.selectNext()` // Fetch next entity row |

**Block 4** — [SET/INIT] (L720)

> Initializes the return value to an empty string before conditional extraction.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ninshoId = ""` // Default: empty string |

**Block 5** — [IF/ELSE] `(null != svcKeiUcwkInfo)` (L721)

> Checks whether the database query returned a valid record. If a record exists, extract the authentication ID; otherwise, the method returns the empty string initialized in Block 4.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ninshoId = svcKeiUcwkInfo.getString(JBSbatKK_T_SVKEIUW_EOH_NET.ISP_NINSHO_ID)` // Extract ISP authentication ID [-> ISP_NINSHO_ID="ISP_NINSHO_ID"] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiNo` | Field | Service contract number — unique identifier for a service contract line item in the telecom order system. |
| `opeDate` | Field | Operational date — the batch processing date used to scope queries to the correct operational period. |
| `ISP_NINSHO_ID` | Field | ISP authentication ID — the username/identifier used to authenticate with the Internet Service Provider's infrastructure for service provisioning. |
| `KK_T_SVKEIUW_EOH_NET` | Table | Service Contract Detail (eo Optical Network) — database table storing detailed service contract information for eo optical network services. |
| `KK_SELECT_069` | SQL Key | SQL select key — a predefined SQL query used to fetch service contract detail records by contract number and operational date. |
| `JBSbatCommonDBInterface` | Type | Common database interface — parameterized data carrier used to build parameter lists and hold database query results. |
| `db_KK_T_SVC_KEI_UCWK` | Field | Database entity manager for the `KK_T_SVC_KEI_UCWK` table — holds the result set of the executed SQL select. |
| `JBSbatKK_T_SVKEIUW_EOH_NET` | Type | Constant class — contains column name constants for the Service Contract Detail (eo Optical Network) table. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service. |
| ninsho (認証) | Japanese term | Authentication — the process of verifying identity credentials (authentication ID) to access the service provider's network management system. |
| SVC_KEI_UCWK_NO | Field | Service contract detail work number — the primary key column in the `KK_T_SVKEIUW_EOH_NET` table used to uniquely identify a service contract line item. |
