# Business Logic — JKKKojiWrisvcAutoAplyCC.execute() [338 LOC]

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

## 1. Role

### JKKKojiWrisvcAutoAplyCC.execute()

This method implements the **Discount Service Auto-Application** logic for maintenance (repair/move/cancel) work orders in the K-Opticom customer core system. It acts as a **routing and preparation dispatcher** that examines the maintenance work context (specifically whether an STB — Set-Top Box — is being removed) and then assembles the appropriate service contract data for downstream auto-application processing.

The method implements a **routing/dispatch pattern**: based on the STB removal flag (`stbTekkyo`), it branches into two major paths. When the STB is being removed (`STB_TEKKYO_TEKKYO = "1"`), it processes three types of contract operations in sequence — **registration** (new setup), **cancellation/restoration/cancellation** (DSL, restoration, and cancellation operations) — each applying the correct `add_chge_div` (registration/change division) code. When the STB is not being removed (`STB_TEKKYO_NASI = "0"`), it only processes service contract detail entries for registration, using a different division code.

Additionally, a **special case** for TV course changes (added in v75.00.00 / ANK-4673-00-00) handles fiber-optic TV new installations where the work type (`kojiakSbt`) is `"001"` and the movement division (`ido_div`) matches specific codes (`"00032"` or `"00035"`), limited to `sckmct_ptn = "9"` (specific customer pattern). This branch builds a single service contract record with before/after pricing details and triggers auto-application with `add_chge_div = "02"` (change/division).

