# Business Logic — JBSbatKKBandWidthOverLmtDtTst.executeKK_T_FTTH_TSRCK_JSK_KK_SELECT_002() [23 LOC]

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

## 1. Role

### JBSbatKKBandWidthOverLmtDtTst.executeKK_T_FTTH_TSRCK_JSK_KK_SELECT_002()

This method is a **data access service method** responsible for querying the FTTH (Fiber To The Home) communication volume over-limit actual performance records from the `KK_T_FTTH_TSRCK_JSK` database table. It serves as a dedicated SELECT routine within the broader batch process that identifies customers whose broadband usage has exceeded their domain-specific data cap limits (帯域制限上限通信超過通知 — "bandwidth limit exceeded communication volume notification"). The method implements the **repository/data access pattern**, acting as the persistence layer abstraction that encapsulates SQL invocation and result iteration behind a clean interface. It receives an array of bind variable values (`Object[] param`) containing the operational date, division month count, and service contract number, constructs the parameter list for the SQL query, executes the parameterized SELECT statement, and collects all returned rows into a `List<JBSbatCommonDBInterface>`. This method is called twice by the parent `execute()` method — once for the 2nd-level (middle) bandwidth tier and once for the 3rd-level (high) bandwidth tier — enabling the batch to independently retrieve over-limit records per tier.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKK_T_FTTH_TSRCK_JSK_KK_SELECT_002(params)"])
    START --> INIT["Initialize list with capacity 4"]
    INIT --> CREATE_PARAM["Create JBSbatCommonDBInterface paramList"]
    CREATE_PARAM --> SET_0["Set paramList value 0: param[0] (operational date)"]
    SET_0 --> SET_1["Set paramList value 1: param[1] (division month count)"]
    SET_1 --> SET_2["Set paramList value 2: param[2] (service contract number)"]
    SET_2 --> EXEC_SQL["Execute selectBySqlDefine with KK_SELECT_002"]
    EXEC_SQL --> FETCH_FIRST["Fetch first row via selectNext()"]
    FETCH_FIRST --> LOOP_CHECK{"resultMap is null?"}
    LOOP_CHECK -->|No| ADD_ROW["Add resultMap to result list"]
    ADD_ROW --> FETCH_NEXT["Fetch next row via selectNext()"]
    FETCH_NEXT --> LOOP_CHECK
    LOOP_CHECK -->|Yes| RETURN["Return list"]
    RETURN --> END_NODE(["End"])
```

**Key observation:** This method has no conditional branches — it executes a single linear flow: parameter binding → SQL execution → iterative row collection → return.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `Object[]` | Array of bind variable values for the SQL query. Must contain exactly 3 elements in order: (1) operational date (運用日) — the business date used for the batch run, (2) division month count (除算する月数) — the number of months over which usage is divided/calculated to determine over-limit status, (3) service contract number (サービス契約番号) — the unique identifier for the customer's service contract line. An additional 4th element (運用日) may be present per Javadoc documentation, likely used as a secondary reference date. |
| — | `db_KK_T_FTTH_TSRCK_JSK` | `JBSbatSQLAccess` | Instance field providing database access to the `KK_T_FTTH_TSRCK_JSK` table. Injected by the framework, holds the SQL execution context for parameterized queries. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `selectBySqlDefine` | — | `KK_T_FTTH_TSRCK_JSK` | Executes parameterized SQL (SQL key `KK_SELECT_002`) to read FTTH communication volume over-limit performance records |
| R | `selectNext` | — | `KK_T_FTTH_TSRCK_JSK` | Iteratively fetches the next row from the open result set returned by `selectBySqlDefine` |

**Classifications:**
- **R (Read):** `selectBySqlDefine` and `selectNext` are both read operations. The method queries the `KK_T_FTTH_TSRCK_JSK` table (FTTH communication volume over-limit actual performance table) without modifying any data. The SQL key `KK_SELECT_002` maps to a predefined SQL statement in the framework's SQL definition registry.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKBandWidthOverLmtDtTst.execute()` | `JBSbatKKBandWidthOverLmtDtTst.execute()` → `executeKK_T_FTTH_TSRCK_JSK_KK_SELECT_002(param)` | `selectBySqlDefine [R] KK_T_FTTH_TSRCK_JSK` |

**Details:**
- The method is called **directly by `execute()`** (the batch entry point) on two occasions:
  1. Line ~234: Called with `setParamFtth2nd` to retrieve 2nd-tier (middle bandwidth) over-limit records.
  2. Line ~249: Called with `setParamFtth3rd` to retrieve 3rd-tier (high bandwidth) over-limit records.
