# Business Logic — JBSbatKKRsvTokiHakTgCst.initial() [17 LOC]

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

## 1. Role

### JBSbatKKRsvTokiHakTgCst.initial()

This method serves as the entry-point initialization routine for the batch process that extracts **scheduled tickets** (预定票) from the **Service Contract Details (eo Optical Telephone)** table (`KK_T_SVC_KEI_UCWK`). Its business role is to prepare the service context before any data processing begins: it delegates common batch parameter configuration to its parent class (`JBSbatBusinessService.setCommonInfo`), creates the database access layer for the service contract details table, and sets the transaction operation date (`trnOpeDate`) to match the online operation date from the parent — a fix applied for a timestamp mismatch between the ICS (Integrated Customer System) and this batch handler (ref: KT1-2013-0000585). This method is **an override of the base class initialization hook**, meaning it follows the template method pattern where each batch service class customizes `initial()` to declare its own DB access and runtime state before the parent framework invokes the main processing logic.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    A["setCommonInfo(commonItem)"] --> B["new JBSbatSQLAccess(commonItem, KK_T_SVC_KEI_UCWK)"]
    B --> C["trnOpeDate = super.onlineOpeDate"]
    C --> END_NODE(["Return / Next"])
    START --> A
```

The processing flow is linear with no conditional branches — each step executes sequentially:

1. **`setCommonInfo(commonItem)`** — Delegates common batch parameter setup (batch ID, operation date, site ID, etc.) to the parent class `JBSbatBusinessService`.
2. **`new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_SVC_KEI_UCWK)`** — Instantiates the database access object (`JBSbatSQLAccess`) bound to the `KK_T_SVC_KEI_UCWK` table (Service Contract Details), enabling SELECT/INSERT/UPDATE/DELETE operations against this table for the remainder of the batch run.
3. **`trnOpeDate = super.onlineOpeDate`** — Assigns the transaction operation date from the parent class's online operation date field. This was added to correct a timestamp format mismatch where the scheduled ticket processing expected a format different from the ICS (ref: KT1-2013-0000585, 2013/05/22).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter message — carries the shared batch execution context including batch ID, operation date, site/center ID, and other cross-cutting configuration used by all batch services in the job chain. |

**Instance fields accessed:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `D_TBL_NAME_KK_T_SVC_KEI_UCWK` | `String` | Table name constant (`"KK_T_SVC_KEI_UCWK"`) for the Service Contract Details table — used as the target table for DB operations. |
| `db_KK_T_SVC_KEI_UCWK` | `JBSbatSQLAccess` | Database access layer instance — initialized in this method and used throughout the batch for queries and updates against the service contract details table. |
| `trnOpeDate` | `String` | Transaction operation date — set to the parent's `onlineOpeDate` to ensure the scheduled ticket processing uses the correct date format aligned with ICS. |
| `onlineOpeDate` | `String` (inherited) | Online operation date from the parent class `JBSbatBusinessService` — the source of truth for the current batch operation date. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | — | — | Sets common batch parameters (batch ID, operation date, site, etc.) on this service instance via the parent class. |
| C | `JBSbatSQLAccess` constructor | — | `KK_T_SVC_KEI_UCWK` | Creates a database access layer instance bound to the Service Contract Details table. Prepares the connection/session for subsequent SELECT/INSERT/UPDATE/DELETE operations. |

**Classification notes:**
- `setCommonInfo` is classified as **U (Update)** because it mutates this service instance's state with the common batch parameters.
- The `JBSbatSQLAccess` constructor is classified as **C (Create)** because it creates a new DB access object, which is the prerequisite for all subsequent database operations against the `KK_T_SVC_KEI_UCWK` table.

## 5. Dependency Trace

This method is the **`initial()` override** of a batch business service class. It follows the template method pattern where the batch framework invokes `initial()` after constructing the service instance and before calling the main processing method (`execute()` or equivalent).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKRsvTokiHakTgCst | `batch framework -> JBSbatKKRsvTokiHakTgCst.initial(commonItem)` | `setCommonInfo [U] — commonItem` |
| 2 | Batch: JBSbatKKRsvTokiHakTgCst | `batch framework -> JBSbatKKRsvTokiHakTgCst.initial(commonItem)` | `JBSbatSQLAccess [C] KK_T_SVC_KEI_UCWK` |

**Notes:**
- The caller is the batch framework/runtime itself, which invokes `initial()` as part of the standard batch job lifecycle for this service class.
- This method is not called directly by other application classes (it is a framework hook method).
- The terminal endpoints reached from this method are `setCommonInfo` (Update: sets batch context) and `JBSbatSQLAccess` (Create: initializes DB access for the service contract details table).

## 6. Per-Branch Detail Blocks

> This method has a linear control flow with no conditional branches. Each step is documented as a sequential block.

### Block 1 — EXEC (L89)

> Invoke parent class to set common batch parameters. This configures shared batch context (batch ID, operation date, site/center, etc.) that downstream processing depends on.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.setCommonInfo(commonItem);` // Sets common batch parameters from the commonItem onto this service instance |

