# Business Logic — JBSbatKKKojiKnrnInfToroku.createTakniKojiInf() [142 LOC]

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

## 1. Role

### JBSbatKKKojiKnrnInfToroku.createTakniKojiInf()

This method performs **Inside-Home Work Order Information Registration** (宅内工事情報登録処理 — takunai kouji jouhou touroku shori). It reads a CSV file containing pre-processed inside-home work order data from an intermediate file directory, parses each CSV line into structured fields, and inserts the records into the `KK_T_TAKNIKJ_WK` (Inside-Home Work Work) database table.

The method operates as a **batch data ingestion step** within the larger work-related information registration batch (`JBSbatKKKojiKnrnInfToroku`). It implements the **file-read-transform-persist** pattern: it reads a comma-separated intermediate file identified by the constant `TAKNI_KOJI_INF_FILE_ID` ("KKIFM066003"), transforms each raw CSV row into a fully-formed parameter list with padding, system timestamps, batch user IDs, and operation metadata, then delegates to `executeKK_T_TAKNIKJ_WK_PKINSERT` to persist the record.

The method handles all records in the file in a single linear pass — there are no conditional branches based on service type or content code. Empty or null CSV fields at indices 4 through 11 are automatically padded with `HAFU_SPACE` (a half-width space " "), ensuring the database INSERT receives the correct number of columns. This method is exclusively called by `JBSbatKKKojiKnrnInfToroku.execute()` during batch processing, and it has no screen-level entry point.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["createTakniKojiInf"])
    START --> LOG_START["printDebugLog START"]
    LOG_START --> LOCAL_INIT["Initialize data_work and file_path"]
    LOCAL_INIT --> GET_SYS_DATE["getSystemDateTimeStamp"]
    GET_SYS_DATE --> BUILD_PATH["Build file_path"]
    BUILD_PATH --> READ_FILE["getInputFile"]
    READ_FILE --> CHECK_EMPTY{data_list empty}
    CHECK_EMPTY -->|Yes| LOG_END["printDebugLog END"]
    CHECK_EMPTY -->|No| FOR_LOOP["for each line in data_list"]
    FOR_LOOP --> GET_LINE["Get line data"]
    GET_LINE --> SPLIT_DATA["Split line by comma"]
    SPLIT_DATA --> BUILD_PARAM["Build param_add ArrayList"]
    BUILD_PARAM --> FIELD_0_3["Add data[0] to data[3]"]
    FIELD_0_3 --> LOOP_CONDITION{Loop condition}
    LOOP_CONDITION --> FIELD_VALID{data item valid}
    FIELD_VALID -->|Yes| ADD_FIELD["Add data[n]"]
    FIELD_VALID -->|No| ADD_HAFU_SPACE["Add HAFU_SPACE"]
    ADD_FIELD --> FIELD_SYS_DATE["Add sysrtem_date"]
    ADD_HAFU_SPACE --> FIELD_SYS_DATE
    FIELD_SYS_DATE --> ADD_BATCH_USERID["Add batchUserId"]
    ADD_BATCH_USERID --> ADD_SYS_DATE_2["Add sysrtem_date"]
    ADD_SYS_DATE_2 --> ADD_BATCH_USERID_2["Add batchUserId"]
    ADD_BATCH_USERID_2 --> ADD_SPACE_1["Add SPACE"]
    ADD_SPACE_1 --> ADD_SPACE_2["Add SPACE"]
    ADD_SPACE_2 --> ADD_ZERO["Add 0"]
    ADD_ZERO --> ADD_OPE_DATE_INS["Add super.opeDate"]
    ADD_OPE_DATE_INS --> ADD_SPACE_INS["Add SPACE"]
    ADD_SPACE_INS --> ADD_OPE_DATE_UPD["Add super.opeDate"]
    ADD_OPE_DATE_UPD --> ADD_SPACE_UPD["Add SPACE"]
    ADD_SPACE_UPD --> ADD_SPACE_DEL["Add SPACE"]
    ADD_SPACE_DEL --> ADD_SPACE_DEL_TV["Add SPACE"]
    ADD_SPACE_DEL_TV --> CALL_INSERT["executeKK_T_TAKNIKJ_WK_PKINSERT"]
    CALL_INSERT --> MORE_LINES{More lines}
    MORE_LINES -->|Yes| FOR_LOOP
    MORE_LINES -->|No| LOG_END
    LOG_END --> END_NODE(["Return void"])
