# Business Logic — JKKPrcSimulationCC.makeWribSvcTankList() [94 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKPrcSimulationCC` |
| Layer | CC/Common Component (Shared business logic component within the EJB tier) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKPrcSimulationCC.makeWribSvcTankList()

This method constructs the discount service pricing list (割引サービス単価リスト) for use in the pricing simulation screen (KKSV0553) in the K-Opticom customer base system. It takes a list of approved discount services (`dojiOKList`) and, for each discount service, queries the external pricing service to retrieve the detailed unit pricing information. The result is a nested list structure: a top-level list of discount services, each containing a sub-list of pricing records with full granularity (pricing number, service type, service code, price group, cost code, plan code, option services, sub-option services, equipment provider services, billing option services, price item codes, and application priority). The method uses a **builder pattern** — it iterates through the input, delegates data fetching to a mapper, and assembles the enriched result into a structured return object. Its role in the larger system is to prepare the pricing data that the KKSV0553 screen displays to users during price simulation operations, enabling customers to view applicable discount pricing tiers for their simulated services. If pricing information cannot be retrieved for a given discount service (the mapper returns an empty list), that service is silently skipped (no error raised).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["makeWribSvcTankList(dojiOKList)"])
    INIT["Initialize wrib_svc_list (new ArrayList)"]
    LOOP["Iterate dojiOKList"]
    GET_MAP["Get matchWribSvcMap from iterator"]
    GET_WRIB_SVC_CD["Extract wribSvcCd from matchWribSvcMap"]
    CALL_PRICING["CALL: callWrisvcTankaShokai(wribSvcCd, FUNC_1='1', serial)"]
    CHECK_EMPTY{"list.isEmpty()?"}
    SKIP{"Continue to next iteration"}
    BUILD_WRIB_INFO["Create wribSvcInfo map
(no, wribSvcCd, wribSvcNm)"]
    BUILD_TANKA_LIST["Initialize tankaList (new ArrayList)"]
    TANKA_LOOP["Iterate pricing list"]
    GET_TANKA["Get tankaInfo from iterator"]
    BUILD_TANKA_INFO["Create wribSvcTankaInfo map
(wribSvcTankaNo, wribSbtCd, svcCd, prcGrpCd,
 pcrsCd, pplanCd, opSvcCd, sbopSvcCd,
 kkTkSvcCd, seiopSvcCd, prcKmkCd,
 wribAplyPriorityCd)"]
    ADD_TANKA["Add wribSvcTankaInfo to tankaList"]
    SET_PRICING_LIST["wribSvcInfo.put(wribSvcTankaList, tankaList)"]
    ADD_TO_RESULT["Add wribSvcInfo to wribSvcList"]
    LOG["printlnEjbLog(return list)"]
    RETURN["Return wrib_svc_list"]

    START --> INIT --> LOOP
    LOOP --> GET_MAP
    GET_MAP --> GET_WRIB_SVC_CD
    GET_WRIB_SVC_CD --> CALL_PRICING
    CALL_PRICING --> CHECK_EMPTY
    CHECK_EMPTY -- true --> SKIP
    SKIP --> LOOP
    CHECK_EMPTY -- false --> BUILD_WRIB_INFO
    BUILD_WRIB_INFO --> BUILD_TANKA_LIST
    BUILD_TANKA_LIST --> TANKA_LOOP
    TANKA_LOOP --> GET_TANKA
    GET_TANKA --> BUILD_TANKA_INFO
    BUILD_TANKA_INFO --> ADD_TANKA
    ADD_TANKA --> TANKA_LOOP
    TANKA_LOOP -- done --> SET_PRICING_LIST
    SET_PRICING_LIST --> ADD_TO_RESULT
    ADD_TO_RESULT --> LOOP
    LOOP -- exhausted --> LOG --> RETURN
```

**Processing description:**

1. **Initialize**: Creates an empty `wrib_svc_list` ArrayList to accumulate the final discount service list.
2. **Outer loop**: Iterates over each entry in `dojiOKList` (approved discount services).
3. **Extract discount service code**: Pulls the `wribSvcCd` (割引サービスコード — Discount Service Code) from the current map.
4. **Query pricing**: Calls `getMapper().callWrisvcTankaShokai()` — an external service IF call to retrieve pricing detail (単価情報 — pricing information) for the given discount service, passing `FUNC_1 = "1"` (機能コード — Function Code) and a serial number derived from the current index.
5. **Empty check**: If the pricing list returned is empty (single price information could not be obtained — 単価情報が取得できない場合), skip to the next iteration silently.
6. **Build discount service info**: Create a new `wribSvcInfo` map containing: sequential number (番号), discount service code, and discount service name (割引サービス名).
7. **Inner loop**: Iterate over the pricing list returned from the mapper.
8. **Build pricing info**: For each pricing record, create a `wribSvcTankaInfo` map containing all 12 pricing detail fields (pricing number, discount type code, service code, price group code, cost code, plan code, option service code, sub-option service code, equipment provider service code, billing option service code, price item code, discount application priority code).
9. **Accumulate pricing**: Add the pricing info map to `tankaList`, then attach `tankaList` to `wribSvcInfo`.
10. **Accumulate result**: Add `wribSvcInfo` to the top-level `wrib_svc_list`.
11. **Log and return**: Log the return list via `printlnEjbLog` and return the result.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `dojiOKList` | `ArrayList<HashMap<String, Object>>` | List of approved discount services (割引サービス — discount services) that have passed validation checks in the pricing simulation flow. Each map contains discount service metadata including `wrib_svc_cd` (Discount Service Code) and `wrib_svc_nm` (Discount Service Name). The list represents discount offerings eligible for pricing lookup in the KKSV0553 price simulation screen. |

**External state read:**
| Source | Field/Method | Description |
|--------|-------------|-------------|
| `JKKPrcSimulationCC.getMapper()` | Returns a `JKKPrcSimulationCCMapper` instance | Delegates service IF calls to external CBS |
| `JKKPrcSimulationCC.getSerial()` | Returns a serial identifier string | Provides a unique serial number per iteration for CBS request tracking |
| `JKKPrcSimulationCC.printlnEjbLog()` | Logs to EJB log | Debug/log output for the return list |
| `JKKPrcSimulationCC.FUNC_1` | `private static final String = "1"` | Function code passed as a parameter to the pricing service call |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKPrcSimulationCC.callWrisvcTankaShokai` | EKK0711B001BS | Pricing table (discount service pricing detail) | Reads discount service pricing detail for a given service code via CBS (Service Component). This is a remote service IF call that queries the pricing database for applicable discount tiers. |

### Additional method calls (utility/infrastructure):

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKPrcSimulationCC.getMapper` | - | - | Retrieves the mapper instance for service IF delegation |
| R | `JKKPrcSimulationCC.getSerial` | - | - | Generates a serial identifier for CBS request tracking |
| - | `JKKPrcSimulationCC.printlnEjbLog` | - | - | Logs the final return list for debugging |
| - | `JKKPrcSimulationCC.FUNC_1` | - | - | Static constant "1" — function code indicating operation mode |

**Called method detail — `callWrisvcTankaShokai`:**
- **SC Code**: `EKK0711B001BS` (from `KKSV0553_KKSV0553OP_EKK0711B001BSMapper`)
- **Operation**: Read — fetches discount service pricing detail (割引サービス単価一覧照会詳細)
- **Purpose**: Retrieves the pricing tier information for a given discount service code from the pricing database via the service component IF layer. The method builds an input map, invokes the CBS through a `ServiceComponentRequestInvoker`, and returns a list of pricing detail maps.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method(s).
Terminal operations from this method: `printlnEjbLog` [-], `callWrisvcTankaShokai` [R], `getSerial` [R], `getMapper` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKPrcSimulationCC.execute()` | `JKKPrcSimulationCC.execute` -> `makeWribSvcTankList` | `callWrisvcTankaShokai [R] EKK0711B001BS (Pricing Detail)` |

**Call chain detail:**
The `execute()` method of `JKKPrcSimulationCC` is the primary caller. This is the main execution entry point for the price simulation business component (CBS), which orchestrates the full pricing simulation workflow. `makeWribSvcTankList()` is invoked as a sub-step within this flow to gather discount service pricing data for display.

**Terminal operations from this method:**
- `callWrisvcTankaShokai` — Reads discount service pricing detail (SC Code: `EKK0711B001BS`)
- `getSerial` — Returns serial number for CBS tracking
- `getMapper` — Returns mapper instance for service IF
- `printlnEjbLog` — Debug logging only

## 6. Per-Branch Detail Blocks

**Block 1** — [LOOP] `(dojiOKList iterator while hasNext)` (L608)

> Initializes the result list and iterates through approved discount services. For each service, queries pricing info, builds the nested result structure.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrib_svc_list = new ArrayList<HashMap<String, Object>>();` // Create result list |
| 2 | SET | `index = 0;` // Sequence counter |
| 3 | SET | `ite = dojiOKList.iterator();` // Iterator for approved discount services |
| 4 | EXEC | `while (ite.hasNext())` // Outer loop — iterate over all approved discount services |

**Block 1.1** — [NESTED LOOP BODY] `(ite.hasNext() == true)` (L610)

> Processes a single approved discount service: extracts its code, queries pricing, and builds the result structure.

| # | Type | Code |
|---|------|------|
| 1 | SET | `matchWribSvcMap = ite.next();` // Get next approved discount service map |
| 2 | SET | `wribSvcCd = (String)matchWribSvcMap.get(KKSV0553_KKSV0553OP_WORK_WRISVC.WRIB_SVC_CD);` // Extract discount service code [-> "wrib_svc_cd"] |
| 3 | CALL | `list = getMapper().callWrisvcTankaShokai(wribSvcCd, FUNC_1="1", getSerial(index, dojiOKList.size()));` // Query pricing detail for this discount service |
| 4 | IF | `if (list.isEmpty())` // Pricing information could not be obtained (単価情報が取得できない) |

**Block 1.1.1** — [IF-TRUE] `(list.isEmpty() == true)` (L617)

> Skip this discount service — no pricing data available. Continue to next iteration.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue;` // Skip to next discount service |

**Block 1.1.2** — [IF-FALSE] `(list.isEmpty() == false)` (L620)

> Pricing data is available. Build the discount service info map with metadata and nested pricing list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcInfo = new HashMap<String, Object>();` // Create discount service info map |
| 2 | SET | `wribSvcInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_INFO.NO, String.valueOf(++index));` // Set sequential number [-> "no"] |
| 3 | SET | `wribSvcInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_INFO.WRIB_SVC_CD, wribSvcCd);` // Set discount service code [-> "wrib_svc_cd"] |
| 4 | SET | `wribSvcInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_INFO.WRIB_SVC_NM, matchWribSvcMap.get(...WRIB_SVC_NM));` // Set discount service name [-> "wrib_svc_nm"] |
| 5 | SET | `tankaList = new ArrayList<HashMap<String, Object>>();` // Initialize pricing sub-list |
| 6 | EXEC | `ite1 = list.iterator();` // Iterator for pricing records |
| 7 | EXEC | `while (ite1.hasNext())` // Inner loop — iterate over pricing records |

**Block 1.1.2.1** — [INNER LOOP BODY] `(ite1.hasNext() == true)` (L632)

> Processes a single pricing record from the discount service pricing list. Extracts all 12 pricing fields and constructs the pricing info map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tankaInfo = ite1.next();` // Get next pricing record |
| 2 | SET | `wribSvcTankaInfo = new HashMap<String, Object>();` // Create pricing info map |
| 3 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.WRIB_SVC_TANKA_NO, tankaInfo.get(...WRIB_SVC_TANKA_NO));` // Discount service pricing number [-> "wrib_svc_tanka_no"] |
| 4 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.WRIB_SBT_CD, tankaInfo.get(...WRIB_SBT_CD));` // Discount type code [-> "wrib_sbt_cd"] |
| 5 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.SVC_CD, tankaInfo.get(...SVC_CD));` // Service code [-> "svc_cd"] |
| 6 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.PRC_GRP_CD, tankaInfo.get(...PRC_GRP_CD));` // Price group code [-> "prc_grp_cd"] |
| 7 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.PCRS_CD, tankaInfo.get(...PCRS_CD));` // Cost code [-> "pcrs_cd"] |
| 8 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.PPLAN_CD, tankaInfo.get(...PP_LAN_CD));` // Plan code [-> "pplan_cd"] |
| 9 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.OP_SVC_CD, tankaInfo.get(...OP_SVC_CD));` // Option service code [-> "op_svc_cd"] |
| 10 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.SBOP_SVC_CD, tankaInfo.get(...SBOP_SVC_CD));` // Sub-option service code [-> "sbop_svc_cd"] |
| 11 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.KKTK_SVC_CD, tankaInfo.get(...KKTK_SVC_CD));` // Equipment provider service code [-> "kktk_svc_cd"] |
| 12 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.SEIOPSVC_CD, tankaInfo.get(...SEIOPSVC_CD));` // Billing option service code [-> "seiopsvc_cd"] |
| 13 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.PRC_KMK_CD, tankaInfo.get(...PRC_KMK_CD));` // Price item code [-> "prc_kmk_cd"] |
| 14 | SET | `wribSvcTankaInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_TANKA_INFO.WRIB_APLY_PRIORITY_CD, tankaInfo.get(...WRIB_APLY_PRIORITY_CD));` // Discount application priority code [-> "wrib_aply_priority_cd"] |
| 15 | EXEC | `tankaList.add(wribSvcTankaInfo);` // Add pricing record to pricing list |

**Block 1.1.2.2** — [INNER LOOP DONE] `(ite1.hasNext() == false)` (L647)

> Attach the completed pricing list to the discount service info, add to result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcInfo.put(KKSV0553_KKSV0553OP_WORK_WRIB_SVC_INFO.WRIB_SVC_TANKA_LIST, tankaList);` // Set pricing sub-list [-> "wrib_svc_tanka_list"] |
| 2 | EXEC | `wrib_svc_list.add(wribSvcInfo);` // Add discount service to final result list |

