# Business Logic — JKKTVSvcKeiKaihukuCC.kaihuku() [328 LOC]

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

## 1. Role

### JKKTVSvcKeiKaihukuCC.kaihuku()

The `kaihuku` method (Japanese: 回復, meaning "recovery") is the central orchestration method for EO Light TV service contract recovery processing within the K-Opticom customer base system. It handles the full lifecycle restoration of a service contract that has reached a terminal state — either **cancelled** (status `920`, キャンセル済) or **terminated** (status `910`, 解約済) — and transitions it back to an active operational state. The method implements a **dispatch-and-recover pattern**: it first queries the current service contract status, branches to the appropriate recovery routine based on that status, and then executes a series of follow-on operations (submission history updates, discount auto-application, progress registration) regardless of the branch taken.

The method handles two primary service contract states. For **cancelled contracts** (`920`), it determines whether the cancellation occurred before or after approval (based on whether `SHOSA_YMD` is populated). If already approved, it performs a cancellation recovery reversal (`cancelRecoveryToCNC`) and optionally records work order case recovery. For **terminated contracts** (`910`), it determines the precise pre-termination state (paused, suspended, or fully concluded) and calls the appropriate recovery routine (`recoveryToPauseStatus`, `recovery`, or `recoveryToConclusion`). In all cases, it also handles returned equipment cancellation (`henpinKikiCancel`), applies discount auto-application (`execWrisvcAutoAply`), registers processing progress (`registProgressInfo`), and conditionally charges customer recovery service fees (`EKK1021D010CBS`).

The method supports a **check-only mode** (`func_code = "2"`) where it retrieves current customer and service contract information without performing any recovery processing — used by screens that need to display status before the user confirms the recovery action.

## 2. Processing Pattern (Detailed Business Logic)

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

    A["Get ccMsg from param by dataMapKey"] --> B["Create ServiceComponentRequestInvoker"]
    B --> C["Get opeDate via JCCBPCommon"]
    C --> D["Call EKK1681C011CBS - Discrepancy Info Get"]
    D --> E["Loop: populate EKK1681C011CBSMsg1List"]
    E --> F["Put EKK1681C011CBSMsg1List into ccMsg"]
    F --> G["call checkAdchgAfterDsl"]
    G --> G1{"adchg_after_dsl_flg true"}
    G1 -- "true" --> EARLY["Set adchg_after_dsl_flg equals 1 and Return param"]
    G1 -- "false" --> H["Check func_code"]
    H -- "equals 2" --> H_RET["Return param"]
    H -- "not 2" --> MAIN["Execute Main Processing"]
    MAIN --> M1["Call ECK0011A010CBS - Customer Consultation"]
    M1 --> M2["Call EKK0081A010CBS - Service Contract Consultation"]
    M2 --> M3["Get curSvcKeiStat from EKK0081A010"]
    M3 --> M4["Call EKK0791A010CBS - Price Code Consultation"]
    M4 --> M5["Build orderInsParamMap"]
    M5 --> M6{"SHOSA_YMD null"}
    M6 -- "Not null - Approved" --> M7["Call execMskm to get mskmNo and mskmDtlNo"]
    M6 -- "Null - Pre-initial" --> M8["Get mskmNo from ccMsg mskmDtlNo from curSvcKeiInfo"]
    M7 --> M9["Call EKK0011B002CBS - Submission History"]
    M8 --> M9
    M9 --> M10["Get mskm_staus from EKK0011B002 If 920 use mskmInfo 1"]
    M10 --> M11{"curSvcKeiStat equals 920 Cancelled"}

    M11 -- "true" --> T920["CancelRecovery or CancelRecoveryToCNC"]
    T920 --> T921{"ID_TCHISHO_HAK_SKBT_CD equals 0"}
    T921 -- "Not 0" --> T922["Call JKKTVSjishoAddCC mainExecute"]
    T922 --> T923{"shosaDslFinCd equals 1"}
    T923 -- "true" --> T924["RecoveryKojiAk"]
    T923 -- "false" --> T925["execWrisvcAutoAply"]
    T924 --> T925
    T925 --> T926["registProgressInfo"]
    T926 --> T927{"idoRsnCd equals T6"}
    T927 -- "true" --> T928["Call EKK1021D010CBS - Temporary Money Setup"]
    T927 -- "false" --> T929["Return param"]
    T928 --> T929

    M11 -- "false" --> M100{"curSvcKeiStat equals 910 Terminated"}

    M100 -- "true" --> M110["Call EKK0081B024CBS for mskmDtlNo"]
    M110 --> M111["RecoveryKojiAk"]
    M111 --> M112{"PauseYmd set and PauseRlsYmd not set"}
    M112 -- "true" --> M113["RecoveryToPauseStatus"]
    M112 -- "false" --> M114{"SvcStaYmd set"}
    M114 -- "true" --> M115["Recovery"]
    M114 -- "false" --> M116["RecoveryToConclusion"]
    M113 --> M117["henpinKikiCancel"]
    M115 --> M117
    M116 --> M117
    M117 --> M118["execWrisvcAutoAply"]
    M118 --> M119{"idoRsnCd equals T6"}
    M119 -- "true" --> M120["Call EKK1021D010CBS - Temporary Money Setup"]
    M119 -- "false" --> M121
    M120 --> M121["Return param"]
    M121 --> END(["End"])

    style START fill:#e1f5e1
    style END fill:#e1f5e1