```

**Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|------------------|
| `TAKNI_KOJI_INF_FILE_ID` | `"KKIFM066003"` | File ID for Inside-Home Work Information File |
| `FILE_KEISHIKI` | `".csv"` | File extension (CSV format) |
| `HAFU_SPACE` | `" "` | Half-width space — used as padding for null/empty CSV fields |
| `SPACE` | `""` | Empty string — used for null operation dates and batch user IDs |

**Field Mapping (CSV column index to param_add position):**

| data[] Index | Field (Japanese) | English Translation | Null Handling |
|--------------|-----------------|---------------------|---------------|
| 0 | サービス契約番号 | Service Contract Number | Always present (unconditional) |
| 1 | サービス契約回線内線番号 | Service Contract Line Extension Number | Always present (unconditional) |
| 2 | 連携年月日 | Coordination Date | Always present (unconditional) |
| 3 | 通番 | Serial Number | Always present (unconditional) |
| 4 | 新規変更コード | New/Change Code | Padded with HAFU_SPACE if null/empty |
| 5 | 工事案件種別コード | Work Case Type Code | Padded with HAFU_SPACE if null/empty |
| 6 | 工事案件番号 | Work Case Number | Padded with HAFU_SPACE if null/empty |
| 7 | 宅内工事完了予定年月日 | Inside-Home Work Completion Scheduled Date | Padded with HAFU_SPACE if null/empty |
| 8 | 宅内工事作業開始時間 | Inside-Home Work Start Time | Padded with HAFU_SPACE if null/empty |
| 9 | 工事都合同時番ポコ否 | Work Schedule Simultaneous Dial Flag | Padded with HAFU_SPACE if null/empty |
| 10 | 番ポ同時工事実施フラグ | Simultaneous Work Execution Flag | Padded with HAFU_SPACE if null/empty |
| 11 | 同時番ポ希望有無 | Simultaneous Dial Desired Flag | Padded with HAFU_SPACE if null/empty |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `mid_dir_kk` | `String` | Intermediate file directory path — the filesystem directory where pre-processed CSV files for work information are stored. This is the base path used to construct the full file path for reading inside-home work data. Passed from `commonItem.getFreeItem()` split at batch entry (`execute()`), where it is the first semicolon-delimited segment of the FREE parameter. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.batchUserId` | `String` (inherited) | Batch user ID — identifies the batch job execution user for audit trail |
| `super.opeDate` | `String` (inherited) | Operation date — the business date for insert/update/delete tracking |
| `super.logPrint` | `JBSbatOutputItem` (inherited) | Debug log print utility — used for START/END debug logging |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatDateUtil.getSystemDateTimeStamp` | - | - | Retrieves the current system date/time stamp as a string |
| R | `JBSbatKKKojiKnrnInfToroku.getInputFile` | - | - | Reads the intermediate CSV file (file path = `mid_dir_kk` + `"KKIFM066003"` + `".csv"`) and returns lines as `ArrayList<String>` |
| C | `JBSbatKKKojiKnrnInfToroku.executeKK_T_TAKNIKJ_WK_PKINSERT` | - | `KK_T_TAKNIKJ_WK` | Inserts a single inside-home work work record with full parameter set (18 fields including system date, batch user ID, operation date, etc.) |
| - | `JACBatCommon.printDebugLog` | - | - | Writes debug log for START marker |
| - | `JACbatDebugLogUtil.printDebugLog` | - | - | Writes debug log for END marker |

**CRUD Analysis:**
- **Create (1):** The sole data-altering operation is `executeKK_T_TAKNIKJ_WK_PKINSERT`, which inserts one row per CSV line into the `KK_T_TAKNIKJ_WK` (Inside-Home Work Work) temporary/intermediate table. This is a batch write — records are prepared from intermediate files and persisted in bulk (one row at a time within a loop).
- **Read (2):** The method reads system date/time via `JBSbatDateUtil.getSystemDateTimeStamp()` and reads the intermediate CSV file via `getInputFile()`. No database queries are executed within this method.
- **Update (0):** No update operations.
- **Delete (0):** No delete operations.

## 5. Dependency Trace

### Direct Caller

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

**Notes:** The method is private and called exclusively from `JBSbatKKKojiKnrnInfToroku.execute()` — the batch's main processing entry point. No screen-level (KKSV) callers exist.

### Call Chain Context (from execute())
The `execute()` method:
1. Parses intermediate file directory from `commonItem.getFreeItem()` (semicolon-delimited)
2. Calls `workInfoDelete()` to clear previous work table data
3. Calls `createTakniKojiInf(mid_dir_kk)` to insert inside-home work data
4. (Other commented-out steps existed historically — now removed by OM-2016-0001816)

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialization and system date retrieval (L2986)

The method starts by logging START, initializing local variables, and fetching the system timestamp.

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = ""` // Inside-home work information file single-line data buffer |
| 2 | SET | `file_path = ""` // File path buffer |
| 3 | CALL | `sysrtem_date = JBSbatDateUtil.getSystemDateTimeStamp()` // Get system date/time |
| 4 | SET | `file_path = mid_dir_kk + TAKNI_KOJI_INF_FILE_ID + FILE_KEISHIKI` // Build full path: `mid_dir_kk` + "KKIFM066003" + ".csv" |

