# Business Logic — JBSbatKKBndWdtOvrSendPstCrd.isSingleCheckKKIFM206_INF1() [43 LOC]

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

## 1. Role

### JBSbatKKBndWdtOvrSendPstCrd.isSingleCheckKKIFM206_INF1()

This method performs single-field (item-level) validation on input data derived from the **Postcard Bandwidth Limit Exceeded Notification Information File** (ハガキ用帯域制限超過通知情報ファイル), a flat-file input used in the **Bandwidth Control Communication Over-Notification Postcard Generation** batch process (帯域制御通信量超過通知ハガキ作成部品). The batch is part of K-Opticom's FTTH (Fiber To The Home) customer notification system, which generates and sends postcards to subscribers who have exceeded their bandwidth limits.

The method implements the **guard-clause** design pattern: it validates input fields sequentially and returns `false` immediately upon encountering any error, avoiding nested conditional logic. It validates exactly two fields from the input record — the **Service Contract Number** (`SVC_KEI_NO`) and the **System ID** (`SYSID`) — each with both a mandatory-field check (not null or empty) and a character-count check (between 0 and 10 digits inclusive).

No third field mentioned in the Javadoc (`TCHI_MSG`, the notification message text) is validated by this method, suggesting that the message field is either handled separately or not subject to the same single-item checks. If all validations pass, the method returns `true` to signal that the input record is clean and may proceed to downstream processing (such as DB lookup, service execution, and postcard dispatch via the `execute()` method).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isSingleCheckKKIFM206_INF1_rsMap, itemvalueMap"]) --> GET_SVC["Get SVC_KEI_NO from rsMap"]
    GET_SVC --> CHECK_SVC_NULL{strValue == null OR empty?}
    CHECK_SVC_NULL -->|true| LOG_SVC_NULL["printBusinessErrorLog EKKB0060TE SVC_KEI_NO"]
    LOG_SVC_NULL --> RET_SVC_NULL["return false"]
    CHECK_SVC_NULL -->|false| CHECK_SVC_LEN["JBSbatCheckUtil.invoke SVC_KEI_NO, batasuu2, 0, 10"]
    CHECK_SVC_LEN --> SVC_LEN_FAIL{Check failed?}
    SVC_LEN_FAIL -->|true| LOG_SVC_LEN["printBusinessErrorLog EKKB0070TE SVC_KEI_NO"]
    LOG_SVC_LEN --> RET_SVC_LEN["return false"]
    SVC_LEN_FAIL -->|false| GET_SYSID["Get SYSID from rsMap"]
    GET_SYSID --> CHECK_SYSID_NULL{strValue == null OR empty?}
    CHECK_SYSID_NULL -->|true| LOG_SYSID_NULL["printBusinessErrorLog EKKB0060TE SYSID"]
    LOG_SYSID_NULL --> RET_SYSID_NULL["return false"]
    CHECK_SYSID_NULL -->|false| CHECK_SYSID_LEN["JBSbatCheckUtil.invoke SYSID, batasuu2, 0, 10"]
    CHECK_SYSID_LEN --> SYSID_LEN_FAIL{Check failed?}
    SYSID_LEN_FAIL -->|true| LOG_SYSID_LEN["printBusinessErrorLog EKKB0070TE SYSID"]
    LOG_SYSID_LEN --> RET_SYSID_LEN["return false"]
    SYSID_LEN_FAIL -->|false| RET_TRUE["return true"]
    RET_SVC_NULL --> END(["End"])
    RET_SVC_LEN --> END
    RET_SYSID_NULL --> END
    RET_SYSID_LEN --> END
    RET_TRUE --> END
```

**Constant Resolution:**
- `SVC_KEI_NO` — Key in `rsMap` for Service Contract Number, corresponding to `TXT-KKIFM206-INF1.SVC_KEI_NO`
- `SYSID` — Key in `rsMap` for System ID, corresponding to `TXT-KKIFM206-INF1.SYSID`
- `"ketasuu2"` — Validation rule code passed to `JBSbatCheckUtil.invoke()` indicating a digit-count check (Katakana "ketasu" = "number of digits")
- `"0"` — Minimum allowed character count
- `"10"` — Maximum allowed character count
- `"EKKB0060TE"` — Error code for mandatory-field violations (null or empty)
- `"EKKB0070TE"` — Error code for character-count format violations

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `rsMap` | `HashMap` | Input data map containing key-value pairs parsed from the TXT-KKIFM206-INF1 flat-file (the postcard bandwidth limit exceeded notification information file). Each entry maps a field name (e.g., `"SVC_KEI_NO"`, `"SYSID"`) to its string value. This represents one record of subscriber notification data. |
| 2 | `itemvalueMap` | `HashMap` | Error message template map containing display-value strings keyed by descriptive identifiers (e.g., `"TXT-KKIFM206-INF1.SVC_KEI_NO"`). Used to populate human-readable error messages when validation fails. |

| Type | Name | Business Description |
|------|------|---------------------|
| Instance Field | `commonItem` | `JBSbatCommonItem` — batch common parameters set during `initial()`. Provides access to `getLogPrint()` for error logging and system-wide batch context. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `commonItem.getLogPrint().printBusinessErrorLog` | - | - | Logs business errors via the logging infrastructure. Used 4 times to report validation failures for `SVC_KEI_NO` and `SYSID`. |
| - | `JBSbatCheckUtil.invoke` | - | - | Reusable validation utility that checks field values against predefined rules (e.g., digit count constraints). Called 2 times with `"ketasuu2"`, `"0"`, `"10"` parameters. |

**Classification Notes:**
- This method performs **no database reads, writes, or CRUD operations**. It is a pure input validation gate.
- All external calls are to the logging subsystem (`printBusinessErrorLog`) and a framework-level utility (`JBSbatCheckUtil.invoke`).
- The error codes `EKKB0060TE` and `EKKB0070TE` are business error codes defined elsewhere in the system — likely mapped to Japanese user-facing error messages.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKBndWdtOvrSendPstCrd.execute()` | `execute()` -> `isSingleCheckKKIFM206_INF1(rsMap, itemvalueMap)` | `printBusinessErrorLog [-]` |