- The `execute()` method extends `JBSbatBusinessService`, which is the base class for batch processing services.
- Terminal operations from this method: `selectBySqlDefine` (Read) and `selectNext` (Read), both acting on the `KK_T_FTTH_TSRCK_JSK` table.

## 6. Per-Branch Detail Blocks

### Block 1 — INITIALIZATION (L833–L834)

> Initializes the result container with a pre-allocated capacity of 4 elements.

| # | Type | Code |
|---|------|------|
| 1 | SET | `List<JBSbatCommonDBInterface> list = new ArrayList<JBSbatCommonDBInterface>(4)` // Create result list with initial capacity 4 |

### Block 2 — PARAMETER BINDING (L836–L839)

> Creates the bind variable parameter list by extracting values from the input array and converting them to strings. This prepares the parameter structure expected by the SQL execution framework.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface()` // Create parameter container |
| 2 | EXEC | `paramList.setValue(param[0].toString())` // Set bind value 0: operational date (運用日) [-> param[0]] |
| 3 | EXEC | `paramList.setValue(param[1].toString())` // Set bind value 1: division month count (除算する月数) [-> param[1]] |
| 4 | EXEC | `paramList.setValue(param[2].toString())` // Set bind value 2: service contract number (サービス契約番号) [-> param[2]] |

### Block 3 — SQL EXECUTION (L842)

> Executes the parameterized SELECT query against the `KK_T_FTTH_TSRCK_JSK` table using the pre-configured SQL key `KK_SELECT_002`. This is the core data access operation.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_FTTH_TSRCK_JSK.selectBySqlDefine(paramList, KK_T_FTTH_TSRCK_JSK_KK_SELECT_002)` // Execute SQL select [-> KK_T_FTTH_TSRCK_JSK_KK_SELECT_002="KK_SELECT_002"] |

### Block 4 — RESULT ITERATION (L844–L850)

> Fetches the first row from the result set and iterates through all remaining rows, collecting each into the result list. This pattern handles zero-to-N results: if no records match, the loop is skipped entirely and an empty list is returned.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface resultMap = db_KK_T_FTTH_TSRCK_JSK.selectNext()` // Fetch first row from result set |
| 2 | WHILE | `while (null != resultMap)` // Iterate through all remaining rows |
| 2.1 | EXEC | `list.add(resultMap)` // Add current result row to the result list |
| 2.2 | SET | `resultMap = db_KK_T_FTTH_TSRCK_JSK.selectNext()` // Fetch the next row |
| 3 | RETURN | `return list` // Return the collected result list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service provided by K-Opticom |
| 帯域制限 (Taiiki Seigen) | Field | Bandwidth restriction — domain-specific speed/cap limits applied to customer connections |
| 通信超過 (Tsushin Chouka) | Field | Communication volume over-limit — condition where customer usage exceeds their contracted data allowance |
| 通知 (Tsuchi) | Field | Notification — alert or message sent to customers about over-limit status |
| 運用日 (Un'you-bi) | Field | Operational date — the business date used as reference for batch processing and reporting |
| 除算する月数 (Josan suruGetsusuu) | Field | Division month count — the number of months over which usage is averaged/divided to determine over-limit classification |
| サービス契約番号 (Saabisu Keiyaku Bangou) | Field | Service contract number — unique identifier for a customer's service contract line item |
| KK_T_FTTH_TSRCK_JSK | Entity | FTTH Communication Volume Over-Limit Actual Performance table — stores records of FTTH customers whose usage has exceeded bandwidth limits |
| KK_SELECT_002 | SQL Key | Predefined SQL statement key for selecting FTTH over-limit performance records, bound by operational date, division months, and contract number |
| JBSbatCommonDBInterface | Technical | Common database interface — the framework's row container for SQL result sets, providing `setValue()` for bind variable binding |
| JBSbatSQLAccess | Technical | SQL access layer — the framework class that handles parameterized SQL execution and result set iteration |
| JBSbatBusinessService | Technical | Base class for batch processing services — provides lifecycle management and common batch infrastructure |
| 2nd tier | Business term | Middle bandwidth tier — second level of domain-specific bandwidth restriction (e.g., after first alert, before third tier) |
| 3rd tier | Business term | High bandwidth tier — third and final level of bandwidth restriction applied after repeated over-limit events |
