# Business Logic — JBSbatKKAdHenkoHoyuDataChstuMan.terminal() [21 LOC]

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

## 1. Role

### JBSbatKKAdHenkoHoyuDataChstuMan.terminal()

The `terminal()` method serves as the **business service termination handler** (業務サービス終了処理) for the `JBSbatKKAdHenkoHoyuDataChstuMan` batch processing component. This class is responsible for extracting and managing **modified address master record data** (住所マスタ最新レコードデータ抽出部品) — specifically, it operates on changed target address code work tables to extract and process updated address information from the modified address master table.

The method implements the **cleanup/teardown pattern** within the batch service lifecycle. In this enterprise batch architecture, each business service class follows a structured lifecycle: initialization (`init()`), main processing (`execute()`), and termination (`terminal()`). The `terminal()` method is the final step in this lifecycle, ensuring all database access resources opened during the processing phase are properly released.

Its **role in the larger system** is as a resource manager within the `eo` customer base system (`eo顧客基盤システム`). The class extends `JBSbatBusinessService`, which provides the standard batch service template. As a batch-only service (located in the `koptBatch` module), it is invoked during scheduled batch jobs that process address change/registration workflows. The method has no parameters and is a void-returning cleanup method, making it a straightforward resource management endpoint.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal"])
    STEP1["Close db_CHGTGAD_CD_WK"]
    STEP2["Close db_CHG_AD_JGRTWK"]
    STEP3["Close db_CK_T_CUST"]
    STEP4["Close db_CK_T_CUST_KOJIN"]
    STEP5["Close db_KK_T_KKTK_SVC_KEI"]
    STEP6["Close db_KK_T_OPSVKEI_TV"]
    STEP7["Close db_KK_T_SEIKY_KEI"]
    STEP8["Close db_KU_T_KOJIAK"]
    STEP9["Close db_TU_T_DNWACHOMSK_NYO"]
    SKIP["Skipped: db_TU_T_BMP_KOJI, db_TU_T_DOBANITEN - ANK-4494-00-00"]
    END_NODE(["Return void / Next"])

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> STEP6 --> STEP7 --> STEP8 --> STEP9 --> END_NODE
```

**Processing description:**

1. The method executes a sequential chain of **database access object (DB Access Object) cleanup calls**. Each call invokes `close()` on a `JBSbatSQLAccess` instance, releasing the underlying database resources (connections, statements, result sets) allocated during the initialization phase.

2. The cleanup operates on **9 active database connections** covering work tables, customer master tables, service detail tables, settlement tables, and watchlist registration tables.

3. **2 database connections are commented out** (`db_TU_T_BMP_KOJI`, `db_TU_T_DOBANITEN`) due to the **ANK-4494-00-00** change (「eo定期」双方向番号対応), which removed dual-direction phone number support. These lines are preserved as commented code for reference.

4. All calls are unconditional sequential operations with no branching — the method follows a deterministic linear execution path from initialization to completion.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates entirely on instance-level database access objects that were initialized during the `init()` phase of the batch service lifecycle. |

**Instance fields accessed by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_CHGTGAD_CD_WK` | `JBSbatSQLAccess` | Database access to `KK_T_CHGTGAD_CD_WK` (Changed Target Address Code Work table) — tracks address code changes in progress |
| `db_CHG_AD_JGRTWK` | `JBSbatSQLAccess` | Database access to `CHG_AD_JGRTWK` (Change Address Joint Work table) — stores address change joint processing data |
| `db_CK_T_CUST` | `JBSbatSQLAccess` | Database access to `CK_T_CUST` (Customer Master table) — customer account information |
| `db_CK_T_CUST_KOJIN` | `JBSbatSQLAccess` | Database access to `CK_T_CUST_KOJIN` (Customer Individual table) — individual customer data |
| `db_KK_T_KKTK_SVC_KEI` | `JBSbatSQLAccess` | Database access to `KK_T_KKTK_SVC_KEI` (KK Customer Service Detail table) — service detail/line item data |
| `db_KK_T_OPSVKEI_TV` | `JBSbatSQLAccess` | Database access to `KK_T_OPSVKEI_TV` (Operation Service Detail TV table) — service detail table view |
| `db_KK_T_SEIKY_KEI` | `JBSbatSQLAccess` | Database access to `KK_T_SEIKY_KEI` (Settlement Detail table) — billing/settlement line item data |
| `db_KU_T_KOJIAK` | `JBSbatSQLAccess` | Database access to `KU_T_KOJIAK` (Individual Account table) — individual account information |
| `db_TU_T_DNWACHOMSK_NYO` | `JBSbatSQLAccess` | Database access to `TU_T_DNWACHOMSK_NYO` (Download Watch Registration Input table) — download watchlist registration input data |
| `db_TU_T_BMP_KOJI` | `JBSbatSQLAccess` | **Commented out** (ANK-4494-00-00) — previously accessed `TU_T_BMP_KOJI` (BMP Old Record table) |
| `db_TU_T_DOBANITEN` | `JBSbatSQLAccess` | **Commented out** (ANK-4494-00-00) — previously accessed `TU_T_DOBANITEN` (Alternate Store table) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JACbatDataBnktUtil.close` | JACbatDataBnkt | - | Calls `close` in `JACbatDataBnktUtil` |
| - | `JACbatParamUtil.close` | JACbatParam | - | Calls `close` in `JACbatParamUtil` |
| - | `JACbatSchdlUtil.close` | JACbatSchdl | - | Calls `close` in `JACbatSchdlUtil` |
| - | `JBSbatCHChangeGroupKei.close` | JBSbatCHChangeGroupKei | - | Calls `close` in `JBSbatCHChangeGroupKei` |
| - | `JBSbatKKPrcIfCommon.close` | JBSbatKKPrcIfCommon | - | Calls `close` in `JBSbatKKPrcIfCommon` |
| - | `db_CHGTGAD_CD_WK.close` | JBSbatSQLAccess | KK_T_CHGTGAD_CD_WK | Closes database access to Changed Target Address Code Work table |
| - | `db_CHG_AD_JGRTWK.close` | JBSbatSQLAccess | CHG_AD_JGRTWK | Closes database access to Change Address Joint Work table |
| - | `db_CK_T_CUST.close` | JBSbatSQLAccess | CK_T_CUST | Closes database access to Customer Master table |
| - | `db_CK_T_CUST_KOJIN.close` | JBSbatSQLAccess | CK_T_CUST_KOJIN | Closes database access to Customer Individual table |
| - | `db_KK_T_KKTK_SVC_KEI.close` | JBSbatSQLAccess | KK_T_KKTK_SVC_KEI | Closes database access to KK Customer Service Detail table |
| - | `db_KK_T_OPSVKEI_TV.close` | JBSbatSQLAccess | KK_T_OPSVKEI_TV | Closes database access to Operation Service Detail TV table |
| - | `db_KK_T_SEIKY_KEI.close` | JBSbatSQLAccess | KK_T_SEIKY_KEI | Closes database access to Settlement Detail table |
| - | `db_KU_T_KOJIAK.close` | JBSbatSQLAccess | KU_T_KOJIAK | Closes database access to Individual Account table |
| - | `db_TU_T_DNWACHOMSK_NYO.close` | JBSbatSQLAccess | TU_T_DNWACHOMSK_NYO | Closes database access to Download Watch Registration Input table |

**Note:** The `close()` calls on `JBSbatSQLAccess` instances release underlying JDBC resources (database connections, prepared statements, result sets). These are not CRUD operations themselves — they are resource management operations that clean up previously opened database connections used by `insert`, `update`, and `select` operations during the processing phase.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKAdHenkoHoyuDataChstuMan` lifecycle | `JBSbatBusinessService.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.terminal` | `db_CHGTGAD_CD_WK.close [R] KK_T_CHGTGAD_CD_WK` |

