# Business Logic — JKKFmtcelMskmInfoTrkmCC.runHiChrgJdgUtil() [59 LOC]

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

## 1. Role

### JKKFmtcelMskmInfoTrkmCC.runHiChrgJdgUtil()

This method is the **non-taxable judgment execution processor** (非課金判定部品実行処理) — a core component that orchestrates the billing judgment workflow for telecom service contract cancellations. It determines whether a customer qualifies for "non-taxable" (fee-exempt) cancellation status, which determines whether cancellation fees are waived or applied. The method operates as a **delegation and routing pattern**: it validates input, maps service contract data into a target structure, delegates the actual judgment logic to `JKKBpCommon.jdgHiChrgKK`, and persists the result back to the work area. It handles **three cancellation service types** — standard service contract cancellation (解約種別フラグ = "1"), option service cancellation (解約種別フラグ = "2"), and sub-option service cancellation (解約種別フラグ = "3") — each with different message object requirements. As a shared utility, it is called by multiple DSL (dsl = 解約, cancellation) processing paths within the broader order fulfillment system, acting as the centralized decision point for whether cancellation fees should be assessed.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["runHiChrgJdgUtil"])
    
    START --> CHECK_NULL["Check: dslSbtFlg == null"]
    CHECK_NULL -->|true| THROW1["Throw IllegalArgumentException
 DSL Sbt Flg not set"]
    CHECK_NULL -->|false| CHECK_MSG1["Check: msgEKK0081A010 == null"]
    
    CHECK_MSG1 -->|true| THROW2["Throw IllegalArgumentException
 Service Contract Inquiry Result not set"]
    CHECK_MSG1 -->|false| CHECK_DSL_FLAG["Check: DSL Sbt Flg is valid"]
    
    CHECK_DSL_FLAG -->|is 1 or 2 or 3| CHECK_SPECIFIC["Check: specific DSL Sbt Flg"]
    CHECK_DSL_FLAG -->|is unknown| THROW3["Throw IllegalArgumentException
 Invalid DSL Sbt Flg"]
    
    CHECK_SPECIFIC -->|dslSbtFlg = 2 and msgEKK0351A010 is null| THROW4["Throw IllegalArgumentException
 Result object not set for DSL Sbt Flg"]
    CHECK_SPECIFIC -->|valid condition met| CLEAN_WORK["Clean work area
 delWorkJdgHiChrgJdgUtil"]
    
    CLEAN_WORK --> INIT_VARS["Initialize
 trgtData = null
 resultMap = null"]
    INIT_VARS --> EDIT_MAP["call editMapHiChrgJdgUtil
 Map necessary info"]
    EDIT_MAP --> CHECK_RESULT["Check: trgtData != null"]
    
    CHECK_RESULT -->|true| CALL_JDG["call JKKBpCommon.jdgHiChrgKK
 Execute non-taxable judgment"]
    CHECK_RESULT -->|false| RETURN_NULL["Return null"]
    
    CALL_JDG --> CHECK_RM["Check: resultMap != null"]
    CHECK_RM -->|true| SET_WORK["call setWorkJdgHiChrgJdgUtil
 Save result to work area"]
    CHECK_RM -->|false| RETURN_NULL
    SET_WORK --> RETURN_NULL
    
    THROW1 --> END_NODE(["End"])
    THROW2 --> END_NODE
    THROW3 --> END_NODE
    THROW4 --> END_NODE
    RETURN_NULL --> END_NODE
```

**CRITICAL — Constant Resolution:**

| Constant Name | Resolved Value | Business Meaning |
|---------------|---------------|-----------------|
| `DSL_SBT_FLG_SVC_KEI_DSL` | `"1"` | Service Contract Cancellation (サービス契約解約) |
| `DSL_SBT_FLG_OP_SVC_KEI_DSL` | `"2"` | Option Service Cancellation (オプションサービス契約解約) |
| `DSL_SBT_FLG_SBOP_SVC_KEI_DSL` | `"3"` | Sub-Option Service Cancellation (サブオプションサービス契約解約) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing transactional context for all data operations. Used to maintain session state across service component calls. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object containing the model group and control map. Used for work area management — reading prior judgment results (`getWorkjdgHiChrgJdgUtil`), deleting stale work data, and storing final judgment results (`setWorkJdgHiChrgJdgUtil`). |
| 3 | `inMap` | `HashMap<String, Object>` | Input parameter map carrying the source data to be mapped. Contains original service contract information and order details passed from the caller. |
| 4 | `msgEKK0081A010` | `CAANMsg` | Service Contract Single Inquiry Result (サービス契約一意照会結果) — contains the queried service contract data (EKK0081A010 schema). **Required for all cancellation types.** Retrieved from the service contract inquiry service component. |
| 5 | `msgEKK0351A010` | `CAANMsg` | Option Service Contract Single Inquiry Result (オプションサービス契約一意照会結果) — contains the queried option service contract data (EKK0351A010 schema). **Required only when dslSbtFlg = "2" (Option Service Cancellation).** |
| 6 | `dslSbtFlg` | `String` | Cancellation Type Flag (解約種別フラグ) — determines which service category is being cancelled. Must be exactly `"1"`, `"2"`, or `"3"`. Controls which inquiry results are validated and which data mapping paths are taken in `editMapHiChrgJdgUtil`. |

**Instance fields or external state read:** None directly — the method is stateless and relies entirely on parameters and called methods for all state interactions.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKFmtcelMskmInfoTrkmCC.getWorkjdgHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | - | Reads work area for existing judgment results (`R`) |
| - | `JKKFmtcelMskmInfoTrkmCC.delWorkJdgHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | - | Clears/deletes stale work area judgment data (clears work storage) |
| U | `JKKFmtcelMskmInfoTrkmCC.editMapHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | - | Maps and transforms service contract data into target judgment format (`U`) |
| - | `JKKBpCommon.jdgHiChrgKK` | JKKBpCommon | - | Core non-taxable judgment logic — evaluates whether cancellation fees are waived. Actual DB/entity operations are delegated to this component. |
| U | `JKKFmtcelMskmInfoTrkmCC.setWorkJdgHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | - | Stores/updates judgment result in the work area (`U`) |

**Detailed Analysis:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKFmtcelMskmInfoTrkmCC.getWorkjdgHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | Work area (in-memory) | Reads existing non-taxable judgment results from the work area to determine if cleanup is needed before re-processing. |
| U | `JKKFmtcelMskmInfoTrkmCC.delWorkJdgHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | Work area (in-memory) | Removes stale judgment data from the work area to prevent stale results from interfering with new judgment execution. |
| U | `JKKFmtcelMskmInfoTrkmCC.editMapHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | In-memory map | Maps input parameters and inquiry results (`msgEKK0081A010`, `msgEKK0351A010`) into the target data structure (`trgtData`) required by the judgment engine. |
| - | `JKKBpCommon.jdgHiChrgKK` | JKKBpCommon | (internal to JKKBpCommon) | The core non-taxable judgment service — evaluates cancellation eligibility and determines whether fees are waived (non-taxable) or applied. Implementation details are encapsulated within JKKBpCommon. |
| U | `JKKFmtcelMskmInfoTrkmCC.setWorkJdgHiChrgJdgUtil` | JKKFmtcelMskmInfoTrkmCC | Work area (in-memory) | Persists the judgment result map into the work area for downstream processing stages to consume (e.g., cancellation fee calculation, contract update). |

## 5. Dependency Trace

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

Direct callers found: 1 method.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `excuteDsl` | `excuteDsl` → `runHiChrgJdgUtil(handle, param, work, msgEKK0081A010, msgEKK0351A010, DSL_SBT_FLG_OP_SVC_KEI_DSL)` | `jdgHiChrgKK [-]`, `editMapHiChrgJdgUtil [U]`, `delWorkJdgHiChrgJdgUtil [-]`, `getWorkjdgHiChrgJdgUtil [R]`, `setWorkJdgHiChrgJdgUtil [U]` |
| 2 | Method: `JKKDslRun` (multiple call sites) | `JKKDslRun.runHiChrgJdgUtil` variant (8-param overload) delegates to this method | `jdgHiChrgKK [-]`, `editMapHiChrgJdgUtil [U]`, `delWorkJdgHiChrgJdgUtil [-]`, `getWorkjdgHiChrgJdgUtil [R]`, `setWorkJdgHiChrgJdgUtil [U]` |

**Notes on call sites:**
- The method is called within `excuteDsl` (line ~422) during **option service cancellation** processing (フラグ = `"2"`), where it is invoked after service contract and option service contract inquiry results have been fetched.
- Additional call sites exist in `JKKDslRun.java` (lines 746, 2601, 4007, 4501) which call an 8-parameter overload that delegates to this method with a DSL cancellation flag.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF-ELSEIF chain: Argument validation] (L1995)

> Validates that all required parameters are present and that the DSL cancellation type flag is within the supported set. This is the guard clause section that prevents null pointer and logic errors downstream.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (dslSbtFlg == null)` // Check if cancellation type flag is set |
| 2 | THROW | `throw new IllegalArgumentException("解約種別フラグが設定されていません")` // "Cancellation type flag is not set" [-> Original Japanese] |
| 3 | ELSEIF | `else if (msgEKK0081A010 == null)` // Check if service contract inquiry result is available |
| 4 | THROW | `throw new IllegalArgumentException("サービス契約一意照会結果が設定されていません")` // "Service contract inquiry result is not set" [-> Original Japanese] |
| 5 | ELSEIF | `else if (!DSL_SBT_FLG_SVC_KEI_DSL.equals(dslSbtFlg) && !DSL_SBT_FLG_OP_SVC_KEI_DSL.equals(dslSbtFlg) && !DSL_SBT_FLG_SBOP_SVC_KEI_DSL.equals(dslSbtFlg))` // Check if DSL Sbt Flg is within supported values. [-> DSL_SBT_FLG_SVC_KEI_DSL = "1", DSL_SBT_FLG_OP_SVC_KEI_DSL = "2", DSL_SBT_FLG_SBOP_SVC_KEI_DSL = "3"] |
| 6 | THROW | `throw new IllegalArgumentException("不正な解約種別フラグが選択されました。")` // "Invalid cancellation type flag was selected." [-> Original Japanese] |
| 7 | ELSEIF | `else if (DSL_SBT_FLG_OP_SVC_KEI_DSL.equals(dslSbtFlg) && (msgEKK0351A010 == null))` // When cancellation type is Option Service (フラグ = "2"), verify option contract inquiry result exists. [-> DSL_SBT_FLG_OP_SVC_KEI_DSL = "2"] |
| 8 | THROW | `throw new IllegalArgumentException("指定した解約種別フラグに応じた結果オブジェクトが設定されていません")` // "Result object corresponding to the specified cancellation type flag is not set." [-> Original Japanese] |

**Block 2** — [IF: Work area cleanup] (L2021)

> Before running a fresh judgment, this block checks if there is existing judgment data in the work area and removes it to prevent stale results from interfering. This ensures clean state for the current processing cycle.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (getWorkjdgHiChrgJdgUtil(param) != null)` // Check if work area contains existing judgment results |
| 2 | EXEC | `delWorkJdgHiChrgJdgUtil(param)` // Remove/clean up stale work area judgment data |

**Block 3** — [Variable initialization] (L2025-L2026)

> Declares and initializes local target data and result maps. Initialized to `null` and populated by `editMapHiChrgJdgUtil` / `jdgHiChrgKK` respectively.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> trgtData = null;` // Target data map for judgment input |
| 2 | SET | `HashMap<String, Object> resultMap = null;` // Result map from judgment execution |

**Block 4** — [Data mapping] (L2029)

> Maps the input parameters and inquiry results into a unified target data structure. This prepares the data in the format expected by the core judgment engine. The mapping considers the cancellation type flag to determine which service contract data sources to include.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `trgtData = editMapHiChrgJdgUtil(inMap, msgEKK0081A010, msgEKK0351A010, dslSbtFlg)` // Maps input and inquiry data into target judgment format |

**Block 5** — [IF: Judgment execution gate] (L2032)

> Guards the judgment execution. If the mapping produced no target data (trgtData is null), the method returns null early without calling the judgment engine. This prevents unnecessary processing when there is nothing to evaluate.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (trgtData != null)` // Proceed only if mapping produced valid target data |
| 2 | CALL | `resultMap = JKKBpCommon.jdgHiChrgKK(handle, param, trgtData, dslSbtFlg)` // Execute the core non-taxable judgment [OM-2013-0001096 UPD] // Comment: 非課金判定部品実行処理 (Non-taxable judgment component execution) |
| 3 | IF | `if (resultMap != null)` // Check if judgment engine returned a result |
| 4 | CALL | `setWorkJdgHiChrgJdgUtil(param, resultMap)` // Store judgment result in work area for downstream consumers // Comment: 結果をワーク領域に保持 (Retain result in work area) |

**Block 6** — [RETURN: Final result] (L2043)

> Returns the judgment result map. Returns `null` if either the mapping produced no data, the judgment engine returned no result, or the method returned early due to null target data.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return resultMap;` // Returns the non-taxable judgment result map, or null if no judgment was executed |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `dslSbtFlg` | Field | Cancellation Type Flag (解約種別フラグ) — Classifies which type of service cancellation is being processed. Value "1" = standard service contract cancellation, "2" = option service cancellation, "3" = sub-option service cancellation. |
| 非課金判定 | Business term | Non-taxable judgment — The business process of determining whether a customer qualifies for fee-exempt (non-taxable) cancellation. If the judgment result is "non-taxable," the customer is exempt from cancellation fees. |
| 解約 | Business term | Cancellation / Contract termination — The act of terminating a service contract. In this system, cancellation is differentiated by service type (standard, option, sub-option). |
| `msgEKK0081A010` | Field | Service Contract Single Inquiry Result — CAANMsg containing the queried service contract data via the EKK0081A010 schema. Always required. |
| `msgEKK0351A010` | Field | Option Service Contract Single Inquiry Result — CAANMsg containing the queried option service contract data via the EKK0351A010 schema. Required only for option service cancellation (フラグ = "2"). |
| `JKKBpCommon.jdgHiChrgKK` | Method | Core non-taxable judgment engine — Delegates the actual fee-waiver evaluation logic. "jdg" = 判定 (judgment), "HiChrg" = 高額課金 (high charge / cancellation fee), "KK" = 課金 (billing). |
| `editMapHiChrgJdgUtil` | Method | Target data mapping utility — Transforms raw inquiry results and input parameters into the unified target data structure required by the judgment engine. |
| `setWorkJdgHiChrgJdgUtil` | Method | Work area result storage — Persists judgment results to the in-memory work area for downstream processes. |
| `getWorkjdgHiChrgJdgUtil` | Method | Work area judgment result reader — Retrieves existing judgment results from the work area to check for stale data. |
| `delWorkJdgHiChrgJdgUtil` | Method | Work area cleanup — Removes judgment results from the work area to prepare for fresh processing. |
| DSL_SBT_FLG_SVC_KEI_DSL | Constant | Service Contract Cancellation Flag = "1" (サービス契約解約) |
| DSL_SBT_FLG_OP_SVC_KEI_DSL | Constant | Option Service Cancellation Flag = "2" (オプションサービス契約解約) |
| DSL_SBT_FLG_SBOP_SVC_KEI_DSL | Constant | Sub-Option Service Cancellation Flag = "3" (サブオプションサービス契約解約) |
| `jkdgHiChrg` | Abbreviation | Judgment High Charge — Shortened form for cancellation fee judgment (非課金判定 / 高額課金判定) |
| `SVC_KEI` | Abbreviation | Service Detail / Service Category (サービス種目) |
| `OP` | Abbreviation | Option — Refers to optional services attached to a base service contract |
| `SBOP` | Abbreviation | Sub-Option — Refers to services nested under option services |
| CAANMsg | Technical | CAAN message object — Standard inter-component communication container used throughout the system for data exchange between service components and business logic classes. |
| SessionHandle | Technical | Database session handle — Manages transaction context and connection state for all database operations within a processing flow. |
| IRequestParameterReadWrite | Technical | Request parameter interface — Generic container for passing structured data between components, supporting both read and write access to model groups and control maps. |
| JKKBpCommon | Component | Common BP Business Logic Component — Shared service component containing common business operations such as non-taxable judgment, format change information, and other cross-cutting functionality. |
| JKKFmtcelMskmInfoTrkmCC | Component | Format Change Masking Information Tracking CC — Primary class containing this method. Handles format change and masking information tracking for service contracts, including cancellation processing. |
| FTTH | Business term | Fiber To The Home — Fiber-optic broadband internet service. This system processes order fulfillment for FTTH and related telecom services. |
