# Business Logic — JKKCancelSvcKeiMapperCC.editMapKKkopSvcUseKeiUpd() [83 LOC]

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

## 1. Role

### JKKCancelSvcKeiMapperCC.editMapKKkopSvcUseKeiUpd()

This method is the **data mapping hub** for updating a **Equipment Option Service Utilization Equipment Contract** (機器オプションサービス利用機器契約) in the K-Opticom fiber-to-the-home (FTTH) customer service system. It aggregates business data from multiple input sources — including the service contract number, movement classification (add/change vs. cancellation), operator date, and penalty determination — into a single structured `workMap` that serves as the input payload for the downstream contract update Service Component (`JKKKkopSvcUseKeiUpdCC`). 

The method implements a **routing/dispatch pattern** based on the movement type code (`idoDiv`): when the code is `"00019"` (add/change), it preserves the original movement division in the output; for any other code (typically cancellation, `"00008"`), it normalizes the division to the cancellation value. It also performs **conditional penalty mapping**: it queries the results of a prior one-agreement inquiry (EKK0771A010) to determine whether a breach penalty (違約金) was incurred, and maps `"1"` (penalty incurred) or `"0"` (penalty not incurred) accordingly. The method's role in the larger system is as a **pre-execution mapper** — it prepares the `CAANMsg`-compatible data structure that the service component requires before performing the actual contract update.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["editMapKKkopSvcUseKeiUpd(params)"]

    GET_DATA["param.getData(workFixedText)"]
    GET_IDO_DIV["inMap.get(IDO_DIV)"]

    INIT_WORK["workArray = new ArrayList<HashMap>()"]
    INIT_WORKMAP["workMap = new HashMap<String, Object>()"]

    PUT_SVC_KEY_NO["workMap.put(KEY_SVC_KEI_NO, svcKeiNo)"]

    CONDITION1{"idoDiv equals
ADCHG_ADD (00019)?"}

    PUT_ADCHG_DIV["workMap.put(KEY_IDO_DIV, idoDiv)"]
    PUT_CANCEL_DIV["workMap.put(KEY_IDO_DIV, CANCEL (00008))"]

    PUT_KKTK_SVC_NO["workMap.put(KEY_KKTK_SVC_KEI_NO, tmpKktkSvcKeiNo)"]
    PUT_MSKM_DTL_NO["workMap.put(KEY_MSKM_DTL_NO, mskmDtlMap value)"]
    PUT_UPD_DTM_BF["workMap.put(KEY_UPD_DTM_BF, tmpLastUpdDtm)"]
    GET_OPE_DATE["JCCBPCommon.getOpeDate(null)"]
    PUT_SVC_ENDYMD["workMap.put(KEY_SVC_ENDYMD, operateDate)"]
    PUT_SVC_CHRG_ENDYMD["workMap.put(KEY_SVC_CHRG_ENDYMD, operateDate minus 1 day)"]
    PUT_SVC_CANCEL_RSN["workMap.put(KEY_SVC_CANCEL_RSN_CD, mskmDtlMap value)"]

    GET_EKK0771_HASH["resultHash.get(EKK0771A010)"]
    INIT_PNLTY["pnltyHasseiUm = UM_NASHI (0)"]
    CONDITION2{"eKK0771A010Hash not null?"}
    GET_PNLTY["pnltyHasseiUm = eKK0771A010Hash.get(PNLTY_HASSEI_UM)"]
    CONDITION3{"pnltyHasseiUm equals ARI (1)?"}
    PUT_PNLTY_HASSEI["workMap.put(KEY_PNLTY_HASSEI_CD, HASSEI (1))"]
    PUT_PNLTY_NASHI["workMap.put(KEY_PNLTY_HASSEI_CD, NASHI (0))"]

    ADD_WORKMAP["workArray.add(workMap)"]
    PUT_TRGT_DATA["outMap.put(trgt_data_list, workArray)"]
    END_NODE["Return / Next"]

    START --> GET_DATA --> GET_IDO_DIV --> INIT_WORK --> INIT_WORKMAP --> PUT_SVC_KEY_NO --> CONDITION1
    CONDITION1 -->|Yes| PUT_ADCHG_DIV
    CONDITION1 -->|No| PUT_CANCEL_DIV
    PUT_ADCHG_DIV --> PUT_KKTK_SVC_NO
    PUT_CANCEL_DIV --> PUT_KKTK_SVC_NO
    PUT_KKTK_SVC_NO --> PUT_MSKM_DTL_NO --> PUT_UPD_DTM_BF --> GET_OPE_DATE --> PUT_SVC_ENDYMD --> PUT_SVC_CHRG_ENDYMD --> PUT_SVC_CANCEL_RSN --> GET_EKK0771_HASH --> INIT_PNLTY --> CONDITION2
    CONDITION2 -->|Yes| GET_PNLTY
    CONDITION2 -->|No| CONDITION3
    GET_PNLTY --> CONDITION3
    CONDITION3 -->|Yes| PUT_PNLTY_HASSEI
    CONDITION3 -->|No| PUT_PNLTY_NASHI
    PUT_PNLTY_HASSEI --> ADD_WORKMAP
    PUT_PNLTY_NASHI --> ADD_WORKMAP
    ADD_WORKMAP --> PUT_TRGT_DATA --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The work data retrieval interface — provides access to operation-scoped data via `getData(workFixedText)`. Represents the current work context for the cancel/service-contract-update operation. |
| 2 | `inMap` | `HashMap<String, Object>` | Business information map holding input data including the movement type division (`idoDiv`), which determines whether this is an add/change or cancellation operation. |
| 3 | `workFixedText` | `String` | User-specified string acting as a data scope/key to retrieve the target output map from `param`. Functions as a namespace for the work data. |
| 4 | `svcKeiNo` | `String` | Service contract number (サービス契約番号) — the unique identifier of the service contract line item being updated. |
| 5 | `mskmDtlMap` | `HashMap<String, Object>` | Application detail map (申込明細マップ) containing the application detail number (`mskmDtlNo`) and the cancellation reason code (`cancelRsnCd`) for this service contract. |
| 6 | `tmpKktkSvcKeiNo` | `String` | Equipment-provider service contract number (機器提供サービス契約番号) — the sub-contract number assigned to the equipment provider for this service line. |
| 7 | `tmpLastUpdDtm` | `String` | Last update date-time (更新年月日時分秒) — used as the "before update" timestamp for optimistic concurrency control or audit tracking. |
| 8 | `resultHash` | `HashMap<String, Object>` | Results hash carrying outcomes from prior service component calls, specifically the one-agreement inquiry result keyed by `"EKK0771A010"`, which contains the penalty occurrence flag. |

## 4. CRUD Operations / Called Services

This method does not directly access databases or invoke Service Components (SCs). Instead, it reads data from utility classes and maps it into a work structure. The called methods serve as **read-only data suppliers**:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBPCommon.getOpeDate` | - | - | Retrieves the current operator date (business date) for use as service end date and billing end date. |
| R | `JKKDslRun.addYYYYMMDD` | - | - | Computes a date offset by a specified number of days (here, -1 day for service charge end date). |

**Notes on the pre-computed evidence:**
The pre-computed evidence lists many SC codes and data accessors, but they belong to **other methods in the same class** (`JKKCancelSvcKeiMapperCC`) or in caller classes. This specific method, `editMapKKkopSvcUseKeiUpd()`, only calls `JCCBPCommon.getOpeDate()` and `JKKDslRun.addYYYYMMDD()` — both are pure date utility calls with no SC codes or database entities directly involved.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 14 methods.
Terminal operations from this method: `addYYYYMMDD` [R], `getOpeDate` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKCancelSvcKeiCC.callCancelKktkSvcKei()` | `callCancelKktkSvcKei()` → `editMapKKkopSvcUseKeiUpd()` | `getOpeDate` [R], `addYYYYMMDD` [R] |
| 2 | `JKKDslRun.dslKktkSvcKei()` | `dslKktkSvcKei()` → `editMapKKkopSvcUseKeiUpd()` | `getOpeDate` [R], `addYYYYMMDD` [R] |

**Instructions:**
These are the two pre-extracted callers. `JKKCancelSvcKeiCC` is the Service Contract Cancel Execution CC class that orchestrates cancel flows. `JKKDslRun` is the DSL (service contract) run processor that coordinates full-service contract lifecycle operations. Both invoke this mapper before calling the actual contract update component.

## 6. Per-Branch Detail Blocks

### Block 1 — INIT (L4798-L4799)
> Initialize local variables for the output map and movement division retrieval.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = null` |
| 2 | SET | `idoDiv = null` |

### Block 2 — GET DATA (L4801)
> Retrieve the target output map from the parameter interface using the work fixed text as the data scope key.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap = (HashMap)param.getData(workFixedText)` |

### Block 3 — GET MOVEMENT DIVISION (L4803)
> Extract the movement division (異動区分) from the input map using the constant `IDO_DIV = "ido_div"` as the key.
> (コメント: 異動区区分取得 — Movement division retrieval)

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoDiv = (String)inMap.get(JKKDslRunConstCC.IDO_DIV)` |-> `IDO_DIV = "ido_div"` |

### Block 4 — INITIALIZE WORK DATA LIST (L4806)
> Create the target data list (対象データリスト) that will hold the mapped work records.
> (コメント: 対象データリスト — Target data list)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workArray = new ArrayList<HashMap>()` |

### Block 5 — INITIALIZE WORK MAP (L4809)
> Create the work map (機器オプションサービス利用機器契約更新マップ) for the equipment option service utilization equipment contract update mapping.
> (コメント: 機器オプションサービス利用機器契約更新マップ — Equipment option service utilization equipment contract update map)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = new HashMap<String, Object>()` |

### Block 6 — PUT SERVICE CONTRACT NUMBER (L4812)
> Set the service contract number (サービス契約番号) into the work map.
> (コメント: サービス契約番号 — Service contract number)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_SVC_KEI_NO, svcKeiNo)` |-> `KEY_SVC_KEI_NO = "svc_kei_no"` |

### Block 7 — MOVEMENT DIVISION ROUTING (L4815-L4822)
> Route the movement division (異動区分) based on whether the operation is an add/change (ADCHG_ADD = "00019") or a cancellation. If add/change, preserve the original `idoDiv`; otherwise, normalize to cancellation division (CANCEL = "00008").
> (コメント: 異動区分 — Movement division)

| # | Type | Code |
|---|------|------|
| 1 | IF | `IDO_KBN_ADCHGADD.equals(idoDiv)` |-> `IDO_KBN_ADCHGADD = "00019"` |

**Block 7.1 — IF BRANCH (Add/Change)** (L4817-L4818)
> For add/change operations, the original movement division code is preserved in the output.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_IDO_DIV, idoDiv)` |-> `KEY_IDO_DIV = "ido_div"` |

**Block 7.2 — ELSE BRANCH (Cancellation)** (L4820-L4821)
> For non-add/change operations, the movement division is set to the cancellation code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_IDO_DIV, IDO_KBN_CANCEL)` |-> `IDO_KBN_CANCEL = "00008"` |

