# Business Logic — JKKAdchgCheckerCC.isChokuso() [65 LOC]

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

## 1. Role

### JKKAdchgCheckerCC.isChokuso()

The `isChokuso()` method determines whether a device attached to a given service contract should be handled as a **customer direct ship** (直送 — chokusou) or as a **construction company delivery** (工事会社配送). "Chokusou" means the customer receives the equipment directly from the vendor or retailer, bypassing the installation contractor. This method is a **decision-only utility** called from the higher-level `isShukkaKanryo()` method (shipment completion check), which is itself invoked by `idoKikiStatusCheck()` (standalone device status verification) during address-change registration screens. The method implements a **two-stage query dispatch pattern**: first it queries the contract device delivery target list (EDK0011B090) to obtain the work case number (kojiAkNo) by matching the device change number (KIKI_CHG_NO) from the input check map. Then it queries the work case indoor device list (EKU0141B020) using the work case number. If no indoor device records are found in the second query, the device is determined to be under direct customer delivery; if indoor device records exist, the device is routed through the construction company for delivery. This classification directly impacts error handling — when `isChokuso()` returns `true` (customer direct ship) and the delivery status is already "received" (isHaisoUketukeZumi is `true`), an error is triggered to alert the operator that a directly-shipped device should not appear as received.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isChokuso param, fixedText, chkMap"])
    START --> SETUP["Setup: create reqMap, condMap, resMap local vars"]
    SETUP --> GET_MAPP["Get JKKAdchgMapperCC mapper instance"]
    GET_MAPP --> GET_INV["Get SC RequestInvoker instance"]
    GET_INV --> EDK_SET["Call setEDK0011B090: build request for contract device delivery items"]
    EDK_SET --> EDK_COND["Build condMap: KEY_KKTK_SVC_KEI_NO from chkMap"]
    EDK_COND --> EDK_SC["Call SC.run with EDK0011B090 request"]
    EDK_SC --> EDK_GET["Get EDK0011B090 result list from mapper"]
    EDK_GET --> EDK_CHECK["Call scResultCheck for error check"]
    EDK_CHECK --> COND_NULL{dk0011_b090_list == null<br/>or isEmpty?}
    COND_NULL -->|Yes| NOT_CHOKUSO["Return false<br/>(not direct ship - delivery items could not be retrieved)"]
    COND_NULL -->|No| FOR_INIT["Initialize kojiAkNo = empty string"]
    FOR_INIT --> FOR_LOOP["Loop: iterate dk0011_b090_list"]
    FOR_LOOP --> MATCH_CHECK{KIKI_CHG_NO matches<br/>chkMap KIKI_CHG_NO?}
    MATCH_CHECK -->|Yes| GET_KOJIAK["Extract KOJIAK_NO from map entry"]
    GET_KOJIAK --> KOJIAK_NOT_EMPTY{kojiAkNo is not empty?}
    KOJIAK_NOT_EMPTY -->|Yes| FOR_BREAK["Break loop"]
    KOJIAK_NOT_EMPTY -->|No| FOR_LOOP
    MATCH_CHECK -->|No| FOR_LOOP
    FOR_BREAK --> KOJIAK_EMPTY{kojiAkNo is empty?}
    KOJIAK_EMPTY -->|Yes| CHOKUSO_TRUE["Return true<br/>(customer direct ship)"]
    KOJIAK_EMPTY -->|No| EKU_SET["Call setEKU0141B020: build request for work case indoor devices"]
    EKU_SET --> EKU_COND["Build condMap: KOJIAK_NO from kojiAkNo"]
    EKU_COND --> EKU_SC["Call SC.run with EKU0141B020 request"]
    EKU_SC --> EKU_GET["Get EKU0141B020 result list from mapper"]
    EKU_GET --> EKU_CHECK["Call scResultCheck for error check"]
    EKU_CHECK --> EKU_NOT_EMPTY{ku0141_b020_list not null<br/>and size > 0?}
    EKU_NOT_EMPTY -->|Yes| NOT_CHOKUSO2["Return false<br/>(construction company delivery)"]
    EKU_NOT_EMPTY -->|No| CHOKUSO_TRUE2["Return true<br/>(customer direct ship)"]
    CHOKUSO_TRUE --> END(["Return true"])
    CHOKUSO_TRUE2 --> END
    NOT_CHOKUSO --> END2(["Return false"])
    NOT_CHOKUSO2 --> END2
