# Business Logic — JKKPrcSimulationCC.execute() [39 LOC]

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

## 1. Role

### JKKPrcSimulationCC.execute()

This method performs the **price simulation** for telecommunications service contracts within the K-Opticom customer management system. It orchestrates the calculation of applicable discount services based on the customer's current service configuration, contract type, and eligibility conditions.

The method acts as a **delegation coordinator** within the billing simulation domain. It receives a parameter map containing customer information (dispute category, application subtype code, application form code, and a list of service items), validates the input, initializes a mapper for CC-to-SC mapping, and then dispatches the core discount eligibility logic to helper methods. It identifies which discount services the customer qualifies for (via `chkMainWribSvc`) and assembles the final list of discounted service unit prices (via `makeWribSvcTankList`).

Its role in the larger system is that of a **shared common component** — it does not correspond to a single screen entry point but is invoked by CBS-level business logic (specifically `JKKBpCommon.simulationWribSvc()`) as part of a larger service-order simulation pipeline. The result (a list of discount services and their pricing) is stored back into the parameter data for downstream screens to display simulated billing to the operator or customer.

The method implements a linear processing flow: extract data -> validate -> initialize -> compute discounts -> store result -> return. There are no conditional branches in the execute method itself; the branching logic is delegated to the called methods (`chkMainWribSvc`, `makeWribSvcTankList`).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(handle, param, fixedText)"])

    START --> GET_MAP["GET HashMap inMap = param.getData(fixedText)"]
    GET_MAP --> CHECK_NULL{inMap == null?}

    CHECK_NULL -->|"Yes"| SKIP["printlnEjbLog - cannot get CC map<br/>RETURN param"]
    CHECK_NULL -->|"No"| GET_COMMON["GET HashMap commonInfo = inMap.get(COMMON_INFO='common_info')"]

    GET_COMMON --> CHK_PARAM["EXEC chkParam(commonInfo)<br/>Throws exception on validation failure"]

    CHK_PARAM --> INIT_MAPPER["SET ccMapper = new JKKPrcSimulationCCMapper(handle, param, getOpeDate(null), fixedText)"]
    INIT_MAPPER --> CALL_CHK_WRIB["CALL chkMainWribSvc(commonInfo)<br/>Returns dojiOKList"]

    CALL_CHK_WRIB --> CALL_MAKE_TANK["CALL makeWribSvcTankList(dojiOKList)<br/>Returns discounted service price list"]
    CALL_MAKE_TANK --> PUT_RESULT["PUT commonInfo.put(WRIB_SVC_LIST='wrib_svc_list', result)"]

    PUT_RESULT --> END_RETURN["RETURN param"]
    END_RETURN --> END_NODE(["End"])