```

**Processing Flow Summary:**

1. **Preparation Phase (L344–L373)**: Extract the `ccMsg` data map from the input parameter, instantiate the `ServiceComponentRequestInvoker`, and obtain the operational date. Call the EKK1681C011 CBS to retrieve discrepancy pre-contract date arrival unreflected information (異動予約期日到来済・未反映情報取得).

2. **Adchg-After-Dsl Guard (L376–L380)**: Check for post-DSL-change discrepancies via `checkAdchgAfterDsl`. If a discrepancy is detected, flag `adchg_after_dsl_flg = "1"` and return early — preventing further processing that could cause incorrect recovery.

3. **Check-Only Mode (L383–L386)**: If `func_code = "2"`, skip all recovery logic and return immediately. This supports display-only screens.

4. **Consultation Phase (L390–L523)**: Query current customer information (ECK0011A010CBS) and current service contract details (EKK0081A010CBS). Retrieve the price code (EKK0791A010CBS) and build `orderInsParamMap` for instruction book registration support.

5. **Service Contract Status Branching**:
   - **For Terminated (910)**: If the DSL status is `CD00037_DSL_ZM` (解約済), retrieve the mskm detail number from the latest terminated service contract history record (EKK0081B024CBS). Then determine the precise pre-termination state (paused vs. active vs. concluded) and call the appropriate recovery method.
   - **For Cancelled (920)**: If the submission status is approved (SHOSA_YMD is not null), perform cancellation recovery reversal via `cancelRecoveryToCNC`. Otherwise, perform standard cancellation recovery via `cancelRecovery`.

6. **Post-Recovery Processing**: In all recovery paths, execute discount auto-application (`execWrisvcAutoAply`), register progress info (`registProgressInfo`), conditionally issue instruction books (JKKTVSjishoAddCC), and conditionally charge the customer recovery service fee if the discrepancy reason code is `T6` (お客さま回復要請のため(事務手数料料)).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for the current business transaction context. Provides the connection and transaction management infrastructure for CBS (Call-Back Service) invocations. |
| 2 | `param` | `IRequestParameterReadWrite` | The business data object carrying all input and output parameters. Contains the operation mode flag (`func_code`), service contract number (`svc_kei_no`), system ID (`sysid`), and carries back results including `adchg_after_dsl_flg`, `EKK1681C011CBSMsg1List` (discrepancy info), and `mskm_dtl_no` (submission detail number). |
| 3 | `fixedText` | `String` | Used as the data map key to access the `ccMsg` HashMap within `param`. This text value (e.g., `"KKSV047401CC"`) serves as the namespace key for the common component's data transfer object, ensuring data isolation when multiple CCs share the same parameter object. |

**Instance Fields / External State Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `idoRsnCd` | `String` | Discrepancy reason code — determines if customer recovery service fee should be charged. Read from external context (set before kaihuku is called). |
| `TEMPLATE_ID_EKK1681C011` | `String` | Template ID constant (`"EKK1681C011"`) for the discrepancy info CBS message. |
| `TEMPLATE_ID_ECK0011A010` | `String` | Template ID constant (`"ECK0011A010"`) for the customer consultation CBS. |
| `TEMPLATE_ID_EKK0081A010` | `String` | Template ID constant (`"EKK0081A010"`) for the service contract consultation CBS. |
| `TEMPLATE_ID_EKK0011D020` | `String` | Template ID constant (`"EKK0011D020"`) for the submission info CBS. |
| `TEMPLATE_ID_EKK0011B002` | `String` | Template ID constant (`"EKK0011B002"`) for the submission history CBS. |
| `TEMPLATE_ID_EKK0081B024` | `String` | Template ID constant (`"EKK0081B024"`) for the service contract history CBS. |
| `TEMPLATE_ID_EKK0791A010` | `String` | Template ID constant (`"EKK0791A010"`) for the price code consultation CBS. |
| `TEMPLATE_ID_EKK1021D010` | `String` | Template ID constant (`"EKK1021D010"`) for the temporary money setup CBS. |
| `MSKM_STAT_920` | `String` | Submission status code (`"920"`) meaning "cancelled" (キャンセル済). Used to skip to the next submission record. |
| `IDO_RSN_CD_KAIHK_REQ_CHRG` | `String` | Discrepancy reason code for customer recovery request fee (`"T6"`) — when set, a temporary money setup CBS is invoked to charge the service fee. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` | EKK1681C011CBS | EKK1681C011 (異動予約期日到来済・未反映情報取得) | Retrieve discrepancy reservation date arrival unreflected information for the given service contract number |
| R | `callSC` | ECK0011A010CBS | ECK0011A010 (お客様一意照会) | Retrieve current customer information (customer master consultation) |
| R | `callSC` | EKK0081A010CBS | EKK0081A010 (サービス契約一意照会) | Retrieve current service contract details including status, service start/end dates, pause dates, price code |
| R | `callSC` | EKK0081B024CBS | EKK0081B024 (サービス契約履歴一覧照会) | Retrieve full service contract history list, ordered by creation datetime descending, to find the latest terminated record |
| R | `callSC` | EKK0011B002CBS | EKK0011B002 (申請履歴一覧照会) | Retrieve submission history records to determine the current submission status (mskm_staus) |
| R | `callSC` | EKK0791A010CBS | EKK0791A010 (料金コード一意照会) | Retrieve price code information associated with the service contract |
| CALL | `execMskm` | EKK0011D020CBS | EKK0011D020 (申請明細) | Create a new submission record and retrieve the submission number and detail number for approved contracts |
| CALL | `checkAdchgAfterDsl` | - | - | Post-DSL-change check — validates whether a residence change cancellation caused data inconsistency |
| C | `cancelRecovery` | - | - | Cancel recovery processing — reverses a cancellation that was not yet approved (SHOSA_YMD is null) |
| C | `cancelRecoveryToCNC` | - | - | Cancel recovery reversal processing — handles cancellation that was already approved (SHOSA_YMD is set), reversing to CANCEL state |
| C | `recovery` | - | - | Service contract recovery processing — restores a terminated (910) contract to active provision state when service start date is set |
| C | `recoveryKojiAk` | - | - | Work order case recovery — recovers the associated work order case record |
| C | `recoveryToConclusion` | - | - | Recovery to concluded state — restores a terminated contract without active pause or service start to concluded (締結済) status |
| C | `recoveryToPauseStatus` | - | - | Recovery to paused state — restores a terminated contract that was in a pause-suspended (休止中) state at time of termination |
| C | `henpinKikiCancel` | - | - | Returned equipment cancellation — processes cancellation of equipment that was returned as part of the termination |
| C | `execWrisvcAutoAply` | - | - | Discount auto-application — applies applicable service discounts based on customer and contract information |
| C | `registProgressInfo` | - | - | Progress registration — records the current processing progress state with the submission detail number |
| C | `callSC` | EKK1021D010CBS | EKK1021D010 (一時金設定登録) | Register temporary money (一時金) for customer recovery service fee charge when discrepancy reason code is T6 |
| CALL | `JKKTVSjishoAddCC.mainExecute` | - | - | Instruction book registration — issues the service instruction book when ID notice book issuance code is not "0" |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0474 | `KKSV0474Flow.run` -> `KKSV0474OPOperation.run` -> `CCRequestBroker.run` -> `JKKTVSvcKeiKaihukuCC.kaihuku` | `EKK1681C011CBS[R]`, `ECK0011A010CBS[R]`, `EKK0081A010CBS[R]`, `EKK0791A010CBS[R]`, `EKK0081B024CBS[R]`, `EKK0011B002CBS[R]`, `execMskm[EKK0011D020CBS[C]]`, `cancelRecovery[C]`, `cancelRecoveryToCNC[C]`, `recovery[C]`, `recoveryKojiAk[C]`, `recoveryToConclusion[C]`, `recoveryToPauseStatus[C]`, `henpinKikiCancel[C]`, `execWrisvcAutoAply[C]`, `registProgressInfo[C]`, `EKK1021D010CBS[C]`, `JKKTVSjishoAddCC[C]` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/ALLOC] Data preparation (L344–L355)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataMapKey = fixedText` | Store the fixedText parameter as the data map access key |
| 2 | EXEC | `ccMsg = (HashMap<String, Object>)param.getData(dataMapKey)` | Retrieve the ccMsg HashMap from the request parameter using the data map key |
| 3 | SET | `dataList = new ArrayList<HashMap<String, Object>>()` | Initialize the list for discrepancy info results |
| 4 | SET | `childMap = null` | Initialize child map variable |
| 5 | SET | `scCall = new ServiceComponentRequestInvoker()` | Instantiate the SC call invoker (empty string passed as class name — no logging output) |
| 6 | SET | `opeDate = JPCBPCommon.getOpeDate(null)` | Obtain the operational date for the current transaction |

**Block 2** — [CALL] Discrepancy pre-contract info retrieval — EKK1681C011 (L358–L373)

> 異動予約期日到来済・未反映情報取得 — Retrieve unreflected discrepancy reservation date arrival information.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk1681c011IN = new CAANMsg(EKK1681C011CBSMsg.class.getName())` | Create input message for discrepancy info CBS |
| 2 | SET | `ekk1681c011IN.set(TEMPLATEID, "EKK1681C011")` | Set template ID constant |
| 3 | SET | `ekk1681c011IN.set(FUNC_CODE, "1")` | Function code 1 |
| 4 | SET | `ekk1681c011IN.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Pass the service contract number from ccMsg |
| 5 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk1681c011IN)` | Invoke the EKK1681C011 CBS |
| 6 | SET | `ekk1681c011OUTLIST = result.getCAANMsgList(...)` | Extract the result list |
| 7 | FOR | `for (CAANMsg ekk1681c011OUT : ekk1681c011OUTLIST)` | Iterate over each discrepancy record |
| 7.1 | SET | `childMap = new HashMap<>()` | Create new map for this record |
| 7.2 | EXEC | `childMap.put("ido_rsv_no", ...getString(IDO_RSV_NO))` | Store the discrepancy reservation number |
| 7.3 | EXEC | `childMap.put("ido_rsv_dtl_cd_nm", ...getString(IDO_RSV_DTL_CD_NM))` | Store the discrepancy detail code name |
| 7.4 | EXEC | `dataList.add(childMap)` | Add to the result list |
| 8 | EXEC | `ccMsg.put("EKK1681C011CBSMsg1List", dataList)` | Store the populated list back into ccMsg |

