# Business Logic — JBSbatKKKojiKnrnInfCheck.kojiFinInfOutPut() [258 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKKojiKnrnInfCheck` |
| Layer | Batch (Service layer within the batch processing pipeline) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKKojiKnrnInfCheck.kojiFinInfOutPut()

This method performs **Construction Completion Information Output Processing** (工事完了情報出力処理). It is a core batch processing step in the K-Opticom fiber-to-the-home (FTTH) service provisioning pipeline. The method reads a pre-processed intermediate file containing CSV records of construction completion data, validates each record against business rules, retrieves the corresponding service contract status from the `KK_T_SVC_KEI` table, and routes each record to one of three destination output files based on the validation outcome.

The method handles three primary business outcomes: **(1) Reception OK** (受入可) — records where the service contract status is active (100: Service provision in progress) or has valid promotion info and the construction case is a new installation — these are written to the "Reception OK" intermediate file (`KKIFM051003.csv`); **(2) Next-day Reception** (翌日受入) — records where the contract is in initial states (010: Receipt completed, 020: Confirmation completed, 030: Contract completed) or have equipment flow issues, requiring processing on the next batch run — written to the "Next-day Reception" file (`KKIFM051004.csv`); and **(3) Delayed Contract Correction Registration** (工事遅延契約補正登録) — records where reception fails but the contract is found in the delayed correction table, triggering a correction record insertion.

The method also implements **dummy ONU/V-ONU model code retrieval** from the work parameter management table (`ZM_M_WORK_PARAM_KNRI`) for equipment flow tracking, and generates a separate **Construction Completion Equipment Flow Target File** (工事完了機器流用対象ファイル) for device reuse analysis. It delegates rule-based validation to `executeRule0081001`, promotional availability checks to `isUkeirePsb`, and new installation NG detection to `isNewestaKoji`, implementing a **delegation pattern** for complex business logic.