### Block 8 — PUT EQUIPMENT-PROVIDER SERVICE CONTRACT NUMBER (L4825)
> Set the equipment-provider service contract number (機器提供サービス契約番号).
> (コメント: 機器提供サービス契約番号 — Equipment-provider service contract number)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_KKTK_SVC_KEI_NO, tmpKktkSvcKeiNo)` |-> `KEY_KKTK_SVC_KEI_NO = "kktk_svc_kei_no"` |

### Block 9 — PUT APPLICATION DETAIL NUMBER (L4828)
> Set the application detail number (申込明細番号) from the `mskmDtlMap`.
> (コメント: 申込明細番号 — Application detail number)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_MSKM_DTL_NO, mskmDtlMap.get(JKKCancelSvcKeiCC.MSKM_DTL_NO))` |-> `KEY_MSKM_DTL_NO = "mskm_dtl_no"`, `MSKM_DTL_NO = "mskm_dtl_no"` |

### Block 10 — PUT LAST UPDATE DATE-TIME (L4831)
> Set the "before update" timestamp (更新年月日時分秒) for optimistic concurrency control.
> (コメント: 更新年月日時分秒 — Update date-time)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_UPD_DTM_BF, tmpLastUpdDtm)` |-> `KEY_UPD_DTM_BF = "upd_dtm_bf"` |

### Block 11 — GET OPERATOR DATE (L4834)
> Retrieve the current operator/business date from the common utility.

| # | Type | Code |
|---|------|------|
| 1 | SET | `operateDate = JCCBPCommon.getOpeDate(null)` |

### Block 12 — PUT SERVICE END DATE (L4837)
> Set the operator date as the service end date (サービス終了年月日).
> (コメント: 運用日 → サービス終了年月日 — Operating date → Service end date)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_SVC_ENDYMD, operateDate)` |-> `KEY_SVC_ENDYMD = "svc_endymd"` |