**Notes:**
- This method is called internally as part of the batch service lifecycle within `JBSbatKKAdHenkoHoyuDataChstuMan` itself. It is not called by external screens or other services.
- The parent class `JBSbatBusinessService` manages the lifecycle and invokes `terminal()` after the main processing (`execute()`) completes.

## 6. Per-Branch Detail Blocks

### Block 1 — EXEC (DB Access Cleanup) `(L727)`

> Closes the Changed Target Address Code Work database access object. This table tracks address code changes that are in progress and are stored in a work table format.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_CHGTGAD_CD_WK.close()` // Closes DB access to KK_T_CHGTGAD_CD_WK (Changed Target Address Code Work table) [Tool-generated termination processing] |

### Block 2 — EXEC (DB Access Cleanup) `(L728)`

> Closes the Change Address Joint Work database access object. This table stores joint processing data for address changes.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_CHG_AD_JGRTWK.close()` // Closes DB access to CHG_AD_JGRTWK (Change Address Joint Work table) [Tool-generated termination processing] |

### Block 3 — EXEC (DB Access Cleanup) `(L729)`

> Closes the Customer Master database access object. This table contains core customer account information.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_CK_T_CUST.close()` // Closes DB access to CK_T_CUST (Customer Master table) [Tool-generated termination processing] |

### Block 4 — EXEC (DB Access Cleanup) `(L730)`

> Closes the Customer Individual database access object. This table stores individual customer data.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_CK_T_CUST_KOJIN.close()` // Closes DB access to CK_T_CUST_KOJIN (Customer Individual table) [Tool-generated termination processing] |

