# Business Logic — JKKTVSvcKeiKaihukuCC.recovery() [746 LOC]

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

## 1. Role

### JKKTVSvcKeiKaihukuCC.recovery()

This method performs **service contract recovery** for the "In Service" state (recovering from "サービス提供中") as part of the K-Opticom eo TV service contract disassociation/recovery workflow. It is a shared common component called by `JKKTVSvcKeiKaihukuCC.kaihuku()`, which orchestrates the broader recovery process that undoes a prior contract cancellation/termination action. The method implements a **multi-layered dispatch pattern**: it recovers five distinct entity types — (1) base service contracts, (2) equipment provision service contracts, (3) abnormal reservation entries (pre-arrived), (4) option service contracts, and (5) service disconnection details — each branching on a status date field (service start date, contract conclusion date, or inspection date) to select the appropriate reverse CBS call. Its role in the larger system is to act as the **central recovery coordinator**, ensuring that all related sub-contracts and ancillary records are restored to a consistent pre-cancellation state. The method also builds a viewing-control order map (`svcUcwkMap`) for downstream `execWctrlOrder` execution, and synchronizes Skuiper key information via `JKKSptvKeyInfOperateCC` before returning.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["recovery()"])

    START --> LOAD["Extract ccMsg from param.getData"]
    LOAD --> EXTRACT["Extract funcCode, ido_div, mskmDtlNoBf, lastUpdDtm, sysID"]
    EXTRACT --> OPEDATE["Get opeDate via JPCBPCommon.getOpeDate()"]

    OPEDATE --> EKK0081["EKK0081C200 - Service Contract Recovery"]
    EKK0081 --> EKK0161["EKK0161B004 - Service Contract Detail List"]
    EKK0161 --> SVCLOOP["Loop: Service Contract Details"]

    SVCLOOP --> SVCSTRT["uwSvcStrtYmd != null and not empty"]
    SVCSTRT -->|"Yes"| EKK0161C210["EKK0161C210 - Service Contract Recovery"]
    SVCSTRT -->|"No"| SVCKEI["uwKeiTeiketuYmd != null and not empty"]
    SVCKEI -->|"Yes"| EKK0161C250["EKK0161C250 - Service Contract Cancel Release"]
    SVCKEI -->|"No"| SVCSHOSA["uwShosaYmd != null and not empty"]
    SVCSHOSA -->|"Yes"| EKK0161C240["EKK0161C240 - Post-Inspection Cancel Release"]
    SVCSHOSA -->|"No"| SVCNEXT["Next Service Detail"]
    EKK0161C210 --> SVCNEXT
    EKK0161C250 --> SVCNEXT
    EKK0161C240 --> SVCNEXT

    SVCNEXT --> EQUIPMENT["EKK0341B031 - Equipment Contract History"]
    EQUIPMENT --> EKQUIPLOOP["Loop: Equipment Contracts"]

    EKQUIPLOOP --> CHECKPROC["Already processed?"]
    CHECKPROC -->|"Yes"| EKQUIPNEXT["Next Equipment"]
    CHECKPROC -->|"No"| KIKISVC["kikiSvcStrtYmd != null and not empty"]

    KIKISVC -->|"Yes"| EKK0341C380["EKK0341C380 - Equipment Contract Recovery"]
    KIKISVC -->|"No"| KIKIKEI["kikiKeiTeiketuYmd != null and not empty"]
    KIKIKEI -->|"Yes"| EKK0341C390["EKK0341C390 - Pre-Service Equipment Recovery"]
    KIKIKEI -->|"No"| KIKISHOSA["kikiShosaYmd != null and not empty"]
    KIKISHOSA -->|"Yes"| EKK0341C420["EKK0341C420 - Post-Inspection Equip Cancel Release"]
    KIKISHOSA -->|"No"| EKQUIPNEXT
    EKK0341C380 --> PROCESSADD["Add to kaihkZmSet"]
    EKK0341C390 --> PROCESSADD
    EKK0341C420 --> PROCESSADD
    PROCESSADD --> EKQUIPNEXT

    EKQUIPNEXT --> ABNORMAL["EKK1681C011 - Abnormal Reservation Info"]

    ABNORMAL --> A1["ido_div=00026 AND ido_rsv_dtl_cd=013?"]
    A1 -->|"Yes"| EKK1681B001["EKK1681B001 - Abnormal Resv List"]
    A1 -->|"No"| EKK0351B002["EKK0351B002 - Option Svc Contract List"]

    EKK1681B001 --> EKK1681A010ABN["EKK1681A010 - Abnormal Resv Consultation"]
    EKK1681A010ABN --> EKK1681C010ABN["EKK1681C010 - Abnormal Resv Status Change"]
    EKK1681C010ABN --> EKK0351B002

    EKK0351B002 --> OPTLOOP["Loop: Option Service Contracts"]

    OPTLOOP --> OPT910["opSvcKeiStat = 910?"]
    OPT910 -->|"Yes"| CHKABNORM["Has abnormal opc start?"]
    CHKABNORM -->|"Yes"| OPTABNORM["EKK1681A010 + EKK1681C010"]
    CHKABNORM -->|"No"| OPCSTRT["opSvcStaYmd != null and not empty"]
    OPTABNORM --> OPTNEXT["Next Option Service"]
    OPCSTRT -->|"Yes"| EKK0351C270["EKK0351C270 - Option Service Recovery"]
    OPCSTRT -->|"No"| EKK0351C310["EKK0351C310 - Option Cancel Release"]
    EKK0351C270 --> OPTNEXT
    EKK0351C310 --> OPTNEXT
    OPT910 -->|"No"| OPTNEXT

    OPTNEXT --> EKK0241B001["EKK0241B001 - Disconnection Detail List"]
    EKK0241B001 --> KAILOOP["Loop: Disconnection Details"]

    KAILOOP --> EKK0251A010["EKK0251A010 - Disconnection Consultation"]
    EKK0251A010 --> EKK0341B504["EKK0341B504 - Equipment Contract List"]
    EKK0341B504 --> KKTKCHK["stat=910 AND svc_cd=C013?"]
    KKTKCHK -->|"Yes"| EKK0341C380K["EKK0341C380 - Equipment Recovery"]
    KKTKCHK -->|"No"| KAISTAT["UCWK_STAT = 210?"]
    EKK0341C380K --> KAISTAT
    KAISTAT -->|"Yes"| EKK0251C060["EKK0251C060 - Disconnection Reactivation"]
    KAISTAT -->|"No"| KAINEXT["Next Disconnection"]
    EKK0251C060 --> KAINEXT

    KAINEXT --> VCTRL["execWctrlOrder for each viewing order"]
    VCTRL --> SPTVSYNC["JKKSptvKeyInfOperateCC.execute"]
    SPTVSYNC --> END(["End"])
