# Business Logic — JBSbatKKSkaWrkCnclProc.executeKK_T_OP_SVC_KEI_PKSELECT() [10 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKSkaWrkCnclProc` |
| Layer | Service (Batch Processing — KKS Ska Work Cancellation Processing) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKSkaWrkCnclProc.executeKK_T_OP_SVC_KEI_PKSELECT()

This method performs a **primary key-based lookup** (ＰＫ検索 / PK Search) on the operation service contract line item table (`KK_T_OP_SVC_KEI`). It serves as the dedicated data access gateway within the KKS Ska Work Cancellation Processing batch — retrieving a specific service contract record using its composite primary key, which consists of the **service contract detail number** (`OP_SVC_KEI_NO`) and the **generation addition date/time** (`GENE_ADD_DTM`).

The method follows a **delegation pattern**: it constructs a parameter map with the provided primary key values, then delegates the actual database query to the `db_KK_T_OP_SVC_KEI.selectByPrimaryKeys()` method, which is a `JBSbatSQLAccess` instance initialized against the `KK_T_OP_SVC_KEI` table. This pattern centralizes PK-based retrieval logic for the operation service contract entity across the batch processing flow, ensuring consistent key construction and reuse.

Within the larger system, this method is called during cancellation processing to verify whether an operation service contract is in a cancellable state (contract cancelled or dissolution completed). If the contract is neither, the batch proceeds with cancellation registration logic. The method encapsulates a standard **CRUD Read (R)** operation on the operation service contract entity.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKK_T_OP_SVC_KEI_PKSELECT(whereParam)"])
    STEP1["Create JBSbatCommonDBInterface whereMap"]
    STEP2["whereMap.setValue('OP_SVC_KEI_NO', whereParam[0])"]
    STEP3["whereMap.setValue('GENE_ADD_DTM', whereParam[1])"]
    STEP4["db_KK_T_OP_SVC_KEI.selectByPrimaryKeys(whereMap)"]
    END_RETURN["Return JBSbatCommonDBInterface result"]

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> END_RETURN
```

**Processing Description:**
1. **Map Creation**: A `JBSbatCommonDBInterface` instance named `whereMap` is instantiated to serve as the query parameter container. This object functions as a key-value map for database access.
2. **Primary Key Construction**: The two PK fields are set into the map:
   - `OP_SVC_KEI_NO` (Service Contract Detail Number) from `whereParam[0]`
   - `GENE_ADD_DTM` (Generation Addition Date/Time) from `whereParam[1]`
3. **PK-Based Query Execution**: The `selectByPrimaryKeys()` method on `db_KK_T_OP_SVC_KEI` (a `JBSbatSQLAccess` instance) executes a SELECT query against the `KK_T_OP_SVC_KEI` table using the composite primary key.
4. **Result Return**: The resulting `JBSbatCommonDBInterface` (containing the retrieved record's data as key-value pairs) is returned to the caller.

There are no conditional branches in this method — it is a straightforward, linear data access method.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `whereParam` | `Object[]` | An array containing the composite primary key values for the operation service contract record. Index 0 holds the **Service Contract Detail Number** (`OP_SVC_KEI_NO`), and Index 1 holds the **Generation Addition Date/Time** (`GENE_ADD_DTM`). This parameter uniquely identifies a single record in the `KK_T_OP_SVC_KEI` table. The caller constructs this array after performing a preliminary query that retrieves the `GENE_ADD_DTM` value for the target `OP_SVC_KEI_NO`. |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_OP_SVC_KEI` | `JBSbatSQLAccess` | The database access instance initialized against the `KK_T_OP_SVC_KEI` table. Used to execute the primary key SELECT query via `selectByPrimaryKeys()`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_OP_SVC_KEI.selectByPrimaryKeys(whereMap)` | KK_T_OP_SVC_KEI (DAO Layer) | `KK_T_OP_SVC_KEI` | Selects a single operation service contract line item record by its composite primary key (`OP_SVC_KEI_NO`, `GENE_ADD_DTM`). Returns a `JBSbatCommonDBInterface` containing the record's fields as key-value pairs. |

**CRUD Classification: R (Read)** — This method performs a primary key-based SELECT to retrieve a specific operation service contract record. No create, update, or delete operations occur.

## 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: `selectByPrimaryKeys` [R] `KK_T_OP_SVC_KEI`

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKSkaWrkCnclProc | `JBSbatKKSkaWrkCnclProc.execute()` -> `JBSbatKKSkaWrkCnclProc.executeKK_T_OP_SVC_KEI_PKSELECT()` | `selectByPrimaryKeys [R] KK_T_OP_SVC_KEI` |

**Call Chain Detail:**

1. **Batch: JBSbatKKSkaWrkCnclProc.execute()** — The main processing method of the KKS Ska Work Cancellation Processing batch. Within its flow, after a preliminary query (`executeKK_T_OP_SVC_KEI_KK_SELECT_094`) retrieves a service contract map, the batch calls `executeKK_T_OP_SVC_KEI_PKSELECT()` with the composite PK (`OP_SVC_KEI_NO` and `GENE_ADD_DTM`) to perform an exact record lookup. The returned record's `OP_SVC_KEI_STAT` field is then checked against cancellation-completed status values. If the status is neither "dissolution completed" nor "contract cancelled," the batch proceeds with cancellation registration (`insertOpsvckei`).

## 6. Per-Branch Detail Blocks

**Block 1** — [SET / EXEC] `(Map construction and PK value assignment)` (L467–L470)

This block constructs the query parameter map and populates it with the primary key values from the input parameter array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface whereMap = new JBSbatCommonDBInterface();` // Create the query parameter map (条件マップの作成 — Create condition map) |
| 2 | EXEC | `whereMap.setValue("OP_SVC_KEI_NO", whereParam[0]);` // Set service contract detail number into the map |
| 3 | EXEC | `whereMap.setValue("GENE_ADD_DTM", whereParam[1]);` // Set generation addition date/time into the map |

