# Business Logic — JBSbatKKSyuKeiJudgeTran.addPrg() [46 LOC]

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

## 1. Role

### JBSbatKKSyuKeiJudgeTran.addPrg()

This method performs the progress registration processing for TV contract main and subordinate fee setting operations within the K-Opticom customer backbone batch system. Specifically, it creates a new progress tracking record in the `KK_T_PRG` (Progress) table to document the successful completion of a TV contract fee configuration change (disruption division code `"00066"`, progress status `"1430"` — "TV contract main/sub fee setting completed"). The method receives service contract detail search results via the `outMap` parameter, extracts the service contract number and service contract detail number from it, generates an auto-allocated progress number from the database sequence, and resolves the latest migration date/time using a shared utility. This is a dedicated single-purpose write operation used exclusively by the `execute()` method of the same class as part of the broader primary contract judgment batch workflow, which evaluates and records the outcome of service contract change judgments. The method follows a straightforward builder-insertion pattern: resolve external timestamps, assemble a flat parameter array with 33 fields (most set to null or default values), and delegate persistence to the internal `executeKK_T_PRG_PKINSERT` method.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addPrg(outMap)"])
    START --> GET_SYSDATE["Get system datetime stamp (sysdate)"]
    GET_SYSDATE --> GET_IDO_DTM["Get migration date/time via JKKBatCommon.getIdoDtmMax(commonItem, svc_kei_no, IDO_DIV_TV_SYUJU_PRC_SET, stmt)"]
    GET_IDO_DTM --> BUILD_PARAMS["Build setParam array [33 elements]"]
    BUILD_PARAMS --> IDX0_SEQ["Index 0: Auto-allocate PRG_NO via JBSbatOracleSeqUtil.getNextSeq(SEQ_PRG_NO), 12-digit padded"]
    BUILD_PARAMS --> IDX5_SVC["Index 5: SVC_KEI_NO from outMap (trailing space-trimmed)"]
    BUILD_PARAMS --> IDX6_SVCWK["Index 6: SVC_KEI_UCWK_NO from outMap (trailing space-trimmed)"]
    BUILD_PARAMS --> IDX14_IDO["Index 14: IDO_DIV = \"00066\" (TV contract main/sub fee setting) [-> IDO_DIV_TV_SYUJU_PRC_SET]"]
    BUILD_PARAMS --> IDX15_DTM["Index 15: IDO_DTM = value from getIdsDtmMax call"]
    BUILD_PARAMS --> IDX16_STAT["Index 16: PRG_STAT = \"1430\" (TV contract main/sub fee setting completed) [-> PRG_STAT_SYUJU_PRC_SET_FIN]"]
    BUILD_PARAMS --> IDX17_PRGDTM["Index 17: PRG_DTM = opeDate + sysdate.substring(8)"]
    BUILD_PARAMS --> IDX20_26["Indexes 20-26: ADD_DTM, ADD_OPEACNT, UPD_DTM, UPD_OPEACNT, DEL_DTM, DEL_OPEACNT, MK_FLG = \"0\""]
    BUILD_PARAMS --> IDX27_32["Indexes 27-32: ADD_UNYO_YMD through DEL_TRN_ID = empty strings"]
    IDX27_32 --> INSERT_PRG["executeKK_T_PRG_PKINSERT(setParam)"]
    INSERT_PRG --> END_NODE(["Return / Next"])