This method serves as a **batch entry point** called by `execute()`, making it a primary processing orchestrator within the batch pipeline. It acts as a data router and business rule executor, bridging raw intermediate file data with structured output files consumed by downstream processes.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["kojiFinInfOutPut(mid_dir_kk)"])
    START --> LOG_START["Log: kojiFinInfOutPut_START"]
    LOG_START --> INIT["Initialize local variables"]
    INIT --> SELECT_WORK["selectWorkParamKnri021()"]
    SELECT_WORK --> LOOP_WORK{"outMapWkParam021 != null?"}
    LOOP_WORK -->|Yes| GET_PARAM_ID["workParamId = getString(WORK_PARAM_ID)"]
    GET_PARAM_ID --> CHECK_ONU{"KK_SBRY_DUMMY_ONU.equals(workParamId)?"}
    CHECK_ONU -->|Yes| SET_DUMMY_ONU["dummyOnuModelCd = getString(WORK_PARAM_SETTE_VALUE)"]
    CHECK_ONU -->|No| SET_DUMMY_VONU["dummyVOnuModelCd = getString(WORK_PARAM_SETTE_VALUE)"]
    SET_DUMMY_ONU --> GET_NEXT["db_ZM_M_WORK_PARAM_KNRI.selectNext()"]
    SET_DUMMY_VONU --> GET_NEXT
    GET_NEXT --> LOOP_WORK
    LOOP_WORK -->|No| GEN_FILEPATH["file_path = mid_dir_kk + KKIFM051 + 002 + .csv"]
    GEN_FILEPATH --> GET_INPUT["getInputFile(file_path, KKIFM051)"]
    GET_INPUT --> FOR_LOOP{"for each data_list row"}
    FOR_LOOP -->|while i < size| GET_ROW["data_work = data_list.get(i)"]
    GET_ROW --> SPLIT_DATA["data = data_work.split(,)"]
    SPLIT_DATA --> EXTRACT_FLD["Extract: svc_kei_no=data[0], kuj_ank_stb_cd=data[5], opmskjakRsltCd=data[7], kojiak_no=data[6], rec_div=data[17]"]
    EXTRACT_FLD --> BUILD_PARAM["paramList = svc_kei_no, opeDate"]
    BUILD_PARAM --> SELECT_SVC["executeKK_T_SVC_KEI_KK_SELECT_060(paramList)"]
    SELECT_SVC --> CHECK_RESULT{"outDbMap != null?"}
    CHECK_RESULT -->|Yes| GET_STAT["svc_kei_stat = outDbMap.getString(SVC_KEI_STAT)"]
    GET_STAT --> EXEC_RULE["executeRule0081001(kuj_ank_stb_cd, svc_kei_stat, rec_div)"]
    EXEC_RULE --> CHECK_CD{"result_cd != 9?"}
    CHECK_CD -->|No| INC_I["i++"]
    CHECK_CD -->|Yes| CHECK_UKEIRE{"result_cd == 0 (RESULT_UKEIRE_PSB)?"}
    CHECK_UKEIRE -->|Yes| CHECK_PROMO{"isUkeirePsb(svc_kei_stat, svc_kei_no)?"}
    CHECK_PROMO -->|Yes| CHECK_EQUIP{"checkEquipRyuyo(data)?"}
    CHECK_EQUIP -->|NG| ERROR_LOG["printBusinessErrorLog(EKKB0310JW, equipment flow)"]
    ERROR_LOG --> INC_SBRY["businessErrSbryCnt++"]
    INC_SBRY --> APPEND_WAIT["setKojiFinInf(data_work, koji_fin_inf2)"]
    APPEND_WAIT --> INC_I8["i++"]
    CHECK_EQUIP -->|OK| APPEND_OK["setKojiFinInf(data_work, koji_fin_inf1)"]
    APPEND_OK --> SET_PRG["setPrgIfAdd(data)"]
    SET_PRG --> CHECK_NESTA{"isNewestaKoji(svc_kei_stat, kuj_ank_stb_cd, opmskjakRsltCd)?"}
    CHECK_NESTA -->|NG| ERROR_NESTA["printBusinessErrorLog(EKKB0310JW, newestaNG)"]
    ERROR_NESTA --> INC_ERR["businessErrCnt++"]
    INC_ERR --> INC_I9["i++"]
    CHECK_NESTA -->|OK| INC_I10["i++"]
    INC_I10 --> FOR_LOOP
    CHECK_PROMO -->|No| APPEND_WAIT2["setKojiFinInf(data_work, koji_fin_inf2)"]
    APPEND_WAIT2 --> INC_I11["i++"]
    INC_I11 --> FOR_LOOP
    CHECK_UKEIRE -->|No: result_cd == 1 (RESULT_YOKUJITSU_UKEIRE)| CHECK_YOKUJITSU{"isYokujitsuUkeire(svc_kei_stat, outDbMap)?"}
    CHECK_YOKUJITSU -->|Yes| APPEND_YOKU["setKojiFinInf(data_work, koji_fin_inf2)"]
    APPEND_YOKU --> INC_I12["i++"]
    APPEND_YOKU --> INC_I12
    CHECK_YOKUJITSU -->|No| INC_I13["i++"]
    INC_I13 --> FOR_LOOP
    CHECK_UKEIRE -->|No: result_cd == 2 (RESULT_UKEIRE_FAIL)| CHECK_FAIL{"isKojiDlyKeiHosei(svc_kei_no, data[2])?"}
    CHECK_FAIL -->|Yes| CREATE_HOSEI["createKojiDlyKeiHosei(data, outDbMap)"]
    CREATE_HOSEI --> INC_I14["i++"]
    INC_I14 --> FOR_LOOP
    CHECK_FAIL -->|No| INC_I15["i++"]
    INC_I15 --> FOR_LOOP
    CHECK_RESULT -->|No: null| ERROR_NO_SVC["printBusinessErrorLog(EKKB0630NW, service contract not found)"]
    ERROR_NO_SVC --> INC_I16["i++"]
    INC_I16 --> FOR_LOOP
    INC_I --> FOR_LOOP
    INC_I8 --> FOR_LOOP
    INC_I9 --> FOR_LOOP
    INC_I11 --> FOR_LOOP
    INC_I12 --> FOR_LOOP
    INC_I13 --> FOR_LOOP
    INC_I14 --> FOR_LOOP
    INC_I15 --> FOR_LOOP
    FOR_LOOP -->|Loop done| OUT_PUT1["file_path1 = mid_dir_kk + KKIFM051 + 003 + .csv"]
    OUT_PUT1 --> OUT_FILE1["executeOutputFile(koji_fin_inf1, file_path1, KKIFM051)"]
    OUT_FILE1 --> OUT_PUT2["file_path2 = mid_dir_kk + KKIFM051 + 004 + .csv"]
    OUT_PUT2 --> OUT_FILE2["executeOutputFile(koji_fin_inf2, file_path2, KKIFM051)"]
    OUT_FILE2 --> SYS_DATE["sysDate = getSystemDateTimeStamp()"]
    SYS_DATE --> FILE_DATE["fileDate = opeDate + sysDate.substring(8,14)"]
    FILE_DATE --> OUT_PUT3["file_path3 = mid_dir_kk + KKIFM768 + _ + fileDate + .csv"]
    OUT_PUT3 --> OUT_FILE3["executeOutputFile(kojiFinKikiRyuyoInf, file_path3, KKIFM768)"]
    OUT_FILE3 --> LOG_END["Log: kojiFinInfOutPut_END"]
    LOG_END --> END_NODE(["Return"])