```

**Key conditional branches explained:**

- **Service Contract Detail Recovery (Block 1):** For each detail record matching `mskmDtlNoBf`, the method checks three date fields in order: `SVC_STA_YMD` (service start date), `KEI_CNC_YMD` (contract conclusion date), and `SHOSA_YMD` (inspection date). Each triggers a different recovery CBS call.
- **Equipment Provision Recovery (Block 2):** After version 8.00.00 changes, equipment recovery queries by `sysID` (not `ido_div`). Records already processed are tracked in `kaihkZmSet` to avoid duplicate recovery calls.
- **Abnormal Reservation Processing (Block 3):** Handles pre-arrived abnormal reservations where `ido_div = "00026"` and `ido_rsv_dtl_cd = "013"`, canceling the reservation to resolve the pre-arrived state before continuing with option service contracts.
- **Option Service Recovery (Block 4):** For option services in "Cancelled" status (`"910"`), first checks if an abnormal option start reservation exists. If so, cancels it instead of recovering. Then recovers or releases based on `SVC_STAYMD`.
- **Disconnection Detail Processing (Block 5):** For cable disconnection details, checks if the equipment provision sub-status is `"910"` (cancelled) and service code `"C013"`, recovering the equipment. Then reactivates the disconnection detail if its status is `"210"`.
- **Viewing Control Orders (Block 6):** Iterates over `svcUcwkMap` to execute viewing-control orders for all recovered service work numbers.
- **Skuiper Key Sync (Block 7):** Calls `JKKSptvKeyInfOperateCC.execute` to synchronize Skuiper key information.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for transaction management and database access |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service component invocation gateway used to call remote CBS services |
| 3 | `param` | `IRequestParameterReadWrite` | Request/response parameter container holding the business data map (ccMsg) and work data |
| 4 | `dataMapKey` | `String` | Key used to retrieve the main business data map (`ccMsg`) from the parameter container, identifying the current business context |
| 5 | `mskmDtlNo` | `String` | Disassociation detail number — the unique identifier for the current disassociation/termination request being processed (the new disassociation being registered as part of the recovery) |
| 6 | `ekk1681c011OUTLIST` | `CAANMsg[]` | Array of abnormal reservation detail records obtained from a prior EKK1681C011 call, containing pre-arrived abnormal reservation information that may need to be canceled during recovery |

**External state / instance fields read:**

None — this method does not read any instance fields. All state is passed through parameters or derived from the `ccMsg` data map.

## 4. CRUD Operations / Called Services

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

| CR | SC / CBS | SC Code | Entity / DB | Operation Description |
|----|----------|---------|-------------|----------------------|
| U | `callSC` (EKK0081C200CBS) | EKK0081C200SC | Service contract record | Calls EKK0081C200 — Service Contract Recovery to recover the base service contract from "In Service" state |
| R | `callSC` (EKK0161B004CBS) | EKK0161B004SC | Service contract detail table | Calls EKK0161B004 — Service Contract Detail List to retrieve all detail records for the service contract |
| U | `callSC` (EKK0161C210CBS) | EKK0161C210SC | Service contract detail record | Calls EKK0161C210 — Service Contract Recovery to recover a service contract detail line that is currently "In Service" |
| U | `callSC` (EKK0161C250CBS) | EKK0161C250SC | Service contract detail record | Calls EKK0161C250 — Service Contract Cancellation Release to reverse a detail line that was concluded (「結合済」) |
| U | `callSC` (EKK0161C240CBS) | EKK0161C240SC | Service contract detail record | Calls EKK0161C240 — Post-Inspection Cancellation Release to reverse a detail line that passed inspection |
| R | `callSC` (EKK0341B031CBS) | EKK0341B031SC | Equipment provision contract history | Calls EKK0341B031 — Equipment Provision Contract History List (by SYSID) to retrieve all equipment contracts for recovery |
| U | `callSC` (EKK0341C380CBS) | EKK0341C380SC | Equipment provision contract record | Calls EKK0341C380 — Equipment Contract Recovery to recover an equipment provision contract from "In Service" state |
| U | `callSC` (EKK0341C390CBS) | EKK0341C390SC | Equipment provision contract record | Calls EKK0341C390 — Pre-Service Equipment Contract Recovery to recover an equipment provision contract from "Concluded" state |
| U | `callSC` (EKK0341C420CBS) | EKK0341C420SC | Equipment provision contract record | Calls EKK0341C420 — Post-Inspection Equipment Contract Cancellation Release to reverse post-inspection equipment |
| R | `callSC` (EKK1681B001CBS) | EKK1681B001SC | Abnormal reservation table | Calls EKK1681B001 — Abnormal Reservation List to find pre-arrived abnormal reservations by detail number |
| R | `callSC` (EKK1681A010CBS) | EKK1681A010SC | Abnormal reservation master | Calls EKK1681A010 — Abnormal Reservation Consultation to retrieve reservation details for status change |
| U | `callSC` (EKK1681C010CBS) | EKK1681C010SC | Abnormal reservation master | Calls EKK1681C010 — Abnormal Reservation Status Change to update abnormal reservation status to "02" (canceled) |
| R | `callSC` (EKK0351B002CBS) | EKK0351B002SC | Option service contract table | Calls EKK0351B002 — Option Service Contract List to retrieve option service contracts for recovery |
| U | `callSC` (EKK0351C270CBS) | EKK0351C270SC | Option service contract record | Calls EKK0351C270 — Option Service Contract Recovery to recover an option service contract that has a service start date |
| U | `callSC` (EKK0351C310CBS) | EKK0351C310SC | Option service contract record | Calls EKK0351C310 — Option Service Contract Cancellation Release to release a cancelled option service with no start date |
| R | `callSC` (EKK0241B001CBS) | EKK0241B001SC | Service disconnection detail table | Calls EKK0241B001 — Service Disconnection Detail List to retrieve disconnection details for recovery |
| R | `callSC` (EKK0251A010CBS) | EKK0251A010SC | Service disconnection detail record | Calls EKK0251A010 — Service Disconnection Detail Consultation to get disconnection detail status |
| R | `callSC` (EKK0341B504CBS) | EKK0341B504SC | Equipment provision contract table | Calls EKK0341B504 — Equipment Contract List (by disconnection detail) to find equipment under disconnection |
| U | `callSC` (EKK0251C060CBS) | EKK0251C060SC | Service disconnection detail record | Calls EKK0251C060 — Service Disconnection Reactivation to reactivate a disconnection detail that was in use |
| - | `callSC` (EKK0341B501CBS) | EKK0341B501SC | — | Commented out in v6.00.00 — was Equipment Provision Service Contract List (by service contract number) |
| C | `JKKSptvKeyInfOperateCC.execute` | — | — | Executes Skuiper key information operation (synchronization) to sync key data for the new TV course |
| - | `execWctrlOrder` | — | Viewing control order data | Internal method — Executes viewing-control orders for recovered service work numbers |

## 5. Dependency Trace

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

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKTVSvcKeiKaihukuCC.kaihuku()` | `kaihuku()` -> `recovery()` | `EKK0081C200 [U] Service Contract`, `EKK0161B004 [R] Service Contract Detail`, `EKK0161C210 [U] Service Contract Recovery`, `EKK0161C250 [U] Contract Cancel Release`, `EKK0161C240 [U] Post-Inspection Cancel Release`, `EKK0341B031 [R] Equipment History`, `EKK0341C380 [U] Equipment Recovery`, `EKK0341C390 [U] Pre-Service Recovery`, `EKK0341C420 [U] Post-Inspection Equip Cancel Release`, `EKK1681B001 [R] Abnormal Reservation List`, `EKK1681A010 [R] Abnormal Resv Consultation`, `EKK1681C010 [U] Abnormal Resv Status Change`, `EKK0351B002 [R] Option Service Contract`, `EKK0351C270 [U] Option Recovery`, `EKK0351C310 [U] Option Cancel Release`, `EKK0241B001 [R] Disconnection Detail`, `EKK0251A010 [R] Disconnection Consultation`, `EKK0341B504 [R] Equipment Contract List`, `EKK0251C060 [U] Disconnection Reactivation`, `execWctrlOrder [-] Viewing Control`, `JKKSptvKeyInfOperateCC.execute [-] Skuiper Key Sync` |

