# Business Logic - JFUHakkoSODCC.callEKK0191A010SC() [29 LOC]

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

## 1. Role

### JFUHakkoSODCC.callEKK0191A010SC()

This method is a **cached wrapper** around the parent class's `callEKK0191A010SC`, which invokes the **Service Contract Details (eo Light Phone) Unique Inquiry Service Component (SC)** - `EKK0191A010SC`. The Service Contract Details inquiry (サービス契約内訳照会) is a read operation that retrieves detailed information about a specific service contract line item, specifically for eo Light Phone (eo光電話) subscriptions. It includes data such as the subscriber's ported number status (番号有無 - whether a ported telephone number exists), VA home router model code (VA宅内機器型式コード), device change number (機器変更番号), and registration datetime.

The method implements an **intercepting filter / caching pattern**: before delegating to the actual service component, it checks whether identical inquiry parameters (service contract detail number `svc_kei_ucwk_no` and generation registration datetime `gene_add_dtm`) have already been processed and cached in the instance-level `mapSC` HashMap. If the parameters match a cached entry, the method returns the previously stored status and merged result data without making a redundant service call. If they differ (or if funcCode is not "1", bypassing the datetime check), it delegates to `super.callEKK0191A010SC` to execute the actual SC, then stores the results in the cache for future reuse within the same business operation.

Its role in the larger system is to **deduplicate repeated inquiries** of the same service contract detail during multi-step service order processing - for example, when the same contract line item is referenced multiple times across different processing branches (such as optional service contract inquiry, ISP agreement inquiry, sub-optional service listing, or device provision service agreement listing). This avoids unnecessary SC invocations and database reads within a single business transaction, reducing latency and database load.

The method supports two funcCode paths: `"1"` (standard mode, checking both `svc_kei_ucwk_no` and `gene_add_dtm`) and `"2"` (cache lookup mode, checking only `svc_kei_ucwk_no`). The funcCode `"2"` variant is used when the contract detail registration datetime needs to be fetched via cache lookup rather than computed through the full service call.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callEKK0191A010SC params"])
    CACHE_KEY["Build cache key: EKK0191A010 + UNDER_BAR + funcCode"]
    GET_MAP["getMapSC retrieve cached map"]
    COND1{"svc_kei_ucwk_no mismatch?"}
    COND2{"funcCode equals 1 AND gene_add_dtm mismatch?"}
    CALL_SUPER["super.callEKK0191A010SC invoke actual SC"]
    SET_STATUS["map.put(STATUS, status)"]
    SET_SVC_NO["map.put(SVC_KEI_UCWK_NO, inHash value)"]
    SET_DTM["map.put(GENE_ADD_DTM, inHash value)"]
    SET_OUT["map.put(OUT_MAP, resultHash)"]
    PUT_CACHE["mapSC.put(cacheKey, map)"]
    ELSE_BLOCK["Else branch - cached data"]
    GET_STATUS["status = map.get(STATUS)"]
    MERGE_RESULT["resultHash.putAll(map.get(OUT_MAP))"]
    RETURN_STATUS["return status"]

    START --> CACHE_KEY --> GET_MAP --> COND1
    COND1 -- "yes - mismatch" --> CALL_SUPER
    COND1 -- "no - same" --> COND2
    COND2 -- "funcCode=1 AND datetime mismatch" --> CALL_SUPER
    COND2 -- "funcCode!=1 OR datetime same" --> ELSE_BLOCK
    CALL_SUPER --> SET_STATUS --> SET_SVC_NO --> SET_DTM --> SET_OUT --> PUT_CACHE --> RETURN_STATUS
    ELSE_BLOCK --> GET_STATUS --> MERGE_RESULT --> RETURN_STATUS