```

**CRITICAL - Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `COMMON_INFO` | `"common_info"` | Key in the parameter map for the common customer context data |
| `WRIB_SVC_LIST` | `"wrib_svc_list"` | Key for storing the final discounted service list in commonInfo |

**Processing steps:**
1. **Extract data** from the parameter map using the `fixedText` key.
2. **Null guard**: If the extracted map is null, log a warning ("Cannot obtain CC map. Map key [fixedText]") and return the param unchanged — simulating an empty result set.
3. **Extract common info** from the map under the `common_info` key.
4. **Validate parameters** by calling `chkParam` — this checks that all required fields (dispute category, application subtype code, application form code, service info list with its sub-fields) are present and non-blank. Throws an `Exception` with message "Input parameter invalid" if any check fails.
5. **Initialize mapper** — creates a new `JKKPrcSimulationCCMapper` instance (v4.00.02 change from ThreadLocal to direct instantiation) to handle CC-to-SC field mapping.
6. **Compute discount eligibility** — calls `chkMainWribSvc` which performs complex matching logic: it groups services, searches for discount services, checks application info, validates discount-eligible service conditions, and returns a list of discount services whose conditions are met (`dojiOKList`).
7. **Build discount price list** — calls `makeWribSvcTankList` to construct the final list of discounted service unit prices from the qualified discount services.
8. **Store result** — puts the result list into `commonInfo` under the key `wrib_svc_list`.
9. **Return** — returns the original `param` object, which now contains the simulation result.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database/session handle providing transaction context and database connectivity for the EJB layer. Used when initializing the CC mapper. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter container that holds all input/output data for the simulation. Contains a data map (retrieved via `getData(fixedText)`) that carries common customer information, service item lists, and is the carrier for the output discount service list. |
| 3 | `fixedText` | `String` | A string key used to identify and extract the specific data block from the `param` object. Acts as a namespace or correlation ID to locate the correct simulation data section within the parameter map. |

**Instance fields / external state read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ccMapper` | `JKKPrcSimulationCCMapper` | CC-SC mapping mapper instance. Initialized during processing (was previously ThreadLocal-backed). Used to map fields between the Common Component layer and Service Component layer. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCModelCommon.getOpeDate` | (unknown) | - | Calls `getOpeDate` in `JCCModelCommon` — retrieves the current operational date for the simulation context. |
| R | `JCCBPCommon.getOpeDate` | (unknown) | - | Static import of `getOpeDate` for retrieving business date. |
| R | `JKKPrcSimulationCC.chkMainWribSvc` | - | - | Calls `chkMainWribSvc` — computes discount eligibility by matching discount services against customer service conditions. Returns list of qualifying discount services. |
| R | `JKKPrcSimulationCC.chkParam` | - | - | Calls `chkParam` — validates that all required input fields are present and non-blank. Returns boolean error flag. |
| R | `JKKPrcSimulationCC.makeWribSvcTankList` | - | - | Calls `makeWribSvcTankList` — constructs the final list of discounted service unit prices from qualified discount services. |
| - | `JKKPrcSimulationCC.printlnEjbLog` | - | - | Calls `printlnEjbLog` — logs simulation status and error messages to the EJB log. |

### Analysis of `chkMainWribSvc` and `makeWribSvcTankList` (internal methods):

These are both internal helper methods within `JKKPrcSimulationCC`. The `chkMainWribSvc` method (starting at line 462) performs complex discount service matching logic including:
- Making service group lists via `makeSvcGrpList`
- Searching for discount services via `searchWribSvc`
- Checking application info via `chkGetAplyInfo`
- Searching discount-eligible services via `searchWrisvcTgSvc`
- Checking service code validity via `chkVariSvcCd`

The `makeWribSvcTankList` method (starting at line 600) builds the final discounted service price list from the qualifying services.

**Note**: No direct database CRUD operations are performed within `execute` itself. All data operations are delegated to helper methods which may perform SC-level database queries and CBS-level reads.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 10 methods.
Terminal operations from this method: `makeWribSvcTankList` [-], `chkMainWribSvc` [-], `getOpeDate` [R], `chkParam` [-], `printlnEjbLog` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKBpCommon.simulationWribSvc` | `JKKBpCommon.simulationWribSvc` -> `JKKPrcSimulationCC.execute` | `chkMainWribSvc [R]`, `makeWribSvcTankList [R]`, `getOpeDate [R]` |
| 2 | (Internal) | `chkMainWribSvc` -> `makeSvcGrpList` | Discount service matching |
| 3 | (Internal) | `chkMainWribSvc` -> `searchWribSvc` | Discount service search |
| 4 | (Internal) | `chkMainWribSvc` -> `chkGetAplyInfo` | Application info validation |
| 5 | (Internal) | `chkMainWribSvc` -> `searchWrisvcTgSvc` | Eligible service search |
| 6 | (Internal) | `chkMainWribSvc` -> `chkVariSvcCd` | Service code validation |

## 6. Per-Branch Detail Blocks

**Block 1** — [EXTRACT DATA] (L140)

Extracts the data map from the parameter object using the `fixedText` key.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `HashMap inMap = (HashMap) param.getData(fixedText)` |

---

**Block 2** — [IF] `(inMap == null)` (L143)

Null guard: if the parameter data block cannot be retrieved, log an error and return early.