**Notes:**
- The `recoveryToConclusion()` method is a private sibling method for the "Concluded to Cancelled" recovery path. It is called separately from `kaihuku()` when the `ido_div` indicates a conclusion-type disassociation.
- The `callSC` method is a private helper within this class that invokes CBS services with proper error handling and message mapping.

## 6. Per-Branch Detail Blocks

### Block 1 — SETUP `(Extract data and get operating date)` (L2013)

Extracts the business data map and core fields from the request, then retrieves the operating date.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ccMsg = param.getData(dataMapKey)` | Retrieve the business data map from request parameter |
| 2 | SET | `funcCode = ccMsg.get("func_code")` | Function code (機能コード) — identifies the functional context of this operation [-> resolves to a specific function identifier] |
| 3 | SET | `ido_div = ccMsg.get("ido_div")` | Disassociation classification (異動区分) — the type of movement/disassociation being processed [-> e.g., termination, conclusion, etc.] |
| 4 | SET | `mskmDtlNoBf = ccMsg.get("mskm_dtl_no")` | Disassociation request detail number before (解約時申請明細番号) — the prior disassociation being undone |
| 5 | SET | `lastUpdDtm = ccMsg.get("lastUpdDtm")` | Last update timestamp (更新年月日时分秒) — optimistic concurrency control timestamp |
| 6 | SET | `opeDate = JPCBPCommon.getOpeDate(null)` | Operating date (運用日) — current business date for all recovery operations |
| 7 | SET | `sysID = ccMsg.get("sysID")` | System ID (SYSID) — v6.00.00 addition, used to identify the equipment system for recovery queries |

---

### Block 2 — CALL `(EKK0081C200 Service Contract Recovery)` (L2034)

Recovers the base service contract from "In Service" state.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0081c200IN = new CAANMsg(EKK0081C200CBSMsg.class)` | Create request message for EKK0081C200CBS |
| 2 | SET | `in.set(TEMPLATEID, TEMPLATE_ID_EKK0081C200)` | Set message template ID |
| 3 | SET | `in.set(FUNC_CODE, funcCode)` | Propagate function code |
| 4 | SET | `in.set(SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Service contract number |
| 5 | SET | `in.set(MSKM_DTL_NO, mskmDtlNo)` | New disassociation detail number |
| 6 | SET | `in.set(KAIHK_YMD, opeDate)` | Recovery date |
| 7 | SET | `in.set(IDO_DIV, ido_div)` | Disassociation classification |
| 8 | SET | `in.set(UPD_DTM_BF, lastUpdDtm)` | Previous update timestamp |
| 9 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0081c200IN)` | Call EKK0081C200 - Service Contract Recovery |
| 10 | SET | `lastUpdDtm = ekk0081c200OUT.getString(UPD_DTM)` | Get updated timestamp from response |