**Block 3** — [IF] Post-DSL-change discrepancy check (L376–L380)

> 解約後住所変更中チェック — Check for inconsistencies during post-termination residence changes. If a discrepancy is detected, the method aborts all further processing and returns early.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `checkAdchgAfterDsl(handle, param, scCall, dataMapKey)` | Execute the residence change cancellation discrepancy check |
| 2 | IF | Result is truthy (discrepancy detected) | |
| 2.1 | EXEC | `ccMsg.put("adchg_after_dsl_flg", "1")` | Set the post-DSL-change flag to indicate detected discrepancy |
| 2.2 | RETURN | `return param` | Early return — skip all recovery processing |

**Block 4** — [IF] Check-only mode guard (L383–L386)

> 機能コードが「チェックのみ」の場合 — When func_code is "2" (check-only), skip all recovery processing and return immediately. This mode is used by screens that need to display the current service status before the user confirms the recovery action.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"2".equals(ccMsg.get("func_code"))` [func_code = "2"] |
| 1.1 | RETURN | `return param` | Early return — check-only mode, no recovery processing |

**Block 5** — [CALL] Customer consultation — ECK0011A010 (L390–L397)

> お客様一意照会 — Retrieve current customer information (customer master consultation).

| # | Type | Code |
|---|------|------|
| 1 | SET | `eck0011a010IN = new CAANMsg(ECK0011A010CBSMsg.class.getName())` | Create input message |
| 2 | SET | `eck0011a010IN.set(TEMPLATEID, "ECK0011A010")` | Set template ID |
| 3 | SET | `eck0011a010IN.set(FUNC_CODE, "2")` | Function code 2 (consultation) |
| 4 | SET | `eck0011a010IN.set(KEY_SYSID, ccMsg.get("sysid"))` | Pass the system ID from ccMsg |
| 5 | SET | `eck0011a010IN.set(KEY_GENE_ADD_DTM, "")` | Pass empty creation datetime |
| 6 | SET | `eck0011a010IN.set(KEY_RSV_APLY_YMD, opeDate)` | Pass the operational date as reservation application date |
| 7 | CALL | `callSC(handle, scCall, param, dataMapKey, eck0011a010IN)` | Invoke the customer consultation CBS |
| 8 | SET | `curCustInfo = result.getCAANMsgList(...)[0]` | Extract the first result record — current customer info |

**Block 6** — [CALL] Service contract consultation — EKK0081A010 (L400–L410)

> サービス契約一意照会 — Retrieve current service contract details including status (910=terminated, 920=cancelled), service start/end dates, pause dates, price code, and review date.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081a010IN = new CAANMsg(EKK0081A010CBSMsg.class.getName())` | Create input message |
| 2 | SET | `ekk0081a010IN.set(TEMPLATEID, "EKK0081A010")` | Set template ID |
| 3 | SET | `ekk0081a010IN.set(FUNC_CODE, "2")` | Function code 2 (consultation) |
| 4 | SET | `ekk0081a010IN.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Pass the service contract number |
| 5 | SET | `ekk0081a010IN.set(KEY_GENE_ADD_DTM, "")` | Pass empty creation datetime |
| 6 | SET | `ekk0081a010IN.set(KEY_RSV_APLY_YMD, opeDate)` | Pass the operational date |
| 7 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0081a010IN)` | Invoke the service contract consultation CBS |
| 8 | SET | `curSvcKeiInfo = result.getCAANMsgList(...)[0]` | Extract the first result record |
| 9 | SET | `curSvcKeiStat = curSvcKeiInfo.getString(SVC_KEI_STAT)` | Get current service contract status ("910"=terminated, "920"=cancelled) |

