---

# Business Logic — JBSbatKKKojiKnrnInfToroku.createKojiFinInf() [179 LOC]

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

## 1. Role

### JBSbatKKKojiKnrnInfToroku.createKojiFinInf()

This method performs **construction completion information registration** (工事完了情報登録処理). It processes CSV files containing construction completion data for telecom service contracts and routes each record through one of two business paths based on the OPMS (Operational Support System) construction case result code. When the OPMS result is "1" (OK), the method updates the service contract line's PON (Passive Optical Network) type code in the database, applying proper record-locking via the service contract control table. When the OPMS result is "2" (NG / failure), the method registers cancellation work for the affected service contract, ensuring data consistency by also handling phone-line-related cancellation work for bundled network-voice services. The method operates as a batch processing service that transforms intermediate CSV files into authoritative database records and consistency updates, implementing a **dispatch/routing pattern** where the OPMS result code determines the post-processing path. It is called from the `execute()` method of the same class, serving as the core completion-registration phase of the construction completion information registration batch.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["createKojiFinInf"])

    START --> A["Get system datetime stamp"]
    A --> B["Build file path with KKIFM051003 and .csv"]
    B --> C["Read input file KKIFM051003.csv"]
    C --> D{"data_list size > 0"}

    D -->|Yes| E["For each row in data_list"]
    D -->|No| END1(["End"])

    E --> F["Parse CSV row"]
    F --> G["Build param_add with 27 fields"]
    G --> H["Insert into KK_T_KJ_FIN_WK"]
    H --> I{"OPMS code present?"}

    I -->|No| E
    I -->|Yes| J{"OPMS code is OK?"}

    J -->|Yes| K["Search KK_T_SVKEI_KAISEN_UW"]
    K --> L{"Record found?"}

    L -->|No| M["Log and skip update"]
    M --> E

    L -->|Yes| N{"PON type code present?"}

    N -->|No| O["Log and skip update"]
    O --> E

    N -->|Yes| P["Lock KK_T_SVKEI_EXC_CTRL"]
    P --> Q["Update KK_T_SVKEI_KAISEN_UW PON type"]
    Q --> R["Update KK_T_SVKEI_EXC_CTRL"]
    R --> E

    J -->|No| S["Create cancellation work (createKjClWk)"]
    S --> T["Create phone cancellation (createKjClWkTel)"]
    T --> E
```

**Constant Resolution:**
- `KOJI_FIN_INF_FILE_ID = "KKIFM051003"` (Construction Completion Information File ID — intermediate file identifier for completion data CSV)
- `FILE_KEISHIKI = ".csv"` (File extension constant)
- `HAFU_SPACE = " "` (Half-width space — used for null/empty field padding)
- `OPMS_KOJIAK_PSLT_CD_OK = "1"` (OPMS Construction Case Selection Code OK — value "1" indicates OPMS construction case result is OK/successful)

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `mid_dir_kk` | `String` | Intermediate file storage directory path — the filesystem directory where intermediate CSV files (including the construction completion information file) are stored by prior batch stages. This path is combined with the file ID constant to locate the input CSV. |

**Instance fields read by this method:**

| # | Field | Source Class | Business Description |
|---|-------|--------------|---------------------|
| 1 | `super.batchUserId` | Parent class | Batch TV (terminal) ID — the identity of the batch processing session/user performing DB operations |
| 2 | `super.opeDate` | Parent class | Operation date — the business date used for registration, update, and delete operation date fields |
| 3 | `super.logPrint` | Parent class | Logging utility — used to emit debug log entries for processing traceability |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatDateUtil.getSystemDateTimeStamp` | JBSbatInterface | - | Gets the current system date and timestamp for setting insertion/update timestamps in the record |
| R | `getInputFile` | JBSbatKKKojiKnrnInfToroku | - | Reads the construction completion information CSV file from the intermediate directory, returning a list of row strings |
| C | `executeKK_T_KJ_FIN_WK_PKINSERT` | JBSbatKKKojiKnrnInfToroku | `KK_T_KJ_FIN_WK` | Inserts a construction completion work registration record with 27 fields including service contract number, line details, OPMS result code, PON type, system datetime, and batch user ID |
| R | `searchSvkeiKaisenUw` | JBSbatKKKojiKnrnInfToroku | `KK_T_SVKEI_KAISEN_UW` | Searches the service contract line detail table by service contract line internal detail number to retrieve existing PON type code and generation registration datetime |
| U | `forUpdatehSvkeiExcCtrl` | JBSbatKKKojiKnrnInfToroku | `KK_T_SVKEI_EXC_CTRL` | Performs locking/pessimistic control on the service contract control table by service contract number to prevent concurrent modification during update |
| U | `updateSvkeiKaisenUw` | JBSbatKKKojiKnrnInfToroku | `KK_T_SVKEI_KAISEN_UW` | Updates the PON type code and generation registration datetime in the service contract line detail table |
| U | `updateSvkeiExcCtrl` | JBSbatKKKojiKnrnInfToroku | `KK_T_SVKEI_EXC_CTRL` | Updates the service contract control table record after PON type code update completes |
| C | `createKjClWk` | JBSbatKKKojiKnrnInfToroku | - | Registers cancellation work when OPMS construction case result is NG (code "2"), creating a cancellation work record for the affected service contract |
| C | `createKjClWkTel` | JBSbatKKKojiKnrnInfToroku | - | Registers cancellation work for bundled network-voice (phone) lines when OPMS construction case result is NG (code "2") |
| - | `JACBatCommon.printDebugLog` | JACBatCommon | - | Emits debug log entries for processing trace (start, end, intermediate state messages) |
| - | `JBSbatStringUtil.Rtrim` | JBSbatStringUtil | - | Trims trailing whitespace from database-fetched strings |