### Block 2 — SET (L95)

> Instantiate the database access layer for the Service Contract Details table. This bound access object (`db_KK_T_SVC_KEI_UCWK`) becomes the primary means of interacting with the `KK_T_SVC_KEI_UCWK` table during the batch job.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_SVC_KEI_UCWK = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_SVC_KEI_UCWK);` // Creates DB access for KK_T_SVC_KEI_UCWK table [-> `D_TBL_NAME_KK_T_SVC_KEI_UCWK = "KK_T_SVC_KEI_UCWK"`] |

### Block 3 — SET (L99)

> Assign the transaction operation date from the parent's online operation date. This was added per ticket KT1-2013-0000585 (2013/05/22) to resolve a timestamp format mismatch between the scheduled ticket processing and ICS.

| # | Type | Code |
|---|------|------|
| 1 | SET | `trnOpeDate = super.onlineOpeDate;` // Transaction operation date aligned with ICS (ref: KT1-2013-0000585) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_SVC_KEI_UCWK` | Table | Service Contract Details (eo Optical Telephone) — stores detailed records of service contracts specific to the eo optical telephone product line. |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract line items (used in the `KK_T_SVC_KEI_UCWK` table). |
| `trnOpeDate` | Field | Transaction operation date — the date used for processing within this batch run, set to match the online operation date for timestamp consistency. |
| `onlineOpeDate` | Field | Online operation date — the canonical operation date from the parent batch service, sourced from the online (ICS) system. |
| `SOD` | Acronym | Service Order Data — telecom service order entity used for order fulfillment workflows (e.g., SOD registration, cancellation). Referenced by constants `SOD_HAK_SBT_CD_NONE` ("0" = no SOD), `SOD_HAK_SBT_CD_STA` ("1" = start SOD issuance), `SOD_HAK_SBT_CD_END` ("2" = end SOD issuance). |
| ICS | Acronym | Integrated Customer System — the central customer management system; scheduled ticket processing timestamp formats must align with ICS. |
| `JBSbatCommonItem` | Class | Batch common parameter message — carries shared batch execution context (batch ID, operation date, site ID, etc.) used across all batch services. |
| `JBSbatSQLAccess` | Class | Database access layer — provides CRUD operations against a specific table, configured with the common item and target table name. |
| `JBSbatBusinessService` | Class | Parent batch business service — base class providing common batch infrastructure including `setCommonInfo()` and `onlineOpeDate`. |
| `setCommonInfo` | Method | Sets common batch parameters from `JBSbatCommonItem` onto the service instance (batch ID, date, site, etc.). |
| `SAKI_SVC_KEI_UCWK_STAT` | Constant | Service contract status (post-transfer) — tracking ID for the service contract details number after transfer to a downstream system. |
| `SK_GENE_ADD_DTM` | Constant | Generation registration date/time (Service Contract) — timestamp for service-level contract generation. |
| `SKU_GENE_ADD_DTM` | Constant | Generation registration date/time (Service Contract Details) — timestamp for service detail contract generation. |
| `SKUT_GENE_ADD_DTM` | Constant | Generation registration date/time (Service Contract Details — eo Optical Telephone) — timestamp for eo optical telephone service detail contract generation. |
