# Business Logic — JBSbatKKNrkeFinKikiHktgi.executeKU_T_KJAK_TG_TKKIKI_PKUPDATE() [23 LOC]

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

## 1. Role

### JBSbatKKNrkeFinKikiHktgi.executeKU_T_KJAK_TG_TKKIKI_PKUPDATE()

This method performs a primary-key-based database update on the **construction-project target indoor equipment** table (`KU_T_KJAK_TG_TKKIKI`). It is responsible for updating the record of a specific indoor device associated with a construction project, applying new PK (primary key) values that represent the equipment change destination data.

The method implements a **conditional value assignment pattern** — based on the `chgKikiChgNoFlg` (equipment change number flag) boolean parameter, it determines whether the incoming change number represents a *newly reserved* equipment change number (`RSV_KIKI_CHG_NO`) or an *already changed* equipment change number (`CHGE_KIKI_CHG_NO`). This branching allows the same update method to handle two distinct business states of equipment migration.

The method constructs both the **set values map** (data to update) and the **where condition map** (identifying the target row) from structured `Object[]` parameters, then delegates the actual database write to the `db_KU_T_KJAK_TG_TKKIKI` batch database access interface. It is called by `JBSbatKKNrkeFinKikiHktgi.execute()` when processing equipment change destinations for construction project indoor devices, and serves as the persistence bridge between the batch processing orchestration and the `KU_T_KJAK_TG_TKKIKI` database table.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKU_T_KJAK_TG_TKKIKI_PKUPDATE"])
    
    START --> MAP_CREATE["Create JBSbatCommonDBInterface setMap"]
    MAP_CREATE --> COND_FLG{"chgKikiChgNoFlg"}
    
    COND_FLG -- "true (Reserved PK)" --> SET_RSV["setMap.setValue(RSV_KIKI_CHG_NO, setParam[0])"]
    COND_FLG -- "false (Changed PK)" --> SET_CHGE["setMap.setValue(CHGE_KIKI_CHG_NO, setParam[0])"]
    
    SET_RSV --> SET_SVC["setMap.setValue(KKTK_SVC_KEI_NO, setParam[1])"]
    SET_CHGE --> SET_SVC
    SET_SVC --> SET_UPD["setMap.setValue(UPD_DTM, setParam[2])"]
    
    SET_UPD --> WHERE_CREATE["Create JBSbatCommonDBInterface whereMap"]
    WHERE_CREATE --> SET_WHERE["whereMap.setValue(KOJIAK_TRGT_TAKNKIKI_NO, whereParam[0])"]
    
    SET_WHERE --> DB_UPDATE["db_KU_T_KJAK_TG_TKKIKI.updateByPrimaryKeys(whereMap, setMap)"]
    DB_UPDATE --> END_NODE(["Return"])
```

**Processing flow summary:**

1. **Set values map creation** — Instantiate `JBSbatCommonDBInterface` to act as the set-values map container.
2. **Conditional PK value assignment** — Branch on `chgKikiChgNoFlg`:
   - If `true`: The change number in `setParam[0]` represents a **reserved** (future/planned) equipment change number (`RSV_KIKI_CHG_NO`). This occurs when `CHGE_KIKI_CHG_NO` is null/blank, meaning the equipment has not yet been physically changed.
   - If `false`: The change number in `setParam[0]` represents an **already-changed** equipment change number (`CHGE_KIKI_CHG_NO`). This is the post-change state.
3. **Additional set values** — Regardless of branch, set the service contract line item number (`KKTK_SVC_KEI_NO`) from `setParam[1]` and the update timestamp (`UPD_DTM`) from `setParam[2]`.
4. **Where condition map creation** — Instantiate a second `JBSbatCommonDBInterface` to hold the condition (primary key lookup) parameters.
5. **Set condition values** — Assign the target indoor equipment number (`KOJIAK_TRGT_TAKNKIKI_NO`) from `whereParam[0]`.
6. **Execute DB update** — Call `db_KU_T_KJAK_TG_TKKIKI.updateByPrimaryKeys()` to persist the update against the `KU_T_KJAK_TG_TKKIKI` table using the condition map to identify the row and the set map to define updated columns.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `setParam` | `Object[]` | Array of set-value parameters for the update. Contains: `[0]` = equipment change number (RSV or CHGE depending on `chgKikiChgNoFlg`), `[1]` = service contract line item number (`KKTK_SVC_KEI_NO`), `[2]` = system update timestamp (`UPD_DTM`). |
| 2 | `whereParam` | `Object[]` | Array of condition parameters for identifying the target row. Contains: `[0]` = construction project target indoor equipment number (`KOJIAK_TRGT_TAKNKIKI_NO`), used as the primary key lookup condition. |
| 3 | `chgKikiChgNoFlg` | `boolean` | Equipment change number flag. Determines whether the change number value in `setParam[0]` represents a **reserved** (planned/future) equipment change number (`true` — `RSV_KIKI_CHG_NO`) or an **already-changed** equipment change number (`false` — `CHGE_KIKI_CHG_NO`). This flag is derived from whether `CHGE_KIKI_CHG_NO` is null/blank in the source record (if null, the equipment change number has not yet been assigned, so the flag is set to `true`). |

**External state / instance fields read:**

| Field | Description |
|-------|-------------|
| `db_KU_T_KJAK_TG_TKKIKI` | Batch database access interface for the `KU_T_KJAK_TG_TKKIKI` table. Handles the actual SQL UPDATE operation via `updateByPrimaryKeys()`. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatCommonDBInterface.setValue` | JDKStructuredMap | - | Sets key-value pairs in the set-values map for update columns |
| U | `JBSbatCommonDBInterface.setValue` | JDKStructuredMap | - | Sets key-value pairs in the where condition map for primary key lookup |
| U | `db_KU_T_KJAK_TG_TKKIKI.updateByPrimaryKeys` | KU_T_KJAK_TG_TKKIKI | `KU_T_KJAK_TG_TKKIKI` | Executes primary-key-based UPDATE on the construction-project target indoor equipment table |

