# Business Logic — JBSbatKKPlaceNoChgRnkiInfCst.isSurrenderService() [20 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKPlaceNoChgRnkiInfCst` |
| Layer | Service (inferred from package `eo.business.service`) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKPlaceNoChgRnkiInfCst.isSurrenderService()

This method performs a business check to determine whether a given equipment-provided service (`kktkSvcNo`) has been surrendered (cancelled/deregistered) in the system. It is a conditional-branch predicate used during equipment provision service contract processing — specifically within the context of address-change relocation workflows where the same service may need to be recognized as already surrendered without re-triggering surrender logic.

The method implements a **delegation and guard pattern**: it first validates the input parameter (early exit on null/blank), then delegates to a SQL query against the service contract table (`KK_T_KKTK_SVC_KEI`) using a predefined select statement (`KK_SELECT_139`). The SQL result is inspected — if no row is returned by `selectNext()`, the service is considered **not surrendered**; if a row exists, the service is considered **surrendered**.

The method's role in the larger system is as a **reusable utility predicate** called from the same class's `execute()` method during batch processing of address-change relocation operations. Per its Javadoc, a critical edge case is handled: even if a service record exists (indicating surrender), if the relocation type (`idoun-bunpu`) is an address change, the method returns `true` (surrendered) but the caller must NOT treat it as a new surrender event — the business rule distinguishes between "already surrendered" and "needs surrender processing."

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isSurrenderService kktkSvcNo"])
    COND_NULL["JKKStringUtil.isNullBlank kktkSvcNo"]
    RET_FALSE_1["return false"]
    INIT_PARAM["paramList = new JBSbatCommonDBInterface"]
    SET_KKTSVCNO["paramList.setValue kktkSvcNo"]
    SET_OPEDATE["paramList.setValue opeDate"]
    SELECT_BY_SQL["db_KK_T_KKTK_SVC_KEI.selectBySqlDefine paramList, KK_SELECT_139"]
    COND_SELECT["db_KK_T_KKTK_SVC_KEI.selectNext == null"]
    RET_FALSE_2["return false"]
    RET_TRUE["return true"]
    END_METHOD(["End"])

    START --> COND_NULL
    COND_NULL -->|true| RET_FALSE_1
    RET_FALSE_1 --> END_METHOD
    COND_NULL -->|false| INIT_PARAM
    INIT_PARAM --> SET_KKTSVCNO
    SET_KKTSVCNO --> SET_OPEDATE
    SET_OPEDATE --> SELECT_BY_SQL
    SELECT_BY_SQL --> COND_SELECT
    COND_SELECT -->|true| RET_FALSE_2
    RET_FALSE_2 --> END_METHOD
    COND_SELECT -->|false| RET_TRUE
    RET_TRUE --> END_METHOD
```

**Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `KK_T_KKTK_SVC_KEI_KK_SELECT_139` | `"KK_SELECT_139"` | SQL select statement that queries the service contract table to check surrender status of an equipment-provided service |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `kktkSvcNo` | `String` | Equipment-provided service contract number — the unique identifier for a specific equipment provision service agreement (e.g., leased router, set-top box, or other telecom hardware service). A null, empty, or blank value indicates no service contract exists, in which case the method returns `false` (not surrendered). |

**Instance fields / external state read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `opeDate` | (Date/String inferred) | Operation date — the processing date used as a query parameter for the SQL select, ensuring the query reflects the service state as of a specific point in time |
| `db_KK_T_KKTK_SVC_KEI` | `JBSbatSQLAccess` | Database access object for the `KK_T_KKTK_SVC_KEI` table — manages the SQL execution and result set iteration for querying service contract records |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKStringUtil.isNullBlank` | - | - | Null/blank check utility — validates input parameter |
| READ | `db_KK_T_KKTK_SVC_KEI.selectBySqlDefine` | - | `KK_T_KKTK_SVC_KEI` | Executes SQL query `KK_SELECT_139` to retrieve service contract records matching the given `kktkSvcNo` |
| READ | `db_KK_T_KKTK_SVC_KEI.selectNext` | - | `KK_T_KKTK_SVC_KEI` | Fetches the next row from the result set — if `null`, no matching record found (service not surrendered) |