```

**Block processing summary:**
- **Line 2012**: Acquires the current system date/time stamp as a single string value.
- **Line 2015**: Resolves the latest migration date/time by calling the shared utility `JKKBatCommon.getIdoDtmMax`, which returns either the latest recorded migration date/time for the given service contract number and disruption division, or the system date/time as a fallback.
- **Lines 2018-2050**: Assembles a 33-element `String[]` parameter array that maps each element to a column in the `KK_T_PRG` table. Only a small subset of fields are populated with meaningful data; the majority are set to empty strings (effectively NULL).
- **Line 2051**: Delegates the database insert to `executeKK_T_PRG_PKINSERT(setParam)`, which maps the array into a key-value map and calls `db_KK_T_PRG.insertByPrimaryKeys(setMap)`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outMap` | `JBSbatCommonDBInterface` | Service contract detail search result — a key-value map carrying the results of a prior search on the `KK_T_SVC_KEI_UCWK` (Service Contract Detail) table. Used to extract the service contract number (`SVC_KEI_NO`) and service contract detail number (`SVC_KEI_UCWK_NO`) that identify which contract line item this progress record belongs to. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `commonItem` | `JBSbatCommonItem` | Shared common-item context object holding the database connection used for sequence generation and migration date lookup. |
| `batchUserId` | `String` | Batch update operator ID — identifies the batch job user that performs insert/update operations on progress records. |
| `opeDate` | `String` | Batch execution date — the date portion of the batch run, used as the base for building the progress date/time stamp. |
| `stmt` | `JBSbatSQLAccess` | Shared table access class for common utility operations (used by `getIdoDtmMax`). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatDateUtil.getSystemDateTimeStamp` | JBSbatDateUtil | - | Gets the current system date/time stamp string for use as registration timestamp |
| R | `JKKBatCommon.getIdoDtmMax` | JKKBatCommon | - | Retrieves the maximum (latest) migration date/time for the given service contract number and disruption division code |
| R | `JBSbatOracleSeqUtil.getNextSeq` | JBSbatOracleSeqUtil | - | Fetches the next value from the auto-increment sequence `SEQ_PRG_NO` for progress number allocation |
| C | `db_KK_T_PRG.insertByPrimaryKeys` | - | `KK_T_PRG` (Progress table) | Inserts a new progress tracking record with auto-generated primary key via the `executeKK_T_PRG_PKINSERT` delegate |
| - | `JBSbatStringUtil.padNumFormString` | JBSbatStringUtil | - | Pads the allocated sequence number to a fixed 12-digit string format |
| - | `JBSbatStringUtil.Rtrim` | JBSbatStringUtil | - | Trims trailing whitespace from extracted service contract numbers |

**CRUD Analysis:**
- **Create (1)**: `db_KK_T_PRG.insertByPrimaryKeys` — Creates a new row in the `KK_T_PRG` (Progress) table, recording the completion status of a TV contract main/subordinate fee setting operation.
- **Read (3)**: System date/time acquisition, migration date/time lookup via shared common utility, and auto-increment sequence number generation.
- **No Update/Delete**: This method is a pure append operation; it does not modify or remove existing records.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKSyuKeiJudgeTran.execute()` | `JBSbatKKSyuKeiJudgeTran.execute` → `JBSbatKKSyuKeiJudgeTran.addPrg(outMap)` | `db_KK_T_PRG.insertByPrimaryKeys [C] KK_T_PRG` |