## 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: `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `createKjClWkTel` [C], `createKjClWk` [C], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKKojiKnrnInfToroku.execute() | `JBSbatKKKojiKnrnInfToroku.execute()` -> `createKojiFinInf(mid_dir_kk)` | `executeKK_T_KJ_FIN_WK_PKINSERT [C] KK_T_KJ_FIN_WK`, `searchSvkeiKaisenUw [R] KK_T_SVKEI_KAISEN_UW`, `forUpdatehSvkeiExcCtrl [U] KK_T_SVKEI_EXC_CTRL`, `updateSvkeiKaisenUw [U] KK_T_SVKEI_KAISEN_UW`, `updateSvkeiExcCtrl [U] KK_T_SVKEI_EXC_CTRL`, `createKjClWk [C] KK_T_KJ_CL_WK`, `createKjClWkTel [C] KK_T_KJ_CL_WK_TEL` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize local variables (L1563)

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = ""` // Construction completion information file one-line data holder |
| 2 | SET | `file_path = ""` // File path holder |
| 3 | SET | `param_add = null` // Registration parameter list |

**Block 2** — [EXEC] Get system datetime (L1567)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JBSbatDateUtil.getSystemDateTimeStamp()` |
| 2 | SET | `sysrtem_date = ...` // System date and time for timestamp fields |

**Block 3** — [SET] Generate file path (L1570)

| # | Type | Code |
|---|------|------|
| 1 | SET | `file_path = mid_dir_kk + KOJI_FIN_INF_FILE_ID + FILE_KEISHIKI` // Constructs full path: `[mid_dir_kk]KKIFM051003.csv` |

**Block 4** — [CALL] Read input file (L1573)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getInputFile(file_path, KOJI_FIN_INF_FILE_ID)` // Reads CSV rows into data_list |

**Block 5** — [FOR] Iterate over each CSV row (L1576)

| # | Type | Code |
|---|------|------|
| 1 | SET | `for (int i = 0; i < data_list.size(); i++)` |

**Block 5.1** — [SET] Acquire one line (L1580)

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = data_list.get(i)` // One line from CSV |

**Block 5.2** — [EXEC] Parse CSV data (L1583)

| # | Type | Code |
|---|------|------|
| 1 | SET | `data = data_work.split(",", -1)` // Split CSV row by comma, keeping trailing empty values |

