# Business Logic — JKKUseStpRlsRunCC.executeKkopSvcKei_UseStp() [81 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKUseStpRlsRunCC` |
| Layer | CC (Common Component) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKUseStpRlsRunCC.executeKkopSvcKei_UseStp()

This method implements the **Device Option Service Contract Suspension Release Processing** (機器提供オプションサービス契約利用停止解除処理) within the K-Opticom telecommunications customer backbone system. It is responsible for lifting a service suspension on device option service contracts (e.g., STB set-top boxes, routers, ONUs, splitters, PLC modems) that were previously placed on hold.

The method follows a **query-check-execute** design pattern. It first retrieves the list of device option service contracts associated with a provided contract number via an SC (Service Component) call, then iterates over each contract to determine whether the equipment can undergo status migration (状態遷移) by invoking a migration eligibility check. Only contracts that are eligible and currently in a "Stopped" state (SVC_KEI_STAT_STP = "220") proceed to the actual suspension release. If the contract's pre-suspension status was "Suspended/Broken" (SVC_KEI_STAT_KYUS = "210"), a suspended-contract-specific release routine is executed instead of the standard one.

This method serves as a **shared utility** called within the `JKKUseStpRlsRunCC` class hierarchy — it is invoked by `executeKktkSvcKei_UseStp()`, making it a leaf-level business method in the suspension release processing chain. It handles all device option service types uniformly (STB, BCAS, CCAS, ONU, V-ONU, Router, PLC Modem, ISDN Terminal Adapter, VoIP, Filter, Splitter, Power Antenna, SLEPPER, 64-card modem, and others) without branching by equipment type.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKkopSvcKei_UseStp start"])

    START --> STEP1["Step 1: callEKK2811B010SC
Retrieve device option service contract list"]
    STEP1 --> STEP2["Step 2: Get eKK2811B010HashList from resultHash"]
    STEP2 --> CHECK_LIST{List is not null and not empty?}

    CHECK_LIST -->|Yes| LOOP["Step 3: Iterate each element in eKK2811B010HashList"]
    CHECK_LIST -->|No| SKIP_END["Skip processing - no device option service"]

    LOOP --> STEP4["Step 4: Prepare checkKkopIdoKhInputdata"]
    STEP4 --> STEP5["Set KKOP_SVC_CD from element data"]
    STEP5 --> STEP6["Set IDO_DIV to SVC_STP_RSN_CD_USESTPRLS"]
    STEP6 --> STEP7["Step 7: param.setData checkKkopIdoKh"]
    STEP7 --> STEP8["Step 8: call JKKBpCommon.checkKkopIdoKh"]

    STEP8 --> MIGRATE_CHECK{checkKkopIdoKh returns true?}

    MIGRATE_CHECK -->|Yes| STEP9["Step 9: Get kkopSvcKeiStat from element"]
    MIGRATE_CHECK -->|No| SKIP_MIGRATE["Skip processing - not migration target"]

    STEP9 --> STAT_CHECK{kkopSvcKeiStat equals 220?}

    STAT_CHECK -->|Yes| STEP10["Step 10: callEKK2811A010SC
Contract inquiry"]
    STAT_CHECK -->|No| SKIP_STAT["Skip processing - not stopped status"]

    STEP10 --> STEP11["Get eKK2811A010Hash from resultHash"]
    STEP11 --> STEP12["Get svkeiStatMap via MAP_KEY_GET_SVKEI_STAT"]
    STEP12 --> STEP13["Get useStpBfSvcKeiStat via LAST_KK0081_STAT"]

    STEP13 --> BEFORE_STAT{useStpBfSvcKeiStat equals 210?}

    BEFORE_STAT -->|Yes| STEP14["Step 14: callEKK2811C100SC
Suspended contract suspension"]
    BEFORE_STAT -->|No| STEP15["Step 15: callEKK2811C090SC
Contract suspension release"]

    STEP14 --> STEP16["Return 0"]
    STEP15 --> STEP16
    SKIP_END --> STEP16
    SKIP_MIGRATE --> STEP16
    SKIP_STAT --> STEP16
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The session manager handle that carries database connection, transaction context, and authentication information for the current processing session. |
| 2 | `param` | `IRequestParameterReadWrite` | A read-write parameter object containing the model group and control map. Used to pass input data structures (e.g., checkKkopIdoKhInputdata) to called methods via `setData()`, and to retrieve results via `getData()`. |
| 3 | `requestParam` | `HashMap<String, Object>` | A map of request parameters passed through from the caller, carrying additional configuration or context data needed by downstream SC calls (e.g., service contract numbers, screen input). |
| 4 | `resultHash` | `HashMap<String, Object>` | A result container map populated by SC calls with inquiry data. Used to retrieve template results (e.g., `EKK2811B010`, `EKK2811A010`) and intermediate state (e.g., service status map via `MAP_KEY_GET_SVKEI_STAT`). |
| 5 | `prm_svc_kei_no` | `String` | The input service contract number (サービス契約番号) — a generic service contract identifier used as context for the suspension release operation. Referenced in the method signature but not directly used in the body; likely consumed by called methods. |
| 6 | `kktkSvcKeiNo` | `String` | The device-provided service contract number (機器提供サービス契約番号) — the primary business key used to query the list of device option service contracts via `callEKK2811B010SC`. This is the key input that identifies which device option services belong to this contract. |

**Constants / static fields read by the method:**

| Field | Value | Business Meaning |
|-------|-------|------------------|
| `SVC_KEI_STAT_STP` | `"220"` | Service contract status: "Stopped" — only contracts in this state are eligible for suspension release processing. |
| `SVC_KEI_STAT_KYUS` | `"210"` | Service contract status: "Suspended/Broken" (休止・中断中) — if the pre-suspension status was this value, a suspended-contract-specific release routine is used. |
| `SVC_STP_RSN_CD_USESTPRLS` | `"01"` | Usage suspension release reason code (利用停止解除理由コード) — indicates the migration type is "suspension release." Used in the migration eligibility check. |
| `TEMPLATE_ID_EKK2811B010` | `"EKK2811B010"` | Template ID for device option service contract list inquiry (機器提供サービス契約一覧照会) — key to retrieve results from `resultHash`. |
| `TEMPLATE_ID_EKK2811A010` | `"EKK2811A010"` | Template ID for device option service contract inquiry (機器提供サービス契約照会) — used after the main inquiry to get detailed contract data. |
| `MAP_KEY_GET_SVKEI_STAT` | `"JKKGetSvkeiStat"` | Map key to retrieve the service contract status map from `resultHash`, used to fetch the pre-suspension status. |
| `JKKGetSvkeiStatConstCC.LAST_KK0081_STAT` | `last_kk0081_stat` | Constant defining the map key for the last service contract status in the KK0081 status inquiry result. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKUseStpRlsRunCC.callEKK2811B010SC` | EKK2811B010 | KK_T_KKOP_SVKEI (Device Option Service Contract) | Retrieves the list of device option service contracts associated with the device-provided service contract number. Populates `resultHash` under template `EKK2811B010`. |
| - | `JKKBpCommon.checkKkopIdoKh` | - | - | Checks whether a device option contract is eligible for state migration (status transition). Takes the service code and migration type as input. Returns boolean eligibility. |
| - | `JKKKeiIdoKhCheck.checkKkopIdoKh` | - | - | The underlying migration eligibility check implementation, invoked by `JKKBpCommon.checkKkopIdoKh`. Evaluates business rules to determine if the contract can transition from stopped to active. |
| - | `IRequestParameterReadWrite.setData` | - | - | Sets the check migration input data into the parameter object for transmission to called methods. |
| R | `JKKUseStpRlsRunCC.callEKK2811A010SC` | EKK2811A010 | KK_T_KKOP_SVKEI (Device Option Service Contract) | Performs detailed inquiry of the device option service contract. Retrieves the current contract state and fills `resultHash` under template `EKK2811A010`. Also fetches the pre-suspension service status via `JKKGetSvkeiStat`. |
| U | `JKKUseStpRlsRunCC.callEKK2811C100SC` | EKK2811C100 | KK_T_KKOP_SVKEI (Device Option Service Contract) | Executes suspension release for a **suspended/broken** device option service contract. Used when the pre-suspension status was "210" (Suspended/Broken). Applies special handling for contracts that were already in a suspended state before being stopped. |
| U | `JKKUseStpRlsRunCC.callEKK2811C090SC` | EKK2811C090 | KK_T_KKOP_SVKEI (Device Option Service Contract) | Executes standard suspension release for a device option service contract. Used when the pre-suspension status was NOT "210" (i.e., the contract was in normal "Service Provided" status before being stopped). Transitions the contract from Stopped (220) back to Service Provided (100). |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKUseStpRlsRunCC.executeKktkSvcKei_UseStp()` | `executeKktkSvcKei_UseStp` -> `executeKkopSvcKei_UseStp` | `callEKK2811B010SC [R] KK_T_KKOP_SVKEI`, `callEKK2811A010SC [R] KK_T_KKOP_SVKEI`, `callEKK2811C090SC [U] KK_T_KKOP_SVKEI`, `callEKK2811C100SC [U] KK_T_KKOP_SVKEI` |

## 6. Per-Branch Detail Blocks

### Block 1 — EXEC `(Retrieve device option service contract list)` (L5650)

The method begins by calling the service component to retrieve the list of device option service contracts associated with the given device-provided service contract number.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811B010SC(param, handle, requestParam, kktkSvcKeiNo, null, resultHash)` |

**Business description:** Invokes SC `EKK2811B010` to perform a device option service contract list inquiry. The `kktkSvcKeiNo` parameter serves as the query key, and results are stored in `resultHash` under the template key `EKK2811B010`. A `null` is passed for the optional device service code filter (kktkSvcCd).

---

### Block 2 — EXEC `(Extract result list from hash)` (L5652)

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK2811B010HashList = (ArrayList<HashMap<String, Object>>)resultHash.get(TEMPLATE_ID_EKK2811B010)` |

**Business description:** Extracts the list of device option service contracts from the result hash. The result is cast to `ArrayList<HashMap<String, Object>>` where each element represents one device option service contract record.

---

### Block 3 — IF `(List is not null and not empty)` (L5654)

> Determines whether any device option service contracts were found for this contract number. If no contracts exist, processing is skipped entirely.

**Block 3.1 — FOR `(Iterate each element)` (L5656)**

> Loops through each device option service contract record found in the list, processing each one individually.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0251B010HashListElement = each element of eKK2811B010HashList` |

**Business description:** Iterates over the list of device option service contract records. Each element is a HashMap containing contract details including service code, contract status, and contract number.

---

### Block 4 — IF `(checkKkopIdoKh eligibility check)` (L5659)

> 機器オプションサービス契約異動可否判定処理 — Determines whether this device option service contract can undergo status migration (状態遷移) unconditionally (無条件). Only eligible contracts proceed to the actual suspension release.

**Block 4.1 — EXEC `(Prepare migration check input)` (L5660–L5666)**

| # | Type | Code |
|---|------|------|
| 1 | SET | `checkKkopIdoKhInputdata = new HashMap<String, Object>()` |
| 2 | SET | `checkKkopIdoKhInputdata.put(KKOP_SVC_CD, element.get(EKK2811B010CBSMsg1List.KKOP_SVC_CD))` // Device option service code |
| 3 | SET | `checkKkopIdoKhInputdata.put(IDO_DIV, SVC_STP_RSN_CD_USESTPRLS = "01")` // Migration type: suspension release |
| 4 | SET | `checkKkopIdoKhFixedText = "checkKkopIdoKh"` |
| 5 | EXEC | `param.setData(checkKkopIdoKhFixedText, checkKkopIdoKhInputdata)` |

**Business description:** Builds the input data structure for the migration eligibility check. Sets the device option service code (KKOP_SVC_CD) from the current contract element, and the migration division code to "01" (suspension release). Stores this in the parameter object using the key "checkKkopIdoKh".

**Block 4.2 — IF `(checkKkopIdoKh returns true)` (L5668)**

> The contract is determined to be eligible for state migration. Only if the migration eligibility check passes does the system proceed with the actual suspension release.

**Block 4.2.1 — EXEC `(Retrieve current contract status)` (L5671)**

> 機器オプションサービス契約の状態に従い、利用停止解除を実行 — Execute suspension release according to the device option service contract state.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcKeiStat = (String)element.get(EKK2811B010CBSMsg1List.KKOP_SVC_KEI_STAT)` |

**Block 4.2.2 — IF `(kkopSvcKeiStat equals SVC_KEI_STAT_STP = "220")` (L5673)**

> 機器オプションサービス契約一致照会 — Verifies the contract is in "Stopped" status (220). Only stopped contracts are subject to suspension release. Contracts in other states (e.g., Service Provided, Dissolved, Cancelled) are skipped as they are not eligible for suspension release.

**Block 4.2.2.1 — EXEC `(Contract inquiry and status handling)` (L5677–L5712)**

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811A010SC(param, handle, element.get(EKK2811B010CBSMsg1List.KKOP_SVC_KEI_NO), resultHash)` // Device option service contract inquiry |
| 2 | SET | `eKK2811A010Hash = (HashMap<String, Object>)resultHash.get(TEMPLATE_ID_EKK2811A010)` |
| 3 | SET | `svkeiStatMap = (HashMap<String, Object>)resultHash.get(MAP_KEY_GET_SVKEI_STAT)` |
| 4 | SET | `useStpBfSvcKeiStat = (String)svkeiStatMap.get(JKKGetSvkeiStatConstCC.LAST_KK0081_STAT)` |

**Business description:** Performs a detailed inquiry of the device option service contract using its contract number. Retrieves the contract details hash and the pre-suspension status map. The `LAST_KK0081_STAT` field contains the service contract status before it was stopped.

**Block 4.2.2.1.A — IF `(useStpBfSvcKeiStat equals SVC_KEI_STAT_KYUS = "210")` (L5685)**

> 休止中機器オプションサービス契約停止 — Suspended device option service contract suspension. If the pre-suspension status was "210" (Suspended/Broken / 休止・中断中), a special handling routine is invoked. This addresses the case where a contract was already in a suspended/broken state before being placed on hold.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811C100SC(param, handle, eKK2811A010Hash, resultHash)` |

**Business description:** Executes the suspended contract suspension release routine (`EKK2811C100`). This handles the special case where the contract needs additional processing because it was in a suspended state before being stopped. The suspended-contract-specific release accounts for different business rules and data constraints that apply to contracts in this state.

**Block 4.2.2.1.B — ELSE `(useStpBfSvcKeiStat NOT equals "210")` (L5691)**

> 機器オプションサービス契約停止解除 — Device option service contract suspension release. If the pre-suspension status was NOT "210" (i.e., the contract was in normal "Service Provided" status / サービス提供中), the standard suspension release routine is executed.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811C090SC(param, handle, eKK2811A010Hash, resultHash)` |

**Business description:** Executes the standard device option service contract suspension release routine (`EKK2811C090`). This transitions the contract from Stopped (220) status back to Service Provided (100) status. This is the normal suspension release path for contracts that were fully active before being stopped.

**Block 4.2.3 — ELSE `(kkopSvcKeiStat NOT equals "220")` (L5697)**

> 契約状態が利用停止解除対象外のため、処理なし — Contract status is not subject to suspension release; no processing performed. The contract is not in a "Stopped" state, so suspension release is not applicable.

| # | Type | Code |
|---|------|------|
| 1 | — | (empty — no operation) |

**Block 4.3 — ELSE `(checkKkopIdoKh returns false)` (L5702)**

> 異動対象外の機器オプションのため、処理なし — Device option is not a migration target; no processing performed. The migration eligibility check determined this contract cannot undergo status transition (e.g., due to business rules, dependencies, or data constraints).

| # | Type | Code |
|---|------|------|
| 1 | — | (empty — no operation) |

---

### Block 5 — ELSE `(List is null or empty)` (L5706)

> 機器オプションばなため、処理なし — No device option service; no processing performed. No device option service contracts were found for the given contract number, so there is nothing to process.

| # | Type | Code |
|---|------|------|
| 1 | — | (empty — no operation) |

---

### Block 6 — RETURN `(Fixed success code)` (L5711)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return 0;` // Fixed success return code — not used by caller |

**Business description:** Always returns 0, which is the fixed success return code. The Javadoc notes this return value is not used by callers, making it a placeholder for API compatibility.

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktkSvcKeiNo` | Field | Device-provided service contract number (機器提供サービス契約番号) — the primary contract key identifying a set of device option services provided by the equipment supplier. |
| `kkopSvcKeiStat` | Field | Device option service contract status (機器提供オプションサービス契約状態) — the current state of a device option service contract record (Stopped, Suspended, Service Provided, etc.). |
| `useStpBfSvcKeiStat` | Field | Pre-suspension service contract status (利用停止前のサービス契約状態) — the status of the service contract before it was placed on hold. Used to determine which release routine to execute. |
| `SVC_KEI_STAT_STP` | Constant | Service Status: Stopped (220) — the contract has been placed on hold by the operator. This is the target status for suspension release processing. |
| `SVC_KEI_STAT_KYUS` | Constant | Service Status: Suspended/Broken (210) — the contract is in a suspended or interrupted state (休止・中断中). Contracts in this state require special handling during suspension release. |
| `SVC_KEI_STAT_TKC` | Constant | Service Status: Service Provided (100) — the contract is actively providing service. This is the normal operational state. |
| `SVC_KEI_STAT_UKE` | Constant | Service Status: Received (010) — the contract has been received but not yet processed. |
| `SVC_KEI_STAT_SHOSA` | Constant | Service Status: Under Review (020) — the contract is being reviewed. |
| `SVC_KEI_STAT_TEIK` | Constant | Service Status: Contracted (030) — the contract has been signed but service has not yet started. |
| `SVC_KEI_STAT_DSL` | Constant | Service Status: Dissolved (910) — the contract has been terminated. |
| `SVC_KEI_STAT_CNCL` | Constant | Service Status: Cancelled (920) — the contract has been cancelled. |
| `SVC_STP_RSN_CD_USESTPRLS` | Constant | Suspension Release Reason Code ("01") — identifies this operation as a usage suspension release (利用停止解除). Used in migration eligibility checks. |
| `IDO_DIV` | Field | Migration Division (異動区分) — classifies the type of status migration. Value "00063" indicates suspension release migration. |
| `KKOP_SVC_CD` | Field | Device Option Service Code (機器オプションサービスコード) — identifies the type of device option service (e.g., STB, Router, ONU, Splitter, Filter, PLC Modem). |
| `EKK2811B010` | SC Code | Device Option Service Contract List Inquiry (機器提供サービス契約一覧照会) — SC that retrieves the list of device option service contracts for a given contract number. |
| `EKK2811A010` | SC Code | Device Option Service Contract Inquiry (機器提供サービス契約照会) — SC that retrieves detailed information for a single device option service contract. |
| `EKK2811C090` | SC Code | Device Option Service Contract Suspension Release (機器提供サービス契約停止解除) — SC that performs standard suspension release for a device option service contract. |
| `EKK2811C100` | SC Code | Suspended Device Option Service Contract Suspension (休止中機器提供サービス契約停止解除) — SC that performs suspension release for a contract that was in a suspended state before being stopped. |
| `JKKBpCommon.checkKkopIdoKh` | Method | Migration Eligibility Check (異動可否判定) — determines whether a device option service contract can undergo a status transition. Returns true if the contract is eligible. |
| `JKKKeiIdoKhCheck` | Class | Migration Eligibility Check Component — the component that implements the business rules for determining whether a service contract can transition between states. |
| STB | Business term | Set-Top Box — a device that receives and decodes television signals for the eo-hikari TV service. |
| Router | Business term | Network router device provided as a device option service. |
| ONU | Business term | Optical Network Unit — fiber-optic termination equipment for eo-hikari (FTTH) connections. |
| PLC Modem | Business term | Power Line Communication modem — a modem that transmits data over electrical wiring. |
| KK_T_KKOP_SVKEI | DB Table | Device Option Service Contract Table (機器提供オプションサービス契約テーブル) — stores device option service contract records including status, service codes, and contract numbers. |
| Service Component (SC) | Technical term | Service Component — a layer in the architecture that encapsulates data access and business logic for a specific operation. SC codes follow the pattern `EKKxxxxxSC`. |
| 状態遷移 (Joutai Sen'i) | Japanese term | Status Transition — the process of changing a service contract from one state to another (e.g., from Stopped to Service Provided). |
| 異動可否判定 (Idou Foka Handan) | Japanese term | Migration Eligibility Determination — the process of evaluating whether a service contract can legally/technically undergo a status change. |
