# Business Logic — JBSbatTUBmpKojiFinTrn.executeTU_T_BMP_KOJI_PKUPDATE() [15 LOC]

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

## 1. Role

### JBSbatTUBmpKojiFinTrn.executeTU_T_BMP_KOJI_PKUPDATE()

This method performs a **primary-key-based update** on the `TU_T_BMP_KOJI` table, which stores batch work-order status information for the `TUBmpKoji` (batch construction/work-order) domain. Specifically, it updates two fields — the work-order status (`BMP_KOJI_STAT`) and the work-order completion date (`BMP_KOJI_FIN_YMD`) — for a single existing record identified by its composite primary key (work-order number `BMP_KOJI_NO` and gene add timestamp `GENE_ADD_DTM`). The method is a **private batch helper** that encapsulates the pattern of converting raw parameter arrays into structured `JBSbatCommonDBInterface` maps, then delegating to the SQL access layer's `updateByPrimaryKeys` operation. It plays the role of a **CRUD update endpoint** within the batch processing flow: called by `execute()` to persist completed or updated work-order records after batch job logic has determined the new status. The method implements a straightforward **data-mapping-and-delegation** pattern — no conditional branching, no routing, no aggregation — making it a clean, single-responsibility database updater.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeTU_T_BMP_KOJI_PKUPDATE(setParam, whereParam)"])
    STEP1["Create setMap (JBSbatCommonDBInterface)"]
    STEP2["Set BMP_KOJI_STAT from setParam[0]"]
    STEP3["Set BMP_KOJI_FIN_YMD from setParam[1]"]
    STEP4["Create whereMap (JBSbatCommonDBInterface)"]
    STEP5["Set BMP_KOJI_NO from whereParam[0]"]
    STEP6["Set GENE_ADD_DTM from whereParam[1]"]
    STEP7["Call db_TU_T_BMP_KOJI.updateByPrimaryKeys(whereMap, setMap)"]
    END_NODE(["Return / Next"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    STEP6 --> STEP7
    STEP7 --> END_NODE
```

This is a linear, branchless method. The flow consists of:

1. **Set map construction** (L311–L313): Create a `JBSbatCommonDBInterface` object and populate it with the two fields to update, extracted from the `setParam` array.
2. **Where map construction** (L315–L318): Create a second `JBSbatCommonDBInterface` object and populate it with the primary key fields, extracted from the `whereParam` array.
3. **Database update** (L322): Delegate to `db_TU_T_BMP_KOJI.updateByPrimaryKeys()`, which performs the SQL `UPDATE` statement targeting the record matching the primary key in `whereMap`.

No conditional branches, loops, or error handling exist within this method.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `setParam` | `Object[]` | An array of **new values** for the fields to be updated on the work-order record. Index `[0]` carries the new batch work-order status (`BMP_KOJI_STAT`), and index `[1]` carries the batch work-order completion date/time (`BMP_KOJI_FIN_YMD`). These values represent the outcome of batch processing — e.g., a status transition (such as "in progress" to "completed") and the timestamp when the work-order was finalized. |
| 2 | `whereParam` | `Object[]` | An array of **primary key values** used to identify the exact record to update. Index `[0]` carries the batch work-order number (`BMP_KOJI_NO`), and index `[1]` carries the gene add timestamp (`GENE_ADD_DTM`) — a unique identifier ensuring the correct version of the record is targeted, preventing stale-write conflicts. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_TU_T_BMP_KOJI` | `JBSbatSQLAccess` | SQL access delegate for the `TU_T_BMP_KOJI` table. Initialized during batch setup (L79) with the common batch context and table name constant. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `db_TU_T_BMP_KOJI.updateByPrimaryKeys(whereMap, setMap)` | — | `TU_T_BMP_KOJI` | Updates the work-order record identified by primary key (`BMP_KOJI_NO`, `GENE_ADD_DTM`), setting `BMP_KOJI_STAT` and `BMP_KOJI_FIN_YMD` to the new values provided in `setParam`. |

**Additional internal operations (object-level, not CRUD):**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | `JBSbatCommonDBInterface.setValue("BMP_KOJI_STAT", setParam[0])` | JDKStructuredMap | — | Sets the work-order status value in the update parameter map. |
| — | `JBSbatCommonDBInterface.setValue("BMP_KOJI_FIN_YMD", setParam[1])` | JDKStructuredMap | — | Sets the work-order completion date/time value in the update parameter map. |
| — | `JBSbatCommonDBInterface.setValue("BMP_KOJI_NO", whereParam[0])` | JDKStructuredMap | — | Sets the work-order number in the primary key lookup map. |
| — | `JBSbatCommonDBInterface.setValue("GENE_ADD_DTM", whereParam[1])` | JDKStructuredMap | — | Sets the gene add timestamp in the primary key lookup map. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatTUBmpKojiFinTrn.execute() | `execute()` -> `executeTU_T_BMP_KOJI_PKUPDATE(setParam, whereParam)` | `updateByPrimaryKeys [U] TU_T_BMP_KOJI` |

**Upstream context:** The method is called from `JBSbatTUBmpKojiFinTrn.execute()`, which is the main entry point for this batch job. The batch processes `TU_T_BMP_KOJI` (Batch Construction Work Order) records, and this method is invoked to persist status transitions and completion timestamps for specific work orders.

**Terminal operations from this method:**
- `db_TU_T_BMP_KOJI.updateByPrimaryKeys` → SQL `UPDATE` on table `TU_T_BMP_KOJI`

## 6. Per-Branch Detail Blocks

**Block 1** — SET (set map construction) (L311)

> Creates the parameter map holding the new values to be written to the database.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface setMap = new JBSbatCommonDBInterface();` // Create set-value map |
| 2 | EXEC | `setMap.setValue("BMP_KOJI_STAT", setParam[0]);` // Set work-order status from first element of setParam |
| 3 | EXEC | `setMap.setValue("BMP_KOJI_FIN_YMD", setParam[1]);` // Set work-order completion date/time from second element of setParam |

**Block 2** — SET (where map construction) (L315)

> Creates the parameter map holding the primary key values used to locate the record to update.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface whereMap = new JBSbatCommonDBInterface();` // Create where/condition map |
| 2 | EXEC | `whereMap.setValue("BMP_KOJI_NO", whereParam[0]);` // Set work-order number (PK part 1) from first element of whereParam |
| 3 | EXEC | `whereMap.setValue("GENE_ADD_DTM", whereParam[1]);` // Set gene add timestamp (PK part 2) from second element of whereParam |

**Block 3** — CALL (database update) (L322)

> Executes the primary-key-based update on the database table.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_TU_T_BMP_KOJI.updateByPrimaryKeys(whereMap, setMap);` // Update TU_T_BMP_KOJI record matching PK from whereMap, applying values from setMap |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `BMP_KOJI_STAT` | Field | Batch construction work-order status — indicates the current state of a batch work-order (e.g., pending, in progress, completed). |
| `BMP_KOJI_FIN_YMD` | Field | Batch construction work-order completion date/time — the timestamp when the work-order was completed. |
| `BMP_KOJI_NO` | Field | Batch construction work-order number — the unique identifier for a batch work-order record. |
| `GENE_ADD_DTM` | Field | Gene add date/time — a system-generated timestamp serving as the second part of the composite primary key, ensuring version uniqueness for the record. |
| `TU_T_BMP_KOJI` | Table | Batch Construction Work Order table — the database table storing batch work-order records. |
| `JBSbatCommonDBInterface` | Type | A map-like data structure used to pass parameter values between the batch service layer and the SQL access layer. |
| `JBSbatSQLAccess` | Type | The batch SQL access delegate that wraps database operations (SELECT, UPDATE, INSERT, DELETE) for a specific table. |
| `updateByPrimaryKeys` | Method | A database operation that performs an SQL UPDATE targeting a record identified by its primary key columns. |
| `setParam` | Parameter | The "set" parameter array — carries the new field values to write. |
| `whereParam` | Parameter | The "where" parameter array — carries the primary key values to locate the record. |
| Batch (バッチ) | Business term | A batch processing job that operates on records in bulk, typically scheduled or triggered independently of user interaction. |
| PK (ＰＫ / Primary Key) | Business term | Primary Key — the unique identifier for a database record. |
| DBアクセス (DB Access) | Business term | Database access — the operation of reading from or writing to the database. |