**Upstream context:** This method is a private helper called exclusively from the `execute()` method of the same class. The `execute()` method is the main processing entry point of the primary contract judgment batch service, which evaluates service contract details and registers the judgment results as progress records.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(System datetime acquisition) (L2012)`

> Retrieves the current system date/time stamp as a string. This value serves as the canonical timestamp for the registration date/time and update date/time fields of the progress record.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `sysdate = JBSbatDateUtil.getSystemDateTimeStamp()` // Gets system date/time [-> sysdate] |

---

**Block 2** — [SET] `(Migration date/time acquisition) (L2015)`

> Acquires the latest migration date/time for the given service contract number and disruption division code. The disruption division is `"00066"` (TV contract main/sub fee setting). This value is used to populate the migration date/time field in the progress record.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `idoDtm = JKKBatCommon.getIdoDtmMax(commonItem, outMap.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_NO), IDO_DIV_TV_SYUJU_PRC_SET, stmt)` // Migration date/time from common utility |
| - | - | `[-> IDO_DIV_TV_SYUJU_PRC_SET = "00066" (TV contract main/sub fee setting)]` |

---

**Block 3** — [SET] `(Parameter array construction — 33 elements) (L2018-2050)`

> Constructs the 33-element parameter array that maps to columns in the `KK_T_PRG` table. The table columns (in order) are: PRG_NO, MSKM_DTL_NO, SEIKY_KEI_NO, SEIKY_WAY_NO_KOZA, SEIKY_WAY_NO_CRECARD, SVC_KEI_NO, SVC_KEI_UCWK_NO, SVC_KEI_KAISEN_UCWK_NO, KKTK_SVC_KEI_NO, OP_SVC_KEI_NO, SEIOPSVC_KEI_NO, SBOP_SVC_KEI_NO, WRIB_SVC_KEI_NO, IDO_DIV, IDO_DTM, PRG_STAT, PRG_DTM, PRG_MEMO, PRG_TKJK_1, PRG_TKJK_2, ADD_DTM, ADD_OPEACNT, UPD_DTM, UPD_OPEACNT, DEL_DTM, DEL_OPEACNT, MK_FLG, ADD_UNYO_YMD, ADD_TRN_ID, UPD_UNYO_YMD, UPD_TRN_ID, DEL_UNYO_YMD, DEL_TRN_ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam[0]` = `JBSbatStringUtil.padNumFormString(JBSbatOracleSeqUtil.getNextSeq(commonItem.getConnection(), SEQ_PRG_NO), 12)` // Progress number → auto-allocated [-> SEQ_PRG_NO = "SEQ_PRG_NO"] |
| 2 | SET | `setParam[1]` = `""` // Application detail number → NULL (not set) |
| 3 | SET | `setParam[2]` = `""` // Billing contract number → NULL (not set) |
| 4 | SET | `setParam[3]` = `""` // Billing method number (desk) → NULL (not set) |
| 5 | SET | `setParam[4]` = `""` // Billing method number (credit card) → NULL (not set) |
| 6 | SET | `setParam[5]` = `JBSbatStringUtil.Rtrim(outMap.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_NO))` // Service contract number → from service contract detail search result |
| 7 | SET | `setParam[6]` = `JBSbatStringUtil.Rtrim(outMap.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_NO))` // Service contract detail number → from service contract detail search result |
| 8 | SET | `setParam[7]` = `""` // Service contract line item detail number → NULL (not set) |
| 9 | SET | `setParam[8]` = `""` // Device provider service contract number → NULL (not set) |
| 10 | SET | `setParam[9]` = `""` // Option service contract number → NULL (not set) |
| 11 | SET | `setParam[10]` = `""` // Billing option service contract number → NULL (not set) |
| 12 | SET | `setParam[11]` = `""` // Sub-option service contract number → NULL (not set) |
| 13 | SET | `setParam[12]` = `""` // Discount service contract number → NULL (not set) |
| 14 | SET | `setParam[13]` = `IDO_DIV_TV_SYUJU_PRC_SET` // Disruption division code [-> IDO_DIV_TV_SYUJU_PRC_SET = "00066" (TV contract main/sub fee setting)] |
| 15 | SET | `setParam[14]` = `idoDtm` // Migration date/time → from getIdoDtmMax call (Block 2) |
| 16 | SET | `setParam[15]` = `PRG_STAT_SYUJU_PRC_SET_FIN` // Progress status [-> PRG_STAT_SYUJU_PRC_SET_FIN = "1430" (TV contract main/sub fee setting completed)] |
| 17 | SET | `setParam[16]` = `super.opeDate + sysdate.substring(8)` // Progress date/time → batch execution date + hhmmssSSS from sysdate |
| 18 | SET | `setParam[17]` = `""` // Progress memo → NULL (not set) |
| 19 | SET | `setParam[18]` = `""` // Progress special item 1 → NULL (not set) |
| 20 | SET | `setParam[19]` = `""` // Progress special item 2 → NULL (not set) |
| 21 | SET | `setParam[20]` = `sysdate` // Registration date/time → system date/time |
| 22 | SET | `setParam[21]` = `batchUserId` // Registration operator account → batch updaters ID |
| 23 | SET | `setParam[22]` = `sysdate` // Update date/time → system date/time |
| 24 | SET | `setParam[23]` = `batchUserId` // Update operator account → batch updaters ID |
| 25 | SET | `setParam[24]` = `""` // Deletion date/time → NULL (not set) |
| 26 | SET | `setParam[25]` = `""` // Deletion operator account → NULL (not set) |
| 27 | SET | `setParam[26]` = `"0"` // Valid flag → "0" (valid/active) |
| 28 | SET | `setParam[27]` = `""` // Registration operation date → NULL (not set) |
| 29 | SET | `setParam[28]` = `""` // Registration process ID → NULL (not set) |
| 30 | SET | `setParam[29]` = `""` // Update operation date → NULL (not set) |
| 31 | SET | `setParam[30]` = `""` // Update process ID → NULL (not set) |
| 32 | SET | `setParam[31]` = `""` // Deletion operation date → NULL (not set) |
| 33 | SET | `setParam[32]` = `""` // Deletion process ID → NULL (not set) |

---

**Block 4** — [CALL] `(Progress record insertion) (L2051)`