**Block 2** — [CALL] Read intermediate CSV file (L3002)

Reads the pre-processed inside-home work CSV file and returns all lines as an ArrayList.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `data_list = getInputFile(file_path, TAKNI_KOJI_INF_FILE_ID)` // Reads file "KKIFM066003.csv" |

**Block 3** — [FOR] Iterate over each line in the file (L3004)

Iterates over every CSV line to process and insert it into the database.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter |
| 2 | SET | `i < data_list.size()` // Loop condition |
| 3 | EXEC | `i++` // Increment |

**Block 3.1** — [SET] Get single line data (L3007)

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = data_list.get(i)` // Get current line from file |

**Block 3.2** — [EXEC] Split CSV line into fields (L3010)

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] data = data_work.split(",", -1)` // Split by comma, keep trailing empty strings (-1) |

**Block 3.3** — [SET] Initialize parameter list for INSERT (L3013)

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add = new ArrayList<String>(data.length)` // Prepared INSERT parameter container |

**Block 3.4** — [SET] Fields 0-3: Unconditional adds (L3017-L3030)

These four fields are always added regardless of null/empty status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[0])` // Service Contract Number (サービス契約番号) |
| 2 | SET | `param_add.add(data[1])` // Service Contract Line Extension Number (サービス契約回線内線番号) |
| 3 | SET | `param_add.add(data[2])` // Coordination Date (連携年月日) |
| 4 | SET | `param_add.add(data[3])` // Serial Number (通番) |

**Block 3.5** — [IF/ELSE] Field 4: New/Change Code — conditional padding (L3032-L3040)

Condition: `[data[4] != null and data[4] != ""]`

> If the new/change code field has content, use it. Otherwise, pad with a half-width space to maintain column alignment.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[4])` // New/Change Code (新規変更コード) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // New/Change Code — padded with " " (half-width space) |

**Block 3.6** — [IF/ELSE] Field 5: Work Case Type Code — conditional padding (L3041-L3049)

Condition: `[data[5] != null and data[5] != ""]`

> If the work case type code has content, use it. Otherwise, pad with a half-width space.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[5])` // Work Case Type Code (工事案件種別コード) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Work Case Type Code — padded with " " |

**Block 3.7** — [IF/ELSE] Field 6: Work Case Number — conditional padding (L3050-L3058)