```

**Conditional Branch Details:**

| Branch Condition | Constant Resolution | Business Meaning |
|-----------------|---------------------|------------------|
| `svc_kei_ucwk_no` mismatch | `SVC_KEI_UCWK_NO = "svc_kei_ucwk_no"` [-> SVC_KEI_UCWK_NO="svc_kei_ucwk_no" (JKKHakkoSODConstCC.java:560)] | The service contract detail number differs from the cached entry - a different contract line item is being queried |
| `funcCode == "1"` AND `gene_add_dtm` mismatch | `FUNC_CODE_1 = "1"` [-> FUNC_CODE_1="1" (JKKHakkoSODConstCC.java:747)], `GENE_ADD_DTM = "gene_add_dtm"` [-> GENE_ADD_DTM="gene_add_dtm" (JKKHakkoSODConstCC.java:572)] | The funcCode is standard mode ("1"), and the registration datetime differs - the same contract detail has been modified since the cached version was created |
| `funcCode != "1"` (bypass datetime check) | `FUNC_CODE_2 = "2"` [-> FUNC_CODE_2="2" (JKKHakkoSODConstCC.java:749)] | When funcCode is "2" (cache lookup mode), only the service contract detail number is compared - the datetime check is skipped because the SC returns the datetime to populate the cache |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter object used for reading/writing business data during SC invocation. Carries control map data (return codes, messages), input parameters, and output results. Provides the interface for the underlying SC framework to exchange data. |
| 2 | `handle` | `SessionHandle` | Session handle containing the database connection and transaction context. Passed to the parent SC call to maintain transactional integrity across the service component invocation. |
| 3 | `inHash` | `HashMap<String, Object>` | Input condition HashMap containing the inquiry criteria. Must include `svc_kei_ucwk_no` [-> SVC_KEI_UCWK_NO="svc_kei_ucwk_no" (JKKHakkoSODConstCC.java:560)] (the service contract detail number to look up) and `gene_add_dtm` [-> GENE_ADD_DTM="gene_add_dtm" (JKKHakkoSODConstCC.java:572)] (the generation registration datetime used for cache comparison). |
| 4 | `resultHash` | `HashMap<String, Object>` | Result HashMap that receives the SC output. On a cache hit, it is populated by merging the cached `OUT_MAP` data. On a cache miss, it is populated by the parent SC call and then stored in the cache. |
| 5 | `funcCode` | `String` | Function code that controls the caching behavior. `"1"` [-> FUNC_CODE_1="1" (JKKHakkoSODConstCC.java:747)] triggers full comparison (both `svc_kei_ucwk_no` and `gene_add_dtm`). `"2"` [-> FUNC_CODE_2="2" (JKKHakkoSODConstCC.java:749)] triggers cache-lookup-only comparison (only `svc_kei_ucwk_no`), used when the caller needs to fetch the registration datetime from the SC result itself. |

**Instance fields read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `mapSC` | `HashMap<String, Object>` | Instance-level cache storage. Maps cache keys (template ID + funcCode) to HashMaps containing STATUS, SVC_KEI_UCWK_NO, GENE_ADD_DTM, and OUT_MAP. Lifecycle is tied to the `JFUHakkoSODCC` instance. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JFUHakkoSODCC.getMapSC` | - | - (in-memory cache) | Retrieves cached map data from instance field `mapSC` by composite key. Reads from in-memory HashMap. |
| R | `JFUHakkoSODCC.callEKK0191A010SC` (super) | `EKK0191A010SC` | Service Contract Details table (KK_T_* pattern) | Invokes the parent class method which calls the Service Contract Details (eo Light Phone) Unique Inquiry SC. This is a READ operation that queries the service contract detail line item table. |

### Detailed method call analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JFUHakkoSODCC.getMapSC` | - | `mapSC` (in-memory HashMap) | In-memory cache read. Retrieves previously cached SC results indexed by template ID and funcCode composite key. Prevents redundant SC invocations. |
| R | `super.callEKK0191A010SC` | `EKK0191A010SC` | Service Contract Details (KK_T_SVC_KEI_UCWK or similar) | Service Component invocation for service contract detail inquiry. Reads contract line item data including ported number status (BMP_UM), VA router model code (VA_TAKNKIKI_MODEL_CD), device change number (VA_KIKI_CHG_NO), and registration datetime (GENE_ADD_DTM) for eo Light Phone services. The actual SC is implemented in the EKK0191A010SC class. |