**Block 2** — [END OF OUTER LOOP] (L650)

> After all discount services are processed, log the result and return.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("返却用割引サービスリスト[" + wrib_svc_list + "]");` // Log the return list (Discount service list for return) |
| 2 | RETURN | `return wrib_svc_list;` // Return the completed discount service pricing list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `dojiOKList` | Field/Parameter | Approved discount service list — the list of discount services that have passed validation in the pricing simulation flow |
| `wrib_svc_cd` | Field | Discount Service Code (割引サービスコード) — unique identifier for a discount service offering |
| `wrib_svc_nm` | Field | Discount Service Name (割引サービス名) — human-readable name of the discount service |
| `wrib_svc_tanka_no` | Field | Discount Service Pricing Number (割引サービス単価番号) — unique identifier for a pricing tier within a discount service |
| `wrib_sbt_cd` | Field | Discount Type Code (割引種別コード) — classifies the type of discount (e.g., percentage, fixed amount) |
| `svc_cd` | Field | Service Code (サービスコード) — identifier for the underlying service (e.g., FTTH, Mail) |
| `prc_grp_cd` | Field | Price Group Code (料金グループコード) — groups related pricing records for billing organization |
| `pcrs_cd` | Field | Cost Code (料金コースコード) — pricing course/cost code identifying the pricing tier |
| `pplan_cd` | Field | Plan Code (料金プランコード) — specific pricing plan within a course |
| `op_svc_cd` | Field | Option Service Code (オプションサービスコード) — code for optional add-on services |
| `sbop_svc_cd` | Field | Sub-Option Service Code (サブオプションサービスコード) — code for sub-option services nested under options |
| `kktk_svc_cd` | Field | Equipment Provider Service Code (機器提供サービスコード) — code for equipment provisioning services |
| `seiopsvc_cd` | Field | Billing Option Service Code (請求オプションサービスコード) — code for billing-related option services |
| `prc_kmk_cd` | Field | Price Item Code (料金項目コード) — code identifying the specific pricing line item |
| `wrib_aply_priority_cd` | Field | Discount Application Priority Code (割引適用優先度コード) — determines the order in which discounts are applied when multiple apply |
| `wrib_svc_tanka_list` | Field | Discount Service Pricing List (割引サービス単価リスト) — nested list of pricing records for a discount service |
| `FUNC_1 = "1"` | Constant | Function Code (機能コード) — operation mode indicator passed to CBS service calls |
| KKSV0553 | Screen | Pricing Simulation Discount Service screen (料金シミュレーション 割引サービス) — the customer-facing screen for price simulation |
| JKKPrcSimulationCC | Class | K-Opticom Price Simulation Common Component — shared business logic component for price simulation |
| callWrisvcTankaShokai | Method | Discount Service Pricing Detail Query (割引サービス単価一覧照会) — CBS service call to retrieve pricing information |
| EKK0711B001BS | SC Code | Service Component / Business Service for discount service pricing lookup |
| 割引サービス (Wribu Sai bisu) | Domain term | Discount Service — a price reduction or promotional offer on telecom services |
| 単価 (Tanki) | Domain term | Unit Pricing / Rate — the per-unit cost or price of a service |
| 料金シミュレーション (Ryouru Shimyureeshon) | Domain term | Price Simulation — the process of simulating and displaying estimated charges for services |
| SC | Acronym | Service Component — a modular business logic unit in the Fujitsu futuricity framework |
| CBS | Acronym | Custom Business Service — a backend business service component |
| IF | Acronym | Interface — the integration layer between CC (Common Component) and SC/CBS |