**CRUD Classification:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKStringUtil.isNullBlank` | - | - | Input validation — checks if the equipment-provided service contract number is null, empty, or whitespace-only |
| R | `selectBySqlDefine` | - | `KK_T_KKTK_SVC_KEI` | SQL-based read — queries the equipment-provided service contract table to find records for the given service number, filtering by operation date. Returns a result set cursor positioned before the first row |
| R | `selectNext` | - | `KK_T_KKTK_SVC_KEI` | Result set iteration — advances to the next row and returns it, or `null` if no more rows exist. A `null` result indicates the service has no surrender record, meaning it is NOT surrendered |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `isNullBlank` [-], `selectBySqlDefine` [-], `selectNext` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKPlaceNoChgRnkiInfCst | `JBSbatKKPlaceNoChgRnkiInfCst.execute()` -> `isSurrenderService(kktkSvcNo)` | `isNullBlank [-]`, `selectBySqlDefine [R] KK_T_KKTK_SVC_KEI`, `selectNext [R] KK_T_KKTK_SVC_KEI` |

**Notes:**
- This method is called from its own class's `execute()` method during batch processing of address-change relocation operations.
- The caller is a batch processing class (`JBSbatKKPlaceNoChgRnkiInfCst`), not a screen. No intermediate CBS layer.
- The terminal operations are all read-based: input validation (`isNullBlank`) and SQL queries against the service contract table (`KK_T_KKTK_SVC_KEI`).

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(JKKStringUtil.isNullBlank(kktkSvcNo))` (L837)

> Guard clause: If the equipment-provided service contract number is null, empty, or blank, the method determines the service is **not surrendered** and returns `false`. This represents the business rule that no service contract means no surrender has occurred.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JKKStringUtil.isNullBlank(kktkSvcNo)` // Null/blank check on input parameter |
| 2 | RETURN | `return false` // Not surrendered — no service contract exists |

**Block 2** — [PROCESSING SEQUENCE] (L840–843)

> Initialize the query parameter list and execute the SQL select to check surrender status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramList = new JBSbatCommonDBInterface()` // Generate a database interface parameter list (JDBC value list) |
| 2 | SET | `paramList.setValue(kktkSvcNo)` // Set the equipment-provided service contract number as first parameter |
| 3 | SET | `paramList.setValue(opeDate)` // Set the operation date as second parameter |
| 4 | CALL | `db_KK_T_KKTK_SVC_KEI.selectBySqlDefine(paramList, KK_T_KKTK_SVC_KEI_KK_SELECT_139)` // Execute SQL define: KK_SELECT_139 = `"KK_SELECT_139"` — query service contract table for surrender records |

**Block 3** — [IF] `(db_KK_T_KKTK_SVC_KEI.selectNext() == null)` (L844)

> Result inspection: If no row is returned by the SQL query, the service has no surrender record and is therefore **not surrendered**.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_KKTK_SVC_KEI.selectNext()` // Fetch next row from result set cursor |
| 2 | RETURN | `return false` // Not surrendered — no matching surrender record found |

**Block 4** — [RETURN] (L845)

> Default return: If execution reaches this point, a surrender record was found, confirming the service is **surrendered**.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // Surrendered — a matching surrender record was found in KK_T_KKTK_SVC_KEI |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `kktkSvcNo` | Field | Equipment-provided service contract number — the unique identifier for a specific telecom hardware/service agreement (e.g., leased router, modem, or set-top box) |
| `kktk` | Acronym | 機器提供 (Kiki Tei-kyou) — Equipment Provision; refers to telecom equipment leased or provided to customers |
| `opeDate` | Field | Operation date — the processing/reference date used to determine the temporal validity of the query result |
| `KK_T_KKTK_SVC_KEI` | Table | Equipment-provided service contract table — stores records of equipment provision service agreements including surrender/cancellation status |
| `KK_SELECT_139` | SQL Define | Predefined SQL select statement used to query the service contract table for surrender status checks |
| `JBSbatCommonDBInterface` | Class | Common database interface — a generic parameter list class that holds values to be passed to SQL execute calls (acts as a bind parameter container) |
| `JBSbatSQLAccess` | Class | SQL access layer — a database abstraction class that manages SQL execution, result set handling, and cursor navigation (`selectBySqlDefine`, `selectNext`) |
| `JKKStringUtil.isNullBlank` | Utility | Null/blank validation utility — returns `true` if the input string is null, empty, or contains only whitespace |
| `selectNext` | Method | Result set cursor advance — moves to the next row in a prepared query's result set; returns `null` when no more rows exist |
| Address-change relocation | Business term | A customer service event where a customer's registered address is changed (often due to moving); this method's Javadoc notes that surrender records created during address-change transfers should be recognized but not re-processed as new surrenders |
| 異動区分 (Idoun-bunpu) | Field | Relocation type classification — distinguishes between different types of service changes, including address changes. When set to address change, surrender records are informational only |
| 解約 (Kaikyou) | Business term | Surrender / cancellation — the formal process of terminating a service contract. In this domain, a surrendered service no longer requires active equipment provision |
| Batch (JBSbat*) | Pattern | Batch processing class naming convention — `JBSbat*` classes handle offline/batch operations as opposed to real-time screen processing |