**Caller Context:**
The `execute()` method in `JBSbatKKBndWdtOvrSendPstCrd` processes FTTH bandwidth-limit-over postcard records. It reads notification records from a text file (TXT-KKIFM206-INF1), then calls `isSingleCheckKKIFM206_INF1()` to validate each record before proceeding to DB lookup, service execution, and postcard dispatch. A `false` return triggers error logging and record-level error handling.

**Terminal Operations:**
All terminal operations from this method are logging calls (`printBusinessErrorLog`) — no database or service component calls flow through this method's control paths.

## 6. Per-Branch Detail Blocks

**Block 1** — SET `(Initialization)` (L257)

> Initializes the temporary variable used for field value extraction.

| # | Type | Code |
|---|------|------|
| 1 | SET | `strValue = null` // local temp variable for field extraction |

**Block 2** — SET + IF `[SVC_KEI_NO mandatory check]` (L260–L268)

> Extracts the Service Contract Number from the input map and validates it is not null or empty (required field check). Japanese: サービス契約番号項目チェック (Service contract number item check).

| # | Type | Code |
|---|------|------|
| 1 | SET | `strValue = (String)rsMap.get("SVC_KEI_NO")` // [-> `TXT-KKIFM206-INF1.SVC_KEI_NO`] Extract service contract number |
| 2 | IF | `strValue == null \|\| "".equals(strValue)` `[Mandatory field check]` (L262) |
| 2.1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("EKKB0060TE", ...)` // [-> Error: mandatory field missing] (L264) |
| 2.2 | RETURN | `return false` // validation failed (L265) |

**Block 3** — IF `[SVC_KEI_NO character count check]` (L268–L275)

> Validates the Service Contract Number character count using the `ketasuu2` rule (must be between 0 and 10 digits). Japanese: 桁数チェック (Digit count check).

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JBSbatCheckUtil.invoke(strValue, new String[]{"ketasuu2", "0", "10"})` `[ketasuu2: digit count between 0 and 10]` (L269) |
| 1.1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("EKKB0070TE", ...)` // [-> Error: format/length violation] (L271) |
| 1.2 | RETURN | `return false` // validation failed (L272) |

**Block 4** — SET + IF `[SYSID mandatory check]` (L275–L283)

> Extracts the System ID from the input map and validates it is not null or empty (required field check). Japanese: ＳＹＳＩＤ項目チェック (SYSID item check).

| # | Type | Code |
|---|------|------|
| 1 | SET | `strValue = (String)rsMap.get("SYSID")` // [-> `TXT-KKIFM206-INF1.SYSID`] Extract system ID |
| 2 | IF | `strValue == null \|\| "".equals(strValue)` `[Mandatory field check]` (L277) |
| 2.1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("EKKB0060TE", ...)` // [-> Error: mandatory field missing] (L279) |
| 2.2 | RETURN | `return false` // validation failed (L280) |

**Block 5** — IF `[SYSID character count check]` (L280–L288)

> Validates the System ID character count using the `ketasuu2` rule (must be between 0 and 10 digits). Japanese: 桁数チェック (Digit count check).

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JBSbatCheckUtil.invoke(strValue, new String[]{"ketasuu2", "0", "10"})` `[ketasuu2: digit count between 0 and 10]` (L281) |
| 1.1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("EKKB0070TE", ...)` // [-> Error: format/length violation] (L283) |
| 1.2 | RETURN | `return false` // validation failed (L284) |

**Block 6** — RETURN `[All validations passed]` (L286)

> All four checks (null/empty + digit count) for both fields passed. The record is valid.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // no errors, record is valid |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `SVC_KEI_NO` | Field | Service Contract Number — the unique identifier for a subscriber's service contract line. Corresponds to `TXT-KKIFM206-INF1.SVC_KEI_NO` (ハガキ用帯域制限超過通知情報ファイル.サービス契約番号). |
| `SYSID` | Field | System ID — identifies the source system for the notification record. Corresponds to `TXT-KKIFM206-INF1.SYSID` (ハガキ用帯域制限超過通知情報ファイル.ＳＹＳＩＤ). |
| `TCHI_MSG` | Field | Communication Volume Limit Exceedance Notification Message — the message text sent to customers about their bandwidth overuse. Corresponds to `TXT-KKIFM206-INF1.TCHI_MSG`. |
| KKIFM206-INF1 | File ID | Text file format ID for the Postcard Bandwidth Limit Exceeded Notification Information File — the input file processed by the band-with control postcard generation batch. |
| `EKKB0060TE` | Error Code | Business error code for mandatory field missing (null or empty value). |
| `EKKB0070TE` | Error Code | Business error code for field format/length violation. |
| `ketasuu2` | Validation Rule | Character digit-count validation rule — ensures the value consists of a specified number of digits within a range (here, 0 to 10). Katakana "ketasu" (桁数) means "number of digits." |
| `commonItem` | Field | `JBSbatCommonItem` — batch common parameters object providing access to logging, error flags, and shared batch context. |
| `JBSbatCheckUtil` | Utility | Framework utility class for field validation (format checks, length checks, etc.). |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service offered by K-Opticom. |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity. |
| `execute()` | Method | Parent batch processing method that orchestrates the full flow: file reading, single-check validation, DB lookup, service execution, and postcard dispatch. |