```

**Constant Resolution Reference:**

| Constant Name | Value | Business Meaning |
|---------------|-------|------------------|
| `KK_SBRY_DUMMY_ONU` | `"KK_SBRY_DUMMY_ONU"` | Dummy ONU service flag indicator for work parameter type |
| `RESULT_UKEIRE_PSB` | `"0"` | Reception OK — construction completion data is valid for processing |
| `RESULT_YOKUJITSU_UKEIRE` | `"1"` | Next-day Reception — record deferred to next batch run |
| `RESULT_UKEIRE_FAIL` | `"2"` | Reception Impossible — record failed validation checks |
| `SVC_KEI_STAT_UKZM` | `"010"` | Contract Status: Receipt Completed |
| `SVC_KEI_STAT_SHOSAZM` | `"020"` | Contract Status: Confirmation Completed |
| `SVC_KEI_STAT_CNCZM` | `"030"` | Contract Status: Contract Completed |
| `SVC_KEI_STAT_SVCTKCHU` | `"100"` | Contract Status: Service Provision In Progress |
| `SVC_KEI_STAT_DSL` | `"910"` | Contract Status: Rescinded Completed |
| `SVC_KEI_STAT_CANCEL` | `"920"` | Contract Status: Canceled Completed |
| `KOJIAK_SBT_CD_NEWESTA` | `"001"` | Construction Case Type: New Construction |
| `KOJIAK_SBT_CD_ADCHG_NEWESTA` | `"003"` | Construction Case Type: Address Change (New Construction) |
| `KOJI_FIN_INF_FILE_ID` | `"KKIFM051"` | File ID for construction completion information file |
| `KOJI_FIN_KIKI_RYUYO_FILE_ID` | `"KKIFM768"` | File ID for construction completion equipment flow target file |
| `RULE_CONT_ID` | `"RULE0081001"` | Rule contents ID for construction-related information reception check rules |
| `RESULT_CD` | `"RESULT_CD"` | Judgment result code key |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `mid_dir_kk` | `String` | Intermediate file storage directory path — the base filesystem directory where the batch reads the input construction completion data file (KKIFM051002.csv) and writes output files (KKIFM051003.csv, KKIFM051004.csv, KKIFM768_*.csv). This directory is shared across batch processing stages and determines all file paths for this operation. |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `opeDate` | `String` | Batch operation date — used as a query parameter when retrieving service contract information from `KK_T_SVC_KEI` |
| `businessErrCnt` | `int` | New construction NG business error counter — tracks the count of new construction NG errors encountered during processing |
| `businessErrSbryCnt` | `int` | Equipment flow construction case check NG business error counter — tracks equipment flow validation failures |
| `kojiFinKikiRyuyoInf` | `StringBuilder` | Construction completion equipment flow target text buffer — accumulates records for the equipment reuse output file |
| `dummyOnuModelCd` | `String` | Dummy ONU home device model code — retrieved from work parameter table, used for equipment flow tracking |
| `dummyVOnuModelCd` | `String` | Dummy V-ONU home device model code — retrieved from work parameter table, used for equipment flow tracking |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKKojiKnrnInfCheck.selectWorkParamKnri021` | KK_SELECT_021 | `ZM_M_WORK_PARAM_KNRI` | Retrieves work parameter records to fetch dummy ONU and V-ONU model codes |
| R | `JBSbatZM_M_WORK_PARAM_KNRI.selectNext` | KK_SELECT_021 | `ZM_M_WORK_PARAM_KNRI` | Fetches next record from work parameter result set in the while loop |
| R | `JBSbatKKKojiKnrnInfCheck.getInputFile` | - | Intermediate file | Reads the input construction completion intermediate file (KKIFM051002.csv) as a string list |
| R | `JBSbatKKKojiKnrnInfCheck.executeKK_T_SVC_KEI_KK_SELECT_060` | KK_SELECT_060 | `KK_T_SVC_KEI` | Queries service contract record by service contract number and batch operation date |
| C | `JBSbatKKKojiKnrnInfCheck.createKojiDlyKeiHosei` | - | `KK_T_KOJI_DLY_KEHSI` | Registers delayed contract correction records when reception fails but the contract exists in the delay table |
| R | `JBSbatKKKojiKnrnInfCheck.isKojiDlyKeiHosei` | - | `KU_T_KOJIAK`, `KK_T_KKTK_SVC_KEI` | Checks if service contract number exists in the delayed contract correction table |
| - | `JBSbatKKKojiKnrnInfCheck.isUkeirePsb` | - | Promotion info | Checks whether promotion information is retrievable for the service contract (determines Reception OK vs Next-day Reception) |
| - | `JBSbatKKKojiKnrnInfCheck.checkEquipRyuyo` | - | `KK_T_KKTK_SVC_KEI`, `KU_T_SVKEI_KOJIAK`, `KK_T_SVC_KEI` | Validates equipment flow eligibility — checks if construction case is in a device-reusable state |
| - | `JBSbatKKKojiKnrnInfCheck.isNewestaKoji` | - | - | Determines whether a new construction NG condition exists based on service contract status, construction case type code, and OPMS result code |
| - | `JBSbatKKKojiKnrnInfCheck.isYokujitsuUkeire` | - | Promotion info / delayed contract correction | Determines whether next-day reception conditions are met based on service contract status and database state |
| - | `JBSbatKKKojiKnrnInfCheck.setKojiFinInf` | - | - | Appends a formatted construction completion record to the target StringBuilder (koji_fin_inf1 or koji_fin_inf2) |
| - | `JBSbatKKKojiKnrnInfCheck.setPrgIfAdd` | - | - | Registers progression data for intermediate file output |
| - | `JBSbatKKKojiKnrnInfCheck.executeRule0081001` | RULE0081001 | Rule engine | Executes business rule validation for construction-related information reception — returns result code (0=Reception OK, 1=Next-day, 2=Reception Fail, 9=Skip) |
| - | `JBSbatKKKojiKnrnInfCheck.executeOutputFile` | - | Intermediate files | Writes StringBuilder content to a CSV file at the specified path |
| R | `JBSbatInterface.getSystemDateTimeStamp` | - | System | Retrieves the current system date/time stamp for the equipment flow output file date suffix |

