# Business Logic — JBSbatKKAdChgTekkyoKjFinUpd.execute() [124 LOC]

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

## 1. Role

### JBSbatKKAdChgTekkyoKjFinUpd.execute()

This method processes **address-change-associated withdrawal work completion notifications** (住所変更具中撤去工事完了データ). It is a batch service that receives input data containing service contract numbers, work project case numbers, application numbers, and work project case implementation dates. Upon receiving this data, the method validates the input, searches for associated application details and their linked abnormal contracts (異動予約), and updates those abnormal contracts with the withdrawal work completion information.

The method implements a **delegation pattern** — it orchestrates a chain of internal helper methods that each handle a specific concern: input extraction, single-field validation, application detail lookup, abnormal contract lookup, service contract disposal control verification, timestamp concurrency checking, contract record updates, and disposal control table updates. The method is invoked as part of the customer base system batch processing pipeline, handling work completion notifications that are triggered when a withdrawal (cancellation) work order — whose cancellation settlement date is tied to the same operational date as the work completion — needs to be reflected in the system.

The method has conditional branches: if input validation fails, it sets an error flag and terminates early. If no application details are found for the given application number and service contract number, it terminates gracefully (no error). If abnormal contracts exist, it iterates through each one, verifying the service contract disposal control record and timestamp before performing the update.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute() Start"])

    START --> EXTRACT["Extract Input Fields from inMap"]
    EXTRACT --> LOG_START["Log debug: execute_START"]
    LOG_START --> INMAP["HashMap rsMap = inMap.getMap()"]
    INMAP --> SINGLECHECK{"isSingleCheckKKIFM629_INF1"}

    SINGLECHECK -->|Check Failed| SETERR["setErrFlg(true)"]
    SETERR --> LOG_END_ERR["Log debug: execute_END"]
    LOG_END_ERR --> RET_ERR(["Return null"])

    SINGLECHECK -->|Check Passed| GETMSKMDTL["getMskmDtlNo"]
    GETMSKMDTL --> LISTEMPTY{"mskm_dtl_inf_list.size != 0"}

    LISTEMPTY -->|Empty| LOG_END_NODATA["Log debug: execute_END"]
    LOG_END_NODATA --> RET_NODATA(["Return null"])

    LISTEMPTY -->|Has Items| INITSVC["svcKeiNoList.add(inSvcKeiNo)"]
    INITSVC --> FORJ{"For each mskm_dtl_inf"}
    FORJ --> RESET["mskmdtl_mskm_dtl_no = empty"]
    RESET --> GETITEM["db_map = mskm_dtl_inf_list.get(j)"]
    GETITEM --> EXTRACTDTL["Extract MSKM_DTL_NO"]
    EXTRACTDTL --> LOGSEARCH["Log: Search abnormal contract"]
    LOGSEARCH --> GETIDO["getIdoRsv"]
    GETIDO --> IDOLISTEMPTY{"ido_rsv_inf_list.size != 0"}

    IDOLISTEMPTY -->|Empty| FORJ_NEXT["Next j iteration"]
    FORJ_NEXT --> FORJ_CHECK{Continue?}
    FORJ_CHECK -->|Yes| FORJ
    FORJ_CHECK -->|No| LOG_END_ALL["Log debug: execute_END"]
    LOG_END_ALL --> RET_ALL(["Return null"])

    IDOLISTEMPTY -->|Has Items| FORK{"For each ido_rsv_inf"}
    FORK --> SVCCHECK["searchSvkeiExcCtrl"]
    SVCCHECK --> SVCELTY{"svcKeiNo null?"}

    SVCELTY -->|Yes| LOGERRCTRL["Log business error: EKKB0360KE"]
    LOGERRCTRL --> LOGDBGCTRL["Log debug: ctrl table missing"]
    LOGDBGCTRL --> LOG_END_CTRL["Log debug: execute_END"]
    LOG_END_CTRL --> RET_CTRL(["Return null"])

    SVCELTY -->|No| TSCHK["timeStampCheckSvcExecHaita"]
    TSCHK --> TSEMPTY{"Stamp check failed?"}

    TSEMPTY -->|Yes| LOG_END_TS["Log debug: execute_END"]
    LOG_END_TS --> RET_TS(["Return null"])

    TSEMPTY -->|No| EXTRACTIDO["Extract IDO_RSV_NO RSV_APLY_YMD SVC_CHRG_ENDYMD"]
    EXTRACTIDO --> SETPARAM["Build setParam array size 6"]
    SETPARAM --> SETWHERE["Build whereParam[0] = ido_rsv_no"]
    SETWHERE --> CALLUPDATE["executeKK_T_IDO_RSV_KK_PKUPDATE"]
    CALLUPDATE --> CALLCTRL["updateSvkeiExecCtrl"]
    CALLCTRL --> FORK_NEXT["Next k iteration"]
    FORK_NEXT --> FORK_CHECK2{Continue?}
    FORK_CHECK2 -->|Yes| FORK
    FORK_CHECK2 -->|No| FORJ_NEXT
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message containing address-change-associated withdrawal work completion data. Carries four fields: service contract number (`SVC_KEI_NO`), work project case number (`KOJI_ANK_NO`), application number (`MSKM_NO`), and work project case implementation date (`KOJIAK_JSSI_YMD`). |
| 2 | `super.opeDate` | inherited field | Batch operational date — the date the batch job is running. Used as the update operational date for abnormal contracts. |
| 3 | `super.batchUserId` | inherited field | Batch user ID — identifies the operator/account performing the batch update. |
| 4 | `super.jobid` | inherited field | Batch job ID — the processing transaction ID for the batch job. |
| 5 | `super.logPrint` | inherited field | Logging utility providing debug and business error log output. |
| 6 | `super.commonItem` | inherited field | Common item holding error flag (`setErrFlg`), shared across batch services. |
| 7 | `super.opeDate` | inherited field | Operational date for updates, taken from batch configuration. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `isSingleCheckKKIFM629_INF1` | - | - | Input data single-field validation check for address-change withdrawal work completion data |
| R | `getItemvalueMap` | - | - | Returns error-related item value mapping (field name to display label) |
| R | `getMskmDtlNo` | EKK0361A010SC | `KK_T_MSKM_DTL` | Searches for application details linked to the given application number and service contract number |
| R | `getIdoRsv` | EKK0361A010SC | `KK_T_IDO_RSV` | Searches for abnormal contracts (reservation records) linked to the given application detail number |
| R | `searchSvkeiExcCtrl` | - | `KK_T_SVKEI_EXC_CTRL` | Verifies that the service contract disposal control record exists for the given service contract number list |
| - | `timeStampCheckSvcExecHaita` | - | - | Timestamp concurrency check to prevent stale updates on service contract disposal control |
| R | `JBSbatStringUtil.Rtrim` | - | - | Utility method for right-trimming string whitespace |
| R | `JBSbatKKIFM629.SVC_KEI_NO` | - | - | Constant key for service contract number field |
| R | `JBSbatKKIFM629.KOJI_ANK_NO` | - | - | Constant key for work project case number field |
| R | `JBSbatKKIFM629.MSKM_NO` | - | - | Constant key for application number field |
| R | `JBSbatKKIFM629.KOJIAK_JSSI_YMD` | - | - | Constant key for work project case implementation date field |
| U | `JBSbatKKAdChgTekkyoKjFinUpd.executeKK_T_IDO_RSV_KK_PKUPDATE` | EKK0361A010CBS | `KK_T_IDO_RSV` | Updates the abnormal contract record with work completion date, system datetime, operator account, operational date, transaction ID, and service charge end date |
| U | `JBSbatKKAdChgTekkyoKjFinUpd.updateSvkeiExecCtrl` | EKK0361A010CBS | `KK_T_SVKEI_EXC_CTRL` | Updates the service contract disposal control record after successful contract update |
| - | `JBSbatDateUtil.getSystemDateTime` | - | - | Returns the current system date and time string |
| - | `JBSbatLogUtil.printDebugLog` | - | - | Writes debug-level log entries |
| - | `JBSbatLogUtil.printBusinessErrorLog` | - | - | Writes business-level error log (error code + message parameters) |
| R | `JBSbatCommonDBInterface.getString` | - | - | Retrieves field value from database interface row |
| R | `JBSbatCommonDBInterface` | - | `KK_T_MSKM_DTL` / `KK_T_IDO_RSV` | Database access rows returned from SQL queries for application details and abnormal contracts |
| U | `JBSbatKK_T_SVKEI_EXC_CTRL` | EKK0361A010CBS | `KK_T_SVKEI_EXC_CTRL` | Service contract disposal control table — updated to reflect the latest update timestamp after abnormal contract processing |