**Block 7** — [IF] Service contract is Terminated (910) — retrieve mskmDtlNo from history (L482–L499)

> サービス契約が「解約済」 — When the current service contract status is "910" (Terminated), retrieve the submission detail number (mskmDtlNo) from the latest terminated history record. The service contract history is retrieved ordered by creation datetime descending (降順), and the loop iterates until finding a record with a non-terminated status, which marks the boundary where the contract transitioned to terminated.

| # | Type | Code |
|---|------|------|
| 1 | IF | `JKKStrConst.CD00037_DSL_ZM.equals(curSvcKeiStat)` [CD00037_DSL_ZM = "910" (Terminated/解約済)] |
| 1.1 | SET | `ekk0081b024IN = new CAANMsg(EKK0081B024CBSMsg.class.getName())` | Create input for service contract history CBS |
| 1.2 | SET | `ekk0081b024IN.set(TEMPLATEID, "EKK0081B024")` | Template ID |
| 1.3 | SET | `ekk0081b024IN.set(FUNC_CODE, "1")` | Function code 1 (history inquiry) |
| 1.4 | SET | `ekk0081b024IN.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Pass the service contract number |
| 1.5 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0081b024IN)` | Invoke the service contract history CBS |
| 1.6 | SET | `wkMskmDtlNo = ""` | Initialize working variable for mskm detail number |
| 1.7 | FOR | `for (CAANMsg ekk0081b024OUT : ekk0081b024OUTLIST)` | Iterate over service contract history records (descending by creation datetime) |
| 1.7.1 | IF | `!JKKStrConst.CD00037_DSL_ZM.equals(svcKeiStat)` [Not terminated] |
| 1.7.1.1 | EXEC | `break` | Stop iterating — found the boundary where the contract was no longer terminated |
| 1.7.2 | SET | `wkMskmDtlNo = ekk0081b024OUT.getString(MSKM_DTL_NO)` | Store the mskm detail number from the last terminated record |
| 1.8 | EXEC | `ccMsg.put("mskm_dtl_no", wkMskmDtlNo)` | Store the resolved mskm detail number in ccMsg |

