# Business Logic — JKKKojiWrisvcAutoAplyCC.setSvcUcwk() [27 LOC]

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

## 1. Role

### JKKKojiWrisvcAutoAplyCC.setSvcUcwk()

This method serves as a **data transformer** for service contract line items (service detail / サーチー契約内訳) within the construction-assignment discount service auto-application workflow. It receives a raw list of service detail records extracted from an operation parameter (such as create, cancel, restore, or contract termination batches) and produces a clean, enriched copy ready for submission to the downstream discount auto-application engine (`JKKWrisvcAutoAplyCC.execute`).

Specifically, the method iterates over each input HashMap (representing one service detail row) and produces an output HashMap carrying a fixed set of four business fields: the target contract identification code (`tg_kei_skbt_cd`), the service detail work number (`svc_kei_ucwk_no`), the service detail work status (`svc_kei_ucwk_stat`), the price code (`pcrs_cd`), and the price plan code (`pplan_cd`). The target contract type is hard-coded to `"03"`, which corresponds to the **Service Detail** contract category in the system's contract identification taxonomy.

The method implements the **builder/collector pattern**: it reads from the input list, constructs new maps, and accumulates them into a fresh `ArrayList`. It performs no database access, no external service calls, and no conditional branching beyond the null/empty guard on the input list. Its sole responsibility is structural transformation — reshaping and enriching the data for the next stage.

Within the larger system, `setSvcUcwk` is called repeatedly by `execute()` (the class entry point) whenever a batch of service detail records needs to be forwarded to the discount auto-application CC — including during service registration, cancellation, restoration, and cancel operations. Each caller passes a different source list (create, DSL, restore, cancel) but receives the same enriched output shape.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setSvcUcwk list"])
    CHECK_LIST["Check list is not null and not empty"]
    INIT_LIST["Initialize svcKeiList as new ArrayList"]
    INIT_VARS["Initialize ucwkMap and svcKeiMap as null"]
    LOOP_START["Loop over list items"]
    GET_ITEM["ucwkMap = list.get i"]
    NEW_MAP["svcKeiMap = new HashMap"]
    PUT_TG["Put tg_kei_skbt_cd = 03"]
    PUT_UCWK_NO["Put svc_kei_ucwk_no from source"]
    PUT_UCWK_STAT["Put svc_kei_ucwk_stat from source"]
    PUT_PCRS["Put pcrs_cd from source"]
    PUT_PPLAN["Put pplan_cd from source"]
    ADD_TO_RESULT["svcKeiList add svcKeiMap"]
    NEXT_I["i increment"]
    RETURN["Return svcKeiList"]

    START --> CHECK_LIST
    CHECK_LIST -->|Yes| INIT_LIST
    CHECK_LIST -->|No| RETURN
    INIT_LIST --> INIT_VARS
    INIT_VARS --> LOOP_START
    LOOP_START --> GET_ITEM
    GET_ITEM --> NEW_MAP
    NEW_MAP --> PUT_TG
    PUT_TG --> PUT_UCWK_NO
    PUT_UCWK_NO --> PUT_UCWK_STAT
    PUT_UCWK_STAT --> PUT_PCRS
    PUT_PCRS --> PUT_PPLAN
    PUT_PPLAN --> ADD_TO_RESULT
    ADD_TO_RESULT --> NEXT_I
    NEXT_I --> LOOP_START
```

**CRITICAL — Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `tg_kei_skbt_cd = "03"` | `"03"` | Target contract type code — Service Detail (サービ契の内訳) |

The method hard-codes `"03"` for `tg_kei_skbt_cd` on every transformed record. This identifies the record as a **Service Detail** line item (distinct from main contract `"01"`, equipment provision contract `"02"`, etc.). The value is consistent across all callers regardless of whether the source data came from a create, cancel, restore, or DSL batch.

**Requirements:**
- The null/empty guard is represented as the initial diamond node (`CHECK_LIST`).
- The `for` loop and all five `put` operations are represented as sequential rectangular nodes.
- No conditional branches inside the loop — every item is processed uniformly.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `list` | `ArrayList` | A list of service detail (サービ契の内訳) records to transform. Each element is a `HashMap<String, Object>` carrying fields such as `svc_kei_ucwk_no` (service detail work number), `svc_kei_ucwk_stat` (work status), `pcrs_cd` (price code), and `pplan_cd` (price plan code). This list originates from the parent `execute()` method, which pulls it from operation-specific parameter data (e.g., `"svc_kei_ucwk_list"` keys from `KikiInfoAddMap`, or `"dsl_svc_ucwk_list"`, `"kaihk_svc_ucwk_list"`, `"cancel_svc_ucwk_list"` from `KojiKikiMap`). |

**Instance fields or external state read:** None. This method is stateless — it does not access any instance variables, static fields, or external resources.

## 4. CRUD Operations / Called Services

This method performs **no database operations, no service component calls, and no CBS invocations**. It is a pure in-memory data transformation. All operations are list/map manipulations.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| N/A | (none) | — | — | In-memory ArrayList iteration and HashMap population. No persistence layer access. |

## 5. Dependency Trace

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

This method is called exclusively from within the same class — `JKKKojiWrisvcAutoAplyCC.execute()`. There are no screen (KKSV*) or batch entry points that call `setSvcUcwk` directly. It is an internal utility method of the auto-application component.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKKojiWrisvcAutoAplyCC | `JKKKojiWrisvcAutoAplyCC.execute()` -> `setSvcUcwk(ArrayList)` | In-memory transform only — no SC/CRUD |

**Caller instances within `execute()`:**

| Instance | Source List Key | Batch Operation |
|----------|----------------|-----------------|
| 1 | `"svc_kei_ucwk_list"` from `KikiInfoAddMap` | Service Registration (create) — `add_chge_div = "01"` |
| 2 | `"dsl_svc_ucwk_list"` from `KojiKikiMap` | Service Cancellation (DSL) — `add_chge_div = "03"` |
| 3 | `"kaihk_svc_ucwk_list"` from `KojiKikiMap` | Service Restoration — `add_chge_div = "04"` |
| 4 | `"cancel_svc_ucwk_list"` from `KojiKikiMap` | Service Cancel — `add_chge_div = "05"` |
| 5 | `"svc_kei_ucwk_list"` from `KikiInfoAddMap` (STB_TEKKYO_NASI branch) | Service Registration without STB — `add_chge_div = "01"` |

Note: Instances 1 and 5 use the same source key but in different STB attachment branches (with STB vs. without STB).

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(list != null && list.size() > 0)` (L412)

