# Business Logic — JKKCallWrisvcAutoAplyCC.getSeikyKeiNoList() [28 LOC]

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

## 1. Role

### JKKCallWrisvcAutoAplyCC.getSeikyKeiNoList()

This method retrieves the set of **billing contract numbers** (請求契約番号) that are designated as merge targets during the automatic application (auto-apply) workflow. The Javadoc states: "Acquires billing contract numbers for merging" (併合対象の請求契約番号を取得します). It operates on a list of service contract records where each record is a `HashMap<String, String>` carrying metadata about a candidate service. The method filters only those records that have been **selected by the user on the screen** (画面で選択されている場合 — "if selected on screen") and extracts their billing contract numbers into a deduplicated `Set`, ensuring no duplicate contract numbers appear in the result. It then returns this set as a `String[]` array. The method uses a **collector + deduplication** pattern — it iterates over all input items (併合元サービス契約一覧の件数分繰り返す — "iterate for the number of items in the merged-source service contract list"), applies a screen-selection filter, extracts a field, and de-duplicates via `HashSet`. Its role in the larger system is as a **data preparation utility** called by `callWrisvcAutoAply()` to supply the set of billing contract numbers that should be processed during the auto-application merge operation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getSeikyKeiNoList list"])
    INIT["Initialize: Set set, svcMap null, seikyKeiNo null"]

    START --> INIT
    INIT --> LOOP["for i = 0 to list.size - 1"]
    LOOP --> GET["svcMap = cast list.get i to HashMap"]
    GET --> CHECK_SELECT{"isSelect == true?"}

    CHECK_SELECT -->|false| NEXT_I["i++"]
    CHECK_SELECT -->|true| GET_SEIKY["seikyKeiNo = svcMap.get seiky_kei_no"]

    GET_SEIKY --> CHECK_DUPLICATE{"set does not contain seikyKeiNo?"}

    CHECK_DUPLICATE -->|true| ADD_SET["set.add seikyKeiNo"]
    CHECK_DUPLICATE -->|false| NEXT_I

    ADD_SET --> NEXT_I
    NEXT_I --> LOOP_END{"i < list.size?"}
    LOOP_END -->|true| GET
    LOOP_END -->|false| RETURN["return set.toArray as String array"]

    RETURN --> END(["Return String array"])
```

**Processing overview:**

1. **Initialization** — Creates a `HashSet<String>` for deduplication, and nulls out the local variables `svcMap` and `seikyKeiNo`.
2. **Iteration** — Loops over every element of the input `ArrayList` (the merged-source service contract list). Each element is cast to a `HashMap<String, String>` containing field-value pairs.
3. **Selection filter** — Checks the `"isSelect"` key of the map. If `Boolean.valueOf()` resolves to `true`, the record was selected on the screen by the user. If false, the record is skipped.
4. **Extraction** — Retrieves the `"seiky_kei_no"` (billing contract number) from the selected record's map.
5. **Deduplication** — Checks if the `Set` already contains this billing contract number. If not, adds it. If yes (duplicate), skips.
6. **Return** — After the loop completes, converts the `Set<String>` to a `String[]` via `toArray()` and returns it.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `list` | `ArrayList<Object>` | A list of service contract records from the merged-source service contract list (併合元サービス契約一覧). Each element is a `HashMap<String, String>` representing a candidate service record. The map contains key-value pairs including `isSelect` (whether the user selected this record on screen) and `seiky_kei_no` (the billing contract number). The list size determines how many records are iterated over. |
| — | `Set<String> set` (local) | `HashSet<String>` | Temporary deduplication set that accumulates unique billing contract numbers. Acts as an in-memory uniqueness guard. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `set.toArray(new String[set.size()])` | - | - | Converts the internal deduplication Set to a String array for return. No external service or database call. |

**Note:** This method performs **no database operations, no SC/CBS calls, and no entity access**. It is a pure in-memory data transformation and deduplication utility. All processing occurs on the input `ArrayList` passed as a parameter.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `toArray` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: JKKCallWrisvcAutoAplyCC | `callWrisvcAutoAply()` -> `getSeikyKeiNoList(list)` | `toArray [-]` |

**Caller details:**

| # | Caller Class | Caller Method | Kind | Description |
|---|-------------|---------------|------|-------------|
| 1 | `JKKCallWrisvcAutoAplyCC` | `callWrisvcAutoAply()` | CC (same class) | Calls `getSeikyKeiNoList()` to retrieve the deduplicated set of billing contract numbers for the auto-apply/merge workflow. |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET / INIT] (L211)

> Initialize local variables and the deduplication set.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Set<String> set = new HashSet<String>();` // Deduplication set for billing contract numbers |
| 2 | SET | `HashMap<String, String> svcMap = null;` // Map for current service contract record |
| 3 | SET | `String seikyKeiNo = null;` // Billing contract number extracted from current record |

