---

# Business Logic — JBSbatKKPlaceNoChgRnkiInfCst.getLogMsgKojiStop() [47 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKPlaceNoChgRnkiInfCst` |
| Layer | Service (Batch processing component) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKPlaceNoChgRnkiInfCst.getLogMsgKojiStop()

This method is a logging utility used during address change processing to assemble a diagnostic message string containing the system ID (SYSID) and service contract numbers associated with a given address change record. In the K-Opticom customer backbone system, when a customer moves (address change), the system tracks service contract lines before and after the move. This method queries the `KK_T_ADCHG_DTL` (address change detail) table to identify which service contract lines were added, cancelled, held, or transferred as part of the address change operation identified by `adchgNo`. It concatenates these service contract numbers into a human-readable log message, and fetches the SYSID from the service contract header table (`KK_T_SVC_KEI`) if not yet captured. The method implements a routing/dispatch pattern: for each detail row, it branches based on whether the "before" (moto) and "after" (saki) service contract line numbers are null or non-null to determine the business operation type — add (追加), cancel/hold (解約・保留), or transfer (引越し). Its role in the larger system is a shared logging helper called (currently commented out) from the main processing flow when notifying about suspended construction projects, enabling operations staff to quickly identify which service contracts were affected by a stopped address change.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getLogMsgKojiStop adchgNo"])
    INIT["Initialize msgSvcKei and sysId"]
    CREATE_PARAM["Create paramList set adchgNo and ADCHG_DTL_SBT_CD_SVC_KEI_NO"]
    DB_SELECT["DB: selectBySqlDefine on KK_T_ADCHG_DTL KK_SELECT_003"]
    WHILE_LOOP{while true}
    FETCH_ROW["adchgDtl = selectNext"]
    CHECK_NULL{adchgDtl == null}
    BREAK["break exit loop"]
    GET_FIELDS["Extract motoSvcKeiNo and sakiSvcKeiNo"]
    BOTH_NULL{motoSvcKeiNo null AND sakiSvcKeiNo null}
    CONTINUE["continue skip row"]
    ONE_NULL{One is null}
    ADD_BRANCH["svcKeiNo = sakiSvcKeiNo (Add)"]
    CANCEL_HOLD["svcKeiNo = motoSvcKeiNo (Cancel/Hold)"]
    APPEND_SVC_KEI["msgSvcKei append service contract number info"]
    BOTH_NON_NULL{Both non-null}
    SAME_CHECK{motoSvcKeiNo equals sakiSvcKeiNo}
    SAME_MSG["msgSvcKei append same number (Transfer)"]
    DIFF_MSG["msgSvcKei append original and new (Transfer Cancel plus New)"]
    SET_SVC_KEY["svcKeiNo = motoSvcKeiNo"]
    SYSID_CHECK{sysId empty}
    CALL_SYSID["sysId = getSysId svcKeiNo"]
    RETURN_MSG["Return SYSID and service contract info"]

    START --> INIT --> CREATE_PARAM --> DB_SELECT --> WHILE_LOOP
    WHILE_LOOP --> FETCH_ROW --> CHECK_NULL
    CHECK_NULL -->|Yes| BREAK --> WHILE_LOOP
    CHECK_NULL -->|No| GET_FIELDS --> BOTH_NULL
    BOTH_NULL -->|Yes| CONTINUE --> WHILE_LOOP
    BOTH_NULL -->|No| ONE_NULL
    ONE_NULL -->|Yes moto null| ADD_BRANCH --> APPEND_SVC_KEI
    ONE_NULL -->|Yes saki null| CANCEL_HOLD --> APPEND_SVC_KEI
    ONE_NULL -->|No| BOTH_NON_NULL --> SAME_CHECK
    SAME_CHECK -->|Yes| SAME_MSG --> SET_SVC_KEY
    SAME_CHECK -->|No| DIFF_MSG --> SET_SVC_KEY
    SET_SVC_KEY --> SYSID_CHECK
    APPEND_SVC_KEI --> SYSID_CHECK
    SYSID_CHECK -->|Yes| CALL_SYSID --> WHILE_LOOP
    SYSID_CHECK -->|No| WHILE_LOOP
