# Business Logic — JBSbatKKBndWdtUpdFile.insertFileKanri() [38 LOC]

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

## 1. Role

### JBSbatKKBndWdtUpdFile.insertFileKanri()

This method registers a downloaded electronic file into the **Download File Management** table (`ZM_T_DL_FILE_KANRI`). It is a dedicated batch registration routine used by the domain-control file download processing pipeline. Specifically, it is invoked after the `execute()` method completes the electronic file creation workflow (via `JCCBatCommon.createDenshiFile`) — the returned file management number (`fileKanriNo`) and the data record count (`datacnt`) are persisted as a metadata record. The method follows a **sequential parameter-building pattern**: it constructs a `JBSbatCommonDBInterface` object by setting 15 fields one by one, then delegates to the insert method `executeZM_T_DL_FILE_KANRI_PKINSERT` to perform the actual database insertion. Its role in the larger system is to ensure every downloaded domain-control file (such as a warning notification postcard for communication-volume overage) is tracked in the file management registry with its generated sequence number, processing category code, and timestamp.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertFileKanri(datacnt, fileKanriNo, sysDateTime)"])
    STEP1["Create JBSbatCommonDBInterface param"]
    STEP2["Generate FILE_NO via JCCBatCommon.getFormatedNextSeq"]
    STEP3["Set TRN_KANRI_NO = 000000000066 (Processing management number for warning info)"]
    STEP4["Set EFILE_KANRI_NO from fileKanriNo parameter"]
    STEP5["Extract fileName from in_postcard_file_path split by /"]
    STEP6["Set FILE_NM = fileName[fileName.length - 1]"]
    STEP7["Set FILE_SIZE = empty string"]
    STEP8["Set DATA_CNT from datacnt parameter"]
    STEP9["Set FILE_ADD_DTM from sysDateTime parameter"]
    STEP10["Set FILE_DEL_YMD = null"]
    STEP11["Set ADD_DTM = null"]
    STEP12["Set ADD_OPEACNT = null"]
    STEP13["Set UPD_DTM = null"]
    STEP14["Set UPD_OPEACNT = null"]
    STEP15["Set DEL_DTM = null"]
    STEP16["Set DEL_OPEACNT = null"]
    STEP17["Set MK_FLG = null"]
    STEP18["Execute executeZM_T_DL_FILE_KANRI_PKINSERT with param data"]
    END(["Return / Next"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    STEP6 --> STEP7
    STEP7 --> STEP8
    STEP8 --> STEP9
    STEP9 --> STEP10
    STEP10 --> STEP11
    STEP11 --> STEP12
    STEP12 --> STEP13
    STEP13 --> STEP14
    STEP14 --> STEP15
    STEP15 --> STEP16
    STEP16 --> STEP17
    STEP17 --> STEP18
    STEP18 --> END
```

**Processing Overview:** The method performs a linear sequence of 15 parameter assignments followed by a single database insert call. There are no conditional branches, loops, or exception handling within this method. Each `param.setValue()` call assigns the next field expected by the `executeZM_T_DL_FILE_KANRI_PKINSERT` method, which maps positional array elements (`setParam[0]` through `setParam[14]`) to database column names. The constants used are:

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `FILE_CD_POSTCARD_TIIK_LMT_INFO` | `"000000000066"` | Processing management number identifying the file as a warning communication-volume overage notification |
| `SEQ_PREFIX_SEQ_FILE_NOO` | `""` (empty string) | No prefix for the file number sequence |
| `SEQ_LEN_SEQ_FILE_NO` | `12` | Sequence number length of 12 digits |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `datacnt` | `int` | Data record count — the number of data records contained in the downloaded file. Used to track the volume of data associated with this file management entry. |
| 2 | `fileKanriNo` | `String` | Electronic file management number — a unique identifier assigned by `JCCBatCommon.createDenshiFile()` when the electronic file was created. This links the file management record to the actual stored file. |
| 3 | `sysDateTime` | `String` | System date and time — the timestamp at which this file registration record is created. Used as the file registration datetime (`FILE_ADD_DTM`) in the management table. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `in_postcard_file_path` | `String` | The file system path to the warning communication-volume notification postcard file. Used to extract the file name (step 5–6) by splitting on `/` and taking the last segment. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBatCommon.getFormatedNextSeq` | JCCBatCommon | - | Calls `getFormatedNextSeq` in `JCCBatCommon` to generate a formatted file number sequence |
| C | `executeZM_T_DL_FILE_KANRI_PKINSERT` | - | `ZM_T_DL_FILE_KANRI` | Calls `executeZM_T_DL_FILE_KANRI_PKINSERT` which performs a primary-key-based insert on the Download File Management table |

### Detailed CRUD Analysis

**How the PKINSERT works:**

The called method `executeZM_T_DL_FILE_KANRI_PKINSERT` (implemented in sibling classes such as `JBSbatACContJgshaEfileAdd` using the same pattern) creates a `JBSbatCommonDBInterface` from the positional parameter array and maps each element to a column name:

| Array Index | Column Name | Business Description |
|-------------|-------------|---------------------|
| [0] | `FILE_NO` | Generated file number (12-digit sequence) |
| [1] | `TRN_KANRI_NO` | Processing management number (`000000000066` for warning info) |
| [2] | `EFILE_KANRI_NO` | Electronic file management number |
| [3] | `FILE_NM` | File name extracted from the file path |
| [4] | `FILE_SIZE` | File size (set to empty string) |
| [5] | `DATA_CNT` | Data record count |
| [6] | `FILE_ADD_DTM` | File registration date/time |
| [7] | `FILE_DEL_YMD` | File deletion date (null — not yet deleted) |
| [8] | `ADD_DTM` | Registration date/time (null) |
| [9] | `ADD_OPEACNT` | Registration operator account (null) |
| [10] | `UPD_DTM` | Update date/time (null) |
| [11] | `UPD_OPEACNT` | Update operator account (null) |
| [12] | `DEL_DTM` | Deletion date/time (null) |
| [13] | `DEL_OPEACNT` | Deletion operator account (null) |
| [14] | `MK_FLG` | Make flag / invalid flag (null) |

Then it invokes `db_ZM_T_DL_FILE_KANRI.insertByPrimaryKeys(setMap)` to perform the database insert. The `db_ZM_T_DL_FILE_KANRI` SQL access object is initialized with the table name `ZM_T_DL_FILE_KANRI` (Download File Management table).

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBatCommon.getFormatedNextSeq` | JCCBatCommon | - | Generates a 12-digit formatted file number sequence (SEQ_FILE_NO) for the new file management record |
| C | `executeZM_T_DL_FILE_KANRI_PKINSERT` | - | `ZM_T_DL_FILE_KANRI` | Inserts a new row into the Download File Management table via primary-key-based insertion with all 15 columns populated |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKBndWdtUpdFile | `JBSbatKKBndWdtUpdFile.execute()` → `insertFileKanri(datacnt, rc[0], sysDateTime)` | `executeZM_T_DL_FILE_KANRI_PKINSERT [C] ZM_T_DL_FILE_KANRI` |

**Caller context:** The `execute()` method in `JBSbatKKBndWdtUpdFile` first creates the electronic file via `JCCBatCommon.createDenshiFile()` (which returns an array where `rc[0]` is the file management number), then immediately calls `insertFileKanri()` to register that file's metadata into the download file management table.

## 6. Per-Branch Detail Blocks

Since `insertFileKanri()` has a purely linear flow with no conditional branches, loops, or exception handling, the entire method is treated as a single block.

**Block 1** — [LINEAR PROCESS] `No branching` (L226–L263)

> Creates a parameter object and populates all 15 fields for the download file management insert, then delegates to the PK insert method.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param = new JBSbatCommonDBInterface()` // Create the parameter container [-> `JBSbatCommonDBInterface`] |
| 2 | SET | `param.setValue(JCCBatCommon.getFormatedNextSeq(super.commonItem, "SEQ_FILE_NO", SEQ_PREFIX_SEQ_FILE_NOO, SEQ_LEN_SEQ_FILE_NO))` // 1. File number — generate next sequence [-> `SEQ_PREFIX_SEQ_FILE_NOO=""`, `SEQ_LEN_SEQ_FILE_NO=12`] |
| 3 | SET | `param.setValue(FILE_CD_POSTCARD_TIIK_LMT_INFO)` // 2. Processing management number [-> `FILE_CD_POSTCARD_TIIK_LMT_INFO="000000000066"` — Warning communication-volume overage notification] |
| 4 | SET | `param.setValue(fileKanriNo)` // 3. Electronic file management number — passed from caller |
| 5 | SET | `String[] fileName = in_postcard_file_path.split("/", -1)` // 4. Extract file name from full path, -1 keeps trailing empty strings [Field: `in_postcard_file_path`] |
| 6 | SET | `param.setValue(fileName[fileName.length - 1])` // 4. File name — last segment of the path |
| 7 | SET | `param.setValue("")` // 5. File size — set to empty string |
| 8 | SET | `param.setValue(datacnt)` // 6. Data record count — from parameter |
| 9 | SET | `param.setValue(sysDateTime)` // 7. File registration date/time — from parameter |
| 10 | SET | `param.setValue(null)` // 8. File deletion date — not applicable at registration |
| 11 | SET | `param.setValue(null)` // 9. Registration date/time |
| 12 | SET | `param.setValue(null)` // 10. Registration operator account |
| 13 | SET | `param.setValue(null)` // 11. Update date/time |
| 14 | SET | `param.setValue(null)` // 12. Update operator account |
| 15 | SET | `param.setValue(null)` // 13. Deletion date/time |
| 16 | SET | `param.setValue(null)` // 14. Deletion operator account |
| 17 | SET | `param.setValue(null)` // 15. Invalid flag |
| 18 | CALL | `executeZM_T_DL_FILE_KANRI_PKINSERT(param.getList().toArray())` // Execute primary-key insert into ZM_T_DL_FILE_KANRI table |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ZM_T_DL_FILE_KANRI` | Table | Download File Management table — stores metadata records for all electronically managed download files including file numbers, names, sizes, timestamps, and deletion status |
| `FILE_NO` | Field | File number — a unique 12-digit sequence number generated via `getFormatedNextSeq` for each file management record |
| `TRN_KANRI_NO` | Field | Processing management number — a category code that identifies the type of processing this file belongs to (e.g., `000000000066` for warning communication-volume overage notification) |
| `EFILE_KANRI_NO` | Field | Electronic file management number — a unique identifier assigned to the electronic file during creation, linking the file to its management record |
| `FILE_NM` | Field | File name — the base name extracted from the full file system path |
| `FILE_SIZE` | Field | File size — stored as an empty string in this implementation (placeholder) |
| `DATA_CNT` | Field | Data record count — number of records contained within the file |
| `FILE_ADD_DTM` | Field | File registration date and time — timestamp when this file management record was created |
| `FILE_DEL_YMD` | Field | File deletion date — the date the file was deleted (null if not yet deleted) |
| `ADD_DTM` / `UPD_DTM` / `DEL_DTM` | Field | Registration / Update / Deletion date and time — audit timestamps for each lifecycle event |
| `ADD_OPEACNT` / `UPD_OPEACNT` / `DEL_OPEACNT` | Field | Registration / Update / Deletion operator account — the user account that performed each lifecycle event |
| `MK_FLG` | Field | Make flag (invalid flag) — a flag indicating whether the record is active or invalid |
| `SEQ_FILE_NO` | Constant | Sequence key for file number generation — used by `getFormatedNextSeq` to fetch the next available file number |
| `SEQ_PREFIX_SEQ_FILE_NOO` | Constant | Prefix for file number sequence — set to empty string, meaning file numbers have no leading prefix |
| `SEQ_LEN_SEQ_FILE_NO` | Constant | File number sequence length — 12 digits |
| `FILE_CD_POSTCARD_TIIK_LMT_INFO` | Constant | Processing management number for warning communication-volume overage notification files — value `"000000000066"` |
| `JBSbatCommonDBInterface` | Class | Common database interface — a parameter container class used to build sets of key-value pairs that map to database columns |
| `getFormatedNextSeq` | Method | Generates a zero-padded formatted next sequence number for a given sequence key |
| `insertByPrimaryKeys` | Method | Database insert operation that inserts a record using the provided parameter map mapped to primary-key columns |
| `in_postcard_file_path` | Field | File system path to the warning communication-volume overage notification postcard — an instance variable holding the full path from which the file name is extracted |
| `JBSbatCommonDBInterface` | Class | A key-value pair container used to build database operation parameters; values are retrieved sequentially via `getList()` and converted to an array |