### Block 5 — EXEC (DB Access Cleanup) `(L731)`

> Closes the KK Customer Service Detail database access object. This table contains service detail/line item data for customer services.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_KKTK_SVC_KEI.close()` // Closes DB access to KK_T_KKTK_SVC_KEI (KK Customer Service Detail table) [Tool-generated termination processing] |

### Block 6 — EXEC (DB Access Cleanup) `(L732)`

> Closes the Operation Service Detail TV (Table View) database access object. This provides a view layer on the service detail data.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_OPSVKEI_TV.close()` // Closes DB access to KK_T_OPSVKEI_TV (Operation Service Detail TV table) [Tool-generated termination processing] |

### Block 7 — EXEC (DB Access Cleanup) `(L733)`

> Closes the Settlement Detail database access object. This table contains billing/settlement line item records.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_SEIKY_KEI.close()` // Closes DB access to KK_T_SEIKY_KEI (Settlement Detail table) [Tool-generated termination processing] |

### Block 8 — EXEC (DB Access Cleanup) `(L734)`

> Closes the Individual Account database access object. This table stores individual account information.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KU_T_KOJIAK.close()` // Closes DB access to KU_T_KOJIAK (Individual Account table) [Tool-generated termination processing] |

### Block 9 — EXEC (DB Access Cleanup) `(L736)`

> Closes the Download Watch Registration Input database access object. This table stores download watchlist registration input data.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_TU_T_DNWACHOMSK_NYO.close()` // Closes DB access to TU_T_DNWACHOMSK_NYO (Download Watch Registration Input table) [Tool-generated termination processing] |

### Block 10 — COMMENT (Skipped DB Accesses) `(L732-L734)`

> These lines are commented out due to the ANK-4494-00-00 change which removed dual-direction phone number support (双方向番号対応). These connections are no longer opened during processing.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// db_TU_T_BMP_KOJI.close()` // Skipped — BMP Old Record table access removed |
| 2 | COMMENT | `// db_TU_T_DOBANITEN.close()` // Skipped — Alternate Store table access removed |
| 3 | COMMENT | `// ANK-4494-00-00 DEL START/END marker` |

### Block 11 — RETURN `(L742)`

> Returns void. The method completes after all resource cleanup is done. The batch service framework continues to the next service in the chain or terminates the batch job.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` // Implicit void return after all DB access cleanup |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_CHGTGAD_CD_WK` | Table | Changed Target Address Code Work — work table tracking address code changes in progress during batch processing |
| `CHG_AD_JGRTWK` | Table | Change Address Joint Work — table storing joint processing data for address change operations |
| `CK_T_CUST` | Table | Customer Master — core customer account master data table |
| `CK_T_CUST_KOJIN` | Table | Customer Individual — individual-level customer data within the customer master |
| `KK_T_KKTK_SVC_KEI` | Table | KK Customer Service Detail — service detail/line item data for customer services (KKTK = K-Opticom Telecom Customer) |
| `KK_T_OPSVKEI_TV` | Table | Operation Service Detail TV (Table View) — view layer on the service detail data for batch operations |
| `KK_T_SEIKY_KEI` | Table | Settlement Detail — billing and settlement line item data table |
| `KU_T_KOJIAK` | Table | Individual Account — individual customer account information table |
| `TU_T_DNWACHOMSK_NYO` | Table | Download Watch Registration Input — table for download watchlist registration input data |
| `db_CHGTGAD_CD_WK` | Field | Database access object for KK_T_CHGTGAD_CD_WK work table |
| `JBSbatSQLAccess` | Class | Framework class providing CRUD database access operations via SQL, part of the batch framework layer |
| `JBSbatBusinessService` | Class | Base class for batch business services, provides lifecycle management (init, execute, terminal) |
| `terminal()` | Method | Business service termination/cleanup handler — closes all database resources opened during processing |
| `JBSbatKKAdHenkoHoyuDataChstuMan` | Class | Modified Address Latest Record Data Extraction Component — batch service that processes address change registration workflows |
| 住所マスタ | Japanese | Address Master — the master data table containing customer address records |
| 更新対象 | Japanese | Changed Target — refers to records targeted for address change/updates |
| ANK-4494-00-00 | Change ID | Batch change ticket for dual-direction phone number support removal (双方向番号対応) in the eo定期 service |
| eo顧客基盤システム | Japanese | eo Customer Base System — the core customer management system platform |
| eo定期 | Japanese | eo Regular Service — the subscription-based service tier requiring dual-direction phone number (now removed) |