```

**CRITICAL — Constant Resolution:**
- `ADCHG_DTL_SBT_CD_SVC_KEI_NO` = `"01"` (Address change detail type code: Service contract number) — used to filter the address change detail table to only service contract lines.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `adchgNo` | `String` | Address change number (住所変更番号) — the unique identifier for an address change transaction in the system. Used to query all service contract line items associated with a specific address change operation. |

**Instance fields / external state read by this method:**
| Name | Type | Business Description |
|------|------|---------------------|
| `db_KK_T_ADCHG_DTL` | `JBSbatSQLAccess` | Database access object for the `KK_T_ADCHG_DTL` (Address change detail) table. Used to execute the SQL query and iterate over result rows. |
| `opeDate` | `String` (inherited from parent `JBSbatBusinessService`) | Operating date used as a parameter for the `getSysId` sub-query against the service contract table. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_ADCHG_DTL.selectBySqlDefine` | - | `KK_T_ADCHG_DTL` (Address change detail table) | Reads address change detail rows filtered by `adchgNo` and detail type code `"01"` (service contract number lines). Uses SQL key `KK_SELECT_003`. |
| R | `db_KK_T_ADCHG_DTL.selectNext` | - | `KK_T_ADCHG_DTL` (Address change detail table) | Iterates through result set row by row to retrieve `motoSvcKeiNo` (before service contract line number) and `sakiSvcKeiNo` (after service contract line number). |
| R | `getSysId` | - | `KK_T_SVC_KEI` (Service contract table) | Calls the local private method `getSysId(svcKeiNo)` which queries the service contract header table to retrieve the SYSID (system identifier) for a given service contract number. Uses SQL key `KK_SELECT_023` with `opeDate` as filter. |
| R | `JBSbatKK_T_SVC_KEI.SYSID` | - | `KK_T_SVC_KEI` | Extracts the SYSID field value from the service contract entity returned by `getSysId`. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKPlaceNoChgRnkiInfCst | `process` (main) -> `getLogMsgKojiStop(inAdchgNo)` (currently commented out) | `KK_T_ADCHG_DTL [R]`, `KK_T_SVC_KEI [R]` |
| 2 | Batch: JBSbatKKFmtcelSodUpdInfCst | Same pattern — `getLogMsgKojiStop(inAdchgNo)` (commented out) | `KK_T_ADCHG_DTL [R]`, `KK_T_SVC_KEI [R]` |
| 3 | Batch: JBSbatKKAdChgAddDataCst | Same pattern — `getLogMsgKojiStop(inAdchgNo)` (commented out) | `KK_T_ADCHG_DTL [R]`, `KK_T_SVC_KEI [R]` |
| 4 | Batch: JBSbatKKSodUpdInfCst | Same pattern — `getLogMsgKojiStop(inAdchgNo)` (commented out) | `KK_T_ADCHG_DTL [R]`, `KK_T_SVC_KEI [R]` |
| 5 | Batch: JBSbatKKSmtvlRnkiInfCst | Same pattern — `getLogMsgKojiStop(inAdchgNo)` (commented out) | `KK_T_ADCHG_DTL [R]`, `KK_T_SVC_KEI [R]` |

**Note:** In all five callers, the invocation of `getLogMsgKojiStop(inAdchgNo)` is currently commented out (`//`). The method is defined in each of these classes independently (each has its own copy with the same signature), suggesting it was a common utility that was duplicated or that this specific class (`JBSbatKKPlaceNoChgRnkiInfCst`) is the canonical source. The callers are batch processing components in the address change / service update domain.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L855)

Initialize the result message accumulator and SYSID holder.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgSvcKei = ""` // Message accumulator for service contract numbers |
| 2 | SET | `sysId = ""` // SYSID holder — populated lazily on first meaningful row |

**Block 2** — [SETUP] (L857–860)

Prepare and execute the database query for address change detail lines of type "service contract number" (type code `"01"`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramList = new JBSbatCommonDBInterface()` [-> Create query parameter object] |
| 2 | EXEC | `paramList.setValue(adchgNo)` // Set address change number as first bind parameter |
| 3 | EXEC | `paramList.setValue(ADCHG_DTL_SBT_CD_SVC_KEI_NO)` [-> ADCHG_DTL_SBT_CD_SVC_KEI_NO = "01"] // Set detail type code for service contract lines |
| 4 | CALL | `db_KK_T_ADCHG_DTL.selectBySqlDefine(paramList, KK_T_ADCHG_DTL_KK_SELECT_003)` // Execute SQL to select address change detail rows |