**Block 8** — [CALL] Price code consultation — EKK0791A010 (L504–L510)

> 料金コード一意照会 — Retrieve price code information associated with the service contract.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0791a010IN = new CAANMsg(EKK0791A010CBSMsg.class.getName())` | Create input message |
| 2 | SET | `ekk0791a010IN.set(TEMPLATEID, "EKK0791A010")` | Set template ID |
| 3 | SET | `ekk0791a010IN.set(FUNC_CODE, "2")` | Function code 2 (consultation) |
| 4 | SET | `ekk0791a010IN.set(KEY_PCRS_CD, curSvcKeiInfo.getString(PCRS_CD))` | Pass the price code from the service contract info |
| 5 | SET | `ekk0791a010IN.set(KEY_RSV_APLY_YMD, opeDate)` | Pass the operational date |
| 6 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0791a010IN)` | Invoke the price code consultation CBS |
| 7 | SET | `ekk0791a010OUT = result.getCAANMsgList(...)` | Extract result list |

**Block 9** — [SET] Instruction book parameter map construction (L513–L523)

> ANK-0545-00-00 — 指示書登録サービスの為に、パラメータ作成 — Build the parameter map for the instruction book registration service, extracting all relevant fields from the current service contract information.

| # | Type | Code |
|---|------|------|
| 1 | SET | `orderInsParamMap = new HashMap<String, String>()` | Initialize the instruction book parameter map |
| 2 | EXEC | `orderInsParamMap.put("prc_grp_cd", curSvcKeiInfo.getString(PRC_GRP_CD))` | Price group code |
| 3 | EXEC | `orderInsParamMap.put("shosaYmd", curSvcKeiInfo.getString(SHOSA_YMD))` | Review date (照会年月日) |
| 4 | EXEC | `orderInsParamMap.put("svcEndymd", curSvcKeiInfo.getString(SVC_ENDYMD))` | Service end date (サービス終了年月日) |
| 5 | EXEC | `orderInsParamMap.put("svcCancelymd", curSvcKeiInfo.getString(SVC_CANCEL_YMD))` | Service cancellation date (サービスキャンセル年月日) |
| 6 | EXEC | `orderInsParamMap.put("mkFlg", curSvcKeiInfo.getString(MK_FLG))` | Invalid flag (無効フラグ) |
| 7 | EXEC | `orderInsParamMap.put("addDtm", curSvcKeiInfo.getString(ADD_DTM))` | Registration datetime (登録年月日時刻分秒) |
| 8 | EXEC | `orderInsParamMap.put("addOpeacnt", curSvcKeiInfo.getString(ADD_OPEACNT))` | Registration operator account (登録オペレーターアカウント) |
| 9 | EXEC | `orderInsParamMap.put("updDtm", curSvcKeiInfo.getString(UPD_DTM))` | Update datetime (更新年月日時刻分秒) |
| 10 | EXEC | `orderInsParamMap.put("updOpeacnt", curSvcKeiInfo.getString(UPD_OPEACNT))` | Update operator account (更新オペレーターアカウント) |

**Block 10** — [IF] Submission number acquisition: approved vs pre-initial state (L528–L539)

> 「照会済」の場合 -> 「申請内容承認登録処理」を行う — When the service contract has been approved (SHOSA_YMD is not null), create a new submission record via execMskm. Otherwise (pre-initial state), use the mskmNo already stored in ccMsg and retrieve mskmDtlNo from the current service contract info.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmNo = ""` | Initialize submission number variable |
| 2 | SET | `mskmDtlNo = ""` | Initialize submission detail number variable |
| 3 | IF | `!curSvcKeiInfo.isNull(SHOSA_YMD)` [Approved — 照会済] |
| 3.1 | CALL | `mskmInfo = execMskm(handle, scCall, param, dataMapKey)` | Execute submission info creation and retrieve mskmNo and mskmDtlNo |
| 3.2 | SET | `mskmNo = mskmInfo.getString(MSKM_NO)` | Extract the submission number |
| 3.3 | SET | `mskmDtlNo = mskmInfo.getCAANMsgList(...)[0].getString(MSKM_DTL_NO)` | Extract the submission detail number from the first list element |
| 4 | ELSE | [Pre-initial — 未初] |
| 4.1 | SET | `mskmNo = (String)ccMsg.get("mskm_no")` | Retrieve mskmNo from ccMsg (already set by the calling screen) |
| 4.2 | SET | `mskmDtlNo = curSvcKeiInfo.getString(MSKM_DTL_NO)` | Retrieve mskmDtlNo from current service contract info |

**Block 11** — [CALL] Submission history inquiry — EKK0011B002 (L544–L553)

> 申請履歴一覧照会 — Retrieve submission history records to determine the current submission status (mskm_staus).

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0011B002IN = new CAANMsg(EKK0011B002CBSMsg.class.getName())` | Create input message |
| 2 | SET | `eKK0011B002IN.set(TEMPLATEID, "EKK0011B002")` | Set template ID |
| 3 | SET | `eKK0011B002IN.set(FUNC_CODE, "1")` | Function code 1 (history inquiry) |
| 4 | SET | `eKK0011B002IN.set(KEY_MSKM_DTL_NO, mskmDtlNo)` | Pass the submission detail number |
| 5 | CALL | `callSC(handle, scCall, param, dataMapKey, eKK0011B002IN)` | Invoke the submission history CBS |
| 6 | SET | `mskm_staus = mskmInfo[0].getString(MSKM_STAT)` | Get the submission status from the first record |
| 7 | IF | `MSKM_STAT_920.equals(mskm_staus)` [MSKM_STAT_920 = "920" (Cancelled/キャンセル済)] |
| 7.1 | SET | `mskm_staus = mskmInfo[1].getString(MSKM_STAT)` | Use the second record's status instead (skip the cancelled record) |