### Block 13 — PUT SERVICE CHARGE END DATE (L4840)
> Compute the service charge end date (サービス課金終了年月日) by subtracting 1 day from the operator date using the date arithmetic utility. The comment explains: "request parameter service end date (billing applicable date) minus 1 day → service charge end date".
> (コメント: リクエストパラメータ.サービス終了年月日（予約適用年月日）−1日 → サービス課金終了年月日)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_SVC_CHRG_ENDYMD, JKKDslRun.addYYYYMMDD(operateDate, -1))` |-> `KEY_SVC_CHRG_ENDYMD = "svc_chrg_endymd"` |

### Block 14 — PUT SERVICE CANCEL REASON CODE (L4843)
> Set the service cancel reason code (サービスキャンセル理由コード) from the application detail map.
> (コメント: サービスキャンセル理由コード — Service cancel reason code)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_SVC_CANCEL_RSN_CD, mskmDtlMap.get(JKKCancelSvcKeiCC.CANCEL_RSN_CD))` |-> `KEY_SVC_CANCEL_RSN_CD = "svc_cancel_rsn_cd"`, `CANCEL_RSN_CD = "cancel_rsn_cd"` |

### Block 15 — PENALTY DETERMINATION (L4846-L4863)
> Query the prior one-agreement inquiry result (機器提供サービス一意照会の結果取得) to determine whether a breach penalty (違約金発生) was incurred. Initialize to "no" (UM_NASHI = "0"), then override based on the inquiry result if available.
> (コメント: KEY_PNLTY_HASSEI_CD 違約金発生コード / 機器提供サービス一意照会の結果取得 — KEY_PNLTY_HASSEI_CD Penalty occurrence code / Equipment-provider service one-agreement inquiry result retrieval)

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0771A010Hash = null` |
| 2 | SET | `eKK0771A010Hash = (HashMap)resultHash.get(TEMPLATE_ID_EKK0771A010)` |-> `TEMPLATE_ID_EKK0771A010 = "EKK0771A010"` |
| 3 | SET | `pnltyHasseiUm = JKKStrConst.CD_DIV_UM_NASHI` |-> `CD_DIV_UM_NASHI = "0"` |
| 4 | IF | `eKK0771A010Hash != null` |

**Block 15.1 — IF BRANCH (Inquiry result present)** (L4850-L4851)
> Extract the penalty occurrence flag from the inquiry result.
> (コメント: 違約金発生コード — Penalty occurrence code)

| # | Type | Code |
|---|------|------|
| 1 | SET | `pnltyHasseiUm = eKK0771A010Hash.get(EKK0771A010CBSMsg1List.PNLTY_HASSEI_UM)` |-> `PNLTY_HASSEI_UM = "pnlty_hassei_um"` |

**Block 15.2 — ELSE BRANCH (Default)** — Implicit (pnltyHasseiUm stays "0")

### Block 16 — PENALTY CODE MAPPING (L4853-L4862)
> Map the penalty occurrence flag to the actual penalty code. If the flag is "ARI" (with penalty, "1"), set penalty occurred code (違約金発生コード); otherwise set penalty not occurred code.
> (コメント: 違約金発生コード / 違約金発生コード — Penalty occurrence code / Penalty occurrence code)

| # | Type | Code |
|---|------|------|
| 1 | IF | `JKKStrConst.CD_DIV_UM_ARI.equals(pnltyHasseiUm)` |-> `CD_DIV_UM_ARI = "1"` |

**Block 16.1 — IF BRANCH (Penalty incurred)** (L4855-L4856)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_PNLTY_HASSEI_CD, JKKStrConst.CD01375_PNLTY_HASSEI)` |-> `KEY_PNLTY_HASSEI_CD = "pnlty_hassei_cd"`, `CD01375_PNLTY_HASSEI = "1"` |