**Block 3** — [WHILE LOOP] `while (true)` (L860)

Iterate over all address change detail rows returned by the query.

| # | Type | Code |
|---|------|------|
| 1 | SET | `adchgDtl = db_KK_T_ADCHG_DTL.selectNext()` // Fetch next row from query result |
| 2 | CONDITION | (Branches to Block 3.1 if null, Block 3.2 otherwise) |

**Block 3.1** — [IF] `adchgDtl == null` (L862–L864)

End-of-result-set check — break out of the loop when no more rows exist.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `break` // Exit while loop — no more rows |

**Block 3.2** — [ELSE] `adchgDtl != null` (L865)

Process a valid address change detail row.

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoSvcKeiNo = adchgDtl.getString(JBSbatKK_T_ADCHG_DTL.CHBF_SKBT_NO)` // "Before" service contract line number |
| 2 | SET | `sakiSvcKeiNo = adchgDtl.getString(JBSbatKK_T_ADCHG_DTL.CHAF_SKBT_NO)` // "After" service contract line number |
| 3 | SET | `svcKeiNo = null` // Temporary holder for the resolved service contract line number |
| 4 | CONDITION | (Branches to Block 3.2.1, Block 3.2.2, or Block 3.2.3 based on null checks) |

**Block 3.2.1** — [IF] `motoSvcKeiNo == null && sakiSvcKeiNo == null` (L867–L869)

Both before and after service contract line numbers are null — skip this row as it carries no meaningful contract information. Japanese comment: 住所変更明細取得（サービス契約）— Address change detail fetch (service contract).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` // Skip to next row — no contract data to report |

**Block 3.2.2** — [ELSE IF] `motoSvcKeiNo == null || sakiSvcKeiNo == null` (L870)

Only one of before/after is null — determines whether the row represents an addition (追加) or cancel/hold (解約・保留).

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | (Nested block 3.2.2.1 if motoSvcKeiNo is null, Block 3.2.2.2 if sakiSvcKeiNo is null) |

**Block 3.2.2.1** — [NESTED IF] `motoSvcKeiNo == null` (L872–L873)

Before-line is null, after-line exists — this is an **addition** (追加). A new service contract line was created as part of the address change.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNo = sakiSvcKeiNo` // The new service contract line number is the "after" value |
| 2 | APPEND | `msgSvcKei += " サービス契約番号:" + svcKeiNo` // Append "Service contract number: <value>" to log message |

**Block 3.2.2.2** — [NESTED ELSE IF] `sakiSvcKeiNo == null` (L874–L875)

After-line is null, before-line exists — this is a **cancel or hold** (解約・保留). The service contract line was removed or suspended as part of the address change.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNo = motoSvcKeiNo` // The cancelled/hold service contract line number is the "before" value |
| 2 | APPEND | `msgSvcKei += " サービス契約番号:" + svcKeiNo` // Append "Service contract number: <value>" to log message |

**Block 3.2.3** — [ELSE] Both `motoSvcKeiNo` and `sakiSvcKeiNo` are non-null (L876–L889)

Both before and after exist — this is a **transfer** (引越し). The service contract line was moved to a different contract number, or stayed the same.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | (Branches to Block 3.2.3.1 if equal, Block 3.2.3.2 if different) |

**Block 3.2.3.1** — [NESTED IF] `motoSvcKeiNo.equals(sakiSvcKeiNo)` (L878–L879)

The before and after service contract line numbers are identical — the transfer retained the same line number. Japanese comment: 引越し — Transfer.

| # | Type | Code |
|---|------|------|
| 1 | APPEND | `msgSvcKei += " サービス契約番号:" + motoSvcKeiNo` // Append "Service contract number: <value>" |
| 2 | SET | `svcKeiNo = motoSvcKeiNo` // Store for potential SYSID fetch |

**Block 3.2.3.2** — [NESTED ELSE] `!motoSvcKeiNo.equals(sakiSvcKeiNo)` (L881–L883)