> Japanese comment: CCマップが設定されていない場合は処理を行わない。 // "If CC map is not set, processing is not performed."

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("料金シミュレーションCCマップが取得できません。マップキー[" + fixedText + "]")` // "Cannot obtain Price Simulation CC map. Map key [fixedText]" |
| 2 | RETURN | `return param` |

---

**Block 3** — [EXTRACT COMMON INFO] (L150)

Extracts the common customer information map from the parameter data block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap commonInfo = (HashMap) inMap.get(COMMON_INFO)` // [-> COMMON_INFO="common_info"] |

> Japanese comment: 共通情報取得 // "Acquire common information"

---

**Block 4** — [CALL: VALIDATION] (L153)

Calls the parameter validation method. If validation fails (returns true), throws an exception.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (chkParam(commonInfo))` |
| 2 | EXEC | `throw new Exception("入力パラメータ不正")` // "Input parameter invalid" |

> Japanese comment: パラメータチェック // "Parameter check"

---

**Block 5** — [INITIALIZE MAPPER] (L158)

Creates the CC-to-SC mapping mapper with the current session, parameter, operational date, and fixedText key.

> Japanese comment: CC-SCマッピングクラスのインスタンス生成 // "Instantiate CC-SC mapping class"

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.ccMapper = new JKKPrcSimulationCCMapper(handle, param, getOpeDate(null), fixedText)` |
| 1 | EXEC | `getOpeDate(null)` — retrieves current business date |

---

**Block 6** — [CALL: DISCOUNT ELIGIBILITY CHECK] (L167)

Computes which discount services the customer qualifies for based on their service configuration and eligibility conditions.