**How records are classified:**

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | R | KK_SELECT_021 | Retrieves dummy ONU/V-ONU model codes from `ZM_M_WORK_PARAM_KNRI` work parameter management table |
| 2 | R | KK_SELECT_060 | Queries service contract record from `KK_T_SVC_KEI` table by service contract number and batch operation date |
| 3 | C | - | Inserts delayed contract correction records into `KK_T_KOJI_DLY_KEHSI` when service contract not found but delay correction table has a match |
| 4 | R | - | Checks `KU_T_KOJIAK` and `KK_T_KKTK_SVC_KEI` tables to determine if service contract exists in the delayed contract correction table |
| 5 | R | RULE0081001 | Executes rule engine check for construction completion data reception validation using `RULE_CONT_ID` |
| 6 | R | - | Retrieves system date/time stamp for equipment flow output file naming |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKKojiKnrnInfCheck | `JBSbatKKKojiKnrnInfCheck.execute()` → `kojiFinInfOutPut(mid_dir_kk)` | `executeKK_T_SVC_KEI_KK_SELECT_060 [R] KK_T_SVC_KEI`, `createKojiDlyKeiHosei [C] KK_T_KOJI_DLY_KEHSI`, `selectWorkParamKnri021 [R] ZM_M_WORK_PARAM_KNRI`, `executeOutputFile [-] Intermediate files` |

**Analysis:**
- The method is called exclusively by `execute()` in the same class `JBSbatKKKojiKnrnInfCheck`, which is a batch processing entry point.
- No screen/batch entry points (KKSV*) were found within 8 hops, confirming this is a **batch-only** method.
- The method reads from `KK_T_SVC_KEI` (service contract), `ZM_M_WORK_PARAM_KNRI` (work parameter management), and writes CSV output files to intermediate directories.
- It also updates `KK_T_KOJI_DLY_KEHSI` (delayed contract correction table) for records that fail reception but have valid delay correction entries.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize local variables (L1763-1801)

| # | Type | Code |
|---|------|------|
| 1 | SET | `data_work = ""` // Construction completion info file line data holder |
| 2 | SET | `file_path = ""` // File path holder |
| 3 | SET | `file_path1 = ""` // File path holder |
| 4 | SET | `file_path2 = ""` // File path holder |
| 5 | SET | `file_path3 = ""` // File path holder (ANK-3136) |
| 6 | SET | `svc_kei_stat = ""` // Service contract status holder |
| 7 | SET | `koji_fin_inf1 = new StringBuilder()` // Text buffer for Reception OK records |
| 8 | SET | `koji_fin_inf2 = new StringBuilder()` // Text buffer for Next-day Reception records |

**Block 2** — [WHILE] Dummy ONU/V-ONU model code retrieval from work parameter table (L1803-1830)

> Retrieves dummy ONU and dummy V-ONU home device model codes from the work parameter management table `ZM_M_WORK_PARAM_KNRI` for equipment flow tracking (ANK-3136 feature).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `outMapWkParam021 = selectWorkParamKnri021()` // Get work parameter result set |
| 2 | WHILE | `while (null != outMapWkParam021)` // Iterate through work parameter records |
| 3 | SET | `workParamId = JBSbatStringUtil.Rtrim(outMapWkParam021.getString(JBSbatZM_M_WORK_PARAM_KNRI.WORK_PARAM_ID))` // Get work parameter ID |

**Block 2.1** — [IF] Dummy ONU model code assignment (L1811-1814) `[KK_SBRY_DUMMY_ONU="KK_SBRY_DUMMY_ONU"]`