**Classification rationale:**
- `setValue` calls (×6) are internal data preparation (building maps), not direct CRUD against entities.
- `updateByPrimaryKeys` is the sole database-writing operation: it performs an **Update (U)** on the `KU_T_KJAK_TG_TKKIKI` table, modifying the specified columns (`RSV_KIKI_CHG_NO` or `CHGE_KIKI_CHG_NO`, `KKTK_SVC_KEI_NO`, `UPD_DTM`) for the row identified by the primary key `KOJIAK_TRGT_TAKNKIKI_NO`.

## 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: `setValue` [-], `setValue` [-], `setValue` [-], `setValue` [-], `setValue` [-], `setValue` [-], `updateByPrimaryKeys` [`KU_T_KJAK_TG_TKKIKI`]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKNrkeFinKikiHktgi.execute() | `JBSbatKKNrkeFinKikiHktgi.execute()` -> checks equipment change flag via `JKKStringUtil.isNullBlank()` -> `executeKU_T_KJAK_TG_TKKIKI_PKUPDATE(kikiChgNoSaki, kktkSvcKeiNoSaki, sysdate, kojiakTrgtTaknkikiNo, chgKikiChgNoFlg)` | `updateByPrimaryKeys [U] KU_T_KJAK_TG_TKKIKI` |

**Caller context:** The method is invoked within the `execute()` method of the same class (`JBSbatKKNrkeFinKikiHktgi`) during batch processing of construction project indoor device data. The caller passes `kikiChgNoSaki` (equipment change number destination), `kktkSvcKeiNoSaki` (service contract line item number destination), `sysdate` (current timestamp), and `kojiakTrgtTaknkikiNo` (target indoor equipment number). The `chgKikiChgNoFlg` is determined by checking if the existing `CHGE_KIKI_CHG_NO` field is null/blank — if so, the flag is set to `true` indicating this is a new reservation of a change number.

## 6. Per-Branch Detail Blocks

**Block 1** — [NEW] Instance creation (L2344)

> Creates the set-values map container for columns to be updated.

| # | Type | Code |
|---|------|------|
| 1 | NEW | `setMap = new JBSbatCommonDBInterface()` // Instantiate map for set values |

**Block 2** — [IF] `(chgKikiChgNoFlg)` [RSV_KIKI_CHG_NO="RSV_KIKI_CHG_NO" / CHGE_KIKI_CHG_NO="CHGE_KIKI_CHG_NO"] (L2345–L2353)

> Determines which equipment change number column to populate based on the flag. If `chgKikiChgNoFlg` is true, the change number represents a **reserved/planned** equipment change number (the equipment has not yet been physically changed). If false, it represents an **already-changed** equipment change number.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(chgKikiChgNoFlg)` // Equipment change number flag check [-> true = Reserved PK, false = Changed PK] |

**Block 2.1** — [IF-TRUE] `[chgKikiChgNoFlg = "true"]` (L2346–L2347)

> Sets the reserved equipment change number column. This path is taken when the target record's `CHGE_KIKI_CHG_NO` was null/blank, meaning the equipment change number has not yet been assigned to the physical device.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setMap.setValue(JBSbatKU_T_KJAK_TG_TKKIKI.RSV_KIKI_CHG_NO, setParam[0])` // Set reserved equipment change number [-> "RSV_KIKI_CHG_NO"] |

