# Business Logic — JBSbatKKKojiKnrnInfToroku.createKojihiInf() [116 LOC]

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

## 1. Role

### JBSbatKKKojiKnrnInfToroku.createKojihiInf()

This method performs **Construction Fee Information Registration** (工事費情報登録処理 — *Kojihi Jouhou Touroku Shori*). It is a batch processing step that reads a pre-processed CSV file containing construction fee (工事費 — *kojihi*) data from an intermediate directory, parses each CSV line into structured fields, and inserts the records into the database work table `KK_T_KOJIHI_SNST_WK` (Construction Fee Information Registration Work Table).

The method follows a **read-transform-insert** batch processing pattern. It operates on a single CSV input file whose path is derived from the input directory (`mid_dir_kk`), a file ID constant (`KKIFM067003`), and the file extension `.csv`. Each CSV line represents one construction fee record containing 9 parsed fields: service contract number, service contract line detail number, linkage year-month-day, sequence number, new/change code, work project type code, work project number, temporary payment price number, and total construction fee amount.

Null or empty string values in fields 4 through 7 are replaced with a half-width space (`" "`) as a padding convention. Field 8 (total construction fee amount) defaults to `"0"` if absent. Every inserted row is enriched with system timestamp, batch user ID, operation date, and audit metadata (ADD/UPD/DEL timestamps, operator accounts, transaction IDs, and make flag).

This method is called by `JBSbatKKKojiKnrnInfToroku.execute()` and serves as the persistence layer for the construction fee information registration batch sub-task within the eO Customer Core System (eO 顧客基幹システム).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["createKojihiInf start"])
    START --> LOG_START["Log: createKojihiInf_START"]

    LOG_START --> INIT[Initialize local variables]

    INIT --> GET_SYS_DATE["Get System DateTime via JBSbatDateUtil"]

    GET_SYS_DATE --> BUILD_PATH["Build file path from mid_dir_kk and constants"]

    BUILD_PATH --> READ_FILE["Read file via getInputFile"]

    READ_FILE --> LOOP_START["For loop over data_list"]

    LOOP_START --> GET_LINE["Get current line from data_list"]

    GET_LINE --> SPLIT_DATA["Split line by comma delimiter"]

    SPLIT_DATA --> CREATE_PARAM["Create param_add ArrayList"]

    CREATE_PARAM --> ADD_F0["Add data field 0 to param_add"]

    ADD_F0 --> ADD_F1["Add data field 1 to param_add"]

    ADD_F1 --> ADD_F2["Add data field 2 to param_add"]

    ADD_F2 --> ADD_F3["Add data field 3 to param_add"]

    ADD_F3 --> COND4{field4 checked}

    COND4 -->|Yes| ADD4H["Add HAFU_SPACE to param_add"]

    COND4 -->|No| ADD4D["Add field4 data to param_add"]

    ADD4H --> COND5{field5 checked}

    ADD4D --> COND5

    COND5 -->|Yes| ADD5H["Add HAFU_SPACE to param_add"]

    COND5 -->|No| ADD5D["Add field5 data to param_add"]

    ADD5H --> COND6{field6 checked}

    ADD5D --> COND6

    COND6 -->|Yes| ADD6H["Add HAFU_SPACE to param_add"]

    COND6 -->|No| ADD6D["Add field6 data to param_add"]

    ADD6H --> COND7{field7 checked}

    ADD6D --> COND7

    COND7 -->|Yes| ADD7H["Add HAFU_SPACE to param_add"]

    COND7 -->|No| ADD7D["Add field7 data to param_add"]

    ADD7H --> COND8{field8 checked}

    ADD7D --> COND8

    COND8 -->|Yes| ADD8Z["Add literal 0 to param_add"]

    COND8 -->|No| ADD8D["Add field8 data to param_add"]

    ADD8Z --> ADD_SYS1["Add sysrtem_date to param_add"]

    ADD8D --> ADD_SYS1

    ADD_SYS1 --> ADD_BAT1["Add batchUserId to param_add"]

    ADD_BAT1 --> ADD_SYS2["Add sysrtem_date to param_add"]

    ADD_SYS2 --> ADD_BAT2["Add batchUserId to param_add"]

    ADD_BAT2 --> ADD_SYS3["Add sysrtem_date to param_add"]

    ADD_SYS3 --> ADD_BAT3["Add batchUserId to param_add"]

    ADD_BAT3 --> ADD_SP1["Add SPACE to param_add"]

    ADD_SP1 --> ADD_SP2["Add SPACE to param_add"]

    ADD_SP2 --> ADD_ZFLG["Add literal 0 to param_add"]

    ADD_ZFLG --> ADD_OPE1["Add opeDate to param_add"]

    ADD_OPE1 --> ADD_SP3["Add SPACE to param_add"]

    ADD_SP3 --> ADD_OPE2["Add opeDate to param_add"]

    ADD_OPE2 --> ADD_SP4["Add SPACE to param_add"]

    ADD_SP4 --> ADD_SP5["Add SPACE to param_add"]

    ADD_SP5 --> ADD_SP6["Add SPACE to param_add"]

    ADD_SP6 --> EXEC_INSERT["Call executeKK_T_KOJIHI_SNST_WK_PKINSERT"]

    EXEC_INSERT --> LOOP_NEXT["Increment i, loop back to GET_LINE"]

    LOOP_NEXT --> LOOP_START

    LOOP_START --> LOG_END["Log: createKojihiInf_END"]

    LOG_END --> END_NODE(["Return"])