---

### Block 3 — CALL + LOOP `(EKK0161B004 - Service Contract Detail List, then recover each detail)` (L2047)

Queries all service contract detail records and recovers each matching detail based on its status date.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0161b004IN = new CAANMsg(EKK0161B004CBSMsg.class)` | Create request for EKK0161B004CBS |
| 2 | SET | `in.set(TEMPLATEID, TEMPLATE_ID_EKK0161B004)` | Set template ID |
| 3 | SET | `in.set(FUNC_CODE, "1")` | Set function code to "1" |
| 4 | SET | `in.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Service contract number |
| 5 | CALL | `callSC(...).getCAANMsgList(EKK0161B004CBSMSG1LIST)` | Call EKK0161B004 - Service Contract Detail List |
| 6 | SET | `svcUcwkMap = new HashMap<>()` | Initialize viewing control work map |
| 7 | FOR | `for (CAANMsg curSvcKeiUcwkInfo : ekk0161b004OUT)` | Loop over service contract detail records |

---

### Block 3.1 — IF-ELSEIF `(Detail recovery based on status date)` (L2056)

For each service contract detail matching `mskmDtlNoBf`, checks which status date is populated and calls the appropriate recovery CBS.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `!mskmDtlNoBf.equals(curSvcKeiUcwkInfo.getString(MSKM_DTL_NO))` | Skip records not matching the disassociation detail number [-> 解約時申請明細番号と異なるレコードは回復対象外] |
| 1.1 | CONTINUE | `continue` | Skip non-matching record |
| 2 | SET | `uwSvcStrtYmd = getNullToStr(curSvcKeiUcwkInfo.getString(SVC_STA_YMD))` | Service start date (サービス開始年月日), null-safe |
| 3 | SET | `uwKeiTeiketuYmd = getNullToStr(curSvcKeiUcwkInfo.getString(KEI_CNC_YMD))` | Contract conclusion date (契約締結年月日), null-safe |
| 4 | SET | `uwShosaYmd = getNullToStr(curSvcKeiUcwkInfo.getString(SHOSA_YMD))` | Inspection date (調査年月日), null-safe |
| 5 | IF | `uwSvcStrtYmd != null && !"".equals(uwSvcStrtYmd)` | "In Service" state — service start date is populated [-> 「サービス提供中」の状態へ回復] |
| 5.1 | CALL | `callSC(EKK0161C210CBS)` | EKK0161C210 - Service Contract Recovery |
| 5.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Get updated timestamp |
| 6 | ELSEIF | `uwKeiTeiketuYmd != null && !"".equals(uwKeiTeiketuYmd)` | "Concluded" state — contract conclusion date is populated [-> 「結合済」の状態へ回復] |
| 6.1 | CALL | `callSC(EKK0161C250CBS)` | EKK0161C250 - Service Contract Cancellation Release |
| 6.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Get updated timestamp |
| 7 | ELSEIF | `uwShosaYmd != null && !"".equals(uwShosaYmd)` | "Inspected" state — inspection date is populated [-> 「調査済」の状態へ回復] |
| 7.1 | CALL | `callSC(EKK0161C240CBS)` | EKK0161C240 - Post-Inspection Cancellation Release |
| 7.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Get updated timestamp |

---

### Block 4 — CALL + LOOP `(EKK0341B031 - Equipment Provision Contract History by SYSID)` (L2707)

