# Business Logic — JBSbatKKDelRun.updateDelTrnJssiDtmSvkeiuw() [84 LOC]

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

## 1. Role

### JBSbatKKDelRun.updateDelTrnJssiDtmSvkeiuw()

This method updates the **deletion execution date/time** stamp (消去実施年月日時分秒) for a **service contract detail** (サービス契約内訳) record in the K-Opticom customer base system. It is part of a batch deletion job (消去バッチ) that processes the removal of customer service data according to a deletion schedule. The method implements an **optimistic concurrency control pattern**: before updating, it reads the current `GENE_ADD_DTM` (世代登録 — generation registration timestamp) from the database and compares it against the value provided in the input message. If the values match, the update proceeds directly; if they differ (indicating the record was modified by another process), the method adapts the where clause to use the fresher database timestamp, ensuring the update is applied against the latest row version. This prevents lost-update anomalies in concurrent batch processing. The method is a **dedicated branch handler** called from the dispatching method `updateDelTrnJssiDtm()`, which routes to this method when the deletion target type (消去対象種類) is SIP User ID, legacy ISP Authentication ID, or OABJ phone number.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["updateDelTrnJssiDtmSvkeiuw(inMap)"])
    START --> CREATE_SET_MAP["Create setMap: JBSbatCommonDBInterface"]
    CREATE_SET_MAP --> SET_DEL_DTM["SET SVCTK_BUT_DEL_TRN_JSSI_DTM = this.sysDate"]
    SET_DEL_DTM --> CREATE_WHERE_MAP["Create whereMap: JBSbatCommonDBInterface"]
    CREATE_WHERE_MAP --> SET_WHERE_SVKEIUW_NO["SET SVC_KEI_UCWK_NO = inMap.SVKEIUW_NO"]
    SET_WHERE_SVKEIUW_NO --> SET_WHERE_GENE_ADD_DTM["SET GENE_ADD_DTM = inMap.SVKEIUW_GADTM"]
    SET_WHERE_GENE_ADD_DTM --> CREATE_PARAM["Create param[]: new String[2]"]
    CREATE_PARAM --> SET_PARAM_0["SET param[0] = inMap.SVKEIUW_NO"]
    SET_PARAM_0 --> SET_PARAM_1["SET param[1] = super.opeDate"]
    SET_PARAM_1 --> EXEC_SELECT["CALL executeKK_T_SVC_KEI_UCWK_KK_SELECT_038(param)"]
    EXEC_SELECT --> SELECT_NEXT["SELECT: db_KK_T_SVC_KEI_UCWK_KK038.selectNext()"]
    SELECT_NEXT --> GET_SEDAI["GET sedai = getSvckeiuwMap.GENE_ADD_DTM"]
    GET_SEDAI --> COND_DEL_TRGT["sedai == inMap.SVKEIUW_GADTM"]
    COND_DEL_TRGT -->|True| UPDATE_NO_MOD["UPDATE: db_KK_T_SVC_KEI_UCWK.updateByPrimaryKeys(whereMap, setMap)"]
    COND_DEL_TRGT -->|False| SET_WHERE_SEDAI["SET whereMap GENE_ADD_DTM = sedai"]
    SET_WHERE_SEDAI --> UPDATE_WITH_SEDAI["UPDATE: db_KK_T_SVC_KEI_UCWK.updateByPrimaryKeys(whereMap, setMap)"]
    UPDATE_NO_MOD --> END_NODE(["Return / Next"])
    UPDATE_WITH_SEDAI --> END_NODE
