# Business Logic — JKKCourseRkRtrNsIdChgCC.execChgMultiRouterNinshoId() [71 LOC]

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

## 1. Role

### JKKCourseRkRtrNsIdChgCC.execChgMultiRouterNinshoId()

This method orchestrates the **approval-based order registration workflow for a multi-router (home gateway) change** in a Fujitsu Futurity telecom billing/order fulfillment system. It serves as the central dispatch method for processing a multi-router service type (SVC_ORDER_CD = "26") where an existing registration order must be confirmed before proceeding with further order condition registration and order info creation.

The method first validates whether a registration order already exists for the given multi-router service by invoking `isRegiOrdExit`. If no such order exists, the method returns immediately (idempotency guard). If an order exists, it proceeds through three sequential business steps: (1) searching for a **same process number** (同一処理番号 — a transaction grouping identifier that ensures related operations share the same correlation ID), (2) **registering the order issuance conditions** (発行条件登録 — defining the parameters under which an order can be released to downstream systems), and (3) **creating and registering the order info work** (注文情報作成ワーク登録 — building the work record that drives the order creation pipeline, but only when the function code matches "1", indicating a primary order path).

The design pattern used is **delegation + sequential dispatch**: the method prepares input message arrays, delegates data retrieval to helper methods (`editInMsgEKK1081C011`), and dispatches actual service execution to `callSC` (Service Component caller). It is a **shared utility** called from `JKKCourseRkRtrNsIdChgCC.execute()`, and is specific to the multi-router change use case.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execChgMultiRouterNinshoId(params)"])
    STEP1["Extract kktksvckeino from paraMap"]
    STEP2["Call isRegiOrdExit check"]
    COND1{isRegiOrdered?}
    STEP3["Call editInMsgEKK1081C011"]
    STEP4["Call SC EKK1081C011 - Same process number search"]
    STEP5["Build ekk1081d010InMsg"]
    STEP6["Call SC EKK1081D010 - Order issuance condition registration"]
    STEP7{funcCode equals FUNC_CODE_1?}
    STEP8["Build ekk1051d010InMsg"]
    STEP9["Call SC EKK1551D010 - Order info creation work registration"]
    END_NODE(["Return void"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> COND1
    COND1 -- false --> END_NODE
    COND1 -- true --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    STEP6 --> STEP7
    STEP7 -- true --> STEP8
    STEP8 --> STEP9
    STEP9 --> END_NODE
    STEP7 -- false --> END_NODE
```

**Branch summary:**
- **Block 1 (isRegiOrdered == false):** Method returns immediately. This is an idempotency guard — if no registration order exists, the workflow has nothing to approve, so no further processing occurs.
- **Block 2 (isRegiOrdered == true):** Proceeds to execute the three-step order registration pipeline: same process number search, order issuance condition registration, and conditionally, order info creation work registration.

**CRITICAL — Constant Resolution:**
- `FUNC_CODE_1 = "1"` — Function code indicating primary order path [resolved from `JKKHakkoSODConstCC.FUNC_CODE_1`]
- `SVC_ORDER_CD_MULTI_ROUTER = "26"` — Service order code for multi-router information
- `ORDER_SBT_CD_MULTI_2 = "2"` — Order subtype code: Phone IoT — Multi-router change
- `YOKYU_SBT_CD_CHG = "04"` — Request subtype code: Change
- `ODR_HAKKO_JOKEN_CD_SOKJI_HAKKO = "01"` — Order issuance condition code: Immediate issuance
- `ODR_NAIYO_CD_404 = "404"` — Order content code: Multi-router setup/change (router function, connection info change)

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database/session handle used for all service component calls. Carries the current transaction context, user identity, and database connection for the order registration workflow. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation bridge used to dispatch calls to CBS/SC layers. Enables the method to execute remote service operations without direct coupling. |
| 3 | `param` | `IRequestParameterReadWrite` | Request/response parameter holder that carries data between service components. Used to read and write business data during the workflow, including extracting the same process number from output. |
| 4 | `fixedText` | `String` | Fixed text/configuration parameter passed through to called service components. Used for template selection and formatting across CBS invocations. |
| 5 | `funcCode` | `String` | Function code that determines the execution path. When equal to `"1"` (FUNC_CODE_1), the method additionally registers order info creation work (EKK1551D010). Other values skip this third step. |
| 6 | `paraMap` | `HashMap<String,String>` | Parameter map carrying business data extracted from the request. Contains keys: `kktkSvcKeiNo` (home gateway provider service contract number), `svcKeiNo` (service contract number), `svcKeikaisenUwNo` (service contract line item number for routed services), `svcKeiUcwkNo` (service detail work number), `taknKikiMdCd` (indoor equipment model code), `kikiSeizoNo` (equipment serial number), and various date/time fields for service contract generations. |

**Instance fields read:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `isRegiOrdered` | `boolean` | Flag set by `isRegiOrdExit()` indicating whether a registration order already exists. Controls whether the method proceeds with order processing. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `isRegiOrdExit` (internal call) | EKK1081B001CBS | KK_T_ODR_HAKKO_JOKEN (implied) | Reads order issuance condition list via EKK1081B001CBS to check if a registration order exists. Returns false if no matching records found, preventing duplicate processing. |
| R | `editInMsgEKK1081C011` | EKK1081C011CBS | - | Prepares input message for same process number search. Returns Object[][] containing template and function parameters. |
| R | `callSC` (EKK1081C011) | EKK1081C011CBS | - | Calls service component to search and retrieve the same process number (SAME_TRN_NO) used to correlate related transactions. Output contains the correlation ID for downstream order registration. |
| C | `callSC` (EKK1081D010) | EKK1081D010CBS | KK_T_ODR_HAKKO_JOKEN (implied) | Registers order issuance conditions with service contract details, equipment info, order subtype (Phone IoT: multi-router change), service order code (26: multi-router), request subtype (04: change), and issuance condition code (01: immediate issuance). Uses the same process number from the prior step. Returns ODR_HAKKO_JOKEN_NO (order issuance condition number) used in the next step. |
| C | `callSC` (EKK1551D010) | EKK1551D010CBS | KK_T_ODR_INFO (implied) | Conditionally executes when funcCode="1". Registers order info creation work with full service contract details, equipment information, order content code (404: multi-router), generation dates, and all related service contract line item data. Drives the order creation pipeline for multi-router changes. |
| U | `editInMsgEKK1081C011` | - | - | Builds the input message array for the same process number search SC call. |
| R | `JKKCourseRkRtrNsIdChgCC.callSC` | - | - | Reusable SC invocation method that dispatches service component calls and returns CAANMsg responses. |
| R | `JKKCourseRkRtrNsIdChgCC.isRegiOrdExit` | - | - | Internal helper that checks for existing registration orders by calling EKK1081B001CBS with the home gateway service contract number. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `callSC` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `callSC` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `callSC` [R], `editInMsgEKK1081C011` [U], `isRegiOrdExit` [-]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `JKKCourseRkRtrNsIdChgCC` | `execute()` -> `execChgMultiRouterNinshoId()` | `EKK1081B001CBS [R]`, `EKK1081C011CBS [R]`, `EKK1081D010CBS [C]`, `EKK1551D010CBS [C]` |

**Call chain notes:**
- The method is invoked from `JKKCourseRkRtrNsIdChgCC.execute()` which is the main execution entry point for the course/router number change processing flow.
- The terminal operations reach four CBS endpoints: EKK1081B001CBS (order issuance condition inquiry), EKK1081C011CBS (same process number search), EKK1081D010CBS (order issuance condition registration), and EKK1551D010CBS (order info creation work registration, conditional on funcCode).

## 6. Per-Branch Detail Blocks

### Block 1 — IF (isRegiOrdered check) (L887)

> This block performs an idempotency guard: if no registration order exists for the given multi-router service, the method returns immediately without executing any downstream processing. The `isRegiOrdExit` method internally calls EKK1081B001CBS to query the order issuance condition list and returns false when no matching records exist.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktksvckeino = paraMap.get("kktkSvcKeiNo")` // Extract home gateway provider service contract number from parameter map |
| 2 | CALL | `isRegiOrdered = isRegiOrdExit(handle, scCall, param, fixedText, kktksvckeino, SVC_ORDER_CD_MULTI_ROUTER)` // Check if registration order exists [SVC_ORDER_CD_MULTI_ROUTER="26"] |
| 3 | IF | `if (isRegiOrdered)` — Proceed only if a registration order already exists [L887] |

#### Block 1.1 — IF body (isRegiOrdered == true) (L889)

> The registration order exists, so proceed with the three-step order registration pipeline.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ekk1081c011InMsg = editInMsgEKK1081C011()` // Prepare input message for same process number search [同一処理番号探索] (L893) |
| 2 | CALL | `ekk1081c011OutMsg = callSC(handle, scCall, param, fixedText, ekk1081c011InMsg)` // Execute same process number search to obtain correlation ID |

#### Block 1.2 — Build EKK1081D010 input message (L899)

> Construct the input message array for the order issuance condition registration CBS call. This assembles all service contract, equipment, order, and condition parameters needed to register the order issuance conditions for a multi-router change.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk1081d010InMsg = Object[][]` with 14 key-value pairs [注文発行条件登録] (L899) |
|   |   | `TEMPLATEID -> TEMPLATE_ID_EKK1081D010` |
|   |   | `FUNC_CODE -> funcCode` |
|   |   | `SVC_KEI_NO -> paraMap.get("svcKeiNo")` |
|   |   | `SVC_KEI_KAISEN_UCWK_NO -> paraMap.get("svcKeikaisenUwNo")` // Service contract line item number [サービス契約回線内訳番号] |
|   |   | `SVC_KEI_UCWK_NO -> paraMap.get("svcKeiUcwkNo")` |
|   |   | `KKTK_SVC_KEI_NO -> paraMap.get("kktkSvcKeiNo")` |
|   |   | `TAKNKIKI_MODEL_CD -> paraMap.get("taknKikiMdCd")` // Indoor equipment model code [宅内機器型式コード] |
|   |   | `KIKI_SEIZO_NO -> paraMap.get("kikiSeizoNo")` // Equipment serial number [機器製造番号] |
|   |   | `ORDER_SBT_CD -> ORDER_SBT_CD_MULTI_2` // [-> ORDER_SBT_CD_MULTI_2="2"] Phone IoT: Multi-router change [電話IoT：多機能ルーター変更] |
|   |   | `SVC_ORDER_CD -> SVC_ORDER_CD_MULTI_ROUTER` // [-> SVC_ORDER_CD_MULTI_ROUTER="26"] Multi-router [多機能ルーター] |
|   |   | `YOKYU_SBT_CD -> YOKYU_SBT_CD_CHG` // [-> YOKYU_SBT_CD_CHG="04"] Request subtype: Change [要求種別コード：変更] |
|   |   | `ODR_HAKKO_JOKEN_CD -> ODR_HAKKO_JOKEN_CD_SOKJI_HAKKO` // [-> ODR_HAKKO_JOKEN_CD_SOKJI_HAKKO="01"] Order issuance condition: Immediate issuance [発行条件コード：即発行] |
|   |   | `SAME_TRN_NO -> ekk1081c011OutMsg.getString(EKK1081C011CBSMsg.SAME_TRN_NO)` // Same process number obtained from prior step [同一処理番号] |

#### Block 1.3 — Execute EKK1081D010 CBS (L914)

> Call the CBS to register the order issuance conditions. The output provides the order issuance condition number (ODR_HAKKO_JOKEN_NO) used in the next conditional step.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ekk1081d010OutMsg = callSC(handle, scCall, param, fixedText, ekk1081d010InMsg)` // Register order issuance conditions [注文発行条件登録] |

#### Block 1.4 — IF (funcCode == FUNC_CODE_1) (L916)

> Conditionally execute order info creation work registration when the function code matches "1" (primary order path). This step creates the work record that drives the order creation pipeline for multi-router changes.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (FUNC_CODE_1.equals(funcCode))` — [FUNC_CODE_1="1"] Execute order info creation work registration [注文情報作成ワーク登録] (L916) |

##### Block 1.4.1 — Build EKK1551D010 input message (L920)

> Construct the input message array for the order info creation work registration CBS call. This assembles comprehensive order and service contract data including generation timestamps from multiple service contract generations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk1051d010InMsg = Object[][]` with 14 key-value pairs [注文情報作成ワーク登録] (L920) |
|   |   | `TEMPLATEID -> TEMPLATE_ID_EKK1551D010` |
|   |   | `FUNC_CODE -> funcCode` |
|   |   | `ODR_HAKKO_JOKEN_NO -> ekk1081d010OutMsg.getString(EKK1081D010CBSMsg.ODR_HAKKO_JOKEN_NO)` // Order issuance condition number from prior step |
|   |   | `ODR_NAIYO_CD -> ODR_NAIYO_CD_404` // [-> ODR_NAIYO_CD_404="404"] Order content: Multi-router [注文内容コード：多機能ルーター] |
|   |   | `SVC_KEI_NO -> paraMap.get("svcKeiNo")` |
|   |   | `SVKEI_GADTM -> paraMap.get("ekk0081GeneAddDtm")` // Service contract generation 1 registration date/time [サービス契約世代登録年月日時分秒] |
|   |   | `SVC_KEI_UCWK_NO -> paraMap.get("svcKeiUcwkNo")` |
|   |   | `SVKEIUW_GADTM -> paraMap.get("kk0161GeneAddDtm")` |
|   |   | `KKOP_SVC_KEI_NO_1 -> paraMap.get("KkOpSvcKeiNo")` // Equipment option service contract number 1 (router function) [機器オプションサービス契約番号1（ルーター機能）] |
|   |   | `KKOSVKEI_GADTM_1 -> paraMap.get("kk2811GeneAddDtm")` // Equipment option service contract generation 1 registration timestamp [機器オプションサービス契約世代登録年月日時分秒1（ルーター機能）] |
|   |   | `HUKA_INF_KEI_NO -> paraMap.get("svcKeikaisenUwNo")` // Additional info contract number (service contract line item) [追加情報契約番号] |
|   |   | `HUKA_INF_KEI_GADTM -> paraMap.get("ekk0251GeneAddDtm")` // Additional info contract generation 1 registration timestamp [追加情報契約世代登録年月日時分秒] |
|   |   | `KKTK_SVC_KEI_NO -> paraMap.get("kktkSvcKeiNo")` |
|   |   | `KKTSVKEI_GADTM -> paraMap.get("kk0341GeneAddDtm")` |

##### Block 1.4.2 — Execute EKK1551D010 CBS (L935)

> Call the CBS to register the order info creation work. This is the final step in the multi-router change approval workflow when funcCode="1".

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk1051d010InMsg)` // Execute order info creation work registration [注文情報作成ワーク登録] |

### Block 2 — IF body closing (L937)

> Closes the idempotency guard if block. When `isRegiOrdered` is false, the method simply returns without executing any downstream processing.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (implicit void return after if block exits) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktkSvcKeiNo` | Field | Home gateway provider service contract number — the service contract number associated with the home gateway (multi-router) provider |
| `svcKeiNo` | Field | Service contract number — primary identifier for a service contract in the billing system |
| `svcKeiUcwkNo` | Field | Service detail work number — internal tracking ID for service contract line items |
| `svcKeikaisenUwNo` | Field | Service contract line item number (routed services) — identifies a specific line item within a service contract for routed/additional services |
| `kikiSeizoNo` | Field | Equipment serial number — unique manufacturing serial number of the installed equipment |
| `taknKikiMdCd` | Field | Indoor equipment model code — model identifier for home-installed equipment |
| `KkOpSvcKeiNo` | Field | Equipment option service contract number 1 (router function) — service contract number for the router option feature |
| `ekk0081GeneAddDtm` | Field | Service contract generation 1 registration date/time — timestamp when the first service contract generation was registered |
| `kk0161GeneAddDtm` | Field | Service contract generation 1 registration date/time (additional detail) |
| `kk2811GeneAddDtm` | Field | Equipment option service contract generation 1 registration date/time (router function) |
| `ekk0251GeneAddDtm` | Field | Additional information contract generation 1 registration date/time (routed service contract generation registration) |
| `kk0341GeneAddDtm` | Field | KKT (home gateway provider) service contract generation registration date/time |
| `SAME_TRN_NO` | Field | Same process number — a correlation identifier that groups related transactions under a single processing batch |
| `ODR_HAKKO_JOKEN_NO` | Field | Order issuance condition number — identifier for the registered order issuance conditions |
| `isRegiOrdered` | Field | Boolean flag indicating whether a registration order already exists for the given service |
| FUNC_CODE_1 | Constant | Function code "1" — indicates the primary order processing path that includes order info creation work registration |
| SVC_ORDER_CD_MULTI_ROUTER | Constant | "26" — Service order code for multi-router (home gateway) service type |
| ORDER_SBT_CD_MULTI_2 | Constant | "2" — Order subtype code for Phone IoT: Multi-router change |
| YOKYU_SBT_CD_CHG | Constant | "04" — Request subtype code: Change |
| YOKYU_SBT_CD_REG | Constant | "02" — Request subtype code: Registration |
| ODR_HAKKO_JOKEN_CD_SOKJI_HAKKO | Constant | "01" — Order issuance condition code: Immediate issuance |
| ODR_NAIYO_CD_404 | Constant | "404" — Order content code: Multi-router setup/change (router function, connection info change) |
| EKK1081B001CBS | Service Component | Order issuance condition inquiry CBS — retrieves the list of order issuance conditions for a given service contract |
| EKK1081C011CBS | Service Component | Same process number search CBS — searches and retrieves a correlation transaction number for grouping related operations |
| EKK1081D010CBS | Service Component | Order issuance condition registration CBS — registers the conditions under which an order can be released to downstream systems |
| EKK1551D010CBS | Service Component | Order info creation work registration CBS — creates and registers the work record that drives the order creation pipeline |
| CAANMsg | Type | Common message container class used for service component request/response communication |
| SessionHandle | Type | Database session and transaction context handle |
| ServiceComponentRequestInvoker | Type | Service Component request invocation interface for dispatching service operations |
| IRequestParameterReadWrite | Type | Interface for request/response parameter data exchange between service components |
| Multi-router | Business term | Home gateway device providing routing functionality — the service type being changed in this workflow (Japanese: 多機能ルーター) |
| Order issuance condition | Business term | Parameters that define when and how an order can be issued/released to downstream fulfillment systems |
| Order info creation work | Business term | A work record that drives the downstream order creation pipeline, containing all necessary order and service contract data |
| Same process number | Business term | A transaction grouping identifier (同一処理番号) that ensures related operations share the same correlation ID for processing coherence |