```

**Constant Resolution Reference:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `KOJIHI_INF_FILE_ID` | `"KKIFM067003"` | Intermediate file ID for construction fee information registration input file |
| `FILE_KEISHIKI` | `".csv"` | File extension — comma-separated values |
| `HAFU_SPACE` | `" "` | Half-width space character — used as padding for missing optional fields (fields 4-7) |
| `SPACE` | `""` | Empty string — used for unused audit placeholder fields |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `mid_dir_kk` | `String` | Intermediate file storage directory path — the directory where the pre-processed CSV file containing construction fee information is stored. The file is constructed as `mid_dir_kk + "KKIFM067003" + ".csv"`. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.batchUserId` | `String` | The batch processing user/operation account ID, inherited from the parent class — used as the ADD/UPD/DEL operator account in audit columns |
| `super.opeDate` | `String` | The operation date (year-month-day) — used as the ADD/UPD operation year-month-day in audit columns |
| `super.logPrint` | `JBSbatCommon` (inherited) | Debug log printer — used to emit START/END debug markers |

## 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 | - | Retrieves system date-time stamp string for audit timestamps |
| R | `getInputFile(file_path, KOJIHI_INF_FILE_ID)` | JBSbatKKKojiKnrnInfToroku | - | Reads CSV file from intermediate directory, returns list of lines |
| C | `executeKK_T_KOJIHI_SNST_WK_PKINSERT(param_add.toArray())` | JBSbatKKKojiKnrnInfToroku | `KK_T_KOJIHI_SNST_WK` | Inserts one construction fee registration record with primary key columns |
| - | `JACBatCommon.printDebugLog` | JACBatCommon | - | Logs START marker for debugging |
| - | `JACbatDebugLogUtil.printDebugLog` | JACbatDebugLogUtil | - | Logs END marker for debugging |
| - | `String.split(",", -1)` | Java String | - | Splits CSV line into field array, preserving trailing empty fields |
| - | `ArrayList.toArray()` | Java ArrayList | - | Converts param_add list to array for insert method |