| # | Type | Code |
|---|------|------|
| 1 | IF | `JKKStrConst.KK_SBRY_DUMMY_ONU.equals(workParamId)` // Is this a Dummy ONU parameter? |
| 2 | SET | `dummyOnuModelCd = JBSbatStringUtil.Rtrim(outMapWkParam021.getString(JBSbatZM_M_WORK_PARAM_KNRI.WORK_PARAM_SETTE_VALUE))` // Assign Dummy ONU home device model code |
| 3 | SET | `outMapWkParam021 = db_ZM_M_WORK_PARAM_KNRI.selectNext()` // Get next record |

**Block 2.2** — [ELSE] Dummy V-ONU model code assignment (L1817-1820)

| # | Type | Code |
|---|------|------|
| 1 | ELSE | // Not Dummy ONU → Dummy V-ONU |
| 2 | SET | `dummyVOnuModelCd = JBSbatStringUtil.Rtrim(outMapWkParam021.getString(JBSbatZM_M_WORK_PARAM_KNRI.WORK_PARAM_SETTE_VALUE))` // Assign Dummy V-ONU home device model code |
| 3 | SET | `outMapWkParam021 = db_ZM_M_WORK_PARAM_KNRI.selectNext()` // Get next record |

**Block 3** — [SET] Generate input file path and read intermediate file (L1836-1840)

| # | Type | Code |
|---|------|------|
| 1 | SET | `file_path = mid_dir_kk + KOJI_FIN_INF_FILE_ID + "002" + FILE_KEISHIKI` // `[-> KOJI_FIN_INF_FILE_ID="KKIFM051", FILE_KEISHIKI=".csv"]` — e.g., `/path/KKIFM051002.csv` |
| 2 | CALL | `data_list = getInputFile(file_path, KOJI_FIN_INF_FILE_ID)` // Read intermediate file as ArrayList<String> |

**Block 4** — [FOR] Iterate through construction completion data records (L1843-1983)

> Main processing loop: for each record in the intermediate file, extract fields, query service contract, validate against business rules, and route to appropriate output.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (int i = 0; i < data_list.size(); i++)` // Process each CSV line |
| 2 | SET | `data_work = data_list.get(i)` // Get current line |
| 3 | SET | `data = data_work.split(",", -1)` // Parse CSV fields |
| 4 | SET | `svc_kei_no = data[0]` // Service contract number |
| 5 | SET | `kuj_ank_stb_cd = data[5]` // Construction case type code |
| 6 | SET | `kojiak_no = data[6]` // Construction case number (ANK-3136) |
| 7 | SET | `paramList = new Object[2]` // Query parameter array |
| 8 | SET | `paramList[0] = svc_kei_no` // Service contract number for query |
| 9 | SET | `paramList[1] = super.opeDate` // Batch operation date |
| 10 | CALL | `outDbMap = executeKK_T_SVC_KEI_KK_SELECT_060(paramList)` // Query `KK_T_SVC_KEI` |

**Block 4.1** — [IF] Service contract query result exists (L1857-1861)

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != outDbMap` // Service contract record found |
| 2 | SET | `svc_kei_stat = JBSbatStringUtil.Rtrim(outDbMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_STAT))` // Get service contract status |

**Block 4.2** — [ELSE] Service contract not found (L1865-1871) `[v7.00.03: Minus-aiming alteration]`

| # | Type | Code |
|---|------|------|
| 1 | ELSE | // outDbMap is null |
| 2 | EXEC | `super.logPrint.printBusinessErrorLog("EKKB0630NW", new String[]{"サービス契約", "サービス契約番号", svc_kei_no})` // Log error: service contract not found — changed from exception throw to minusing (v7.00.03) |
| 3 | EXEC | `continue` // Skip this record |

**Block 4.3** — [SET] Extract record division and debug logging (L1875-1881)

| # | Type | Code |
|---|------|------|
| 1 | SET | `rec_div = data[17]` // Record division code |
| 2 | EXEC | `super.logPrint.printDebugLog("kuj_ank_stb_cd:" + kuj_ank_stb_cd)` |
| 3 | EXEC | `super.logPrint.printDebugLog("svc_kei_stat:::" + svc_kei_stat)` |
| 4 | EXEC | `super.logPrint.printDebugLog("rec_div::::::::" + rec_div)` |

**Block 4.4** — [CALL] Execute business rule validation (L1884-1887)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `result_cd = executeRule0081001(kuj_ank_stb_cd, svc_kei_stat, rec_div)` // Rule validation — `[-> RULE_CONT_ID="RULE0081001"]` |
| 2 | EXEC | `super.logPrint.printDebugLog("工事関連情報受入確認結果：" + result_cd)` // Log validation result |

**Block 5** — [IF] Result code is not "9" (skip marker) (L1890-1980)