> Guard clause: only proceed with transformation if the input list is non-null and non-empty. Otherwise, skip to return.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiList = new ArrayList()` // Create empty result list [-> INIT] |
| 2 | SET | `ucwkMap = null` // Initialize source item variable [-> INIT] |
| 3 | SET | `svcKeiMap = null` // Initialize output item variable [-> INIT] |
| 4 | LOOP | `for (int i = 0; i < list.size(); i++)` // Iterate over all input service detail records |
| 5 | SET | `ucwkMap = (HashMap)list.get(i)` // Cast and extract the i-th source map [-> GET] |
| 6 | SET | `svcKeiMap = new HashMap()` // Create a fresh output map [-> INIT] |
| 7 | SET | `svcKeiMap.put("tg_kei_skbt_cd", "03")` // [-> TG_KEI_SKBT_CD = "03"] Target contract type — Service Detail |
| 8 | SET | `svcKeiMap.put("svc_kei_ucwk_no", (String)ucwkMap.get("svc_kei_ucwk_no"))` // [-> COPY] Service detail work number — internal tracking ID |
| 9 | SET | `svcKeiMap.put("svc_kei_ucwk_stat", (String)ucwkMap.get("svc_kei_ucwk_stat"))` // [-> COPY] Service detail work status — processing state indicator |
| 10 | SET | `svcKeiMap.put("pcrs_cd", (String)ucwkMap.get("pcrs_cd"))` // [-> COPY] Price code — pricing tier identifier |
| 11 | SET | `svcKeiMap.put("pplan_cd", (String)ucwkMap.get("pplan_cd"))` // [-> COPY] Price plan code — specific pricing plan identifier |
| 12 | SET | `svcKeiList.add(svcKeiMap)` // Append the enriched map to the result list [-> ADD] |
| 13 | RETURN | `return svcKeiList` // Return the transformed list [-> RETURN] |

**Block 2** — [ELSE] `(list == null || list.size() == 0)` (implicit, L412)

> The input list is null or empty. The method skips all processing and returns the freshly-initialized (but still empty) `svcKeiList`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return svcKeiList` // Return empty result list — caller will see `svcKeiList.size() == 0` and skip downstream processing |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `tg_kei_skbt_cd` | Field | Target contract type code — classifies the contract line item category. `"03"` = Service Detail (サービ契の内訳) |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for a service contract line item, used to correlate and reference individual service entries |
| `svc_kei_ucwk_stat` | Field | Service detail work status — indicates the current processing state of the service detail record |
| `pcrs_cd` | Field | Price code — identifies the pricing tier applied to a service detail line item |
| `pplan_cd` | Field | Price plan code — identifies the specific price plan associated with a service detail |
| `svc_kei_ucwk_list` | Field | Service detail list — a list of HashMaps representing service contract line items, stored in operation parameter maps |
| `KikiInfoAddMap` | Field | Equipment info add map — parameter key holding equipment and service detail data for new service registrations (create operations) |
| `KojiKikiMap` | Field | Facility/Equipment map — parameter key holding data for construction assignments, including cancel, restore, and DSL sub-lists |
| `add_chge_div` | Field | Registration/Change division — operation type discriminator. `"01"` = Register (登録), `"03"` = Cancel (解約), `"04"` = Restore (回復), `"05"` = Cancel with cancel reason (キャンセル) |
| `STB_TEKKYO_TEKKYO` | Constant | `"1"` — STB attachment present (STB撤去チェック有). Branch for contracts where STB set-top boxes are attached and need inventory tracking. |
| `STB_TEKKYO_NASI` | Constant | `"0"` — STB attachment absent (STB撤去チェック無). Branch for contracts without STB set-top boxes. |
| `JKKWrisvcAutoAplyCC` | Class | Discount service auto-application CC — the downstream component that receives enriched contract lists and processes discount auto-application |
| `JKKKojiWrisvcAutoAplyCC` | Class | Construction-assignment discount service auto-application CC — the parent component that orchestrates batches of service registration, cancellation, restoration, and cancel operations |
| WR | Abbreviation | Work Order / 工事 — construction assignment or work order in the telecom service provisioning domain |
| SVC | Abbreviation | Service / サービ — refers to customer service contracts in the telecom billing and provisioning system |
| KEI | Abbreviation | Contract line / 契の内訳 — a line item within a service contract, representing a specific product or charge |
| UCWK | Abbreviation | Work / 内訳 — detail or breakdown work number associated with a contract line item |
| KIKI | Abbreviation | Equipment / 機器 — hardware equipment (e.g., STB set-top boxes) provisioned as part of a service contract |
| DSL | Abbreviation | DSL (Dynamic Service Line) — service cancellation operation code for terminating existing service contracts |
| KAIHK | Abbreviation | Restore / 回復 — service restoration operation, reactivating a previously cancelled service |