```

**Business logic summary:**

1. **Setup phase**: Creates local variables for the request/response cycle and obtains a `JKKAdchgMapperCC` mapper instance and a `ServiceComponentRequestInvoker` for SC calls.

2. **Stage 1 — Contract device delivery target list query (EDK0011B090)**: Builds a condition map keyed by the service contract number (KKTK_SVC_KEI_NO) extracted from the input `chkMap`, sends the query to the service component, and retrieves the list of delivery target devices.

3. **Early-return check (null/empty list)**: If no delivery target items are returned, the method returns `false` — the device is NOT customer direct ship (changed from the original logic that treated this case as direct ship; updated per IT2-2013-0000058 on 2013-01-30).

4. **Device change number matching loop**: Iterates through the delivery target list to find an entry whose `KIKI_CHG_NO` (device change number) matches the one in the input `chkMap`. When a match is found, extracts the `KOJIAK_NO` (work case number) and breaks if it is non-empty.

5. **Early-return check (no work case number)**: If `kojiAkNo` is empty after the loop, the method returns `true` — treating it as customer direct ship because the work case number cannot be resolved.

6. **Stage 2 — Work case indoor device list query (EKU0141B020)**: Builds a new condition map using the resolved `kojiAkNo` and queries the indoor device list for that work case.

7. **Final classification**: If indoor device records exist (`ku0141_b020_list` is non-null and has entries), the device is delivered by the construction company (`false`). If no indoor device records are found, it is a customer direct ship (`true`).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the current session's I/O data, including model groups and control maps used by the mapper to prepare and extract SC request/response payloads. |
| 2 | `fixedText` | `String` | User-specified arbitrary string passed through to mapper methods — likely used for display customization or log identification in the request chain. |
| 3 | `chkMap` | `HashMap<String, Object>` | A check map containing device information for a specific service, including `KKTK_SVC_KEI_NO` (service contract number) and `KIKI_CHG_NO` (device change number). This map is the primary filter used to look up delivery target items in EDK0011B090. |

**External state read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `keepSesHandle` | `ThreadLocal<SessionHandle>` | Thread-local session handle used to maintain the database/SC session context across the request chain. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKAdchgMapperCC.getInstance` | - | - | Gets singleton mapper instance for building SC requests |
| R | `ServiceComponentRequestInvoker` | - | - | Creates new invoker for dispatching SC requests |
| R | `JKKAdchgMapperCC.setEDK0011B090` | - | - | Builds the EDK0011B090 request by populating `param` and `fixedText` with service contract number condition |
| - | `ServiceComponentRequestInvoker.run` | - | - | Invokes the EDK0011B090 service component with the prepared request |
| R | `JKKAdchgMapperCC.getEDK0011B090` | - | - | Extracts the result list of contract device delivery target items from the SC response |
| - | `JKKAdchgMapperCC.scResultCheck` | - | - | Validates the SC response for errors; throws if error detected |
| R | `JKKAdchgMapperCC.setEKU0141B020` | - | - | Builds the EKU0141B020 request by populating `param` and `fixedText` with work case number condition |
| - | `ServiceComponentRequestInvoker.run` | - | - | Invokes the EKU0141B020 service component with the prepared request |
| R | `JKKAdchgMapperCC.getEKU0141B020` | - | - | Extracts the result list of work case indoor devices from the SC response |
| - | `JKKAdchgMapperCC.scResultCheck` | - | - | Validates the SC response for errors; throws if error detected |

## 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: `scResultCheck` [-], `getEDK0011B090` [R], `setEDK0011B090` [-], `run` [-], `getEKU0141B020` [R], `setEKU0141B020` [-], `run` [-], `getInstance` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKAdchgCheckerCC.isShukkaKanryo | `isShukkaKanryo(param, fixedText, chkMap, svcKeiNo)` -> iterates `chkKikiList` -> calls `isChokuso(param, fixedText, chkMap)` | `scResultCheck` [-], `getEDK0011B090` [R], `setEDK0011B090` [-], `run` [-], `getEKU0141B020` [R], `setEKU0141B020` [-], `run` [-] |

**Call chain context:** `isShukkaKanryo()` is called from `idoKikiStatusCheck()` which serves as the entry point for checking standalone device statuses (for FTTH, telephone, and TV services) during address change registration. `isChokuso()` is called within the iteration over each device in the service to determine if it's a direct-shipped device, and the result is combined with `isHaisoUketukeZumi()` (delivery receipt status) to trigger a check error when a directly-shipped device shows as already received.