> When result_cd is "9", the record is skipped entirely. Non-"9" values trigger further branching based on reception status.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!"9".equals(result_cd)` // Not a skip code — proceed with processing |

**Block 5.1** — [IF] Reception OK (RESULT_UKEIRE_PSB = "0") (L1893-1960)

| # | Type | Code |
|---|------|------|
| 1 | IF | `RESULT_UKEIRE_PSB.equals(result_cd)` // `[-> RESULT_UKEIRE_PSB="0"]` — Reception OK |
| 2 | CALL | `isUkeirePsb(svc_kei_stat, svc_kei_no)` // Check if promotion info is retrievable |

**Block 5.1.1** — [IF] Promotion info exists and equipment flow check (L1898-1946)

| # | Type | Code |
|---|------|------|
| 1 | IF | `this.isUkeirePsb(svc_kei_stat, svc_kei_no)` // Promotion info exists |
| 2 | CALL | `checkEquipRyuyo(data)` // Check equipment flow eligibility (ANK-3136) |

**Block 5.1.1.1** — [IF] Equipment flow check NG (L1901-1917)

> When equipment flow validation fails, log business error, increment counter, append to next-day reception buffer, and continue.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!checkEquipRyuyo(data)` // Equipment flow check failed |
| 2 | EXEC | `super.logPrint.printBusinessErrorLog(JPCBatchMessageConstant.EKKB0310JW, new String[]{"設備流用", "工事案件", "対象データ（工事案件番号：" + kojiak_no + " サービス契約番号：" + svc_kei_no + "）を翌日受入とし、処理を続行します。"})` // Log equipment flow NG error |
| 3 | SET | `businessErrSbryCnt++` // Increment equipment flow error counter |
| 4 | CALL | `setKojiFinInf(data_work, koji_fin_inf2)` // Append to Next-day Reception buffer |
| 5 | EXEC | `continue` // Skip to next record |

**Block 5.1.1.2** — [ELSE] Equipment flow check OK — Reception OK processing (L1924-1946)

> When equipment flow check passes: write to Reception OK file, register progression data, and check new construction NG status.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | // checkEquipRyuyo returned true |
| 2 | CALL | `this.setKojiFinInf(data_work, koji_fin_inf1)` // Append to Reception OK buffer |
| 3 | CALL | `this.setPrgIfAdd(data)` // Register progression data (v7.00.02: removed ido_div param) |
| 4 | SET | `opmskjakRsltCd = data[7]` // OPMS construction case result code |
| 5 | CALL | `this.isNewestaKoji(svc_kei_stat, kuj_ank_stb_cd, opmskjakRsltCd)` // Check new construction NG |

**Block 5.1.1.2.1** — [IF] New construction NG (L1934-1953) `[KOJIAK_SBT_CD_NEWESTA="001", KOJIAK_SBT_CD_ADCHG_NEWESTA="003"]`