**Block 2.2** — [ELSE] `[chgKikiChgNoFlg = "false"]` (L2349–L2350)

> Sets the changed equipment change number column. This path is taken when the target record already has a non-blank `CHGE_KIKI_CHG_NO`, meaning the equipment has already been physically changed and this column holds the change number of the replacement device.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setMap.setValue(JBSbatKU_T_KJAK_TG_TKKIKI.CHGE_KIKI_CHG_NO, setParam[0])` // Set changed equipment change number [-> "CHGE_KIKI_CHG_NO"] |

**Block 3** — [SET] Service contract line item number (L2352)

> Sets the service contract line item number regardless of branch.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setMap.setValue(JBSbatKU_T_KJAK_TG_TKKIKI.KKTK_SVC_KEI_NO, setParam[1])` // Set service contract line item number [-> "KKTK_SVC_KEI_NO"] |

**Block 4** — [SET] Update timestamp (L2353)

> Sets the system update timestamp for tracking when the record was last modified.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setMap.setValue(JBSbatKU_T_KJAK_TG_TKKIKI.UPD_DTM, setParam[2])` // Set update timestamp [-> "UPD_DTM"] |

**Block 5** — [NEW] Where condition map creation (L2355–L2356)

> Creates a separate map for the WHERE clause condition, isolating the primary key lookup from the set values.

| # | Type | Code |
|---|------|------|
| 1 | NEW | `whereMap = new JBSbatCommonDBInterface()` // Instantiate map for where condition |

**Block 6** — [SET] Where condition primary key (L2357)

> Sets the primary key lookup value to identify the target row for update.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `whereMap.setValue(JBSbatKU_T_KJAK_TG_TKKIKI.KOJIAK_TRGT_TAKNKIKI_NO, whereParam[0])` // Set target indoor equipment number [-> "KOJIAK_TRGT_TAKNKIKI_NO"] |

**Block 7** — [CALL] DB update execution (L2359–L2360)

> Executes the primary-key-based database update against the `KU_T_KJAK_TG_TKKIKI` table. This is the sole persistence operation — it updates the identified row with the prepared set values.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KU_T_KJAK_TG_TKKIKI.updateByPrimaryKeys(whereMap, setMap)` // Execute DB update [-> `KU_T_KJAK_TG_TKKIKI` table UPDATE] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KU_T_KJAK_TG_TKKIKI` | Table | Construction Project Target Indoor Equipment — database table storing indoor device records associated with construction project orders |
| `RSV_KIKI_CHG_NO` | Field | Reserved Equipment Change Number — planned/future change number assigned to an equipment device that has not yet been physically replaced |
| `CHGE_KIKI_CHG_NO` | Field | Changed Equipment Change Number — the change number of the replacement device after physical equipment swap is completed |
| `KKTK_SVC_KEI_NO` | Field | Service Contract Line Item Number — internal identifier for a service contract line item within the construction project |
| `UPD_DTM` | Field | Update Timestamp — system timestamp indicating when the record was last modified |
| `KOJIAK_TRGT_TAKNKIKI_NO` | Field | Construction Project Target Indoor Equipment Number — primary key identifier for a specific indoor device record within a construction project |
| `chgKikiChgNoFlg` | Parameter | Equipment Change Number Flag — boolean determining whether the change number being set is a reserved (planned) or changed (post-replacement) value |
| `kikiChgNoSaki` | Field | Equipment Change Number (Destination) — the equipment change number value being written to the record |
| `kktkSvcKeiNoSaki` | Field | Service Contract Line Item Number (Destination) — the service contract line item number value being written |
| JBSbatCommonDBInterface | Class | Batch database interface class used as a key-value map for constructing SQL set/where clause parameters |
| updateByPrimaryKeys | Method | Batch DB method that performs a primary-key-based UPDATE operation on the target table |
| 工事案件 (Kouji Anken) | Business term | Construction Project — refers to installation/construction work orders in the K-Opticom telecom system |
| 宅内機器 (Takunai Kiki) | Business term | Indoor Equipment — customer premises equipment (CPE) such as modems, routers, set-top boxes installed at customer locations |
| PK更新 (PK Akushin) | Business term | Primary Key Update — updating the primary key columns of a table row, used here to migrate equipment association data |
| 変更 (Henkou) | Business term | Change / Modification — refers to equipment replacement or change operations in the telecom service context |
| 予約 (Yoyaku) | Business term | Reservation — refers to a planned or reserved state, such as a reserved equipment change number that has been assigned but not yet physically applied |