Condition: `[data[6] != null and data[6] != ""]`

> If the work case number has content, use it. Otherwise, pad with a half-width space.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[6])` // Work Case Number (工事案件番号) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Work Case Number — padded with " " |

**Block 3.8** — [IF/ELSE] Field 7: Inside-Home Work Completion Scheduled Date — conditional padding (L3059-L3067)

Condition: `[data[7] != null and data[7] != ""]`

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[7])` // Inside-Home Work Completion Scheduled Date (宅内工事完了予定年月日) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Completion Scheduled Date — padded with " " |

**Block 3.9** — [IF/ELSE] Field 8: Inside-Home Work Start Time — conditional padding (L3068-L3076)

Condition: `[data[8] != null and data[8] != ""]`

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[8])` // Inside-Home Work Start Time (宅内工事作業開始時間) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Start Time — padded with " " |

**Block 3.10** — [IF/ELSE] Field 9: Work Schedule Simultaneous Dial Flag — conditional padding (L3077-L3085)

Condition: `[data[9] != null and data[9] != ""]`

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[9])` // Work Schedule Simultaneous Dial Flag (工事都合同時番ポコ否) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Simultaneous Dial Flag — padded with " " |

**Block 3.11** — [IF/ELSE] Field 10: Simultaneous Work Execution Flag — conditional padding (L3086-L3094)

Condition: `[data[10] != null and data[10] != ""]`

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[10])` // Simultaneous Work Execution Flag (番ポ同時工事実施フラグ) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Execution Flag — padded with " " |

**Block 3.12** — [IF/ELSE] Field 11: Simultaneous Dial Desired Flag — conditional padding (L3095-L3103)

Condition: `[data[11] != null and data[11] != ""]`

| # | Type | Code |
|---|------|------|
| 1 | SET | `param_add.add(data[11])` // Simultaneous Dial Desired Flag (同時番ポ希望有無) — present |
| 2 | SET | `param_add.add(HAFU_SPACE)` // Desired Flag — padded with " " |

**Block 3.13** — [SET] Add audit/metadata fields (L3104-L3124)

After the CSV data fields, system-generated and batch metadata are appended to complete the INSERT parameter list. Total param_add size: 18 elements.

| # | Type | Code | Business Meaning |
|---|------|------|------------------|
| 1 | SET | `param_add.add(sysrtem_date)` | System date/time — insert timestamp |
| 2 | SET | `param_add.add(super.batchUserId)` | Batch user ID — who ran the batch |
| 3 | SET | `param_add.add(sysrtem_date)` | System date/time — update timestamp |
| 4 | SET | `param_add.add(super.batchUserId)` | Batch user ID — update user |
| 5 | SET | `param_add.add(SPACE)` | Empty string — delete user placeholder |
| 6 | SET | `param_add.add(SPACE)` | Empty string — delete user placeholder |
| 7 | SET | `param_add.add("0")` | Fixed "0" value (purpose: likely a version or status field) |
| 8 | SET | `param_add.add(super.opeDate)` | Operation date — insert operation date |
| 9 | SET | `param_add.add(SPACE)` | Empty string — insert TV (transaction version) |
| 10 | SET | `param_add.add(super.opeDate)` | Operation date — update operation date |
| 11 | SET | `param_add.add(SPACE)` | Empty string — update TV |
| 12 | SET | `param_add.add(SPACE)` | Empty string — delete operation date |
| 13 | SET | `param_add.add(SPACE)` | Empty string — delete TV |

**Block 4** — [CALL] Execute INSERT (L3126)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_TAKNIKJ_WK_PKINSERT(param_add.toArray())` // Insert single row into KK_T_TAKNIKJ_WK |