**Block 2** — [RETURN] `(Database query execution and result return)` (L473)

This block executes the primary key-based database query and returns the result.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return db_KK_T_OP_SVC_KEI.selectByPrimaryKeys(whereMap);` // Execute SELECT by PK and return the result (DBアクセスを実行します — Execute DB access) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `OP_SVC_KEI_NO` | Field | Operation Service Contract Detail Number — unique identifier for a service contract line item within the system |
| `GENE_ADD_DTM` | Field | Generation Addition Date/Time — timestamp indicating when this version of the contract record was generated; used as part of the composite primary key for optimistic concurrency control |
| `OP_SVC_KEI_STAT` | Field | Operation Service Contract Status — the current lifecycle status of a service contract (e.g., dissolution completed, contract cancelled, active) |
| KK_T_OP_SVC_KEI | Table | Operation Service Contract Line Item Table — database table storing service contract line item records with their status, identifiers, and metadata |
| JBSbatSQLAccess | Class | Database Access Utility — a common batch framework class providing CRUD methods (`selectByPrimaryKeys`, `insertByPrimaryKeys`, etc.) for consistent database interaction |
| JBSbatCommonDBInterface | Class | Common Database Interface — a key-value data structure used to pass query parameters and receive query results between service methods and the database access layer |
| PK | Acronym | Primary Key — the unique identifier combination used to locate a single record in a database table |
| PK検索 | Acronym (Japanese) | PK Search — primary key-based database lookup operation |
| KKS | Acronym | (Internal batch processing domain — KKS Work Cancellation Processing batch) |
| Ska | Acronym | (Internal domain term — related to work cancellation workflow) |
| Wrk | Abbreviation | Work — referring to processing work items |
| Cncl | Abbreviation | Cancellation — referring to cancellation processing |
| execute | Japanese | 実行 — execute/run |
| 条件 | Japanese | Condition — refers to the query condition/filter criteria |
| マップ | Japanese | Map — key-value data structure |
| 作成 | Japanese | Create/Make — creating objects or data structures |
| DBアクセス | Japanese | DB Access — direct database query execution |
| 検索 | Japanese | Search/Select — database retrieval operation |
| 結果 | Japanese | Result — the outcome/data returned from a query |
| 引数 | Japanese | Argument/Parameter — values passed into the method |
| 項目 | Japanese | Field/Item — a database column or data attribute |
| 値 | Japanese | Value — the data content of a field |
| 登録 | Japanese | Registration/Insert — data persistence operation |
| 全般 | Japanese | General/broad — indicating all exception types |
| 解約済み | Japanese | Dissolution Completed — a contract status indicating dissolution has been finalized |
| キャンセル済み | Japanese | Contract Cancelled — a contract status indicating cancellation has been finalized |