## 5. Dependency Trace

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JFUTelOptSvcMskmCmpCC | `JFUTelOptSvcMskmCmpCC.hakkoSOD` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 2 | CC:JKKHakkoSODCC | `JKKHakkoSODCC.addTensoDenwaOp` -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L6211) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 3 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (service contract detail change processing) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L6759) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 4 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (OLS SOD issuance for number 2 service) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L8482) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 5 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (number portability check processing) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L8706) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 6 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (restoration order processing) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L9973) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 7 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (EG swap device listing with after-change inquiry) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L13193) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 8 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (service contract detail inquiry with cache lookup mode) -> `callEKK0191A010SC(funcCode="1"/"2")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L13248) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 9 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (registration datetime overwrite processing) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L13557) | `super.callEKK0191A010SC [R] EKK0191A010SC` |
| 10 | CC:JKKHakkoSODCC | `JKKHakkoSODCC` (multi-line service issuance) -> `callEKK0191A010SC(funcCode="1")` -> `JFUHakkoSODCC.callEKK0191A010SC` (via override, L14327) | `super.callEKK0191A010SC [R] EKK0191A010SC` |

**Call chain explanation:**
All callers resolve through the **polymorphic override** - since `JFUHakkoSODCC` extends `JKKHakkoSODCC`, any call to `callEKK0191A010SC` from instances of type `JFUHakkoSODCC` (such as in `JFUTelOptSvcMskmCmpCC` or subclasses) dispatches to this cached wrapper method. The `super.callEKK0191A010SC` then delegates to the parent's implementation which invokes the actual `EKK0191A010SC` service component.

## 6. Per-Branch Detail Blocks

**Block 1** - [SET] `Get cached map by key` (L120)

> Retrieves the cached map from the instance-level `mapSC` HashMap using a composite key of the template ID and funcCode. If no cached entry exists, creates a new empty HashMap. This is the cache initialization step.

| # | Type | Code |
|---|------|------|
| 1 | SET | `map = getMapSC(JKKHakkoSODConstCC.TEMPLATE_ID_EKK0191A010, funcCode)` // Build cache key and retrieve cached data [-> TEMPLATE_ID_EKK0191A010="EKK0191A010" (JKKHakkoSODConstCC.java:652)] |

**Block 2** - [IF] `(svc_kei_ucwk_no mismatch OR (funcCode="1" AND gene_add_dtm mismatch))` (L122-133)

> Cache MISS branch. When the service contract detail number differs from what is cached, or when funcCode is "1" and the registration datetime also differs, this branch executes the actual service component and stores the results in the cache. This ensures the caller always gets fresh data for the current business operation while caching it for subsequent identical calls.
>
> The condition uses a short-circuit OR: if `svc_kei_ucwk_no` differs, the datetime is not checked. If the service contract detail number is the same but funcCode equals "1" (standard mode), then `gene_add_dtm` is also compared - this detects cases where the same contract detail was modified (new generation registration datetime).

| # | Type | Code |
|---|------|------|
| 1 | COND | `!equals(map.get(SVC_KEI_UCWK_NO), inHash.get(SVC_KEI_UCWK_NO))` // Compare service contract detail numbers [-> SVC_KEI_UCWK_NO="svc_kei_ucwk_no" (JKKHakkoSODConstCC.java:560)] |
| 2 | COND | `funcCode.equals("1") && !equals(map.get(GENE_ADD_DTM), inHash.get(GENE_ADD_DTM))` // funcCode="1" AND compare registration datetime [-> FUNC_CODE_1="1" (JKKHakkoSODConstCC.java:747)], [-> GENE_ADD_DTM="gene_add_dtm" (JKKHakkoSODConstCC.java:572)] |
| 3 | OR | Combine conditions with `||` (short-circuit OR) |
| 4 | CALL | `status = super.callEKK0191A010SC(param, handle, inHash, resultHash, funcCode)` // Delegate to parent class to invoke actual SC EKK0191A010SC |
| 5 | SET | `map.put(STATUS, status)` // Store return status in cache [-> STATUS="STATUS" (local constant in JFUHakkoSODCC)] |
| 6 | SET | `map.put(SVC_KEI_UCWK_NO, inHash.get(SVC_KEI_UCWK_NO))` // Cache the input service contract detail number [-> SVC_KEI_UCWK_NO="svc_kei_ucwk_no" (JKKHakkoSODConstCC.java:560)] |
| 7 | SET | `map.put(GENE_ADD_DTM, inHash.get(GENE_ADD_DTM))` // Cache the input generation registration datetime [-> GENE_ADD_DTM="gene_add_dtm" (JKKHakkoSODConstCC.java:572)] |
| 8 | SET | `map.put(OUT_MAP, resultHash)` // Cache the SC result HashMap [-> OUT_MAP="OUT_MAP" (local constant in JFUHakkoSODCC)] |
| 9 | SET | `mapSC.put(TEMPLATE_ID_EKK0191A010 + HALF_UNDER_BAR + funcCode, map)` // Store cache entry with composite key [-> TEMPLATE_ID_EKK0191A010="EKK0191A010" (JKKHakkoSODConstCC.java:652)], [-> HALF_UNDER_BAR="_" (JFUStrConst.java:192)] |

**Block 3** - [ELSE] Cached data branch (L135-137)

> Cache HIT branch. When both the service contract detail number and (if funcCode is "1") the registration datetime match the cached entry, this branch returns the previously stored status and merges the cached results into `resultHash`. This avoids a redundant SC invocation, reducing database reads and processing latency.
>
> Note: `resultHash.putAll` performs a shallow merge - keys from the cached OUT_MAP overwrite any existing keys in resultHash.

| # | Type | Code |
|---|------|------|
| 1 | SET | `status = (Integer) map.get(STATUS)` // Retrieve cached return status [-> STATUS="STATUS" (local constant in JFUHakkoSODCC)] |
| 2 | EXEC | `resultHash.putAll((HashMap<String, Object>) map.get(OUT_MAP))` // Merge cached SC results into output HashMap [-> OUT_MAP="OUT_MAP" (local constant in JFUHakkoSODCC)] |

**Block 4** - [RETURN] (L138)

> Returns the status code from either the freshly executed SC (Block 2) or the cached result (Block 3). A return value of `0` indicates success; non-zero values indicate error codes from the underlying SC.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return status;` // Return SC return code (0=success, non-zero=error) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_ucwk_no` | Field | Service contract detail number - unique identifier for a service contract line item within a subscription |
| `gene_add_dtm` | Field | Generation registration datetime - timestamp (year/month/day hour:minute:second) when the service contract detail was registered or modified; used as a version/timestamp for cache invalidation |
| `funcCode` | Field | Function code - routing parameter that controls caching behavior ("1" = standard mode with full comparison, "2" = cache lookup mode comparing only the contract detail number) |
| SOD | Acronym | Service Order Data - data structure representing a service order to be issued for telecom services |
| SC | Acronym | Service Component - a service layer component that handles specific business operations (e.g., `EKK0191A010SC` for service contract detail inquiry) |
| EKK0191A010 | Code | Service Contract Details (eo Light Phone) Unique Inquiry - service component for querying detailed information of a specific eo Light Phone service contract line item |
| eo Light Phone (eo光電話) | Business term | NTT East's fiber optic telephone service bundled with eo Hikari (NTT East's fiber internet service) |
| BMP_UM | Field | Ported number existence flag - indicates whether a ported telephone number is assigned to the service contract (BMP_UM_ARI = has ported number, BMP_UM_NASI = no ported number) |
| VA_TAKNKIKI_MODEL_CD | Field | VA (home router) home device model code - identifies the model of the home router equipment |
| VA_KIKI_CHG_NO | Field | VA device change number - tracking number for home router device changes |
| `mapSC` | Instance Field | Instance-level cache storage mapping template ID + funcCode keys to result HashMaps; persists across multiple method calls within the same JFUHakkoSODCC instance lifecycle |
| CC | Acronym | Common Component - a shared business logic component in the K-Opticom system architecture |
| hakkoSOD | Method | Service Order Data issuance - method that triggers SOD generation for telecom service changes |
| addTensoDenwaOp | Method | Add Telephone Optional - processes optional telephone service additions including service contract detail inquiries and SOD issuance |
| JKKHakkoSODCC | Class | Parent class - base Service Order Data issuance component with standard callEKK0191A010SC implementation |
| JFUHakkoSODCC | Class | Custom Service Order Data issuance component - extends JKKHakkoSODCC with caching wrapper for repeated service contract detail inquiries |