**Detailed CRUD breakdown:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatDateUtil.getSystemDateTimeStamp` | JBSbatDateUtil | - | Retrieves current system date-time stamp; used for all ADD/UPD/DEL timestamp columns |
| R | `getInputFile` | JBSbatKKKojiKnrnInfToroku | - | Reads the CSV file containing construction fee records from intermediate directory |
| C | `executeKK_T_KOJIHI_SNST_WK_PKINSERT` | EKK_KOJIHI_REG | `KK_T_KOJIHI_SNST_WK` | Inserts a construction fee registration record into the work table using primary key columns (22 parameters: 9 business data fields + 13 audit/metadata fields) |
| - | `super.logPrint.printDebugLog` | JACBatCommon | - | Debug logging of method entry and exit |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKKojiKnrnInfToroku | `JBSbatKKKojiKnrnInfToroku.execute()` -> `createKojihiInf(mid_dir_kk)` | `executeKK_T_KOJIHI_SNST_WK_PKINSERT [C] KK_T_KOJIHI_SNST_WK` |

**Call chain detail:** The method is called directly from the `execute()` method of `JBSbatKKKojiKnrnInfToroku`, which serves as the main batch entry point for construction-related information registration processing. The `execute()` method coordinates multiple sub-tasks (construction completion, reservation, work equipment, cancellation, etc.), and `createKojihiInf` is one of these sub-tasks responsible specifically for construction fee data registration.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(Initialization)` (L3137)

> Initialize local variables.

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = ""` // Construction fee file line data holder (工事費情報ファイル1行データ保持) |
| 2 | SET | `file_path = ""` // File path holder (ファイルパス保持) |

**Block 2** — [CALL] `(Get system datetime)` (L3141)

> Retrieve the current system date-time stamp used for all audit timestamp columns.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sysrtem_date = JBSbatDateUtil.getSystemDateTimeStamp()` // Set system date-time (システム日時を取得) |

**Block 3** — [SET] `(Build file path)` (L3144)

> Construct the full path to the construction fee input CSV file.

| # | Type | Code |
|---|------|------|
| 1 | SET | `file_path = mid_dir_kk + KOJIHI_INF_FILE_ID + FILE_KEISHIKI` // [-> KOJIHI_INF_FILE_ID = "KKIFM067003"] [-> FILE_KEISHIKI = ".csv"] |

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

> Read the CSV file containing construction fee records from the intermediate directory.

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_list = getInputFile(file_path, KOJIHI_INF_FILE_ID)` // [KOJIHI_INF_FILE_ID = "KKIFM067003"] Returns ArrayList of file lines |

**Block 5** — [FOR] `(Iterate over each line of the CSV)` (L3150)

> Loop through each line of the construction fee CSV file. Each line represents one construction fee registration record.

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

**Block 5.1** — [SET] `(Get current line)` (L3153)

> Extract the current line from the data list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = data_list.get(i)` // Get current line (1行目を取得) |

**Block 5.2** — [EXEC] `(Split CSV line into fields)` (L3156)

> Split the CSV line by comma delimiter into individual fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `data = data_work.split(",", -1)` // Split by comma, -1 preserves trailing empty fields (データを分解) |

**Block 5.3** — [SET] `(Create parameter list)` (L3159)

> Create a new ArrayList to hold the 22 parameters for the database insert operation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add = new ArrayList<String>(data.length)` // Parameter data container for registration (登録用データ格納) |

**Block 5.4** — [SET] `(Transform and add fields 0-3)` (L3162-L3170)

> Map the first 4 CSV fields directly to the parameter list without null checking. These are required fields: service contract number, service contract line detail number, linkage year-month-day, and sequence number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[0])` // SVC_KEI_NO: Service Contract Number (サービス契約番号) |
| 2 | SET | `param_add.add(data[1])` // SVC_KEI_KAISEN_UCWK_NO: Service Contract Line Detail Number (サービス契約回線内詳細番号) |
| 3 | SET | `param_add.add(data[2])` // RNKI_YMD: Linkage Year-Month-Day (連携年月日) |
| 4 | SET | `param_add.add(data[3])` // RNKI_SEQ: Sequence Number (通番) |

**Block 5.5** — [IF/ELSE] `(Conditional padding for field 4 — NEW_CHGE_CD)` (L3171-L3179)

> Field 4 is the New/Change Code (新規変更コード). If null or empty, pad with half-width space.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != data[4] && !"".equals(data[4])` |
| 2 | SET (then) | `param_add.add(data[4])` // NEW_CHGE_CD: New/Change Code (新規変更コード) |
| 3 | SET (else) | `param_add.add(HAFU_SPACE)` // [-> HAFU_SPACE = " "] (半角スペース) |

**Block 5.6** — [IF/ELSE] `(Conditional padding for field 5 — KOJIAK_SBT_CD)` (L3180-L3188)

> Field 5 is the Work Project Type Code (工事案件種類コード). If null or empty, pad with half-width space.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != data[5] && !"".equals(data[5])` |
| 2 | SET (then) | `param_add.add(data[5])` // KOJIAK_SBT_CD: Work Project Type Code (工事案件種類コード) |
| 3 | SET (else) | `param_add.add(HAFU_SPACE)` // [-> HAFU_SPACE = " "] (半角スペース) |