```

**Business meaning of the optimistic concurrency check:**

The `GENE_ADD_DTM` field represents the "generation registration timestamp" (世代登録年月日時分秒) — a versioning column on the `KK_T_SVC_KEI_UCWK` table. The input message carries the expected value (`inMap.SVKEIUW_GADTM`). By fetching the current database value and comparing, the method determines whether the record has been modified since the batch job originally read it. If the values differ, the method updates the `whereMap` to match the fresher `sedai` value, thereby applying the update against the latest version of the record and avoiding a lost update.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message carrying deletion parameters for a service contract detail record. Contains the service contract detail number (`SVKEIUW_NO`) and the expected generation registration timestamp (`SVKEIUW_GADTM`). This is the standardized batch input envelope used throughout the K-Opticom batch framework. |
| 2 | `this.sysDate` | `String` (instance field) | The batch system date/time (世代登録年月日時分秒), used as the new value for the deletion execution date/time field. |
| 3 | `super.opeDate` | `String` (inherited field) | Batch operation date (バッチ運用日), used as a parameter in the SQL select to identify records for the current batch run. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatCommonDBInterface.setValue` | - | - | Sets the deletion execution date/time field (`SVCTK_BUT_DEL_TRN_JSSI_DTM`) to the system date |
| U | `JBSbatCommonDBInterface.setValue` | - | - | Sets the service contract detail number (`SVC_KEI_UCWK_NO`) as a where clause key |
| U | `JBSbatCommonDBInterface.setValue` | - | - | Sets the expected generation registration timestamp (`GENE_ADD_DTM`) as a where clause condition |
| R | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_038` | KK_T_SVC_KEI_UCWK_KK_SELECT_038 | KK_T_SVC_KEI_UCWK | Retrieves the current record (optimistic concurrency check) using service contract detail number and batch operation date |
| R | `db_KK_T_SVC_KEI_UCWK_KK038.selectNext` | - | KK_T_SVC_KEI_UCWK | Fetches the next result row from the SELECT_038 query result set |
| U | `JBSbatCommonDBInterface.setValue` | - | - | Overrides the where clause `GENE_ADD_DTM` with the fresh database value (concurrency adaptation) |
| U | `db_KK_T_SVC_KEI_UCWK.updateByPrimaryKeys` | - | KK_T_SVC_KEI_UCWK | Updates the service contract detail record with the new deletion execution date/time via primary key match |
| U | `db_KK_T_SVC_KEI_UCWK.updateByPrimaryKeys` | - | KK_T_SVC_KEI_UCWK | Updates the service contract detail record with the concurrency-adapted where clause |

**DB Table:** `KK_T_SVC_KEI_UCWK` (サービス契約内訳 — Service Contract Detail)

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `updateDelTrnJssiDtm` (Batch) | `JBSbatKKDelRun.updateDelTrnJssiDtm` -> `JBSbatKKDelRun.updateDelTrnJssiDtmSvkeiuw` | `updateByPrimaryKeys [U] KK_T_SVC_KEI_UCWK` |

**Caller detail:** The sole caller is `updateDelTrnJssiDtm()` in the same class, which acts as a **dispatcher**. It reads `DEL_TRGT_SBT` (消去対象種類) from the input map and routes to the appropriate branch handler. This method is invoked when `delTrgtSbt` matches one of: `DEL_TRGT_SBT_SIP_USER_ID` ("17" — SIP User ID), `DEL_TRGT_SBT_ISP_NINSYO_ID_OLD` ("02" — Legacy ISP Authentication ID), or `DEL_TRGT_SBT_OABJ_TELNO` ("09" — OABJ Phone Number).

## 6. Per-Branch Detail Blocks

**Block 1** — SET `(Create setMap)` (L1168-L1169)

> Creates the set map containing the new deletion execution date/time value to be written to the database.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setMap = new JBSbatCommonDBInterface()` |
| 2 | SET | `setMap.setValue("SVCTK_BUT_DEL_TRN_JSSI_DTM", this.sysDate)` // SVCTK_BUT_DEL_TRN_JSSI_DTM = "サービス提供物消去処理実施年月日時分秒" |

**Block 2** — SET `(Create whereMap)` (L1171-L1174)

> Creates the where map with primary key and optimistic concurrency condition.

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereMap = new JBSbatCommonDBInterface()` |
| 2 | SET | `whereMap.setValue("SVC_KEI_UCWK_NO", inMap.getString(JBSbatKKIFM161.SVKEIUW_NO))` // Where key: Service contract detail number |
| 3 | SET | `whereMap.setValue("GENE_ADD_DTM", inMap.getString(JBSbatKKIFM161.SVKEIUW_GADTM))` // Optimistic concurrency: expected generation timestamp |

**Block 3** — SET `(Create param for SELECT)` (L1177-L1181)

> Prepares parameters for the optimistic concurrency check SELECT.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param = null` |
| 2 | SET | `param = new String[2]` |
| 3 | SET | `param[0] = inMap.getString(JBSbatKKIFM161.SVKEIUW_NO)` // Deletion target data (post-check): Service contract detail number |
| 4 | SET | `param[1] = super.opeDate` // Batch operation date |