**Block 12** — [IF] Service contract is Cancelled (920) — Cancellation recovery path (L560–L607)

> カレントのサービス契約が「キャンセル済」である場合、「キャンセル取消処理」を行う — When the current service contract status is "920" (Cancelled), execute cancellation recovery processing. The method determines whether to use `cancelRecoveryToCNC` (if the cancellation was already approved) or `cancelRecovery` (if not yet approved).

| # | Type | Code |
|---|------|------|
| 1 | IF | `"920".equals(curSvcKeiStat)` [Cancelled — キャンセル済] |
| 1.1 | IF | `!curSvcKeiInfo.isNull(SHOSA_YMD)` [Approved — 照会済] |
| 1.1.1 | CALL | `cancelRecoveryToCNC(handle, scCall, param, dataMapKey, mskmDtlNo)` | Cancel recovery reversal — handles already-approved cancellations, reversing to CANCEL state |
| 1.1.2 | IF | `!"0".equals(ekk0791a010OUT[0].getString(ID_TCHISHO_HAK_SKBT_CD))` [ID notice book issuance code is not "0" (発行なし)] |
| 1.1.2.1 | SET | `jKKTVSjishoAddCC = new JKKTVSjishoAddCC()` | Instantiate the instruction book registration CC |
| 1.1.2.2 | CALL | `jKKTVSjishoAddCC.mainExecute(handle, param, fixedText)` | Execute instruction book registration |
| 1.1.3 | SET | `shosaDslFinCd = curSvcKeiInfo.getString(SHOSA_DSL_FIN_CD)` | Get the approval termination code (照会解除コード) |
| 1.1.4 | IF | `"1".equals(shosaDslFinCd)` [Approval termination code equals "1"] |
| 1.1.4.1 | CALL | `recoveryKojiAk(handle, param, scCall, dataMapKey, curSvcKeiInfo)` | Recovery of the work order case (工事案件回復) |
| 1.2 | ELSE | [Not yet approved — 未承認] |
| 1.2.1 | CALL | `cancelRecovery(handle, scCall, param, dataMapKey, mskmNo, mskmDtlNo, mskm_staus)` | Standard cancellation recovery — reverses cancellations that have not yet been approved |
| 1.3 | CALL | `execWrisvcAutoAply(handle, param, curCustInfo, curSvcKeiInfo, dataMapKey, mskmNo)` | Apply discount auto-application based on customer and service contract information |
| 1.4 | CALL | `registProgressInfo(handle, scCall, param, dataMapKey, mskmDtlNo)` | Register the current processing progress |
| 1.5 | IF | `IDO_RSN_CD_KAIHK_REQ_CHRG.equals(idoRsnCd)` [IDO_RSN_CD_KAIHK_REQ_CHRG = "T6" — Customer recovery request fee (お客さま回復要請のため(事務手数料料))] |
| 1.5.1 | SET | `eKK1021D010IN = new CAANMsg(EKK1021D010CBSMsg.class.getName())` | Create input message for temporary money setup |
| 1.5.2 | SET | `eKK1021D010IN.set(TEMPLATEID, "EKK1021D010")` | Set template ID |
| 1.5.3 | SET | `eKK1021D010IN.set(FUNC_CODE, "1")` | Function code 1: check and register (fixed) |
| 1.5.4 | SET | `eKK1021D010IN.set(TMP_PAY_PRC_NO, "210054026010")` | Recovery service fee price number (fixed: 回復事務手数料(固定)) |
| 1.5.5 | SET | `eKK1021D010IN.set(ICJKN_SETTE_CD, "02")` | Present/absent code — "02" (present/有) (fixed) |
| 1.5.6 | SET | `eKK1021D010IN.set(SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Pass the service contract number |
| 1.5.7 | SET | `eKK1021D010IN.set(MSKM_DTL_NO, mskmDtlNo)` | Pass the submission detail number |
| 1.5.8 | SET | `eKK1021D010IN.set(FIN_STAT_CD, "0")` | Financial status — "0" (incomplete/未完) (fixed) |
| 1.5.9 | CALL | `callSC(handle, scCall, param, dataMapKey, eKK1021D010IN)` | Register the temporary money setup |

**Block 13** — [ELSE IF] Service contract is Terminated (910) — Termination recovery path (L609–L668)

> カレントのサービス契約が「解約済」である場合、「回復処理」を行う — When the current service contract status is "910" (Terminated), execute recovery processing. The method determines the precise pre-termination state and calls the appropriate recovery routine.

| # | Type | Code |
|---|------|------|
| 1 | ELSE IF | `"910".equals(curSvcKeiStat)` [Terminated — 解約済] |
| 1.1 | SET | `curSvcStaYmd = curSvcKeiInfo.getString(SVC_STA_YMD)` | Retrieve the service start date (サービス開始日) |
| 1.2 | SET | `curSvcPauseYmd = curSvcKeiInfo.getString(SVC_PAUSE_YMD)` | Retrieve the pause date (休止年月日) |
| 1.3 | SET | `curSvcPauseRlsYmd = curSvcKeiInfo.getString(SVC_PAUSE_RLS_YMD)` | Retrieve the pause release date (休止解除年月日) |
| 1.4 | CALL | `recoveryKojiAk(handle, param, scCall, dataMapKey, curSvcKeiInfo)` | Recovery of the work order case (工事案件回復) |
| 1.5 | IF | `curSvcPauseYmd != null && !"".equals(curSvcPauseYmd)` AND `curSvcPauseRlsYmd == null || "".equals(curSvcPauseRlsYmd)` [Paused — 休止中: pause date set but pause release date not set] |
| 1.5.1 | CALL | `recoveryToPauseStatus(handle, scCall, param, dataMapKey, mskmDtlNo)` | Service contract recovery to paused status — restores from "paused during termination" state |
| 1.6 | ELSE IF | `curSvcStaYmd != null && !"".equals(curSvcStaYmd)` [Service start date set — サービス提供中] |
| 1.6.1 | CALL | `recovery(handle, scCall, param, dataMapKey, mskmDtlNo, ekk1681c011OUTLIST)` | Service contract recovery — restores terminated contract to active provision state |
| 1.7 | ELSE | [Neither paused nor active — 締結済み] |
| 1.7.1 | CALL | `recoveryToConclusion(handle, scCall, param, dataMapKey, mskmDtlNo)` | Recovery to concluded state — restores to terminated (締結済) status |
| 1.8 | CALL | `henpinKikiCancel(handle, param, scCall, dataMapKey, mskmDtlNo, curSvcKeiInfo)` | Cancelled returned equipment processing (返品機器取消) |
| 1.9 | CALL | `execWrisvcAutoAply(handle, param, curCustInfo, curSvcKeiInfo, dataMapKey, mskmNo)` | Discount auto-application |
| 1.10 | IF | `!"0".equals(ekk0791a010OUT[0].getString(ID_TCHISHO_HAK_SKBT_CD))` [ID notice book issuance code is not "0" (発行なし)] |
| 1.10.1 | SET | `jKKTVSjishoAddCC = new JKKTVSjishoAddCC()` | Instantiate the instruction book registration CC |
| 1.10.2 | CALL | `jKKTVSjishoAddCC.mainExecute(handle, param, fixedText)` | Execute instruction book registration |
| 1.11 | CALL | `registProgressInfo(handle, scCall, param, dataMapKey, mskmDtlNo)` | Register processing progress |
| 1.12 | IF | `IDO_RSN_CD_KAIHK_REQ_CHRG.equals(idoRsnCd)` [IDO_RSN_CD_KAIHK_REQ_CHRG = "T6" — Customer recovery request fee] |
| 1.12.1 | SET | `eKK1021D010IN = new CAANMsg(EKK1021D010CBSMsg.class.getName())` | Create input message for temporary money setup |
| 1.12.2 | SET | `eKK1021D010IN.set(TEMPLATEID, "EKK1021D010")` | Set template ID |
| 1.12.3 | SET | `eKK1021D010IN.set(FUNC_CODE, "1")` | Function code 1: check and register (fixed) |
| 1.12.4 | SET | `eKK1021D010IN.set(TMP_PAY_PRC_NO, "210054026010")` | Recovery service fee price number (fixed: 回復事務手数料(固定)) |
| 1.12.5 | SET | `eKK1021D010IN.set(ICJKN_SETTE_CD, "02")` | Present/absent code — "02" (present/有) (fixed) |
| 1.12.6 | SET | `eKK1021D010IN.set(SVC_KEI_NO, ccMsg.get("svc_kei_no"))` | Pass the service contract number |
| 1.12.7 | SET | `eKK1021D010IN.set(MSKM_DTL_NO, mskmDtlNo)` | Pass the submission detail number |
| 1.12.8 | SET | `eKK1021D010IN.set(FIN_STAT_CD, "0")` | Financial status — "0" (incomplete/未完) (fixed) |
| 1.12.9 | CALL | `callSC(handle, scCall, param, dataMapKey, eKK1021D010IN)` | Register the temporary money setup |

**Block 14** — [RETURN] Final return (L669)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` | Return the parameter object with all processed data including discrepancy info, flags, and results |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kaihuku` | Method | Recovery — the Japanese term for restoring a service contract from a terminal state (cancelled or terminated) back to an active operational state |
| `svc_kei_no` | Field | Service contract number — the unique identifier for a service contract line item in the K-Opticom system |
| `svc_kei_stat` | Field | Service contract status — "910" means terminated (解約済), "920" means cancelled (キャンセル済) |
| `ido_rsv_no` | Field | Discrepancy reservation number — internal tracking ID for discrepancy records in the reservation data |
| `ido_rsv_dtl_cd_nm` | Field | Discrepancy detail code name — human-readable name describing the type of discrepancy found |
| `idoRsnCd` | Field | Discrepancy reason code — classifies the reason for discrepancy; "T6" specifically indicates a customer recovery request requiring a service fee charge |
| `mskm_no` | Field | Submission number — the unique identifier for a submission record (申請書番号) in the application management system |
| `mskm_dtl_no` | Field | Submission detail number — the unique identifier for a submission detail record, linking service contract operations to their submission history |
| `mskm_staus` | Field | Submission status — the current state of a submission record; "920" indicates a cancelled submission (which causes the system to skip to the next record) |
| `shosaYmd` | Field | Review/approval date (照会年月日) — when populated, indicates the service contract has been reviewed and approved |
| `shosaDslFinCd` | Field | Approval termination code (照会解除コード) — code indicating the type of approval-termination action taken; "1" triggers work order case recovery |
| `svcStaYmd` | Field | Service start date (サービス開始日) — the date when service provision began; presence indicates the contract was in active provision |
| `svcPauseYmd` | Field | Pause date (休止年月日) — the date when the service was paused/suspended |
| `svcPauseRlsYmd` | Field | Pause release date (休止解除年月日) — the date when the pause was released; absence indicates the contract was still paused at termination |
| `svcEndymd` | Field | Service end date (サービス終了年月日) — the scheduled or actual end date of the service contract |
| `svcCancelymd` | Field | Service cancellation date (サービスキャンセル年月日) — the date the service contract was cancelled |
| `prc_grp_cd` | Field | Price group code (料金グループコード) — classification code for the pricing group associated with the service contract |
| `pcrs_cd` | Field | Price code (料金コード) — the specific pricing code for the service |
| `mkFlg` | Field | Invalid flag (無効フラグ) — indicates whether the record is marked as invalid |
| `addDtm` / `updDtm` | Field | Registration datetime / Update datetime (登録年月日時刻分秒 / 更新年月日時刻分秒) — audit trail timestamps |
| `addOpeacnt` / `updOpeacnt` | Field | Registration operator account / Update operator account (登録オペレーターアカウント / 更新オペレーターアカウント) — audit trail for which operator performed the action |
| `func_code` | Field | Function code — operation mode flag; "1" for normal processing, "2" for check-only (check without recovery) |
| `adchg_after_dsl_flg` | Field | Post-DSL-change flag (解約後住所変更中フラグ) — set to "1" when a residence change during the post-termination period is detected, indicating potential data inconsistency |
| `id_tchisho_hak_skbt_cd` | Field | ID notice book issuance skip code (ID通知書発行スキップコード) — "0" means no issuance (発行なし); non-zero values trigger instruction book registration |
| `tmp_pay_prc_no` | Field | Temporary payment price number (一時金設定価格番号) — fixed value "210054026010" identifies the customer recovery service fee pricing |
| `icjkn_sette_cd` | Field | Present/absent settlement code (有無設定コード) — "02" means present/存在あり; fixed value for the fee setup |
| `fin_stat_cd` | Field | Financial status code (財務状態コード) — "0" means incomplete (未完); the fee has been registered but not yet completed |
| CD00037_DSL_ZM | Constant | Status code for "terminated" (解約済) — equals "910" in JKKStrConst |
| MSKM_STAT_920 | Constant | Submission status "cancelled" (キャンセル済) — equals "920"; causes the system to skip to the next submission record |
| IDO_RSN_CD_KAIHK_REQ_CHRG | Constant | Discrepancy reason code for customer recovery request fee — equals "T6"; triggers the EKK1021D010CBS temporary money setup for service fee charge |
| CC | Abbreviation | Common Component — a shared business logic component in the K-Opticom architecture that extends AbstractCommonComponent |
| CBS | Abbreviation | Call-Back Service — the service component layer that handles business logic and database operations via message-based invocations |
| SC Code | Abbreviation | Service Component Code — naming convention for CBS classes following the pattern `[A-Z]{3}\d{4}[A-Z]\d{3}` (e.g., EKK1681C011) |
| CAANMsg | Type | Message container used for CBS input/output — supports set/get operations for typed fields and nested message lists |
| CCRequestBroker | Type | Request broker that invokes a target CC method with a specified CC target name (e.g., "KKSV047401CC") |
| EKK1681C011CBS | CBS | 異動予約期日到来済・未反映情報取得 — Retrieve unreflected discrepancy reservation date arrival information |
| ECK0011A010CBS | CBS | お客様一意照会 — Customer single consultation / customer master lookup |
| EKK0081A010CBS | CBS | サービス契約一意照会 — Service contract single consultation |
| EKK0081B024CBS | CBS | サービス契約履歴一覧照会 — Service contract history list consultation |
| EKK0791A010CBS | CBS | 料金コード一意照会 — Price code single consultation |
| EKK0011B002CBS | CBS | 申請履歴一覧照会 — Submission history list consultation |
| EKK0011D020CBS | CBS | 申請明細 — Submission detail (used by execMskm for creation) |
| EKK1021D010CBS | CBS | 一時金設定登録 — Temporary money setup registration (used to charge recovery service fees) |
| JKKTVSjishoAddCC | CC | Instruction book registration common component — issues service instruction books |
| EO Light TV | Business term | The FTTH (Fiber To The Home) television and broadband service offered by K-Opticom |
| K-Opticom | Business term | Japanese telecommunications company providing broadband and TV services |