**Block 5** — [SET] Log completion and return (L3128-L3129)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.logPrint.printDebugLog("createTakniKojiInf_END")` // Log END marker |
| 2 | RETURN | (void) // Method returns |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mid_dir_kk` | Field | Intermediate file directory path — base filesystem directory where pre-processed batch CSV files are stored |
| `TAKNI_KOJI_INF_FILE_ID` | Constant | File ID "KKIFM066003" — identifier for the Inside-Home Work Information File |
| `FILE_KEISHIKI` | Constant | File extension ".csv" — intermediate files are comma-separated values |
| `HAFU_SPACE` | Constant | Half-width space " " — used as padding for null or empty CSV fields to maintain column count |
| `SPACE` | Constant | Empty string "" — used as placeholder for null audit fields (delete user, delete TV) |
| `KK_T_TAKNIKJ_WK` | Table | Inside-Home Work Work (Temporary) table — intermediate database table holding inside-home work order records for batch processing |
| `executeKK_T_TAKNIKJ_WK_PKINSERT` | Method | Database INSERT procedure — inserts one inside-home work work record into the `KK_T_TAKNIKJ_WK` table using a parameter array |
| `getInputFile` | Method | Intermediate file reader — reads a CSV file by file ID and returns its lines as an ArrayList of strings |
| `super.batchUserId` | Inherited Field | Batch user ID — audit field identifying the user who ran the batch job |
| `super.opeDate` | Inherited Field | Operation date — the business date for insert/update/delete tracking in audit columns |
| `getSystemDateTimeStamp` | Utility | System date/time retrieval — returns the current database server date/time as a formatted string |
| services | Domain term | Services (サービス) — refers to telecom service contracts (internet, telephone, TV) provided by K-Opticom |
| 宅内工事 (takunai kouji) | Japanese term | Inside-Home Work — installation/maintenance work performed inside a customer's premises (as opposed to outside plant work) |
| 工事案件 (kouji anken) | Japanese term | Work Case / Work Project — a work order or case that bundles installation/maintenance tasks |
| サービス契約番号 (saabuisu keiyaku bangou) | Field | Service Contract Number — unique identifier for a service contract |
| サービス契約回線内線番号 (saabuisu keiyaku kaisen naisen bangou) | Field | Service Contract Line Extension Number — identifies a specific line within a service contract |
| 連携年月日 (renkei nengappi) | Field | Coordination Date — date of data coordination/synchronization with upstream systems |
| 通番 (tsuu-ban) | Field | Serial Number — sequential record number within a batch run |
| 新規変更コード (shinki henkou koudo) | Field | New/Change Code — classifies the type of change (new installation, modification, cancellation, etc.) |
| 工事案件種別コード (kouji anken shubetsu koudo) | Field | Work Case Type Code — classifies the kind of work case (e.g., "01" = Net Home, "03" = TV, "015" = ONU replacement) |
| 工事案件番号 (kouji anken bangou) | Field | Work Case Number — unique identifier for a work case |
| 宅内工事完了予定年月日 (takunai kouji kanryou yotei nengappi) | Field | Inside-Home Work Completion Scheduled Date — planned completion date for inside-home work |
| 宅内工事作業開始時間 (takunai kouji sagyou kaishi jikan) | Field | Inside-Home Work Start Time — planned start time for inside-home work |
| 工事都合同時番ポコ否 (kouji tsugoudoushi bango-poko hi) | Field | Work Schedule Simultaneous Dial Flag — indicates whether simultaneous dialing is feasible given the work schedule |
| 番ポ同時工事実施フラグ (bango-pou douji kouji jisshi flag) | Field | Simultaneous Work Execution Flag — indicates whether simultaneous work execution will be performed |
| 同時番ポ希望有無 (douji bango-pou kibou yumu) | Field | Simultaneous Dial Desired Flag — whether simultaneous dialing is requested |
| OPMS | Acronym | Operation and Maintenance Production System — operations support system for work management |
| CSV | Acronym | Comma-Separated Values — plain text file format used for intermediate batch data exchange |
| Batch | Domain term | Batch processing — non-interactive program execution that processes bulk data, as opposed to screen-based online processing |
| K-Opticom | Domain term | Telecom service provider — the business owner of this system (Japanese cable/telecom operator) |