**Block 5.3** — [SET] Build registration parameter list (L1586-L1680)

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add = new ArrayList<String>(data.length)` // Registration data holder |
| 2 | SET | `param_add.add(data[0])` // Service contract number (サービス契約番号) |
| 3 | SET | `param_add.add(data[1])` // Service contract line internal detail number (サービス契約回線内詳細番号) |
| 4 | SET | `param_add.add(data[2])` // Linkage year month day (連携年月日) |
| 5 | SET | `param_add.add(data[3])` // Sequence number (通番) |
| 6 | SET | Conditional: if `data[4]` (新規変更コード) is null/empty, use `HAFU_SPACE = " "` [-> CONSTANT HAFU_SPACE=" "] |
| 7 | SET | Conditional: if `data[5]` (工事案件種別コード) is null/empty, use `HAFU_SPACE` [-> CONSTANT HAFU_SPACE=" "] |
| 8 | SET | Conditional: if `data[6]` (工事案件番号) is null/empty, use `HAFU_SPACE` [-> CONSTANT HAFU_SPACE=" "] |
| 9 | SET | Conditional: if `data[7]` (OPMS工事案件結果コード) is null/empty, use `HAFU_SPACE` [-> CONSTANT HAFU_SPACE=" "] |
| 10 | SET | Conditional: if `data[8]` (工事案件実施年月日) is null/empty, use `HAFU_SPACE` [-> CONSTANT HAFU_SPACE=" "] |
| 11 | SET | `param_add.add(HAFU_SPACE)` // Construction scope code (工事範囲コード) — always half-width space |
| 12 | SET | `param_add.add(data[9])` // PON type code (PON種別コード) |
| 13 | SET | `param_add.add(sysrtem_date)` // System datetime (insert) |
| 14 | SET | `param_add.add(super.batchUserId)` // Batch TV (insert) |
| 15 | SET | `param_add.add(sysrtem_date)` // System datetime (update) |
| 16 | SET | `param_add.add(super.batchUserId)` // Batch TV (update) |
| 17 | SET | `param_add.add(SPACE)` // System datetime (delete) — full-width space |
| 18 | SET | `param_add.add(SPACE)` // Batch TV (delete) — full-width space |
| 19 | SET | `param_add.add("0")` // Register operation date and time |
| 20 | SET | `param_add.add(super.opeDate)` // Registration operation date (登録運用年月日) |
| 21 | SET | `param_add.add(SPACE)` // Registration process TV — full-width space |
| 22 | SET | `param_add.add(super.opeDate)` // Update operation date (更新運用年月日) |
| 23 | SET | `param_add.add(SPACE)` // Update process TV — full-width space |
| 24 | SET | `param_add.add(SPACE)` // Delete operation date — full-width space |
| 25 | SET | `param_add.add(SPACE)` // Delete process TV — full-width space |

**Block 6** — [CALL] Insert completion work record (L1682)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KJ_FIN_WK_PKINSERT(param_add.toArray())` // Creates record in KK_T_KJ_FIN_WK with 27 fields |

**Block 7** — [IF] OPMS construction case result code check (L1687)

> If the OPMS construction case result code (data[7]) is present and not empty, proceed to conditional routing. Otherwise, skip directly to the next row. [CONSTANT OPMS_KOJIAK_PSLT_CD_OK="1"]

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != data[7] && !"".equals(data[7])` // OPMS construction case result code is present |

**Block 7.1** — [IF] OPMS result is OK (L1690)

> OPMS construction case selection code equals "1" (OK). Search the service contract line detail table and update the PON type code. [CONSTANT OPMS_KOJIAK_PSLT_CD_OK="1"]

| # | Type | Code |
|---|------|------|
| 1 | IF | `OPMS_KOJIAK_PSLT_CD_OK.equals(data[7])` // OPMS code equals "1" (OK) |

**Block 7.1.1** — [CALL] Search service contract line detail (L1692)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `searchSvkeiKaisenUw(data[1])` // Search KK_T_SVKEI_KAISEN_UW by service contract line internal detail number |

**Block 7.1.2** — [IF] Search result is not null (L1695)

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != outDbMap` // Service contract line record found |

**Block 7.1.2.1** — [EXEC] Extract generation registration datetime (L1697)

| # | Type | Code |
|---|------|------|
| 1 | SET | `geneAddDtm = JBSbatStringUtil.Rtrim(outDbMap.getString(JBSbatKK_T_SVKEI_KAISEN_UW.GENE_ADD_DTM))` |
| 2 | EXEC | `printDebugLog("Generation registration datetime: " + geneAddDtm)` |
| 3 | EXEC | `printDebugLog("Construction completion file.PON type code: " + data[9])` |

**Block 7.1.2.2** — [IF] PON type code check (L1701)

> If PON type code is set, perform pessimistic control update on the service contract control table and update the service contract line detail table PON type code. [CONSTANT]

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != data[9] && !"".equals(data[9])` // PON type code is present |

**Block 7.1.2.2.1** — [CALL] Pessimistic control (L1704)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `forUpdatehSvkeiExcCtrl(data[0])` // Lock KK_T_SVKEI_EXC_CTRL by service contract number |

**Block 7.1.2.2.2** — [CALL] Update PON type code (L1707)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `updateSvkeiKaisenUw(data[1], data[9], geneAddDtm)` // Update KK_T_SVKEI_KAISEN_UW with new PON type code |
| 2 | EXEC | `printDebugLog("Service contract line detail table: PON type code update executed")` |

**Block 7.1.2.2.3** — [CALL] Update control table (L1710)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `updateSvkeiExcCtrl(data[0])` // Update KK_T_SVKEI_EXC_CTRL |
| 2 | EXEC | `printDebugLog("Service contract control table: update executed")` |

**Block 7.1.2.3** — [ELSE] PON type code is empty (L1713)

> PON type code is not set, so the service contract line detail table update target is excluded.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printDebugLog("PON type code check: service contract line detail table update target excluded")` |

**Block 7.1.3** — [ELSE] Search result is null (L1718)