After v8.00.00 changes, equipment recovery queries by `sysID` (previously by `ido_div`). The equipment recovery is unified regardless of `ido_div`. Tracks processed contracts in `kaihkZmSet`.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0341B031IN = new CAANMsg(EKK0341B031CBSMsg.class)` | Create request for EKK0341B031CBS |
| 2 | SET | `in.set(TEMPLATEID, TEMPLATE_ID_EKK0341B031)` | Set template ID |
| 3 | SET | `in.set(FUNC_CODE, "1")` | Set function code to "1" |
| 4 | SET | `in.set(KEY_SYSID, sysID)` | SYSID filter (v8.00.00: uses sysID instead of ido_div="00005") |
| 5 | CALL | `callSC(...).getCAANMsgList(EKK0341B031CBSMSG1LIST)` | Call EKK0341B031 - Equipment Provision Contract History List |
| 6 | SET | `kaihkZmSet = new HashSet()` | Initialize processed equipment contract set |
| 7 | FOR | `for (CAANMsg curKktkSvcKeiInfo : ekk0341B031OUT)` | Loop over equipment provision contract records |

---

### Block 4.1 — IF-ELSEIF `(Equipment contract recovery based on status date)` (L2724)

For each equipment contract matching `mskmDtlNoBf`, applies the same three-date recovery pattern as Block 3.1. After recovery, adds the contract number to `kaihkZmSet` to prevent duplicate processing. Also populates `svcUcwkMap` for viewing control orders.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `!mskmDtlNoBf.equals(curKktkSvcKeiInfo.getString(MSKM_DTL_NO))` | Skip non-matching disassociation detail [-> 解約時申請明細番号と異なるレコードは回復対象外] |
| 1.1 | CONTINUE | `continue` | Skip |
| 2 | IF | `kaihkZmSet.contains(curKktkSvcKeiInfo.getString(KKTK_SVC_KEI_NO))` | Already processed? [-> 回復処理済の場合はいったんの処理はしない] |
| 2.1 | CONTINUE | `continue` | Skip duplicate |
| 3 | SET | `kikiSvcStrtYmd = getNullToStr(SVC_STA_YMD)` | Equipment service start date (サービス開始年月日), null-safe |
| 4 | SET | `kikiKeiTeiketuYmd = getNullToStr(KEI_CNC_YMD)` | Equipment conclusion date (締結日), null-safe |
| 5 | SET | `kikiShosaYmd = getNullToStr(SHOSA_YMD)` | Equipment inspection date (調査年月日), null-safe |
| 6 | IF | `kikiSvcStrtYmd != null && !"".equals(kikiSvcStrtYmd)` | Equipment "In Service" state [-> 「サービス提供中」の状態へ回復] |
| 6.1 | CALL | `callSC(EKK0341C380CBS)` | EKK0341C380 - Equipment Contract Recovery |
| 6.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Update timestamp |
| 6.3 | SET | `kaihkZmSet.add(KKTK_SVC_KEI_NO)` | Mark as processed [-> 回復済の機器提供サービス契約番号を格納] |
| 7 | ELSEIF | `kikiKeiTeiketuYmd != null && !"".equals(kikiKeiTeiketuYmd)` | Equipment "Concluded" state [-> 「結合済」の状態へ回復] |
| 7.1 | CALL | `callSC(EKK0341C390CBS)` | EKK0341C390 - Pre-Service Equipment Contract Recovery |
| 7.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Update timestamp |
| 7.3 | SET | `kaihkZmSet.add(KKTK_SVC_KEI_NO)` | Mark as processed |
| 8 | ELSEIF | `kikiShosaYmd != null && !"".equals(kikiShosaYmd)` | Equipment "Inspected" state [-> 「調査済」の状態へ回復] |
| 8.1 | CALL | `callSC(EKK0341C420CBS)` | EKK0341C420 - Post-Inspection Equipment Contract Cancellation Release |
| 8.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Update timestamp |
| 8.3 | SET | `kaihkZmSet.add(KKTK_SVC_KEI_NO)` | Mark as processed |
| 9 | IF | `SVC_KEI_UCWK_NO == null || ""` | Service work number is empty [-> 空文字またはnullの場合はスキップ] |
| 9.1 | CONTINUE | `continue` | Skip |
| 10 | IF | `!svcUcwkMap.containsKey(SVC_KEI_UCWK_NO)` | Initialize map entry if absent |
| 10.1 | SET | `svcUcwkMap.put(svcUcwkNo, new HashMap())` | Create entry |
| 11 | SET | `ucwkInfo = svcUcwkMap.get(svcUcwkNo)` | Get map entry |
| 12 | SET | `ucwkInfo.put(KKTK_SVC_CD, KIKI_SEIZO_NO)` | Map service code -> device serial number |
| 13 | SET | `ucwkInfo.put(KKTK_SVC_CD + "_MODEL", TAKNKIKI_MODEL_CD)` | Map service code + _MODEL -> model code |

---

### Block 5 — LOOP `(EKK1681C011 - Abnormal Reservation Pre-Arrived Processing)` (L2904)

Processes abnormal reservations that are pre-arrived (pre-arrived = 予約期日到来済) but not yet reflected (未反映情報取得). For records matching `ido_div = "00026"` and `ido_rsv_dtl_cd = "013"`, it cancels the abnormal reservation by querying and updating its status.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `syoriMskm = new ArrayList<String>()` | Initialize processed disassociation detail set |
| 2 | FOR | `for (CAANMsg ekk1681c011OUT : ekk1681c011OUTLIST)` | Loop over abnormal reservation detail records |
| 3 | IF | `ido_div="00026" AND ido_rsv_dtl_cd="013" AND not in syoriMskm` | Pre-arrived abnormal reservation with disassociation detail [-> 異動予約期日到来済・未反映情報の結果に機器契約変更（解約）のレコードがある場合] |
| 3.1 | SET | `ekk1681b001IN = new CAANMsg(EKK1681B001CBSMsg.class)` | Create EKK1681B001CBS request |
| 3.2 | SET | `in.set(KEY_IDO_RSV_STAT_CD, "00,03")` | Filter by reservation status codes "00" and "03" |
| 3.3 | SET | `in.set(KEY_MSKM_DTL_NO, ...)` | Filter by disassociation detail number |
| 3.4 | CALL | `callSC(EKK1681B001CBS).getCAANMsgList(...)` | EKK1681B001 - Abnormal Reservation List |
| 3.5 | IF | `outList == null || empty` | No abnormal reservations found, mark as processed |
| 3.5.1 | SET | `syoriMskm.add(...)` | Mark as processed |
| 3.5.2 | CONTINUE | `continue` | Skip |
| 3.6 | FOR | `for (CAANMsg ekk1681b001OUT : outList)` | Loop over found abnormal reservations |
| 3.6.1 | SET | `ekk1681a010IN = new CAANMsg(EKK1681A010CBSMsg.class)` | Create EKK1681A010CBS request |
| 3.6.2 | SET | `in.set(KEY_IDO_RSV_NO, ...)` | Abnormal reservation number |
| 3.6.3 | CALL | `callSC(EKK1681A010CBS).getCAANMsgList(...)[0]` | EKK1681A010 - Abnormal Reservation Consultation |
| 3.6.4 | SET | `ekk1681c010IN = new CAANMsg(EKK1681C010CBSMsg.class)` | Create status change request |
| 3.6.5 | SET | `in.set(IDO_RSV_CL_YMD, opeDate)` | Abnormal reservation cancellation date |
| 3.6.6 | SET | `in.set(IDO_RSV_STAT_CD, "02")` | Status code "02" (canceled) [-> 異動予約ステータスを"02"に変更] |
| 3.6.7 | SET | `in.set(UPD_DTM_BF, ...)` | Previous update timestamp from EKK1681A010 |
| 3.6.8 | CALL | `callSC(EKK1681C010CBS)` | EKK1681C010 - Abnormal Reservation Status Change |
| 3.7 | SET | `syoriMskm.add(...)` | Mark disassociation detail as processed |
| 3.8 | CONTINUE | `continue` | Skip |

---

### Block 6 — CALL + LOOP `(EKK0351B002 - Option Service Contract List)` (L2967)

Queries all option service contracts for the service contract number, then recovers each matching contract.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0351b002IN = new CAANMsg(EKK0351B002CBSMsg.class)` | Create EKK0351B002CBS request |
| 2 | SET | `in.set(TEMPLATEID, TEMPLATE_ID_EKK0351B002)` | Set template ID |
| 3 | SET | `in.set(FUNC_CODE, "1")` | Set function code to "1" |
| 4 | SET | `in.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Service contract number |
| 5 | CALL | `callSC(...).getCAANMsgList(EKK0351B002CBSMSG1LIST)` | EKK0351B002 - Option Service Contract List |
| 6 | FOR | `for (CAANMsg curOpSvcKeiInfo : ekk0351b002OUT)` | Loop over option service contracts |

---

### Block 6.1 — IF `(Option Service Recovery based on status)` (L2981)

For each option service contract matching `mskmDtlNoBf`, checks if status is "910" (cancelled). If so, first checks if an abnormal option start reservation exists — if yes, cancels the reservation and skips recovery. Then recovers or releases based on `SVC_STAYMD`.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `!mskmDtlNoBf.equals(curOpSvcKeiInfo.getString(MSKM_DTL_NO))` | Skip non-matching records [-> 解約時申請明細番号と異なるレコードは回復対象外] |
| 1.1 | CONTINUE | `continue` | Skip |
| 2 | SET | `opSvcKeiStat = curOpSvcKeiInfo.getString(OP_SVC_KEI_STAT)` | Option service contract status |
| 3 | SET | `opSvcStaYmd = curOpSvcKeiInfo.getString(SVC_STAYMD)` | Service start date |
| 4 | SET | `opSvcKeiNo = curOpSvcKeiInfo.getString(OP_SVC_KEI_NO)` | Option service contract number |
| 5 | IF | `opSvcKeiStat == "910"` | Option service is "Cancelled" [-> オプションサービス契約が「解約済」の場合] |
| 5.1 | SET | `opRecoveryFlg = true` | Initialize recovery flag |
| 5.2 | FOR | `for (CAANMsg ekk1681c011OUT : ekk1681c011OUTLIST)` | Check for abnormal option start reservations |
| 5.2.1 | IF | `opSvcKeiNo == out.OP_SVC_KEI_NO AND out.IDO_RSV_DTL_CD == "014"` | Found abnormal option start reservation [-> 異動予約期日到来済・未反映情報にオプション開始のレコード] |
| 5.2.1.1 | CALL | `callSC(EKK1681A010CBS)` | EKK1681A010 - Abnormal Reservation Consultation |
| 5.2.1.2 | SET | `ekk1681c010IN` | Create status change request |
| 5.2.1.3 | SET | `in.set(IDO_RSV_STAT_CD, "02")` | Status to "02" (canceled) |
| 5.2.1.4 | CALL | `callSC(EKK1681C010CBS)` | EKK1681C010 - Abnormal Reservation Status Change |
| 5.2.1.5 | SET | `opRecoveryFlg = false` | Do not recover — reservation will be canceled |
| 5.2.1.6 | BREAK | `break` | Exit inner loop |
| 5.3 | IF | `!opRecoveryFlg` | Abnormal reservation was found and will be canceled |
| 5.3.1 | CONTINUE | `continue` | Skip recovery |
| 5.4 | IF | `opSvcStaYmd != null && !"".equals(opSvcStaYmd)` | Service start date is set [-> サービス開始年月日が空でない場合] |
| 5.4.1 | CALL | `callSC(EKK0351C270CBS)` | EKK0351C270 - Option Service Contract Recovery |
| 5.4.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Update timestamp |
| 5.5 | ELSE | `else` | Service start date is empty |
| 5.5.1 | CALL | `callSC(EKK0351C310CBS)` | EKK0351C310 - Option Service Contract Cancellation Release |
| 5.5.2 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Update timestamp |

---

### Block 7 — CALL + LOOP `(EKK0241B001 - Service Disconnection Detail List)` (L3068)

Queries service disconnection details for the service contract number. For each, checks if equipment provision sub-status is "910" (cancelled) and service code "C013", recovering the equipment if so. Then reactivates the disconnection detail if its status is "210".

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0241b001IN = new CAANMsg(EKK0241B001CBSMsg.class)` | Create EKK0241B001CBS request |
| 2 | SET | `in.set(TEMPLATEID, TEMPLATE_ID_EKK0241B001)` | Set template ID |
| 3 | SET | `in.set(FUNC_CODE, "1")` | Function code "1" |
| 4 | SET | `in.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Service contract number |
| 5 | CALL | `callSC(...).getCAANMsgList(...)` | EKK0241B001 - Service Disconnection Detail List |
| 6 | FOR | `for (CAANMsg curKaiUcwkInfo : ekk0241b001OUT)` | Loop over disconnection details |
| 7 | SET | `ekk0251a010IN = new CAANMsg(EKK0251A010CBSMsg.class)` | Create EKK0251A010CBS request |
| 8 | SET | `in.set(KEY_SVC_KEI_KAISEN_UCWK_NO, ...)` | Disconnection detail work number |
| 9 | SET | `in.set(KEY_GENE_ADD_DTM, ...)` | Generation addition timestamp |
| 10 | CALL | `callSC(EKK0251A010CBS).getCAANMsgList(...)[0]` | EKK0251A010 - Service Disconnection Detail Consultation |
| 11 | SET | `ekk0341b504IN = new CAANMsg(EKK0341B504CBSMsg.class)` | Create EKK0341B504CBS request |
| 12 | SET | `in.set(KEY_SVC_KEI_KAISEN_UCWK_NO, ...)` | Disconnection detail work number |
| 13 | CALL | `callSC(EKK0341B504CBS).getCAANMsgList(...)` | EKK0341B504 - Equipment Contract List (by disconnection) |
| 14 | FOR | `for (CAANMsg curKaisenKiki : ekk0341b504OUTList)` | Loop over equipment under disconnection |
| 14.1 | IF | `kktkSvcKeiStat != "910" OR kktkSvcCd != "C013"` | Skip if not cancelled or not service code C013 |
| 14.1.1 | CONTINUE | `continue` | Skip |
| 14.2 | IF | `!mskmDtlNoBf.equals(curKaisenKiki.getString(MSKM_DTL_NO))` | Skip non-matching detail number [-> v5.00.01 added] |
| 14.2.1 | CONTINUE | `continue` | Skip |
| 14.3 | CALL | `callSC(EKK0341C380CBS)` | EKK0341C380 - Equipment Contract Recovery |
| 14.4 | SET | `lastUpdDtm = out.getString(UPD_DTM)` | Update timestamp |
| 15 | IF | `!ukkSvcKaisenUcwkStat.equals("210")` | Disconnection detail not in use [-> サービス回線内線が使用中の場合は更新しない] |
| 15.1 | CONTINUE | `continue` | Skip |
| 16 | SET | `ekk0251c060IN = new CAANMsg(EKK0251C060CBSMsg.class)` | Create EKK0251C060CBS request |
| 17 | SET | `in.set(SVC_KEI_KAISEN_UCWK_NO, ...)` | Disconnection detail work number |
| 18 | SET | `in.set(USE_STAYMD, opeDate)` | Use start date |
| 19 | SET | `in.set(KK0251_UPD_DTM_BF, ...)` | Previous update timestamp from EKK0251A010 |
| 20 | SET | `msgList = new CAANMsg[]{...}` | Create response message list with SVC_KEI_NO and KK0241_UPD_DTM_BF |
| 21 | SET | `msgList[0].set(SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Service contract number |
| 22 | SET | `msgList[0].set(KK0241_UPD_DTM_BF, lastUpdDtm)` | Last update timestamp |
| 23 | CALL | `callSC(EKK0251C060CBS)` | EKK0251C060 - Service Disconnection Reactivation |

---

### Block 8 — LOOP `(execWctrlOrder for viewing control orders)` (L3148)

Iterates over the `svcUcwkMap` built during equipment recovery, executing viewing-control orders for each recovered service work number.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `it = svcUcwkMap.keySet().iterator()` | Get iterator over service work numbers |
| 2 | WHILE | `it.hasNext()` | Loop over all service work numbers |
| 2.1 | SET | `svcUcwkNo = it.next()` | Get next service work number |
| 2.2 | SET | `ucwkInfo = svcUcwkMap.get(svcUcwkNo)` | Get device info map |
| 2.3 | CALL | `execWctrlOrder(handle, param, scCall, svcUcwkNo, ucwkInfo, dataMapKey)` | Execute viewing-control order for this service work [-> 視聴制御オーダ発行] |

---

### Block 9 — SETUP + CALL `(Skuiper Key Information Synchronization)` (L3157)

Calls `JKKSptvKeyInfOperateCC.execute` to synchronize Skuiper key information for the new TV course. This is part of the ANK-4592-00-00 addition for introducing Skuiper keys.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `workMap = new HashMap<String, Object>()` | Initialize work map for Skuiper sync |
| 2 | SET | `workMap.put("func_cd", funcCode)` | Function code |
| 3 | SET | `workMap.put("shori_cd", SHORI_CD_KAIHK_PAUSE_STP_RLS)` | Process code for recovery pause step release [-> 回復処理一時停止ステップ解除] |
| 4 | SET | `workMap.put("svc_kei_no", ccMsg.get("svc_kei_no"))` | Service contract number |
| 5 | SET | `workMap.put("snst_mt_ymd", opeDate)` | Notification date |
| 6 | SET | `param.setData(CC_WORK_SPTVKAIHK_PAUSE_STP_RLS, workMap)` | Set work data in parameter |
| 7 | SET | `JKKSptvKeyInfOperateCC = new JKKSptvKeyInfOperateCC()` | Instantiate Skuiper key component |
| 8 | CALL | `JKKSptvKeyInfOperateCC.execute(handle, param, CC_WORK_SPTVKAIHK_PAUSE_STP_RLS)` | Execute Skuiper key information sync [-> スカパーキー情報操作CC呼び出し] |

---

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — unique identifier for a TV service contract line |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract work processing |
| `mskm_dtl_no` | Field | Disassociation detail number — unique identifier for a disassociation/termination request line |
| `mskm_dtl_no_bf` | Field | Previous disassociation detail number — the disassociation being undone during recovery |
| `func_code` | Field | Function code — identifies the functional context of the operation |
| `ido_div` | Field | Disassociation classification (異動区分) — type of movement/disassociation (e.g., termination, conclusion, forced cancellation) |
| `opeDate` | Field | Operating date (運用日) — current business date used as the effective date for recovery operations |
| `lastUpdDtm` | Field | Last update timestamp — optimistic concurrency control timestamp to prevent concurrent modification |
| `sysID` | Field | System ID — identifies the equipment provisioning system (added in v6.00.00) |
| `opSvcKeiStat` | Field | Option service contract status — e.g., "910" for cancelled, other values for active/in-progress |
| `kktkSvcKeiStat` | Field | Equipment provision service contract status — e.g., "910" for cancelled |
| `kktkSvcCd` | Field | Equipment provision service code — e.g., "C013" for a specific equipment service type |
| `ukkSvcKaisenUcwkStat` | Field | Disconnection detail work status — "210" indicates the line is in use (使用中) |
| `ido_rsv_dtl_cd` | Field | Abnormal reservation detail code — "013" for equipment contract change (disassociation), "014" for option service start |
| `ido_rsv_stat_cd` | Field | Abnormal reservation status code — "00" for new, "02" for canceled, "03" for in-progress |
| `ido_rsv_no` | Field | Abnormal reservation number — unique identifier for an abnormal reservation |
| `kaihkZmSet` | Field | Processed equipment contract number set (回復処理済みセット) — tracks equipment contracts already recovered to prevent duplicate processing |
| `svcUcwkMap` | Field | Service work number map — maps service work numbers to device info (serial number, model code) for viewing-control order execution |
| `syoriMskm` | Field | Processed disassociation details list (処理明細) — tracks disassociation details already processed in abnormal reservation handling |
| `opRecoveryFlg` | Field | Option service recovery flag — indicates whether the option service should be recovered or if its reservation should be canceled instead |
| `SVC_STA_YMD` | Field | Service start date (サービス開始年月日) — indicates the service is currently "In Service" (「サービス提供中」) |
| `KEI_CNC_YMD` | Field | Contract conclusion date (契約締結年月日) — indicates the contract was concluded (「結合済」) |
| `SHOSA_YMD` | Field | Inspection date (調査年月日) — indicates the contract passed inspection (「調査済」) |
| `SVC_STAYMD` | Field | Option service start date — used to determine option service recovery path |
| `KIKI_SEIZO_NO` | Field | Device serial number (機器製造番号) — unique serial number of the provisioned equipment |
| `TAKNKIKI_MODEL_CD` | Field | Rental equipment model code (レンタル機器モデルコード) — model identifier for rental equipment |
| K-Opticom | Business term | K-Opticom — a Japanese broadband and TV service provider (KDDI's fiber optic service brand) |
| eo TV | Business term | eo TV — K-Opticom's IPTV television service |
| eo光 (eo Hikari) | Business term | eo Light — K-Opticom's fiber optic broadband service |
| CBS | Technical | Component-Based Service — Fujitsu's service component architecture for business logic services |
| SC | Technical | Service Component — a discrete business service unit in the CBS architecture |
| CAANMsg | Technical | Canonical Message — the standard message format used for CBS communication |
| EKKxxxx | Technical | Service component code prefix — EKK prefix identifies TV service-related CBS services |
| EKK0081C200 | SC Code | Service Contract Recovery — recovers a service contract from "In Service" state |
| EKK0081C240 | SC Code | Service Contract Cancellation Release — reverses a service contract cancellation (conclusion path) |
| EKK0081C200CBS | SC Code | (Pre-computed reference: same as EKK0081C200) |
| EKK0161B004 | SC Code | Service Contract Detail List — retrieves all detail records for a service contract |
| EKK0161C210 | SC Code | Service Contract Recovery — recovers a service contract detail line from "In Service" |
| EKK0161C240 | SC Code | Post-Inspection Cancellation Release — reverses a post-inspection detail line |
| EKK0161C250 | SC Code | Service Contract Cancellation Release — reverses a concluded detail line |
| EKK0341B031 | SC Code | Equipment Provision Contract History List — retrieves equipment contracts by SYSID |
| EKK0341B501 | SC Code | Equipment Provision Service Contract List (by service contract number) — commented out since v6.00.00 |
| EKK0341B504 | SC Code | Equipment Contract List (by disconnection detail) — retrieves equipment under a disconnection |
| EKK0341C380 | SC Code | Equipment Contract Recovery — recovers an equipment provision contract from "In Service" |
| EKK0341C390 | SC Code | Pre-Service Equipment Contract Recovery — recovers equipment from "Concluded" state |
| EKK0341C420 | SC Code | Post-Inspection Equipment Contract Cancellation Release |
| EKK0351B002 | SC Code | Option Service Contract List — retrieves option service contracts |
| EKK0351C270 | SC Code | Option Service Contract Recovery |
| EKK0351C310 | SC Code | Option Service Contract Cancellation Release |
| EKK0241B001 | SC Code | Service Disconnection Detail List — retrieves disconnection details |
| EKK0251A010 | SC Code | Service Disconnection Detail Consultation |
| EKK0251C060 | SC Code | Service Disconnection Reactivation — reactivates a disconnection detail back to use |
| EKK1681A010 | SC Code | Abnormal Reservation Consultation — retrieves abnormal reservation details |
| EKK1681B001 | SC Code | Abnormal Reservation List — queries abnormal reservations |
| EKK1681C010 | SC Code | Abnormal Reservation Status Change — updates abnormal reservation status |
| EKK1681C011 | SC Code | Abnormal Reservation Detail Information — pre-arrived abnormal reservation data passed as parameter |
| JKKSptvKeyInfOperateCC | Class | Skuiper Key Information Operation Component — handles Skuiper smart card key data operations |
| Skuiper | Business term | Skuiper — a satellite broadcasting service by KDDI requiring smart card key authentication |
| 視聴制御 (Shichou Seigyo) | Japanese term | Viewing control — conditional access control for premium TV channels (e.g., watching control orders) |
| 解約 (Kaiya) | Japanese term | Cancellation/Termination — the act of canceling a service contract |
| 回復 (Kaihuku) | Japanese term | Recovery — the process of restoring a service contract to a previous active state |
| 結合済 (Ketsugou-zumi) | Japanese term | Concluded — the status of a service contract that has been successfully contracted |
| サービス提供中 (Saabisu Teikyou-chu) | Japanese term | In Service — the active service status of a contract |
| 調査済 (Chousa-zumi) | Japanese term | Inspected — the contract has passed inspection |
| 異動予約 (Idou Yoyaku) | Japanese term | Abnormal/Move reservation — a pending movement/disassociation reservation |
| 予約期日到来済 (Yoyaku Kitabi Tourai-zumi) | Japanese term | Pre-arrived — the reservation date has arrived but the change has not been reflected |
| 未反映 (Mihan'ei) | Japanese term | Unreflected — changes that have not yet been applied to the active records |
| 撤去解約 (Tehai Kaiya) | Japanese term | Removal cancellation — cancellation due to equipment removal (v7.00.00 added handling, currently commented out) |
| 強制解約 (Kyousei Kaiya) | Japanese term | Forced cancellation — cancellation initiated by the provider (commented out) |
| v6.00.00 | Version | v6.00.00 — Added SYSID parameter for equipment recovery queries |
| v7.00.00 | Version | v7.00.00 — Added removal cancellation equipment recovery handling (commented out) |
| v8.00.00 | Version | v8.00.00 — Changed equipment recovery to query by SYSID instead of ido_div, unified equipment recovery processing |
| v5.00.01 | Version | v5.00.01 — Added disassociation detail number filtering for equipment provision recovery |
| ANK-4592-00-00 | Change ID | Skuiper key introduction for new TV courses — adds Skuiper key synchronization during recovery |