The before and after service contract line numbers differ — the transfer involves cancellation of the old line and creation of a new one. Japanese comment: 引越し: 解約＋新規 — Transfer: Cancel plus new.

| # | Type | Code |
|---|------|------|
| 1 | APPEND | `msgSvcKei += " サービス契約番号(転居元・先):" + motoSvcKeiNo + " / " + sakiSvcKeiNo` // Append "Service contract number (before/after): <old> / <new>" |
| 2 | SET | `svcKeiNo = motoSvcKeiNo` // Store for potential SYSID fetch |

**Block 3.3** — [SYSID LAZY FETCH] (L887–L889)

Fetch the SYSID from the service contract table, but only once (on the first non-skipped row where `svcKeiNo` is set). Japanese comment: SYSID未取得の場合サービス契約より取る — If SYSID not obtained, fetch from service contract.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `"".equals(sysId)` — SYSID not yet populated |
| 2 | CALL | `sysId = getSysId(svcKeiNo)` // Query KK_T_SVC_KEI table via KK_SELECT_023 to retrieve SYSID for this service contract line |

**Block 4** — [RETURN] (L891)

Assemble and return the final log message combining SYSID and all service contract numbers.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return " SYSID:" + sysId + msgSvcKei` // Concatenates SYSID and all service contract number annotations into a single log message string |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `adchgNo` | Field | Address change number (住所変更番号) — unique identifier for an address change transaction. When a customer moves to a new address, the system creates an address change record with this number. |
| `motoSvcKeiNo` | Field | Before service contract line number (元サービス契約回線内訳番号) — the service contract line identifier existing before the address change. |
| `sakiSvcKeiNo` | Field | After service contract line number (先サービス契約回線内訳番号) — the service contract line identifier existing after the address change. |
| `svcKeiNo` | Field | Service contract line number (サービス契約回線内訳番号) — the resolved service contract line number after applying the add/cancel/transfer logic. |
| `svc_kei` | Field | Service contract (サービス契約) — a contract line item representing a specific service (e.g., FTTH, Mail) under a service contract. |
| `sysId` / SYSID | Field | System ID — a unique system-level identifier for a service contract, used for cross-system tracking and correlation. |
| `msgSvcKei` | Field | Service contract message accumulator (サービス契約メッセージ) — the in-progress log message string that collects service contract number annotations. |
| `ADCHG_DTL_SBT_CD_SVC_KEI_NO` | Constant | Address change detail type code — service contract number = `"01"`. Used to filter `KK_T_ADCHG_DTL` to only rows carrying service contract line number data. |
| `KK_T_ADCHG_DTL` | Table | Address change detail table (住所変更明細) — stores detail-level information about address change operations, including before/after service contract line numbers. |
| `KK_T_SVC_KEI` | Table | Service contract table (サービス契約) — stores service contract header information including the SYSID. |
| `KK_SELECT_003` | SQL Key | SQL definition key for selecting address change detail rows by address change number and detail type code. |
| `KK_SELECT_023` | SQL Key | SQL definition key for selecting service contract header by service contract line number and operating date. |
| 追加 (tsuika) | Business term | Add — a new service contract line is created as part of the address change. The "before" value is null; the "after" value is the new line number. |
| 解約 (kaiyaku) | Business term | Cancel — a service contract line is terminated as part of the address change. The "after" value is null; the "before" value identifies the cancelled line. |
| 保留 (hoyuu) | Business term | Hold — a service contract line is placed on hold during the address change. Treated identically to cancel in this method. |
| 引越し (hikkoshi) | Business term | Transfer — a service contract line is moved from one line number to another as part of the address change. Both before and after values exist. |
| CHBF_SKBT_NO | Field | Before service contract line number (変更前識別番号) — column in `KK_T_ADCHG_DTL` for the pre-change line identifier. |
| CHAF_SKBT_NO | Field | After service contract line number (変更後識別番号) — column in `KK_T_ADCHG_DTL` for the post-change line identifier. |
| `JBSbatCommonDBInterface` | Class | Common database interface item — a framework class used to pass query parameters and hold result set rows for SQL-based operations. |
| `JBSbatSQLAccess` | Class | SQL access wrapper — a framework class providing database access abstraction with methods like `selectBySqlDefine` and `selectNext`. |

---