> No service contract line detail record found, so the service contract line detail table update target is excluded.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printDebugLog("Service contract line detail information search absent: service contract line detail table update target excluded")` |

**Block 7.2** — [ELSE-IF] OPMS result is NG (L1723)

> OPMS construction case result code is "2" (NG/failure). Register cancellation work for the contract-related service.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | `data[7] != "1"` // OPMS code is "2" (NG) |

**Block 7.2.1** — [EXEC] Log cancellation registration (L1725)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printDebugLog("OPMS construction case result code '2(NG)': Contract-related cancellation work registration")` |

**Block 7.2.2** — [CALL] Create cancellation work (L1728)

> Register cancellation work for the service contract.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `createKjClWk(data)` // Create cancellation work registration |

**Block 7.2.3** — [CALL] Create phone cancellation work (L1731)

> Register cancellation work for bundled network-voice (phone) line service contracts.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `createKjClWkTel(data)` // Create cancellation work registration for phone lines |

**Block 8** — [END] End of loop (L1736)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printDebugLog("createKojiFinInf_END")` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KOJI_FIN_INF_FILE_ID` | Constant | Construction Completion Information File ID — file identifier "KKIFM051003" used to locate the intermediate CSV containing completion data |
| `OPMS_KOJIAK_PSLT_CD_OK` | Constant | OPMS Construction Case Selection Code OK — value "1" indicates successful OPMS construction case result; "2" indicates failure requiring cancellation |
| `HAFU_SPACE` | Constant | Half-width space character (" ") — used to pad empty or null CSV fields to maintain 27-field alignment |
| `svc_kei_no` | Field | Service contract number — unique identifier for a service contract in the telecom billing system |
| `svc_kei_kaisen_ucwk_no` | Field | Service contract line internal detail number — unique identifier for a line item within a service contract |
| `rnki_ymd` | Field | Linkage year month day — the date when this record was linked/synchronized between systems |
| `rnki_seq` | Field | Sequence number — the order position of this record among other records for the same contract |
| `new_chge_cd` | Field | New change code — classifies the type of change (new installation, modification, etc.) |
| `kojiak_sbt_cd` | Field | Construction case type code — categorizes the type of construction work (e.g., new, change, repair) |
| `kojiak_no` | Field | Construction case number — unique identifier for a construction case managed by the field operations system |
| `opms_kojiak_rslt_cd` | Field | OPMS construction case result code — result code from the field operations system indicating OK ("1") or NG ("2") |
| `kojiak_jssi_ymd` | Field | Construction case execution year month day — the date when construction was actually performed |
| `koji_scope_cd` | Field | Construction scope code — defines the scope/boundary of the construction work |
| `pon_sbt_cd` | Field | PON type code — classifies the type of Passive Optical Network service (e.g., FTTH type, shared vs dedicated) |
| KK_T_KJ_FIN_WK | DB Table | Construction completion work table — temporary table storing construction completion registration records before final consolidation |
| KK_T_SVKEI_KAISEN_UW | DB Table | Service contract line detail table — stores detailed information about each line within a service contract, including PON type code |
| KK_T_SVKEI_EXC_CTRL | DB Table | Service contract control table — manages locking and control state for service contracts during concurrent updates |
| KK_T_KJ_CL_WK | DB Table | Construction cancellation work table — stores cancellation work records when service contracts need to be cancelled |
| KK_T_KJ_CL_WK_TEL | DB Table | Construction cancellation work table (phone) — stores cancellation work records specifically for bundled phone-line services |
| OPMS | Acronym | Operations Provisioning Management System — external field operations system that manages physical construction cases |
| PON | Acronym | Passive Optical Network — fiber-to-the-home architecture using optical splitters for broadband delivery |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband service delivered via PON infrastructure |
| TV | Acronym | Terminal / Terminal TV — batch processing session identifier used as a logical user in audit trails |
| GENE_ADD_DTM | Field | Generation registration datetime — timestamp when the service contract line record was originally created |
| 連携年月日 | Field (Japanese) | Linkage year month day — synchronization date between systems |
| 工事完了情報 | Field (Japanese) | Construction completion information — data confirming that field construction work has been completed |
| 工事案件結果コード | Field (Japanese) | Construction case result code — OPMS system result code for the construction case (OK/NG) |
| 工事範囲コード | Field (Japanese) | Construction scope code — classification of the construction work scope |
| PON種別コード | Field (Japanese) | PON type code — classification of the PON service type |
| 登録運用年月日 | Field (Japanese) | Registration operation date — the business date when the record was registered |
| 更新運用年月日 | Field (Japanese) | Update operation date — the business date when the record was last updated |
| 削除運用年月日 | Field (Japanese) | Delete operation date — the business date when the record was deleted |
| 工事取り消し | Field (Japanese) | Construction cancellation — workflow to cancel a construction case and its associated service contracts when OPMS result is NG |

---

---