**Block 4** — CALL `(Optimistic concurrency check SELECT)` (L1183)

> Executes the SELECT_038 SQL definition to fetch the current record from KK_T_SVC_KEI_UCWK.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_038(param)` |

**Block 5** — SET `(Fetch current GENE_ADD_DTM)` (L1186-L1188)

> Retrieves the result row and extracts the current generation registration timestamp.

| # | Type | Code |
|---|------|------|
| 1 | SET | `getSvckeiuwMap = db_KK_T_SVC_KEI_UCWK_KK038.selectNext()` |
| 2 | SET | `sedai = (String)getSvckeiuwMap.getString("GENE_ADD_DTM")` // Service contract generation registration |

**Block 6** — IF/ELSE `(Concurrency check: sedai matches input GADTM?)` (L1189-L1214)

> Compares the database's current GENE_ADD_DTM against the expected value from the input. This is the optimistic concurrency guard.

| # | Type | Code |
|---|------|------|
| 1 | COND | `sedai.equals(inMap.getString(JBSbatKKIFM161.SVKEIUW_GADTM))` |

**Block 6.1** — IF branch `(Match: no modification)` (L1191-L1193)

> The record has not been modified since the batch read. Proceed with the original where clause.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVC_KEI_UCWK.updateByPrimaryKeys(whereMap, setMap)` // Execute DB access |

**Block 6.2** — ELSE branch `(Mismatch: record was modified)` (L1195-L1200)

> The record was modified by another process. Adapt the where clause to the fresher timestamp before updating, ensuring the update targets the correct row version.

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereMap.setValue("GENE_ADD_DTM", sedai)` // Override with fresher DB value |
| 2 | EXEC | `db_KK_T_SVC_KEI_UCWK.updateByPrimaryKeys(whereMap, setMap)` // Execute DB access |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `SVKEIUW_NO` | Field | Service contract detail number (サービス契約内訳番号) — unique internal identifier for a service contract line item |
| `SVKEIUW_GADTM` | Field | Service contract detail generation registration timestamp (サービス契約内訳世代登録年月日時分秒) — version stamp for optimistic concurrency control |
| `SVC_KEI_UCWK_NO` | Field | Database column for service contract detail number |
| `GENE_ADD_DTM` | Field | Generation registration timestamp (世代登録年月日時分秒) — version/revision column on `KK_T_SVC_KEI_UCWK` table |
| `SVCTK_BUT_DEL_TRN_JSSI_DTM` | Field | Service provision deletion execution date/time (サービス提供物消去処理実施年月日時分秒) — the timestamp of when the deletion was executed |
| `sysDate` | Field | Batch system date/time (世代登録年月日時分秒) — current system datetime used as the update value |
| `opeDate` | Field | Batch operation date (バッチ運用日) — the scheduled date for the current batch run |
| `inMap` | Parameter | Input message envelope (入力電文) — standardized batch input carrying deletion target data |
| `KK_T_SVC_KEI_UCWK` | Table | Service contract detail table (サービス契約内訳テーブル) — stores individual service contract line items |
| `KK_SELECT_038` | SQL Key | SQL definition key for fetching service contract detail records used in the optimistic concurrency check |
| `updateDelTrnJssiDtm` | Method | Deletion execution date/time update dispatcher (消去実施年月日時分秒の更新処理の分岐) — routes to branch handlers based on deletion target type |
| `DEL_TRGT_SBT` | Field | Deletion target type (消去対象種類) — classification code specifying what type of data is being deleted |
| `DEL_TRGT_SBT_SIP_USER_ID` | Constant | SIP User ID ("17") — one of the deletion target types routed to this method |
| `DEL_TRGT_SBT_ISP_NINSYO_ID_OLD` | Constant | Legacy ISP Authentication ID ("02") — deprecated ISP authentication ID routed to this method |
| `DEL_TRGT_SBT_OABJ_TELNO` | Constant | OABJ Phone Number ("09") — OABJ (over-access blocking judge) phone number routed to this method |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity used in deletion processing |
| Batching (消去バッチ) | Business process | Scheduled batch job that removes customer service data according to deletion schedules, part of the customer base deletion system (顧客基幹消去システム) |