## 6. Per-Branch Detail Blocks

**Block 1** — SETUP `(Variable declarations)` (L435)

> Sets up local variables for the request/response cycle.

| # | Type | Code |
|---|------|------|
| 1 | SET | `reqMap = new HashMap<String, Object>()` // Request map for SC call |
| 2 | SET | `condMap = new HashMap<String, String>()` // Condition map for building SC queries |
| 3 | SET | `resMap = (Map<?, ?>) null` // Response map from SC call |

**Block 2** — SETUP `(Get mapper and invoker instances)` (L439-L442)

> Acquires the mapper singleton and creates a fresh SC request invoker.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `mapper = JKKAdchgMapperCC.getInstance()` // Gets mapper singleton [-> getInstance (JKKAdchgMapperCC)] |
| 2 | SET | `scCall = new ServiceComponentRequestInvoker()` // Creates SC request invoker |

**Block 3** — STAGE 1 QUERY `(EDK0011B090 — Contract Device Delivery Target List)` (L446-L452)

> Queries the EDK0011B090 service component to retrieve all contract device delivery target items for the service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `condMap = new HashMap<String, String>()` // Re-creates fresh condition map [-> new HashMap] |
| 2 | EXEC | `condMap.put(JKKAdchgMapperCC.COND_KEY_KKTK_SVC_KEI_NO, (String) chkMap.get(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_NO))` // Puts service contract number as condition key [-> KKTK_SVC_KEI_NO from chkMap] |
| 3 | CALL | `reqMap = mapper.setEDK0011B090(param, fixedText, condMap)` // Builds EDK0011B090 request [-> setEDK0011B090 (JKKAdchgMapperCC)] |
| 4 | CALL | `resMap = scCall.run(reqMap, keepSesHandle.get())` // Invokes EDK0011B090 SC [-> run (ServiceComponentRequestInvoker)] |
| 5 | CALL | `dk0011_b090_list = mapper.getEDK0011B090(param, fixedText, resMap)` // Extracts result list [-> getEDK0011B090 (JKKAdchgMapperCC)] |
| 6 | CALL | `mapper.scResultCheck(param)` // Validates SC response [-> scResultCheck (JKKAdchgMapperCC)] |

**Block 4** — CONDITION `(Delivery target list is null or empty)` (L454)

> Per IT2-2013-0000058 (2013-01-30, Suzuki): If no delivery target items are found, this means the device is NOT under customer direct ship. Changed from the original logic which returned `true` (direct ship).

| # | Type | Code |
|---|------|------|
| 1 | COND | `dk0011_b090_list == null || dk0011_b090_list.isEmpty()` |
| 2 | SET | `// Return false` // Delivery items could not be retrieved — NOT direct ship |
| 3 | RETURN | `return false` |

**Block 5** — LOOP `(Iterate delivery target items to find matching device)` (L458-L467)

> Loops through the delivery target list to find the entry matching the input device's change number (KIKI_CHG_NO), and extracts the work case number (KOJIAK_NO).

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiAkNo = ""` // Work case number, initialized empty |
| 2 | SET | `for each dk0011_b090_map in dk0011_b090_list` // Iterates over delivery target items |
| 3 | COND | `dk0011_b090_map.get(EDK0011B090CBSMsg1List.KIKI_CHG_NO).equals(chkMap.get(EKK0341A010CBSMsg1List.KIKI_CHG_NO))` // Matches device change number [-> KIKI_CHG_NO from both maps] |
| 4 | SET | `kojiAkNo = (String) dk0011_b090_map.get(EDK0011B020CBSMsg1List.KOJIAK_NO)` // Extracts work case number from matching entry [-> KOJIAK_NO] |
| 5 | COND | `!StringUtils.isEmpty(kojiAkNo)` // Work case number is non-empty |
| 6 | EXEC | `break` // Found valid work case number, exit loop |

**Block 6** — CONDITION `(Work case number is empty)` (L469)

> If no matching work case number was found (either no matching device entry or the entry had empty KOJIAK_NO), treat as customer direct ship.

| # | Type | Code |
|---|------|------|
| 1 | COND | `StringUtils.isEmpty(kojiAkNo)` // KOJIAK_NO could not be resolved |
| 2 | SET | `// Work case number could not be retrieved — customer direct ship handling` |
| 3 | RETURN | `return true` |