## 5. Dependency Trace

This method is a **standalone batch service**. No caller classes referencing `JBSbatKKAdChgTekkyoKjFinUpd.execute()` were found in the codebase. It is invoked as part of the customer base system batch processing framework, likely triggered by the batch scheduling configuration (batch job definition) that routes address-change withdrawal work completion notifications to this service.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgTekkyoKjFinUpd (scheduled batch) | `BatchScheduler` -> `JBSbatBusinessService.execute` -> `JBSbatKKAdChgTekkyoKjFinUpd.execute` | `getMskmDtlNo [R] KK_T_MSKM_DTL`, `getIdoRsv [R] KK_T_IDO_RSV`, `searchSvkeiExcCtrl [R] KK_T_SVKEI_EXC_CTRL`, `executeKK_T_IDO_RSV_KK_PKUPDATE [U] KK_T_IDO_RSV`, `updateSvkeiExecCtrl [U] KK_T_SVKEI_EXC_CTRL` |

## 6. Per-Branch Detail Blocks

**Block 1** — [EXTRACT] (L126)

> Extract input fields from the input message map and log debug start information.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inSvcKeiNo = JBSbatStringUtil.Rtrim(inMap.getString(JBSbatKKIFM629.SVC_KEI_NO))` // Service contract number |
| 2 | SET | `inKojiAnkNo = JBSbatStringUtil.Rtrim(inMap.getString(JBSbatKKIFM629.KOJI_ANK_NO))` // Work project case number |
| 3 | SET | `inMskmNo = JBSbatStringUtil.Rtrim(inMap.getString(JBSbatKKIFM629.MSKM_NO))` // Application number |
| 4 | SET | `inKojiakJssiYmd = JBSbatStringUtil.Rtrim(inMap.getString(JBSbatKKIFM629.KOJIAK_JSSI_YMD))` // Work project case implementation date [OM-2014-0003696 added] |
| 5 | CALL | `super.logPrint.printDebugLog()` // Log input data values with labels |
| 6 | SET | `rsMap = inMap.getMap()` // Store the raw HashMap |

**Block 2** — [IF] `!isSingleCheckKKIFM629_INF1(rsMap, getItemvalueMap())` — Input validation check (L143)

> Validates the input data (address-change withdrawal work completion data) against error-related item rules. If validation fails, sets the error flag and returns early.

| # | Type | Code |
|---|------|------|
| 1 | SET | `itemvalueMap = getItemvalueMap()` // Returns field labels: SVC_KEI_NO -> "Service contract number", KOJI_ANK_NO -> "Work project case number", MSKM_NO -> "Application number", KOJIAK_JSSI_YMD -> "Work project case implementation date" |
| 2 | EXEC | `super.commonItem.setErrFlg(true)` // Set error flag |
| 3 | CALL | `super.logPrint.printDebugLog("execute_END")` // Log end marker |
| 4 | RETURN | `return null` // Terminate processing |

**Block 3** — [CALL] Application detail lookup (L152)

> Searches for application details linked to the given application number and service contract number.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getMskmDtlNo(inMskmNo, inSvcKeiNo)` // Populates `mskm_dtl_inf_list` |