> Delegates the database insert operation to `executeKK_T_PRG_PKINSERT(setParam)`. This internal method creates a `JBSbatCommonDBInterface` map from the parameter array (mapping index 0→PRG_NO, index 1→MSKM_DTL_NO, ..., index 32→DEL_TRN_ID) and calls `db_KK_T_PRG.insertByPrimaryKeys(setMap)` to write the record.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_PRG_PKINSERT(setParam)` // Inserts new progress record into KK_T_PRG table [-> KK_T_PRG] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `SVC_KEI_NO` | Field | Service contract number — the unique identifier for a service contract line item in the `KK_T_SVC_KEI` table. |
| `SVC_KEI_UCWK_NO` | Field | Service contract detail number — the unique identifier for a specific detail within a service contract, stored in `KK_T_SVC_KEI_UCWK`. |
| `PRG_NO` | Field | Progress number — auto-allocated identifier for a progress tracking record in `KK_T_PRG`. |
| `IDO_DIV` | Field | Disruption division code — classifies the type of service change/disruption (e.g., "00066" = TV contract main/sub fee setting). |
| `IDO_DTM` | Field | Migration date/time — the timestamp when a service disruption/change was last executed for a contract. |
| `PRG_STAT` | Field | Progress status — indicates the completion state of a progress operation (e.g., "1430" = TV contract main/sub fee setting completed). |
| `PRG_DTM` | Field | Progress date/time — the timestamp when the progress record was created. |
| `MK_FLG` | Field | Valid flag — "0" indicates the record is active/valid; non-zero indicates deletion flag. |
| `PRG_STAT_SYUJU_PRC_SET_FIN` | Constant | Progress status "1430" — signifies "TV contract main/sub fee setting completed". |
| `IDO_DIV_TV_SYUJU_PRC_SET` | Constant | Disruption division "00066" — signifies "TV contract main/sub fee setting". |
| `SEQ_PRG_NO` | Constant | Sequence definition name for generating auto-incremented progress numbers. |
| `KK_T_PRG` | Table | Progress table — stores progress tracking records for service contract change operations. |
| `KK_T_SVC_KEI_UCWK` | Table | Service contract detail table — stores detailed breakdowns of service contracts. |
| `KK_SETP_PRC_GRP_CD` | Field | Business parameter group code for eo光 TV subordinate fee setting. |
| `batchUserId` | Field | Batch operator account ID — identifies the batch process user performing updates. |
| `opeDate` | Field | Batch execution date — the operational date of the batch run. |
| `JBSbatBusinessService` | Class | Parent class — base batch business service providing common infrastructure (commonItem, stmt, opeDate, batchUserId). |
| TV contract main/sub fee setting | Business term | A service disruption type where the main and subordinate monthly fees for a TV contract are configured or modified. |
| Progress record | Business term | A tracking entry in KK_T_PRG that documents the execution status and timestamps of a service contract change operation. |
| `MSKM_DTL_NO` | Field | Application detail number — reference to an application detail (left empty in this context). |
| `SEIKY_KEI_NO` | Field | Billing contract number — reference to a billing contract (left empty in this context). |
| `SEIKY_WAY_NO_KOZA` | Field | Billing method number (desk) — payment method identifier for desk-based billing (left empty). |
| `SEIKY_WAY_NO_CRECARD` | Field | Billing method number (credit card) — payment method identifier for credit card billing (left empty). |
| `SVC_KEI_KAISEN_UCWK_NO` | Field | Service contract improved detail number — reference to an improved service contract detail (left empty). |
| `KKTK_SVC_KEI_NO` | Field | KK TV service contract number — a secondary TV service contract reference (left empty). |
| `OP_SVC_KEI_NO` | Field | Option service contract number — reference to an optional service (left empty). |
| `SEIOPSVC_KEI_NO` | Field | Billing option service contract number — reference to a billing option (left empty). |
| `SBOP_SVC_KEI_NO` | Field | Sub-option service contract number — reference to a sub-option service (left empty). |
| `WRIB_SVC_KEI_NO` | Field | Writable service contract number — reference to a writable service (left empty). |
| `ADD_DTM` / `ADD_OPEACNT` | Field | Registration date/time and operator account — audit trail fields for record creation. |
| `UPD_DTM` / `UPD_OPEACNT` | Field | Update date/time and operator account — audit trail fields for record modification. |
| `DEL_DTM` / `DEL_OPEACNT` | Field | Deletion date/time and operator account — audit trail fields for record deletion. |