The method delegates the actual auto-application execution to `JKKWrisvcAutoAplyCC.execute()`, which is the downstream component responsible for applying discount rules to the prepared service data.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(params)"])
    START --> RETRIEVE_IN["Retrieve inMap from param.getData(fixedText)"]
    RETRIEVE_IN --> NULL_CHECK{inMap == null?}
    NULL_CHECK -->|Yes| RETURN_PARAM["Return param"]
    NULL_CHECK -->|No| GET_WORK["Retrieve workMap from param.getMappingWorkArea()"]
    GET_WORK --> SET_MSKM["Set mskm_no in inMap from workMap"]
    SET_MSKM --> CREATE_AUTOCC["Create JKKWrisvcAutoAplyCC instance"]
    CREATE_AUTOCC --> GET_STB["Retrieve stbTekkyo from kojiakInfoMap"]
    GET_STB --> STB_CHECK{stbTekkyo == STB_TEKKYO_TEKKYO = \"1\"?}

    STB_CHECK -->|Yes - STB Removal| BRANCH_TEKKYO["STB Removal Branch"]
    BRANCH_TEKKYO --> GET_KIKI_ADD["Get KikiInfoAddMap"]
    GET_KIKI_ADD --> SET_CREATE_SVC["setKktkSvc(createKikiList)"]
    SET_CREATE_SVC --> SET_CREATE_GRP["setSvcKeiGrpList()"]
    SET_CREATE_GRP --> CREATE_HAS_SVC{svcKeiList.size > 0?}
    CREATE_HAS_SVC -->|Yes| PREP_CREATE["Prepare inMap: svc_kei_list, add_chge_div=01, svc_dlre_cd=00, svc_cancel_rsn_cd=empty"]
    PREP_CREATE --> EXEC_CREATE["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    CREATE_HAS_SVC -->|No| GET_CREATE_UCWK["Get svc_kei_ucwk_list"]
    EXEC_CREATE --> GET_CREATE_UCWK
    GET_CREATE_UCWK --> SET_CREATE_UCWK["setSvcUcwk(createSvcUcwkList)"]
    SET_CREATE_UCWK --> SET_CREATE_UCWK_GRP["setSvcKeiGrpList()"]
    SET_CREATE_UCWK_GRP --> CREATE_UCWK_HAS_SVC{svcKeiList.size > 0?}
    CREATE_UCWK_HAS_SVC -->|Yes| PREP_CREATE_UCWK["Prepare inMap: svc_kei_list, add_chge_div=01, svc_dlre_cd=00, svc_cancel_rsn_cd=00"]
    CREATE_UCWK_HAS_SVC -->|No| GET_KOJIKIKI["Get KojiKikiMap"]
    PREP_CREATE_UCWK --> EXEC_CREATE_UCWK["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    EXEC_CREATE_UCWK --> GET_KOJIKIKI

    GET_KOJIKIKI --> DSL_SECTION["DSL/Cancellation Section"]
    DSL_SECTION --> SET_DSL_SVC["setKktkSvc(dslKikiList)"]
    SET_DSL_SVC --> SET_DSL_GRP["setSvcKeiGrpList()"]
    SET_DSL_SVC --> DSL_HAS_SVC{svcKeiList.size > 0?}
    DSL_HAS_SVC -->|Yes| PREP_DSL["Prepare inMap: add_chge_div=03, svc_dlre_cd=01"]
    PREP_DSL --> EXEC_DSL["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    DSL_HAS_SVC -->|No| GET_DSL_UCWK["Get dsl_svc_ucwk_list"]
    EXEC_DSL --> GET_DSL_UCWK
    GET_DSL_UCWK --> SET_DSL_UCWK["setSvcUcwk(dslSvcUcwkList)"]
    SET_DSL_UCWK --> SET_DSL_UCWK_GRP["setSvcKeiGrpList()"]
    SET_DSL_UCWK_GRP --> DSL_UCWK_HAS_SVC{svcKeiList.size > 0?}
    DSL_UCWK_HAS_SVC -->|Yes| PREP_DSL_UCWK["Prepare inMap: add_chge_div=03, svc_dlre_cd=01"]
    DSL_UCWK_HAS_SVC -->|No| RESTORE_SECTION["Restoration Section"]
    PREP_DSL_UCWK --> EXEC_DSL_UCWK["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    EXEC_DSL_UCWK --> RESTORE_SECTION

    RESTORE_SECTION --> SET_RESTORE_SVC["setKktkSvc(kaihkKikiList)"]
    SET_RESTORE_SVC --> SET_RESTORE_GRP["setSvcKeiGrpList()"]
    SET_RESTORE_SVC --> RESTORE_HAS_SVC{svcKeiList.size > 0?}
    RESTORE_HAS_SVC -->|Yes| PREP_RESTORE["Prepare inMap: add_chge_div=04, svc_dlre_cd=empty"]
    PREP_RESTORE --> EXEC_RESTORE["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    RESTORE_HAS_SVC -->|No| GET_RESTORE_UCWK["Get kaihk_svc_ucwk_list"]
    EXEC_RESTORE --> GET_RESTORE_UCWK
    GET_RESTORE_UCWK --> SET_RESTORE_UCWK["setSvcUcwk(kaihkSvcUcwkList)"]
    SET_RESTORE_UCWK --> SET_RESTORE_UCWK_GRP["setSvcKeiGrpList()"]
    SET_RESTORE_UCWK_GRP --> RESTORE_UCWK_HAS_SVC{svcKeiList.size > 0?}
    RESTORE_UCWK_HAS_SVC -->|Yes| PREP_RESTORE_UCWK["Prepare inMap: add_chge_div=04, svc_dlre_cd=empty"]
    RESTORE_UCWK_HAS_SVC -->|No| CANCEL_SECTION["Cancellation Section"]
    PREP_RESTORE_UCWK --> EXEC_RESTORE_UCWK["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    EXEC_RESTORE_UCWK --> CANCEL_SECTION

    CANCEL_SECTION --> SET_CANCEL_SVC["setKktkSvc(cancelKikiList)"]
    SET_CANCEL_SVC --> SET_CANCEL_GRP["setSvcKeiGrpList()"]
    SET_CANCEL_SVC --> CANCEL_HAS_SVC{svcKeiList.size > 0?}
    CANCEL_HAS_SVC -->|Yes| PREP_CANCEL["Prepare inMap: add_chge_div=05, svc_cancel_rsn_cd=01"]
    PREP_CANCEL --> EXEC_CANCEL["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    CANCEL_HAS_SVC -->|No| GET_CANCEL_UCWK["Get cancel_svc_ucwk_list"]
    EXEC_CANCEL --> GET_CANCEL_UCWK
    GET_CANCEL_UCWK --> SET_CANCEL_UCWK["setSvcUcwk(cancelSvcUcwkList)"]
    SET_CANCEL_UCWK --> SET_CANCEL_UCWK_GRP["setSvcKeiGrpList()"]
    SET_CANCEL_UCWK_GRP --> CANCEL_UCWK_HAS_SVC{svcKeiList.size > 0?}
    CANCEL_UCWK_HAS_SVC -->|Yes| PREP_CANCEL_UCWK["Prepare inMap: add_chge_div=05, svc_cancel_rsn_cd=01"]
    CANCEL_UCWK_HAS_SVC -->|No| END_TEKKYO["End of STB Removal Branch"]
    PREP_CANCEL_UCWK --> EXEC_CANCEL_UCWK["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    EXEC_CANCEL_UCWK --> END_TEKKYO
    END_TEKKYO --> TV_CHECK_SECTION["TV Course Change Check Section"]

    STB_CHECK -->|No - No STB Removal| BRANCH_NASI["STB No-Removal Branch (STB_TEKKYO_NASI = \"0\")"]
    BRANCH_NASI --> GET_NASI_ADD["Get KikiInfoAddMap"]
    GET_NASI_ADD --> NASI_MAP_CHECK{createMap != null?}
    NASI_MAP_CHECK -->|No| END_NASI["End of STB No-Removal Branch"]
    NASI_MAP_CHECK -->|Yes| GET_NASI_UCWK["Get svc_kei_ucwk_list"]
    GET_NASI_UCWK --> NASI_UCWK_CHECK{createSvcUcwkList != null?}
    NASI_UCWK_CHECK -->|No| END_NASI
    NASI_UCWK_CHECK -->|Yes| SET_NASI_SVC["setSvcUcwk(createSvcUcwkList)"]
    SET_NASI_SVC --> SET_NASI_GRP["setSvcKeiGrpList()"]
    SET_NASI_GRP --> NASI_HAS_SVC{svcKeiList.size > 0?}
    NASI_HAS_SVC -->|Yes| PREP_NASI["Prepare inMap: add_chge_div=16, svc_dlre_cd=empty"]
    PREP_NASI --> EXEC_NASI["wrisvcAutoAplyCC.execute(handle, param, fixedText)"]
    NASI_HAS_SVC -->|No| END_NASI
    EXEC_NASI --> END_NASI

    END_TEKKYO --> SBT_CHECK_SECTION{"inMap.get(kojiakSbt)!=null AND kojiakSbt==\"001\" AND (ido_div==\"00032\" OR ido_div==\"00035\") AND sckmct_ptn==\"9\"?"}
    SBT_CHECK_SECTION -->|No| RETURN_FINAL["Return param"]
    SBT_CHECK_SECTION -->|Yes| TV_BRANCH["TV Course Change Branch"]
    TV_BRANCH --> GET_TV_MAP["Get chgTvCourseInfo"]
    GET_TV_MAP --> SET_MSKM_SBT["Set inMap.mskm_sbt_cd = \"00001\""]
    SET_MSKM_SBT --> SET_ADD_CHG["Set inMap.add_chge_div = \"02\""]
    SET_ADD_CHG --> BUILD_SVC_DATA["Build workSvcKeiData with svc_cd, prc_grp_cd, pcrs_cd, pplan_cd, before/after fields"]
    BUILD_SVC_DATA --> CHECK_SVC{checkSvcKeiData == true?}
    CHECK_SVC -->|Yes| ADD_SVC_LIST["Add to workSvcKeiList, wrap in group, set inMap, call wrisvcAutoAplyCC.execute()"]
    CHECK_SVC -->|No| RETURN_FINAL
    ADD_SVC_LIST --> RETURN_FINAL
    RETURN_FINAL --> END(["End"])

    BRANCH_TEKKYO -.-> TV_CHECK_SECTION
    END_NASI -.-> TV_CHECK_SECTION
    TV_CHECK_SECTION -.-> TV_CHECK_SECTION
```

**Processing Summary by Path:**

- **STB Removal Path (`STB_TEKKYO_TEKKYO = "1"`):** Processes three operation categories — registration (div `"01"`), cancellation (div `"03"`), restoration (div `"04"`), and cancellation (div `"05"`) — each with both device-provisioned service contracts and service contract details.
- **No-Removal Path (`STB_TEKKYO_NASI = "0"`):** Only processes service contract details for registration with division code `"16"`.
- **TV Course Change Path:** Independent condition checking `kojiakSbt = "001"`, `ido_div = "00032"` or `"00035"`, and `sckmct_ptn = "9"`. Builds a single service contract record with before/after pricing and calls auto-application with division code `"02"`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle — provides the database connection context for all CRUD operations executed downstream by `JKKWrisvcAutoAplyCC.execute()`. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter carrier — a mutable map-like object that holds all processing data. It contains the inMap (keyed by `fixedText`), the work mapping area, and data maps for various business entities (`KikiInfoAddMap`, `KojiKikiMap`, `kojiakInfoMap`, `chgTvCourseInfo`). The method populates `inMap` with prepared service contract data before delegating. |
| 3 | `fixedText` | `String` | Service message key — used as the map key to retrieve the user data `HashMap` from `param.getData(fixedText)`. This key determines which data area within `param` is treated as the primary processing context. |

**Instance Fields / External State:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `STB_TEKKYO_TEKKYO` | `String = "1"` | Constant representing "STB removal with check" — when `stbTekkyo` equals this value, the method processes device-provisioned service contracts (including STB equipment provisioning) alongside service contract details. |
| `STB_TEKKYO_NASI` | `String = "0"` | Constant representing "STB removal without check" — when `stbTekkyo` equals this value, the method only processes service contract detail entries (no device-provisioned service contracts). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKWrisvcAutoAplyCC.execute` | - (delegated CC) | - (downstream SCs) | Delegates the actual auto-application execution with prepared service contract data for discount rule evaluation. Called once or multiple times depending on the processing path and data availability. |
| - | `JKKKojiWrisvcAutoAplyCC.setKktkSvc` | - | - | Private helper that converts device-provisioned service contract lists (from `KikiInfoAddMap` or `KojiKikiMap`) into the format expected by the auto-application component. Filters for STB equipment only (`kktk_svc_cd = "C009"`) and sets `tg_kei_skbt_cd = "06"`. |
| - | `JKKKojiWrisvcAutoAplyCC.setSvcKeiGrpList` | - | - | Private helper that wraps service contract data into a group structure. Sets `grp_div = "00"` (group division) and creates a single-element group list. |
| - | `JKKKojiWrisvcAutoAplyCC.setSvcUcwk` | - | - | Private helper that converts service contract detail lists into the format expected by the auto-application component. Sets `tg_kei_skbt_cd = "03"` (service contract detail target code). |

**Note:** The actual database/table operations (SC Codes, table names) are performed inside `JKKWrisvcAutoAplyCC.execute()`, which is a downstream component. This method's responsibility is data preparation and routing — it reads data from the `param` object (HashMap lookups from `param.getData()`) and writes prepared structures back into `inMap`. The `setKktkSvc`, `setSvcUcwk`, and `setSvcKeiGrpList` methods are in-memory data transformations with no database I/O.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `execute` [-], `setKktkSvc` [-], `setSvcKeiGrpList` [-], `setSvcUcwk` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | DSL Run: `JKKTekkyoDslRun` | `JKKTekkyoDslRun.runDsl()` -> `JKKKojiWrisvcAutoAplyCC.execute()` | `wrisvcAutoAplyCC.execute` [delegated] |

**Caller Analysis:**
- `JKKTekkyoDslRun.runDsl()` is the DSL (Domain-Specific Language) runner for STB removal work processing. It invokes this method as part of the DSL-based processing pipeline for handling equipment removal and service contract adjustments.

## 6. Per-Branch Detail Blocks

### Block 1 — GET (Early Return Guard) (L53–L57)

> Retrieve user data from the request parameter and guard against null input.

| # | Type | Code |
|---|------|------|
| 1 | GET | `inMap = (HashMap) param.getData(fixedText)` // Retrieve user data HashMap keyed by fixedText |
| 2 | IF | `if (inMap == null)` // Early return guard |
| 2.1 | RETURN | `return param` // Return unchanged if no user data |

### Block 2 — WORK AREA RETRIEVAL (L58–L60)

> Extract the work mapping area and propagate the application number (mskm_no) into the inMap.

| # | Type | Code |
|---|------|------|
| 1 | GET | `workMap = param.getMappingWorkArea()` // Retrieve work area mapping |
| 2 | SET | `inMap.put("mskm_no", (String) workMap.get("mskm_no"))` // Propagate application number [-> mskm_no = Application Number] |

### Block 3 — INITIALIZATION (L62–L72)

> Create the auto-application delegate instance and initialize working variables. Also retrieve the STB removal flag.

| # | Type | Code |
|---|------|------|
| 1 | NEW | `wrisvcAutoAplyCC = new JKKWrisvcAutoAplyCC()` // Create delegate for auto-application execution |
| 2 | SET | `svcKeiGrpList = null` // Initialize service contract group list |
| 3 | SET | `svcKeiGrpMap = null` // Initialize service contract group map |
| 4 | SET | `svcKeiList = null` // Initialize service contract list |
| 5 | SET | `stbTekkyo = ""` // Initialize STB removal status string [v5.00.00 addition] |
| 6 | GET | `kojiInfMap = (HashMap) param.getData("kojiakInfoMap")` // Retrieve maintenance info map |
| 7 | GET | `stbTekkyo = (String) kojiInfMap.get("stb_tekkyo")` // [-> stbTekkyo = STB Removal Flag, (STB撤去判定値)] |

### Block 4 — IF (STB Removal = Yes) (L73–L251) `STB_TEKKYO_TEKKYO = "1"` (L73)

> When STB removal is confirmed, process all contract operations: registration, cancellation, restoration, and cancellation — each for both device-provisioned services and service contract details.

#### Block 4.1 — Registration: Device Provisioned Service (L80–L103)

| # | Type | Code |
|---|------|------|
| 1 | GET | `createMap = (HashMap) param.getData("KikiInfoAddMap")` // [-> KikiInfoAddMap = Device Info Registration Map] |
| 2 | GET | `createKikiList = (ArrayList) createMap.get("create_list")` // [-> create_list = New Device Provision List] |
| 3 | CALL | `svcKeiList = setKktkSvc(createKikiList)` // Filter for STB equipment (kktk_svc_cd = "C009"), set tg_kei_skbt_cd = "06" |
| 4 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 5 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` // Set grp_div = "00" |
| 6 | IF | `if (svcKeiList.size() > 0)` // Process only if STB services found |
| 6.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` // Put service contract list into group map |
| 6.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` // Put group list into inMap |
| 6.3 | SET | `inMap.put("add_chge_div", "01")` // [-> add_chge_div = 01 = Registration (登録)] |
| 6.4 | SET | `inMap.put("svc_dlre_cd", "")` // [-> svc_dlre_cd = Empty for registration] |
| 6.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` // [-> svc_cancel_rsn_cd = Empty for registration] |
| 6.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` // Execute auto-application |

#### Block 4.2 — Registration: Service Contract Details (L105–L128)

| # | Type | Code |
|---|------|------|
| 1 | GET | `createSvcUcwkList = (ArrayList) createMap.get("svc_kei_ucwk_list")` // [-> svc_kei_ucwk_list = Service Contract Detail List] |
| 2 | CALL | `svcKeiList = setSvcUcwk(createSvcUcwkList)` // Set tg_kei_skbt_cd = "03" for details |
| 3 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 4 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 5 | IF | `if (svcKeiList.size() > 0)` |
| 5.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 5.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 5.3 | SET | `inMap.put("add_chge_div", "01")` // [-> 01 = Registration] |
| 5.4 | SET | `inMap.put("svc_dlre_cd", "")` |
| 5.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` |
| 5.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

#### Block 4.3 — Cancellation: Device Provisioned Service (L133–L157)

> Process cancellation operations on existing device contracts. Comment: 解約 (Cancellation)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiList = new ArrayList<HashMap<String, Object>>()` // Reset list |
| 2 | GET | `dataMap = (HashMap) param.getData("KojiKikiMap")` // [-> KojiKikiMap = Maintenance/Repair Device Map] |
| 3 | GET | `dslKikiList = (ArrayList) dataMap.get("dsl_kiki_list")` // [-> dsl_kiki_list = DSL Device Cancellation List] |
| 4 | CALL | `svcKeiList = setKktkSvc(dslKikiList)` |
| 5 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 6 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 7 | IF | `if (svcKeiList.size() > 0)` |
| 7.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 7.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 7.3 | SET | `inMap.put("add_chge_div", "03")` // [-> 03 = Cancellation (解約)] |
| 7.4 | SET | `inMap.put("svc_dlre_cd", "01")` // [-> svc_dlre_cd = "01" Service Cancellation Reason] |
| 7.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` |
| 7.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

#### Block 4.4 — Cancellation: Service Contract Details (L159–L183)

| # | Type | Code |
|---|------|------|
| 1 | GET | `dslSvcUcwkList = (ArrayList) dataMap.get("dsl_svc_ucwk_list")` // [-> dsl_svc_ucwk_list = DSL Contract Detail List] |
| 2 | CALL | `svcKeiList = setSvcUcwk(dslSvcUcwkList)` |
| 3 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 4 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 5 | IF | `if (svcKeiList.size() > 0)` |
| 5.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 5.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 5.3 | SET | `inMap.put("add_chge_div", "03")` // [-> 03 = Cancellation] |
| 5.4 | SET | `inMap.put("svc_dlre_cd", "01")` |
| 5.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` |
| 5.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

#### Block 4.5 — Restoration: Device Provisioned Service (L188–L211)

> Process restoration (reactivation) of previously cancelled devices. Comment: 回復 (Restoration)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiList = new ArrayList<HashMap<String, Object>>()` |
| 2 | GET | `kaihkKikiList = (ArrayList) dataMap.get("kaihk_kiki_list")` // [-> kaihk_kiki_list = Restoration Device List] |
| 3 | CALL | `svcKeiList = setKktkSvc(kaihkKikiList)` |
| 4 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 5 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 6 | IF | `if (svcKeiList.size() > 0)` |
| 6.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 6.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 6.3 | SET | `inMap.put("add_chge_div", "04")` // [-> 04 = Restoration (回復)] |
| 6.4 | SET | `inMap.put("svc_dlre_cd", "")` // Empty — no cancellation reason for restoration |
| 6.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` |
| 6.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

#### Block 4.6 — Restoration: Service Contract Details (L213–L236)

| # | Type | Code |
|---|------|------|
| 1 | GET | `kaihkSvcUcwkList = (ArrayList) dataMap.get("kaihk_svc_ucwk_list")` // [-> kaihk_svc_ucwk_list = Restoration Contract Details] |
| 2 | CALL | `svcKeiList = setSvcUcwk(kaihkSvcUcwkList)` |
| 3 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 4 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 5 | IF | `if (svcKeiList.size() > 0)` |
| 5.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 5.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 5.3 | SET | `inMap.put("add_chge_div", "04")` // [-> 04 = Restoration] |
| 5.4 | SET | `inMap.put("svc_dlre_cd", "")` |
| 5.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` |
| 5.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

#### Block 4.7 — Cancellation (Customer Cancel): Device Provisioned Service (L241–L264)

> Process customer-initiated cancellation. Comment: キャンセル (Customer Cancellation)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiList = new ArrayList<HashMap<String, Object>>()` |
| 2 | GET | `cancelKikiList = (ArrayList) dataMap.get("cancel_kiki_list")` // [-> cancel_kiki_list = Customer Cancellation Device List] |
| 3 | CALL | `svcKeiList = setKktkSvc(cancelKikiList)` |
| 4 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 5 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 6 | IF | `if (svcKeiList.size() > 0)` |
| 6.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 6.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 6.3 | SET | `inMap.put("add_chge_div", "05")` // [-> 05 = Customer Cancellation (キャンセル)] |
| 6.4 | SET | `inMap.put("svc_dlre_cd", "")` // No service cancellation reason |
| 6.5 | SET | `inMap.put("svc_cancel_rsn_cd", "01")` // [-> svc_cancel_rsn_cd = "01" Customer cancellation reason] |
| 6.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

#### Block 4.8 — Cancellation (Customer Cancel): Service Contract Details (L266–L288)

| # | Type | Code |
|---|------|------|
| 1 | GET | `cancelSvcUcwkList = (ArrayList) dataMap.get("cancel_svc_ucwk_list")` // [-> cancel_svc_ucwk_list = Customer Cancellation Contract Details] |
| 2 | CALL | `svcKeiList = setSvcUcwk(cancelSvcUcwkList)` |
| 3 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 4 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 5 | IF | `if (svcKeiList.size() > 0)` |
| 5.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 5.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 5.3 | SET | `inMap.put("add_chge_div", "05")` // [-> 05 = Customer Cancellation] |
| 5.4 | SET | `inMap.put("svc_dlre_cd", "")` |
| 5.5 | SET | `inMap.put("svc_cancel_rsn_cd", "01")` |
| 5.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

### Block 5 — ELSE IF (STB Removal = No) (L291–L324) `STB_TEKKYO_NASI = "0"` (L292)

> When STB is NOT being removed, only process service contract detail entries for registration (new installation without STB). Comment: 登録 (Registration).

#### Block 5.1 — Null Guard on createMap (L293–L294)

| # | Type | Code |
|---|------|------|
| 1 | GET | `createMap = (HashMap) param.getData("KikiInfoAddMap")` |
| 2 | IF | `if (createMap != null)` |

#### Block 5.2 — Service Contract Detail Registration (L297–L323)

| # | Type | Code |
|---|------|------|
| 1 | GET | `createSvcUcwkList = (ArrayList<Map<String, Object>>) createMap.get("svc_kei_ucwk_list")` // Service contract detail list |
| 2 | IF | `if (createSvcUcwkList != null)` |
| 2.1 | CALL | `svcKeiList = setSvcUcwk(createSvcUcwkList)` // Set tg_kei_skbt_cd = "03" |
| 2.2 | NEW | `svcKeiGrpMap = new HashMap<String, Object>()` |
| 2.3 | CALL | `svcKeiGrpList = setSvcKeiGrpList(svcKeiGrpMap)` |
| 2.4 | IF | `if (svcKeiList.size() > 0)` |
| 2.4.1 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` |
| 2.4.2 | SET | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` |
| 2.4.3 | SET | `inMap.put("add_chge_div", "16")` // [-> 16 = Registration without STB (STB撤去なし登録)] |
| 2.4.4 | SET | `inMap.put("svc_dlre_cd", "")` |
| 2.4.5 | SET | `inMap.put("svc_cancel_rsn_cd", "")` |
| 2.4.6 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` |

### Block 6 — TV COURSE CHANGE CHECK (L327–L403) `ANK-4673-00-00 ADD` (L327)

> Independent conditional block for TV course change processing during fiber-optic new installations. Condition: `kojiakSbt = "001"` AND `ido_div` in (`"00032"`, `"00035"`) AND `sckmct_ptn = "9"`. The `sckmct_ptn = "9"` restriction excludes new installations caused by address changes. Comment: eo光TV 新設のみを対象とする（住所変更起因の新設工事は対象外）→ Only target eo Hikari TV new installations (exclude new installations caused by address changes).

#### Block 6.1 — Condition Check (L327–L337)

| # | Type | Code |
|---|------|------|
| 1 | IF | `inMap.get("kojiakSbt") != null && inMap.get("kojiakSbt").equals("001")` // Work subtype = TV service (TVサービス) |
| 1.1 | IF | `inMap.get("ido_div").equals("00032") \|\| inMap.get("ido_div").equals("00035")` // Movement division code |
| 1.2 | IF | `"9".equals(inMap.get("sckmct_ptn"))` // Customer pattern — restricts to new TV installations (eo光TV新設のみ) |

#### Block 6.2 — TV Course Data Preparation (L340–L402)

| # | Type | Code |
|---|------|------|
| 1 | GET | `chgTvCourseInfoMap = (HashMap) param.getData("chgTvCourseInfo")` // [-> chgTvCourseInfo = TV Course Change Info] |
| 2 | SET | `inMap.put("mskm_sbt_cd", "00001")` // [-> mskm_sbt_cd = "00001" Application type code] |
| 3 | SET | `inMap.put("add_chge_div", "02")` // [-> 02 = Change (変更)] |
| 4 | NEW | `workSvcKeiArray = new ArrayList<HashMap<String, Object>>()` // Group array |
| 5 | NEW | `workSvcKeiMap = new HashMap<String, Object>()` // Group map |
| 6 | SET | `workSvcKeiMap.put("grp_div", "00")` // [-> grp_div = "00" Group division] |
| 7 | NEW | `workSvcKeiList = new ArrayList<HashMap<String, Object>>()` // Service list |
| 8 | NEW | `workSvcKeiData = new HashMap<String, Object>()` // Individual service data |
| 9 | SET | `checkSvcKeiData = true` // Validity flag |
| 10 | SET | `workSvcKeiData.put("sysid", inMap.get("sysid"))` // System ID |
| 11 | SET | `workSvcKeiData.put("tg_kei_skbt_cd", "01")` // [-> tg_kei_skbt_cd = "01" Target contract identification code] |
| 12 | SET | `workSvcKeiData.put("svc_kei_no", inMap.get("svc_kei_no"))` // Service contract number |
| 13 | SET | `workSvcKeiData.put("svc_kei_stat", inMap.get("svc_kei_stat"))` // Service contract status |
| 14 | IF | `chgTvCourseInfoMap.get("svc_cd") != null` |
| 14.1 | SET | `workSvcKeiData.put("svc_cd", (String) chgTvCourseInfoMap.get("svc_cd"))` // [-> svc_cd = Service Code (サービスコード)] |
| 14.2 | ELSE | `checkSvcKeiData = false` // Guard: missing svc_cd invalidates record |
| 15 | IF | `chgTvCourseInfoMap.get("prc_grp_cd") != null` |
| 15.1 | SET | `workSvcKeiData.put("prc_grp_cd", (String) chgTvCourseInfoMap.get("prc_grp_cd"))` // [-> prc_grp_cd = Price Group Code (料金グループコード)] |
| 15.2 | ELSE | `checkSvcKeiData = false` |
| 16 | IF | `chgTvCourseInfoMap.get("aft_pcrs_cd") != null` |
| 16.1 | SET | `workSvcKeiData.put("pcrs_cd", (String) chgTvCourseInfoMap.get("aft_pcrs_cd"))` // [-> pcrs_cd = After Price Course Code (料金コースコード)] |
| 16.2 | ELSE | `checkSvcKeiData = false` |
| 17 | IF | `chgTvCourseInfoMap.get("aft_pplan_cd") != null` |
| 17.1 | SET | `workSvcKeiData.put("pplan_cd", (String) chgTvCourseInfoMap.get("aft_pplan_cd"))` // [-> pplan_cd = After Price Plan Code (料金プランコード)] |
| 17.2 | ELSE | `checkSvcKeiData = false` |
| 18 | IF | `chgTvCourseInfoMap.get("bfr_svc_cd") != null` |
| 18.1 | SET | `workSvcKeiData.put("chge_bf_svc_cd", (String) chgTvCourseInfoMap.get("bfr_svc_cd"))` // [-> chge_bf_svc_cd = Before Change Service Code (変更前サービスコード)] |
| 18.2 | ELSE | `checkSvcKeiData = false` |
| 19 | IF | `chgTvCourseInfoMap.get("bfr_prc_grp_cd") != null` |
| 19.1 | SET | `workSvcKeiData.put("chge_bf_prc_grp_cd", (String) chgTvCourseInfoMap.get("bfr_prc_grp_cd"))` // [-> chge_bf_prc_grp_cd = Before Change Price Group Code (変更前料金グループコード)] |
| 19.2 | ELSE | `checkSvcKeiData = false` |
| 20 | IF | `chgTvCourseInfoMap.get("bfr_pcrs_cd") != null` |
| 20.1 | SET | `workSvcKeiData.put("chge_bf_pcrs_cd", (String) chgTvCourseInfoMap.get("bfr_pcrs_cd"))` // [-> chge_bf_pcrs_cd = Before Change Price Course Code (変更前料金コースコード)] |
| 20.2 | ELSE | `checkSvcKeiData = false` |
| 21 | IF | `chgTvCourseInfoMap.get("bfr_pplan_cd") != null` |
| 21.1 | SET | `workSvcKeiData.put("chge_bf_pplan_cd", (String) chgTvCourseInfoMap.get("bfr_pplan_cd"))` // [-> chge_bf_pplan_cd = Before Change Price Plan Code (変更前料金プランコード)] |
| 21.2 | ELSE | `checkSvcKeiData = false` |
| 22 | IF | `checkSvcKeiData` // All required fields present |
| 22.1 | EXEC | `workSvcKeiList.add(workSvcKeiData)` // Add service data to list |
| 22.2 | SET | `workSvcKeiMap.put("svc_kei_list", workSvcKeiList)` |
| 22.3 | EXEC | `workSvcKeiArray.add(workSvcKeiMap)` |
| 22.4 | SET | `inMap.put("svc_kei_grp_list", workSvcKeiArray)` // [-> svc_kei_grp_list = Service Contract Group List] |
| 22.5 | CALL | `wrisvcAutoAplyCC.execute(handle, param, fixedText)` // Execute auto-application |

### Block 7 — RETURN (L406)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return the modified request parameter to the caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskm_no` | Field | Application number — internal tracking ID for the customer work order application |
| `mskm_sbt_cd` | Field | Application type code — classifies the type of application (e.g., `"00001"` = TV course change) |
| `add_chge_div` | Field | Registration/Change Division — numeric code indicating the type of contract operation: `"01"` = Registration (new setup), `"02"` = Change (modification), `"03"` = Cancellation (service termination), `"04"` = Restoration (reactivation), `"05"` = Customer Cancellation (customer-initiated), `"16"` = Registration without STB |
| `svc_dlre_cd` | Field | Service Cancellation Reason Code — reason code for service disconnection (e.g., `"01"` = customer-initiated cancellation); empty for registrations and restorations |
| `svc_cancel_rsn_cd` | Field | Service Cancellation Reason Code — additional reason code for contract cancellation; set to `"01"` for customer-initiated cancellations |
| `svc_kei_grp_list` | Field | Service Contract Group List — list of service contract groups, each containing a group division code and a list of service contract records |
| `svc_kei_list` | Field | Service Contract List — list of individual service contract records within a group |
| `svc_kei_no` | Field | Service Contract Number — unique identifier for a service contract |
| `svc_kei_stat` | Field | Service Contract Status — current status of the service contract |
| `svc_kei_ucwk_no` | Field | Service Contract Detail Number — internal tracking ID for service contract line items / details |
| `svc_kei_ucwk_stat` | Field | Service Contract Detail Status — status of a service contract detail |
| `tg_kei_skbt_cd` | Field | Target Contract Identification Code — distinguishes the type of service contract: `"01"` = regular service, `"03"` = service contract detail, `"06"` = equipment-provided service |
| `kojiakSbt` | Field | Work subtype — classifies the type of maintenance work (e.g., `"001"` = TV service) |
| `ido_div` | Field | Movement Division Code — code indicating the type of customer movement (e.g., `"00032"`, `"00035"` = specific move types for TV course changes) |
| `sckmct_ptn` | Field | Customer Pattern — identifies the customer contract pattern; `"9"` restricts processing to eo Hikari TV new installations |
| `stbTekkyo` | Field | STB Removal Flag — indicates whether a Set-Top Box is being removed during maintenance work (`"1"` = removing, `"0"` = not removing) |
| `stb_tekkyo` | Field | STB Removal (from kojiakInfoMap) — extracted from the maintenance info map to determine the STB removal state |
| `kojiakInfoMap` | Field | Maintenance Info Map — map containing maintenance work context data including the STB removal flag |
| `KikiInfoAddMap` | Field | Device Information Registration Map — contains lists of device/service contracts to be registered (new) |
| `KojiKikiMap` | Field | Maintenance/Repair Device Map — contains lists of device/service contracts for cancellation, restoration, and customer cancellation operations |
| `chgTvCourseInfo` | Field | TV Course Change Info — contains before/after service, pricing, and plan data for TV course modifications |
| `create_list` | Field | Create List — list of new device-provisioned service entries within KikiInfoAddMap |
| `dsl_kiki_list` | Field | DSL Device Cancellation List — devices to be cancelled (DSL-related) |
| `kaihk_kiki_list` | Field | Restoration Device List — devices to be restored (reactivated) |
| `cancel_kiki_list` | Field | Customer Cancellation Device List — devices to be cancelled by customer request |
| `svc_kei_ucwk_list` | Field | Service Contract Detail List — list of service contract detail/line item entries |
| `dsl_svc_ucwk_list` | Field | DSL Service Contract Detail List — contract details associated with DSL cancellation |
| `kaihk_svc_ucwk_list` | Field | Restoration Service Contract Detail List — contract details associated with restoration |
| `cancel_svc_ucwk_list` | Field | Customer Cancellation Service Contract Detail List — contract details associated with customer cancellation |
| `sysid` | Field | System ID — system identifier for the service record |
| `svc_cd` | Field | Service Code — identifies the type of service (e.g., eo Hikari TV) |
| `prc_grp_cd` | Field | Price Group Code — pricing group classification |
| `pcrs_cd` | Field | Price Course Code — pricing course selection |
| `pplan_cd` | Field | Price Plan Code — pricing plan selection |
| `chge_bf_svc_cd` | Field | Before-Change Service Code — service code prior to the modification |
| `chge_bf_prc_grp_cd` | Field | Before-Change Price Group Code — pricing group before modification |
| `chge_bf_pcrs_cd` | Field | Before-Change Price Course Code — pricing course before modification |
| `chge_bf_pplan_cd` | Field | Before-Change Price Plan Code — pricing plan before modification |
| `kktk_svc_cd` | Field | Equipment-Provided Service Code — identifies the type of equipment service (e.g., `"C009"` = STB) |
| `kktk_sbt_cd` | Field | Equipment-Provided Subtype Code — subtype classification for equipment services |
| `kktk_svc_kei_no` | Field | Equipment-Provided Service Contract Number |
| `kktk_svc_kei_stat` | Field | Equipment-Provided Service Contract Status |
| `grp_div` | Field | Group Division — structural code for grouping service contracts (`"00"` = standard group) |
| STB | Acronym | Set-Top Box — set-top box, a cable television receiver/set-top box device provided by the ISP |
| STB_TEKKYO_TEKKYO | Constant | STB removal with check — value `"1"`, indicates STB is being removed (STB撤去（チェック有）) |
| STB_TEKKYO_NASI | Constant | STB removal without check — value `"0"`, indicates STB is NOT being removed (STB撤去（チェック無）) |
| eo Hikari TV | Business term | eo光TV — NTT East's fiber-optic television service bundled with their internet connection |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband connection technology |
| K-Opticom | Business term | Japanese broadband ISP (internet service provider) offering fiber-optic internet, TV, and phone services |
| DSL | Business term | Digital Subscriber Line — in this context, refers to the device/service contract data for DSL-related cancellation operations |