**Block 5.7** — [IF/ELSE] `(Conditional padding for field 6 — KOJIAK_NO)` (L3189-L3197)

> Field 6 is the Work Project Number (工事案件番号). If null or empty, pad with half-width space.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != data[6] && !"".equals(data[6])` |
| 2 | SET (then) | `param_add.add(data[6])` // KOJIAK_NO: Work Project Number (工事案件番号) |
| 3 | SET (else) | `param_add.add(HAFU_SPACE)` // [-> HAFU_SPACE = " "] (半角スペース) |

**Block 5.8** — [IF/ELSE] `(Conditional padding for field 7 — TMP_PAY_PRC_NO)` (L3199-L3207)

> Field 7 is the Temporary Payment Price Number (一時支払料金番号). If null or empty, pad with half-width space.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != data[7] && !"".equals(data[7])` |
| 2 | SET (then) | `param_add.add(data[7])` // TMP_PAY_PRC_NO: Temporary Payment Price Number (一時支払料金番号) |
| 3 | SET (else) | `param_add.add(HAFU_SPACE)` // [-> HAFU_SPACE = " "] (半角スペース) |

**Block 5.9** — [IF/ELSE] `(Conditional default for field 8 — TMPY_PRC_KOJIHI_GOKEI_AMNT)` (L3208-L3216)

> Field 8 is the Total Construction Fee Amount (工事費合計金額). If null or empty, default to `"0"` instead of space (numeric field).

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != data[8] && !"".equals(data[8])` |
| 2 | SET (then) | `param_add.add(data[8])` // TMPY_PRC_KOJIHI_GOKEI_AMNT: Total Construction Fee Amount (工事費合計金額) |
| 3 | SET (else) | `param_add.add("0")` // Default to zero (ゼロ) |

**Block 5.10** — [SET] `(Add audit fields 9-21)` (L3217-L3241)

> Append 13 system-managed audit columns to the parameter list. These cover add/update/delete timestamps, operator accounts, transaction IDs, make flag, and operation dates.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(sysrtem_date)` // ADD_DTM: Add Date-Time (登録日時) |
| 2 | SET | `param_add.add(super.batchUserId)` // ADD_OPEACNT: Add Operator Account (登録処理ID) |
| 3 | SET | `param_add.add(sysrtem_date)` // UPD_DTM: Update Date-Time (更新日時) |
| 4 | SET | `param_add.add(super.batchUserId)` // UPD_OPEACNT: Update Operator Account (更新処理ID) |
| 5 | SET | `param_add.add(sysrtem_date)` // DEL_DTM: Delete Date-Time (削除年月日時分秒) |
| 6 | SET | `param_add.add(super.batchUserId)` // DEL_OPEACNT: Delete Operator Account (削除オペレータアカウント) |
| 7 | SET | `param_add.add(SPACE)` // [-> SPACE = ""] DEL_DTM placeholder |
| 8 | SET | `param_add.add(SPACE)` // [-> SPACE = ""] DEL_OPEACNT placeholder |
| 9 | SET | `param_add.add("0")` // MK_FLG: Make Flag (ゼロ) |
| 10 | SET | `param_add.add(super.opeDate)` // ADD_UNYO_YMD: Add Operation Year-Month-Day (登録運用年月日) |
| 11 | SET | `param_add.add(SPACE)` // [-> SPACE = ""] ADD_TRN_ID placeholder |
| 12 | SET | `param_add.add(super.opeDate)` // UPD_UNYO_YMD: Update Operation Year-Month-Day (更新運用年月日) |
| 13 | SET | `param_add.add(SPACE)` // [-> SPACE = ""] UPD_TRN_ID placeholder |
| 14 | SET | `param_add.add(SPACE)` // [-> SPACE = ""] DEL_UNYO_YMD placeholder |
| 15 | SET | `param_add.add(SPACE)` // [-> SPACE = ""] DEL_TRN_ID placeholder |