**Block 4** — [IF] `mskm_dtl_inf_list.size() != 0` (L154)

> Checks if any application details were found. If none, terminates without error.

| # | Type | Code |
|---|------|------|
| 1 | IF_FALSE | `mskm_dtl_inf_list` is empty — log end and return null (L233-235) |
| 2 | IF_TRUE | Proceed to iterate through application details |

**Block 4.1** — [FOR] `for (int j = 0; j < mskm_dtl_inf_list.size(); j++)` — Iterate over application details (L157)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNoList = new ArrayList<>()` // List to hold service contract numbers for disposal control |
| 2 | SET | `svcKeiNoList.add(inSvcKeiNo)` // Add the main service contract number |
| 3 | SET | `mskmdtl_mskm_dtl_no = ""` // Reset application detail number |
| 4 | SET | `db_map_mskm_dtl = mskm_dtl_inf_list.get(j)` // Get current application detail row |
| 5 | SET | `mskmdtl_mskm_dtl_no = JBSbatStringUtil.Rtrim(db_map_mskm_dtl.getString(JBSbatKK_T_MSKM_DTL.MSKM_DTL_NO))` // Extract application detail number from `KK_T_MSKM_DTL` row |
| 6 | CALL | `super.logPrint.printDebugLog()` // Log search start for abnormal contract by detail number |
| 7 | CALL | `getIdoRsv(mskmdtl_mskm_dtl_no)` // Search abnormal contracts linked to this application detail number |

**Block 4.1.1** — [IF] `ido_rsv_inf_list.size() != 0` (L166)

> Checks if abnormal contracts were found for this application detail.

| # | Type | Code |
|---|------|------|
| 1 | IF_FALSE | No abnormal contracts — continue to next application detail |
| 2 | IF_TRUE | Enter abnormal contract processing loop |

**Block 4.1.1.1** — [FOR] `for (int k = 0; k < ido_rsv_inf_list.size(); k++)` — Iterate over abnormal contracts (L168)

**Block 4.1.1.1.1** — [CALL] Service contract disposal control verification (L174)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svKeiExcLastUpdateList = new ArrayList<>()` // List to receive last update timestamps |
| 2 | CALL | `errSvcKeiNo = searchSvkeiExcCtrl(svcKeiNoList, svKeiExcLastUpdateList)` // Verify disposal control record exists |