> When service contract status is "100: Service provision in progress" AND construction case type is "001: New Construction" or "003: Address Change (New Construction)" AND OPMS result code is "2: NG" → new construction NG.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!this.isNewestaKoji(svc_kei_stat, kuj_ank_stb_cd, opmskjakRsltCd)` // New construction NG condition detected |
| 2 | EXEC | `super.logPrint.printBusinessErrorLog(JPCBatchMessageConstant.EKKB0310JW, new String[]{"サービス契約", "サービス契約ステータス", ...})` // Log new construction NG error with contract number, status, case type, and OPMS code |
| 3 | SET | `businessErrCnt++` // Increment new construction NG error counter |

**Block 5.1.1.2.2** — [ELSE] New construction OK (L1958-1960)

| # | Type | Code |
|---|------|------|
| 1 | ELSE | // New construction check passed |
| 2 | EXEC | `super.logPrint.printDebugLog("新設工事OK：処理続行")` // Debug log: new construction OK, continue processing |

**Block 5.1.2** — [ELSE] Promotion info does NOT exist — Next-day Reception (L1963-1970)

> When contract status is "010: Receipt completed", "020: Confirmation completed", or "030: Contract completed" AND no promotion info → Next-day Reception.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | // isUkeirePsb returned false |
| 2 | CALL | `this.setKojiFinInf(data_work, koji_fin_inf2)` // Append to Next-day Reception buffer |

**Block 5.2** — [ELSE-IF] Next-day Reception (RESULT_YOKUJITSU_UKEIRE = "1") (L1973-1981) `[RESULT_YOKUJITSU_UKEIRE="1"]`

> When the rule engine returns "1", check if next-day reception conditions are met via `isYokujitsuUkeire(svc_kei_stat, outDbMap)`. If true, append to the next-day buffer.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `RESULT_YOKUJITSU_UKEIRE.equals(result_cd)` // `[-> RESULT_YOKUJITSU_UKEIRE="1"]` |
| 2 | IF | `isYokujitsuUkeire(svc_kei_stat, outDbMap)` // Check next-day reception conditions |
| 3 | CALL | `setKojiFinInf(data_work, koji_fin_inf2)` // Append to Next-day Reception buffer |

**Block 5.3** — [ELSE-IF] Reception Impossible (RESULT_UKEIRE_FAIL = "2") (L1984-1991) `[RESULT_UKEIRE_FAIL="2"]`

> When the rule engine returns "2", check if the service contract exists in the delayed contract correction table. If found, register the delay correction record.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `RESULT_UKEIRE_FAIL.equals(result_cd)` // `[-> RESULT_UKEIRE_FAIL="2"]` |
| 2 | IF | `isKojiDlyKeiHosei(svc_kei_no, data[2])` // Check delayed contract correction table |
| 3 | CALL | `createKojiDlyKeiHosei(data, outDbMap)` // Register correction record in `KK_T_KOJI_DLY_KEHSI` |

**Block 6** — [ELSE] Result code IS "9" (skip) (L1994-2000)

> When result_cd equals "9", the record does not pass basic validation checks. Log business error and skip.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | // result_cd == "9" |
| 2 | EXEC | `super.logPrint.printBusinessErrorLog("EKKB0010CW", new String[]{MASSEAGE2 + "(ファイルID：" + KOJI_FIN_INF_FILE_ID + ", サービス契約番号：" + svc_kei_no + ")"})` // MASSEAGE2 = "工事関連情報受入確認条件ルールで異常が発生しました。" |
| 3 | EXEC | `continue` // Skip to next record |

**Block 7** — [SET + CALL] Write Reception OK output file (L2003-2007)

| # | Type | Code |
|---|------|------|
| 1 | SET | `file_path1 = mid_dir_kk + KOJI_FIN_INF_FILE_ID + "003" + FILE_KEISHIKI` // `[-> "KKIFM051003.csv"]` — Reception OK output |
| 2 | CALL | `executeOutputFile(koji_fin_inf1.toString(), file_path1, KOJI_FIN_INF_FILE_ID)` // Write Reception OK records |

**Block 8** — [SET + CALL] Write Next-day Reception output file (L2010-2014)

| # | Type | Code |
|---|------|------|
| 1 | SET | `file_path2 = mid_dir_kk + KOJI_FIN_INF_FILE_ID + "004" + FILE_KEISHIKI` // `[-> "KKIFM051004.csv"]` — Next-day Reception output |
| 2 | CALL | `executeOutputFile(koji_fin_inf2.toString(), file_path2, KOJI_FIN_INF_FILE_ID)` // Write Next-day Reception records |

**Block 9** — [SET + CALL] Write Construction Completion Equipment Flow Target file (L2017-2020) `[ANK-3136]`

> Generates the equipment flow target file with a date-suffixed name using the system date/time stamp. This file contains records eligible for equipment reuse after construction completion.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sysDate = JBSbatDateUtil.getSystemDateTimeStamp()` // Get system date/time |
| 2 | SET | `fileDate = super.opeDate + sysDate.substring(8, 14)` // e.g., "20240115" + "120000" = "20240115120000" |
| 3 | SET | `file_path3 = mid_dir_kk + KOJI_FIN_KIKI_RYUYO_FILE_ID + "_" + fileDate + FILE_KEISHIKI` // `[-> "KKIFM768_" + fileDate + ".csv"]` |
| 4 | CALL | `executeOutputFile(kojiFinKikiRyuyoInf.toString(), file_path3, KOJI_FIN_KIKI_RYUYO_FILE_ID)` // Write equipment flow target records |