> Japanese comment: 割引サービス条件チェック実行 // "Execute discount service condition check"

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList dojiOKList = chkMainWribSvc(commonInfo)` // Returns list of discount services whose conditions are met |

---

**Block 7** — [CALL: BUILD DISCOUNT PRICE LIST + STORE RESULT] (L172)

Builds the final discounted service unit price list and stores it back into the commonInfo map.

> Japanese comment: 返却用割引サービス単価リスト作成・設定 // "Create and set discount service unit price list for return"

| # | Type | Code |
|---|------|------|
| 1 | SET | `commonInfo.put(KKSV0553_KKSV0553OP_WORK.WRIB_SVC_LIST, makeWribSvcTankList(dojiOKList))` // [-> WRIB_SVC_LIST="wrib_svc_list"] |
| 1 | EXEC | `makeWribSvcTankList(dojiOKList)` — constructs discounted service price list from qualifying discount services |

---

**Block 8** — [RETURN] (L174)

Returns the original parameter object, which now contains the computed simulation data in the `commonInfo` map.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `JKKPrcSimulationCC` | Class | Price Simulation Common Component — shared business logic for simulating billing/pricing of telecom service contracts |
| `common_info` | Field/Key | Common customer context data key — contains dispute category, application subtype/form codes, and service item lists |
| `wrib_svc_list` | Field/Key | Discount service list key — stores the final list of discounted services with pricing for the simulation result |
| `ido_div` | Field | Dispute category division — classifies the type of dispute or processing category |
| `mskm_sbt_cd` | Field | Application subtype code — specifies the subtype of application being processed |
| `mskm_form_cd` | Field | Application form code — specifies the application form type |
| `svc_info_list` | Field | Service information list — contains the list of customer's current services with their billing details |
| `seky_kei_no` | Field | Billing contract number — internal contract tracking number for billing |
| `kaisen_kei_no` | Field | Service contract line item number — unique identifier for a service contract line item |
| `sokuwari_um` | Field | Discount presence/absence flag — indicates whether a discount applies (boolean indicator) |
| `family_pack_um` | Field | Family pack presence/absence flag — indicates whether the customer has a family pack subscription |
| `sokuwari` | Business term | Discount — price reduction applied to services based on eligibility conditions |
| `sokuwari_on` | Constant | `"1"` — discount enabled flag value |
| `familypack_wrib_svc` | Constant | `"W00000006"` — Family Pack discount service code |
| `wrib` | Business term | Discount — short for "discount service" (discount applied to service charges) |
| `doji_ok_list` | Variable | Discount service list with conditions met — services that qualify for discount after all eligibility checks pass |
| `wrib_svc_cd` | Field | Discount service code — code identifying a discount service type |
| `WRIB_ADD_JOKEN_CD` | Constant | Additional discount eligibility reason code — used to determine discount qualification criteria (e.g., new contract, improvement, customer-sei, etc.) |
| `WRIB_DCHS_SKBT_FLAG` | Constant | Discount destination service batch flag |
| `SVC_GRP_LIST` | Field | Service group list — services grouped for discount condition checking |
| `GRP_NUMBER` | Field | Group number — sequential group identifier within the service group |
| `MATCH_WRIB_SVC_GRP_LIST` | Field | Matched discount service group list — discount services whose conditions matched |
| `CHK_WRIB_SVC_TGT_SVC_LIST` | Field | Discount check target service list — services subject to discount eligibility checking |
| `FUNC_1` / `FUNC_2` | Constants | `"1"` / `"2"` — function codes for different processing modes |
| `WRIB` | Enum | Discount service categories: SVC (service), SVC_UCWK (service sub-work), OP_SVC (operator service), SBOP_SVC (sub-operator service), KKTK_SVC (K-Opticom TK service), SEI_OP_SVC (sei operator service) |
| `W_SVCCD_VS_W_SVCCD` | Constant | Discount comparison code — service code vs service code comparison |
| `W_SVCCD_VS_W_TYPECD` | Constant | Discount comparison code — service code vs type code comparison |
| `W_TYPECD_VS_W_SVCCD` | Constant | Discount comparison code — type code vs service code comparison |
| `W_TYPECD_VS_W_TYPECD` | Constant | Discount comparison code — type code vs type code comparison |
| `WRSV_APLY_JKN_SBT_CD_MSKM` | Constant | `"01"` — Discount service application condition subtype code: application form |
| `WRIB_SVC_CD` | Field | Discount service code — identifies the discount service |
| `SEKY_KEI_NO` | Field | Billing contract number — contract reference number |
| `KAISEN_KEI_NO` | Field | Service contract line item number — service line reference number |
| `SOKUWARI_UM` | Field | Discount presence/absence flag |
| `FAMILY_PACK_UM` | Field | Family pack presence/absence flag |
| `WRIB_ADD_JOKEN_CD` | Constant | Discount additional condition code — reason code for discount eligibility |
| `WRIB_ADD_JOKEN_CD_CUST` | Constant | Discount additional condition code — customer type |
| `WRIB_ADD_JOKEN_CD_CUST_SEI` | Constant | Discount additional condition code — customer-sei type |
| `WRIB_ADD_JOKEN_CD_JOKEN_NON` | Constant | Discount additional condition code — no additional condition |
| `WRIB_ADD_JOKEN_CD_KAISEN` | Constant | Discount additional condition code — improvement type |
| `WRIB_ADD_JOKEN_CD_SEI` | Constant | Discount additional condition code — sei type |
| `WRIB_ADD_JOKEN_CD_SEI_KAISEN` | Constant | Discount additional condition code — sei improvement type |
| `WribSvc` | Business term | Discount service — a service eligible for price discount |
| `Prc` | Abbreviation | Price — short for pricing/billing simulation |
| `CC` | Abbreviation | Common Component — shared business logic component in the enterprise architecture |
| `SC` | Abbreviation | Service Component — service layer component that interfaces with CBS/DAO |
| `CBS` | Abbreviation | Central Business System — core database transaction layer |
| `KKSV0553` | Screen/Module | Price simulation screen module — the screen context for this simulation |
| `JKKBpCommon` | Class | K-Opticom Business Process Common — calling CBS that invokes price simulation |
| `SessionHandle` | Class | Database session handle — provides transaction and DB context for EJB operations |
| `IRequestParameterReadWrite` | Interface | Request parameter interface — container for input/output data between layers |
| `JKKPrcSimulationCCMapper` | Class | CC-SC mapping mapper — maps fields between Common Component and Service Component layers |