**Block 4.1.1.1.1.1** — [IF] `errSvcKeiNo != null` — Disposal control record not found (L175)

> The service contract disposal control table (`KK_T_SVKEI_EXC_CTRL`) does not contain a record for the service contract number. This is treated as a business error.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.logPrint.printBusinessErrorLog("EKKB0360KE", new String[]{"Contract disposal control table", errSvcKeiNo})` // Log business error |
| 2 | CALL | `super.logPrint.printDebugLog()` // Debug: contract number not found in disposal control table |
| 3 | CALL | `super.logPrint.printDebugLog("execute_END")` // Log end marker |
| 4 | RETURN | `return null` // Terminate processing |

**Block 4.1.1.1.2** — [IF] `!timeStampCheckSvcExecHaita(svcKeiNoList, svKeiExcLastUpdateList)` — Timestamp concurrency check failed (L186)

> Prevents processing if the service contract disposal control record has been modified more recently than expected (stale data protection). If check fails, terminate without error.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `timeStampCheckSvcExecHaita(svcKeiNoList, svKeiExcLastUpdateList)` // Compare timestamps |
| 2 | IF_FALSE | Timestamp mismatch — return null |

**Block 4.1.1.1.3** — [SET] Extract abnormal contract fields (L190-L197)

> Extract the abnormal contract number, reservation application date, and service charge end date from the current abnormal contract row.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_ido_rsv = ido_rsv_inf_list.get(k)` // Get current abnormal contract row |
| 2 | SET | `ido_rsv_no = JBSbatStringUtil.Rtrim(db_ido_rsv.getString(JBSbatKK_T_IDO_RSV.IDO_RSV_NO))` // Abnormal contract number from `KK_T_IDO_RSV.IDO_RSV_NO` |
| 3 | SET | `rsv_aply_ymd = JBSbatStringUtil.Rtrim(db_ido_rsv.getString(JBSbatKK_T_IDO_RSV.RSV_APLY_YMD))` // Reservation application date |
| 4 | SET | `svc_chrg_endymd = JBSbatStringUtil.Rtrim(db_ido_rsv.getString(JBSbatKK_T_IDO_RSV.SVC_CHRG_ENDYMD))` // Service charge end date [OM-2016-0002358 added] |
| 5 | CALL | `super.logPrint.printDebugLog()` // Log abnormal contract number and reservation application date |

**Block 4.1.1.1.4** — [SET] Build update parameters for abnormal contract (L201-L219)

> Constructs a 6-element parameter array for the abnormal contract update. The update target is the reservation application date, which is set to the work project case implementation date (rather than the batch operational date), since the withdrawal work completion date is tied to the cancellation settlement date's operational date.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam = new String[6]` // 6 elements (changed from 5 by OM-2016-0002358) |
| 2 | SET | `setParam[0] = inKojiakJssiYmd` // Work project case implementation date — update target for reservation application date [OM-2014-0003696 modified from super.opeDate] |
| 3 | SET | `setParam[1] = JBSbatDateUtil.getSystemDateTime()` // Update timestamp (datetime) |
| 4 | SET | `setParam[2] = super.batchUserId` // Update operator account |
| 5 | SET | `setParam[3] = super.opeDate` // Update operational date |
| 6 | SET | `setParam[4] = super.jobid` // Update transaction ID |
| 7 | SET | `setParam[5] = svc_chrg_endymd` // Service charge end date [OM-2016-0002358 added] |

**Block 4.1.1.1.5** — [SET] Build where parameter (L222-L223)

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereParam = new String[1]` // 1 element |
| 2 | SET | `whereParam[0] = ido_rsv_no` // Abnormal contract number — primary key for update |

**Block 4.1.1.1.6** — [CALL] Update abnormal contract record (L225)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_IDO_RSV_KK_PKUPDATE(setParam, whereParam)` // Update `KK_T_IDO_RSV` table — sets reservation application date and metadata |