**Block 2** — [FOR LOOP] `(for int i = 0; i < list.size(); i++)` (L215)

> 併合元サービス契約一覧の件数分繰り返す — "Iterate for the number of items in the merged-source service contract list."

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter initialized to 0 |
| 2 | SET | `svcMap = (HashMap<String, String>) list.get(i)` // Cast current element to HashMap (画面で選択されている場合の準備) |

**Block 2.1** — [IF] `(svcMap.get("isSelect") evaluates to true)` (L219)

> 画面で選択されている場合 — "If selected on screen." This filters the input list to only user-selected service contract records.

| # | Type | Code |
|---|------|------|
| 1 | SET | `seikyKeiNo = svcMap.get("seiky_kei_no")` // 請求契約番号の取得 — "Acquire billing contract number" |

**Block 2.1.1** — [IF] `(!set.contains(seikyKeiNo))` (L223)

> 請求契約番号が重複しない場合 — "If billing contract number does not duplicate." Deduplication check: only add if this contract number hasn't been seen before.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `set.add(seikyKeiNo)` // Add to deduplication set |

**Block 2.1.2** — [ELSE] `(!set.contains(seikyKeiNo))` is false — L223 implicit

> The billing contract number already exists in the set. Skip — no action needed.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | _(no-op — duplicate detected, continue to next iteration)_ |

**Block 3** — [RETURN] (L231)

> Convert the deduplicated Set to a String array and return.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return (String[]) set.toArray(new String[set.size()]);` // Return deduplicated billing contract numbers as String array |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `seiky_kei_no` | Field | Billing contract number — the unique identifier for a service billing contract line item |
| `isSelect` | Field | Screen selection flag — indicates whether the user selected this service contract record on the UI screen |
| `getSeikyKeiNoList` | Method | Get billing contract number list — retrieves deduplicated billing contract numbers from selected records |
| 併合対象 (Gouai Taishou) | Domain term | Merge target — service contracts that are candidates for being merged together during the auto-application process |
| 併合 (Gouai) | Domain term | Merge — the business operation of consolidating multiple service contracts into a single contract |
| 請求契約 (Seikyuu Keiyaku) | Domain term | Billing contract — the contractual agreement associated with billing for a service |
| 併合元サービス契約一覧 (Gouaimoto Saabisu Keiyaku Ichiran) | Domain term | Merged-source service contract list — the full list of source service contracts before merge processing |
| 画面で選択されている場合 (Gamen de Sentaku sareteiru Baai) | Japanese comment | If selected on screen — the record was marked by user interaction on the UI |
| 併合対象の請求契約番号を取得します | Javadoc | Acquires billing contract numbers for merging — method purpose description |
| 重複しない場合 (Chofuku shinai Baai) | Japanese comment | If not duplicated — deduplication guard to avoid adding the same billing contract number twice |
| `ArrayList<Object>` | Type | Input parameter — generic list of service contract records (each a HashMap) |
| `String[]` | Return type | Array of unique billing contract numbers extracted from selected records |
| `HashSet<String>` | Type | In-memory deduplication set — ensures no duplicate billing contract numbers in the result |
| Auto-Apply (自動適用) | Domain term | Automatic application — the workflow that automatically applies/merges service contracts based on selection criteria |