**Block 10** — [EXEC] End processing log (L2022)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("kojiFinInfOutPut_END")` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kojiFinInfOutPut` | Field/Method | Construction Completion Information Output — the primary batch method that processes and routes construction completion data records |
| `svc_kei_no` | Field | Service contract number — unique identifier for a service contract in the telecom system |
| `svc_kei_stat` | Field | Service contract status — indicates the current lifecycle state of a service contract (e.g., 010: Receipt completed, 100: Service provision in progress, 910: Rescinded completed) |
| `kuj_ank_stb_cd` | Field | Construction case type code — classifies the type of construction case (e.g., 001: New Construction, 003: Address Change (New Construction)) |
| `kojiak_no` | Field | Construction case number — unique identifier for a construction case record |
| `rec_div` | Field | Record division — categorizes the type of record in the intermediate file (e.g., 20: Design equipment info, 40: Construction completion info, 90: Construction cancellation info) |
| `result_cd` | Field | Judgment result code — the output of the rule engine validation (0: Reception OK, 1: Next-day Reception, 2: Reception Impossible, 9: Skip) |
| `opmskjakRsltCd` | Field | OPMS construction case result code — result code from the OPMS (Optical Network Project Management System) indicating construction outcome (1: OK, 2: NG) |
| `dummyOnuModelCd` | Field | Dummy ONU home device model code — model code for dummy ONU equipment used in the network |
| `dummyVOnuModelCd` | Field | Dummy V-ONU home device model code — model code for dummy V-ONU (Video-ONU) equipment |
| `kojiFinKikiRyuyoInf` | Field | Construction completion equipment flow target text buffer — accumulates records for the equipment reuse output file |
| `koji_fin_inf1` | Field | Construction completion info text buffer (Reception OK) — accumulates records valid for immediate processing |
| `koji_fin_inf2` | Field | Construction completion info text buffer (Next-day Reception) — accumulates records deferred to the next batch run |
| `businessErrCnt` | Field | New construction NG business error counter — tracks count of new construction failure records |
| `businessErrSbryCnt` | Field | Equipment flow construction case check NG error counter — tracks count of equipment flow validation failures |
| KK_T_SVC_KEI | DB Table | Service Contract table — stores service contract information including status, dates, and customer details |
| KK_T_KOJI_DLY_KEHSI | DB Table | Construction Delay Contract Correction table — stores correction records for contracts that could not be processed in the current batch run |
| ZM_M_WORK_PARAM_KNRI | DB Table | Work Parameter Management table — stores runtime work parameters including ONU/V-ONU model codes |
| KU_T_KOJIAK | DB Table | Construction Case table — stores construction case master data |
| KK_T_KKTK_SVC_KEI | DB Table | Equipment Provision Service Contract table — links equipment to service contracts for equipment flow tracking |
| KU_T_SVKEI_KOJIAK | DB Table | Service Contract ↔ Construction Case linking table — maps service contracts to construction cases |
| KK_SBRY_DUMMY_ONU | Constant | Dummy ONU service flag — work parameter type identifier for dummy ONU configuration |
| RESULT_UKEIRE_PSB | Constant | Judgment result code "0" — Reception OK (construction data is valid) |
| RESULT_YOKUJITSU_UKEIRE | Constant | Judgment result code "1" — Next-day Reception (defer to next batch) |
| RESULT_UKEIRE_FAIL | Constant | Judgment result code "2" — Reception Impossible (validation failed) |
| SVC_KEI_STAT_UKZM | Constant | Contract status "010" — Receipt Completed |
| SVC_KEI_STAT_SHOSAZM | Constant | Contract status "020" — Confirmation Completed |
| SVC_KEI_STAT_CNCZM | Constant | Contract status "030" — Contract Completed |
| SVC_KEI_STAT_SVCTKCHU | Constant | Contract status "100" — Service Provision In Progress |
| SVC_KEI_STAT_DSL | Constant | Contract status "910" — Rescinded Completed |
| SVC_KEI_STAT_CANCEL | Constant | Contract status "920" — Canceled Completed |
| KOJIAK_SBT_CD_NEWESTA | Constant | Construction case type "001" — New Construction |
| KOJIAK_SBT_CD_ADCHG_NEWESTA | Constant | Construction case type "003" — Address Change (New Construction) |
| REC_DOV_20 | Constant | Record division "20" — Design equipment information |
| REC_DOV_40 | Constant | Record division "40" — Construction completion information |
| REC_DOV_90 | Constant | Record division "90" — Construction cancellation information |
| REC_DOV_B0 | Constant | Record division "B0" — Residential construction information |
| REC_DOV_60 | Constant | Record division "60" — Scheduled construction information (Net) |
| REC_DOV_61 | Constant | Record division "61" — Scheduled construction information (TV) |
| REC_DOV_E0 | Constant | Record division "E0" — Preliminary cancellation reception information |
| REC_DOV_F0 | Constant | Record division "F0" — Preliminary cancellation cancellation information |
| KKIFM051 | Constant | File ID prefix for construction completion information files |
| KKIFM768 | Constant | File ID prefix for construction completion equipment flow target files |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service provided by K-Opticom |
| ONU | Acronym | Optical Network Unit — customer-premises device that terminates fiber-optic connections |
| V-ONU | Acronym | Video Optical Network Unit — ONU device specialized for video service delivery |
| OPMS | Acronym | Optical Network Project Management System — external project management system for construction case tracking |
| K-Opticom | Business term | Japanese FTTH (fiber-to-the-home) broadband service provider (the domain of this system) |
| 工事完了情報 | Japanese term | Construction completion information — data indicating that a construction task has been completed |
| 受入可 | Japanese term | Reception OK — validation passed, record is valid for immediate processing |
| 翌日受入 | Japanese term | Next-day Reception — record deferred to the next batch run for processing |
| 設備流用 | Japanese term | Equipment flow/reuse — checking whether equipment can be reused in subsequent installations |
| 新設工事NG | Japanese term | New construction NG — condition where a new construction case has a validation failure in OPMS |
| 工事遅延契約補正 | Japanese term | Delayed contract correction — registration of contracts that could not be processed in the current batch run |
| 中間ファイル | Japanese term | Intermediate file — CSV files stored in a shared directory between batch processing stages |
| 進化 | Japanese term | Progression/Progress — tracks the status of service provisioning workflow stages |
| RULE0081001 | Acronym | Rule contents ID — the specific rule set ID used for construction-related information reception validation in the rule engine |