**Block 4.1.1.1.7** — [CALL] Update service contract disposal control (L228)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `updateSvkeiExecCtrl(svcKeiNoList)` // Update `KK_T_SVKEI_EXC_CTRL` table — refreshes the disposal control record |

**Block 5** — [LOG/RETURN] End of processing (L233-L235)

> Log the end marker and return null (this is a fire-and-forget batch notification handler; no output value is returned).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.logPrint.printDebugLog("execute_END")` // Log end marker |
| 2 | RETURN | `return null` // No output data — batch processing completed |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `inSvcKeiNo` | Field | Service contract number — the unique identifier for a customer's service contract line |
| `inKojiAnkNo` | Field | Work project case number — internal tracking number for a work project case (工事案件番号) |
| `inMskmNo` | Field | Application number — the application submission number (申請番号) |
| `inKojiakJssiYmd` | Field | Work project case implementation date — the date the work was carried out (工事案件実施年月日). Populated from withdrawal settlement date when tied to work completion [OM-2014-0003696] |
| `mskm_dtl_inf_list` | Field | Application detail information list — list of `KK_T_MSKM_DTL` rows linked to the application number |
| `ido_rsv_inf_list` | Field | Abnormal contract information list — list of `KK_T_IDO_RSV` rows (異動予約 = migration/preparation reservations) linked to the application detail |
| `mskmdtl_mskm_dtl_no` | Field | Application detail number — unique key within the application detail table |
| `ido_rsv_no` | Field | Abnormal contract number — unique key within the abnormal contract (異動予約) table |
| `rsv_aply_ymd` | Field | Reservation application date — the date the abnormal contract was applied |
| `svc_chrg_endymd` | Field | Service charge end date — the end date of service charging for the abnormal contract [OM-2016-0002358 added] |
| `svKeiExcLastUpdateList` | Field | Service contract disposal control last update list — holds timestamps from `KK_T_SVKEI_EXC_CTRL` for concurrency checking |
| `svcKeiNoList` | Field | Service contract number list — list of service contract numbers used for disposal control checks |
| `setParam` | Array | Update parameter array for abnormal contract update — 6 elements: [0] reservation application date, [1] datetime, [2] operator, [3] operational date, [4] transaction ID, [5] service charge end date |
| `whereParam` | Array | Where clause parameter — contains the abnormal contract number as the primary key for update |
| KK_T_MSKM_DTL | Table | Application detail table — stores application detail records (申請明細) |
| KK_T_IDO_RSV | Table | Abnormal contract table — stores migration/preparation reservation records (異動予約). "Abnormal" refers to contract status changes (migrations, additions, cancellations) |
| KK_T_SVKEI_EXC_CTRL | Table | Service contract disposal control table — tracks the last update timestamp for service contracts to prevent concurrent modification issues |
| KK_SELECT_037 | SQL Key | SQL definition key for querying `KK_T_MSKM_DTL` |
| KK_SELECT_083 | SQL Key | SQL definition key for querying `KK_T_IDO_RSV` |
| 住所変更具中撤去工事完了 | Business term | Address-change-associated withdrawal work completion — work completion notification that a withdrawn/deleted installation at an address change location has been completed |
| 異動予約 | Business term | Migration reservation (異動予約) — a reservation record for a contract status change, including additions, cancellations, or transfers |
| サービス契約排他制御 | Business term | Service contract disposal control — a mechanism that prevents concurrent modifications to service contracts by tracking last update timestamps |
| SVC_KEI_NO | Constant | Input field key for service contract number |
| KOJI_ANK_NO | Constant | Input field key for work project case number |
| MSKM_NO | Constant | Input field key for application number |
| KOJIAK_JSSI_YMD | Constant | Input field key for work project case implementation date |
| IDO_RSV_NO | Constant | Abnormal contract table column: abnormal contract number |
| RSV_APLY_YMD | Constant | Abnormal contract table column: reservation application date |
| SVC_CHRG_ENDYMD | Constant | Abnormal contract table column: service charge end date |
| MSKM_DTL_NO | Constant | Application detail table column: application detail number |
| EKKB0360KE | Error code | Business error code used when a service contract disposal control table record is missing |
| JBSbatKKIFM629 | Class | Input file constant class for address-change withdrawal work completion notification data |
| JBSbatBusinessService | Class | Parent class providing batch service infrastructure (logging, common parameters, DB access) |
| om-2014-0003696 | Change ticket | Change ticket: withdrawal settlement date became tied to the work completion operational date |
| om-2016-0002358 | Change ticket | Change ticket: added service charge end date update handling |