**Block 16.2 — ELSE BRANCH (Penalty not incurred)** (L4858-L4859)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(JKKKkopSvcUseKeiUpdCC.KEY_PNLTY_HASSEI_CD, JKKStrConst.CD01375_PNLTY_NASHI)` |-> `CD01375_PNLTY_NASHI = "0"` |

### Block 17 — FINALIZE OUTPUT (L4864-L4866)
> Add the completed work map to the work data list and put the list into the output map under the key `"trgt_data_list"`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `workArray.add(workMap)` |
| 2 | EXEC | `outMap.put("trgt_data_list", workArray)` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiNo` | Field | Service contract number (サービス契約番号) — unique identifier for a service contract line item in the K-Opticom customer system. |
| `idoDiv` | Field | Movement division (異動区分) — classifies the type of operation: "00019" for addition/change (変更異動), "00008" for cancellation (取消し異動). |
| ADCHG_ADD | Constant | Addition/change movement type code — `"00019"`. Triggers preservation of the original movement division in output. |
| CANCEL | Constant | Cancellation movement type code — `"00008"`. Used when the operation is a service contract cancellation. |
| `mskmDtlMap` | Field | Application detail map (申込明細マップ) — contains the application detail number and cancellation reason code for this service contract. |
| `tmpKktkSvcKeiNo` | Field | Equipment-provider service contract number (機器提供サービス契約番号) — the sub-contract number assigned to the equipment provider for this specific service line. |
| `tmpLastUpdDtm` | Field | Last update date-time (更新年月日時分秒) — timestamp of the last modification, used as the "before update" value for optimistic concurrency control. |
| `operateDate` | Field | Operator date / business date (運用日) — the current business date obtained from `JCCBPCommon.getOpeDate()`. Used as the service end date for cancellations. |
| SERVICE_ENDYMD | Field | Service end date (サービス終了年月日) — the date when the service contract officially terminates. Set to the operator date. |
| SVC_CHRG_ENDYMD | Field | Service charge end date (サービス課金終了年月日) — the date when billing stops. Set to the operator date minus 1 day. |
| `cancelRsnCd` | Field | Cancel reason code (キャンセル理由コード) — the reason why this service contract was cancelled, stored in the application detail map. |
| PNLTY_HASSEI_UM | Field | Penalty occurrence flag (違約金発生有無) — from the EKK0771A010 one-agreement inquiry result. "1" (ARI) means a breach penalty was incurred; "0" (NASHI) means it was not. |
| CD01375_PNLTY_HASSEI | Constant | Penalty occurred code — `"1"`. Mapped when the breach penalty flag indicates penalty was incurred. |
| CD01375_PNLTY_NASHI | Constant | Penalty not occurred code — `"0"`. Mapped when the breach penalty flag indicates no penalty. |
| EKK0771A010 | Template ID | One-agreement inquiry (一意照会) — a service component that checks the status and details of a service contract agreement. Results include the penalty occurrence flag. |
| CD_DIV_UM_ARI | Constant | "With" (有) — value `"1"`. Indicates something exists (e.g., a penalty was incurred). |
| CD_DIV_UM_NASHI | Constant | "Without" (無) — value `"0"`. Indicates something does not exist (e.g., no penalty). |
| `trgt_data_list` | Field | Target data list key — the output map key under which the work data list is stored for downstream consumption. |
| K-Opticom | Business term | Japanese telecommunications provider offering FTTH (fiber-to-the-home) and other broadband services. The eo customer system is their back-office customer management platform. |
| FTTH | Business term | Fiber To The Home — fiber-optic internet service offered by K-Opticom. |
| CAANMsg | Technical | K-Opticom's message object format used for data exchange between components (CC, SC, CBS layers). |
| SC | Technical | Service Component — the service layer component that encapsulates business logic and database operations for a specific function. |
| CBS | Technical | Contract-Based System — the backend system layer handling data persistence and business rule enforcement. |