**Block 5.11** — [CALL] `(Insert record)` (L3244)

> Execute the database insert for the current construction fee record. The param_add array (22 elements) is passed to the insert method which maps each element to a corresponding primary key column of `KK_T_KOJIHI_SNST_WK`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KOJIHI_SNST_WK_PKINSERT(param_add.toArray())` |

**Block 6** — [EXEC] `(End logging)` (L3248)

> Log method completion.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("createKojihiInf_END")` // End log marker (終了ログ出力) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kojihi` (工事費) | Business term | Construction Fee — costs associated with installation/construction work for telecommunications services |
| `SVC_KEI_NO` | Field | Service Contract Number — the primary identifier for a customer's service contract |
| `SVC_KEI_KAISEN_UCWK_NO` | Field | Service Contract Line Detail Number — internal tracking number for a specific line within a service contract |
| `RNKI_YMD` | Field | Linkage Year-Month-Day — the date when data is linked/linked between systems |
| `RNKI_SEQ` | Field | Sequence Number — the order number within a batch or processing group |
| `NEW_CHGE_CD` | Field | New/Change Code — classifies the operation as new registration or modification |
| `KOJIAK_SBT_CD` | Field | Work Project Type Code — categorizes the type of construction project |
| `KOJIAK_NO` | Field | Work Project Number — unique identifier for a specific construction project |
| `TMP_PAY_PRC_NO` | Field | Temporary Payment Price Number — reference number for temporary/advance payment pricing |
| `TMPY_PRC_KOJIHI_GOKEI_AMNT` | Field | Total Construction Fee Amount — total cost amount for the construction work |
| `ADD_DTM` | Field | Add Date-Time — timestamp when the record was created |
| `ADD_OPEACNT` | Field | Add Operator Account — user ID of the operator who created the record |
| `UPD_DTM` | Field | Update Date-Time — timestamp when the record was last modified |
| `UPD_OPEACNT` | Field | Update Operator Account — user ID of the operator who last modified the record |
| `DEL_DTM` | Field | Delete Date-Time — timestamp when the record was soft-deleted |
| `DEL_OPEACNT` | Field | Delete Operator Account — user ID of the operator who deleted the record |
| `MK_FLG` | Field | Make Flag — flag indicating the record is newly created (set to "0") |
| `ADD_UNYO_YMD` | Field | Add Operation Year-Month-Day — the operation date when record was added |
| `ADD_TRN_ID` | Field | Add Transaction ID — transaction identifier for the add operation |
| `UPD_UNYO_YMD` | Field | Update Operation Year-Month-Day — the operation date when record was updated |
| `UPD_TRN_ID` | Field | Update Transaction ID — transaction identifier for the update operation |
| `DEL_UNYO_YMD` | Field | Delete Operation Year-Month-Day — the operation date when record was deleted |
| `DEL_TRN_ID` | Field | Delete Transaction ID — transaction identifier for the delete operation |
| `KK_T_KOJIHI_SNST_WK` | Table | Construction Fee Information Registration Work Table — temporary work table holding construction fee records before final processing |
| `KKIFM067003` | Constant | Intermediate File ID — identifies the construction fee information registration input file in the intermediate directory |
| `HAFU_SPACE` | Constant | Half-width Space — a single ASCII space character (`" "`) used as padding for optional fields |
| `SPACE` | Constant | Empty String — used as a placeholder for unused audit fields |
| `batchUserId` | Instance field | The batch processing user/account ID, inherited from the parent class |
| `opeDate` | Instance field | The current operation date (year-month-day format), inherited from the parent class |
| `mid_dir_kk` | Parameter | Intermediate file directory path — directory where pre-processed CSV files are staged for batch processing |
| eO 顧客基幹システム | System | eO Customer Core System — the Fujitsu-built customer management system for K-Opticom telecommunications |
| 工事費情報登録処理 | Business process | Construction Fee Information Registration Processing — the overall batch task this method belongs to |