**Block 7** — STAGE 2 QUERY `(EKU0141B020 — Work Case Indoor Device List)` (L474-L480)

> Queries the EKU0141B020 service component to retrieve indoor devices associated with the resolved work case number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `condMap = new HashMap<String, String>()` // Re-creates fresh condition map [-> new HashMap] |
| 2 | EXEC | `condMap.put(JKKAdchgMapperCC.COND_KEY_KOJIAK_NO, (String) kojiAkNo)` // Puts work case number as condition key [-> KOJIAK_NO from kojiAkNo] |
| 3 | CALL | `reqMap = mapper.setEKU0141B020(param, fixedText, condMap)` // Builds EKU0141B020 request [-> setEKU0141B020 (JKKAdchgMapperCC)] |
| 4 | CALL | `resMap = scCall.run(reqMap, keepSesHandle.get())` // Invokes EKU0141B020 SC [-> run (ServiceComponentRequestInvoker)] |
| 5 | CALL | `ku0141_b020_list = mapper.getEKU0141B020(param, fixedText, resMap)` // Extracts result list [-> getEKU0141B020 (JKKAdchgMapperCC)] |
| 6 | CALL | `mapper.scResultCheck(param)` // Validates SC response [-> scResultCheck (JKKAdchgMapperCC)] |

**Block 8** — CONDITION `(Indoor device list check)` (L482-L491)

> Final classification: if indoor device records exist, the device is construction company delivery (`false`). Otherwise, it is customer direct ship (`true`).

| # | Type | Code |
|---|------|------|
| 1 | COND | `ku0141_b020_list != null && ku0141_b020_list.size() > 0` // Indoor device list has records |
| 2 | SET | `// Construction company delivery` |
| 3 | RETURN | `return false` |
| 4 | ELSE | (else branch — indoor device list is null or empty) |
| 5 | SET | `// Customer direct ship` |
| 6 | RETURN | `return true` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `isChokuso` | Method | Direct ship check — determines if a device is delivered directly to the customer rather than through the installation contractor |
| `chokusou` | Field (Japanese) | 直送 — Customer direct ship; the customer receives the equipment directly, bypassing the construction/installation company |
| `kojiAkNo` / `KOJIAK_NO` | Field | 工事案件番号 — Work case number; a unique identifier for the installation/work case assigned to a set of devices being installed at a customer site |
| `KIKI_CHG_NO` / `kikiChgNo` | Field | 機器変更番号 — Device change number; identifies a specific device change or modification within a service contract |
| `KKTK_SVC_KEI_NO` | Field | 契約サービス種目番号 — Service contract item number; links devices to their parent service contract |
| `EDK0011B090` | SC Code | Contract device delivery target item list — retrieves all devices that are delivery targets under a given service contract |
| `EKU0141B020` | SC Code | Work case target indoor device list 2 — retrieves all indoor devices associated with a specific work case number |
| `isShukkaKanryo` | Method | 出荷完了 — Shipment completion check — determines whether all devices for a service have been shipped |
| `idoKikiStatusCheck` | Method | 独立機器状態チェック — Standalone device status check — verifies the status of individual devices (FTTH, telephone, TV) during address change processing |
| `isHaisoUketukeZumi` | Method | 配送受付済み — Delivery receipt status — checks whether delivery has already been acknowledged/received |
| `JKKAdchgMapperCC` | Class | Address change registration mapper; builds SC requests and extracts SC responses for address change operations |
| `ServiceComponentRequestInvoker` | Class | Invoker for dispatching Service Component (SC) requests to the backend service layer |
| `chkMap` | Parameter | Check map; contains device information (service contract number, device change number) for a specific service/device pair |
| `dk0011_b090_list` | Variable | Result list from EDK0011B090; contains contract device delivery target items |
| `ku0141_b020_list` | Variable | Result list from EKU0141B020; contains indoor devices for a work case |
| `keepSesHandle` | Field | Thread-local session handle; maintains the SC/database session context across the request lifecycle |
| `SC` | Acronym | Service Component — the backend service layer handling business logic and data access |
| `KK_T_*` | Pattern | Contract/Order-related database table naming pattern (inferred from SC naming convention) |
| IT2-2013-0000058 | Change ticket | Change ticket from 2013-01-30 (Suzuki) that modified the null/empty delivery list behavior from returning `true` to returning `false` |
