# Business Logic — JKKAdchgVLanGetCC.checkKojiAnkenStatus() [64 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKAdchgVLanGetCC` |
| Layer | CC/Common Component (Service component helper class) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKAdchgVLanGetCC.checkKojiAnkenStatus()

This method serves as a **pre-allocation guard** for the VLAN-ID allocation process within K-Opticom's fiber-optic internet service provisioning system (eo Hikari Phone). Its primary business purpose is to verify whether the **construction project status (工事案件ステータス)** of a new installation (新設工事) is in a range where the VLAN-ID has already been handled by other batch processes — specifically when the status falls between **160: Contractor Company Decision Complete (工事会社決定済)** and **200: Construction Complete (工事完了済)**. If the status is within this range, the method returns `false`, signaling that VLAN-ID allocation has already been or will be handled separately, so this method should skip allocation. If the status is outside this range (including the initial "120: Registration Complete (登録済み)" state), the method returns `true`, indicating that the system should proceed to allocate a VLAN-ID for this service contract line.

The method implements a **delivery-method-based branching pattern** (提供方式パターン別分岐): it differentiates between **fiber-optic connections (光コンセント, code "51" for ODR_HOSHISIKI_PTN_CD_NET)** and **other delivery methods** (e.g., FTTH, Mail, ENUM). For fiber-optic connections, it queries the **maintenance project status (マンスション工事案件状態)** from the EKU0011A010 response, since condominium multi-dwelling installations use a separate status field. For all other methods, it queries the standard **construction project status (工事案件ステータス)**. This dual-path design ensures accurate status checking across different service deployment scenarios.

The method acts as a **shared utility** called by the `execute` method of `JKKAdchgVLanGetCC`, which is the entry point for VLAN-ID allocation on transfer-destination circuits. It delegates to the `EKU0011A010` SC (Service Component) — Construction Project Inquiry (工事案件照会) — to fetch the current project status from the database, then applies business rules to determine VLAN-ID allocation eligibility.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["checkKojiAnkenStatus starts"])
    
    START --> INIT["Initialize: get mapper, create ServiceComponentRequestInvoker"]
    INIT --> COND["condMap: key=kojiak_no from paramMap"]
    COND --> CALL1["mapper.setEKU0011A010 - Build SC request map"]
    CALL1 --> CALL2["scCall.run - Execute EKU0011A0011A010 Construction Project Inquiry SC"]
    CALL2 --> CALL3["mapper.getEKU011A010 - Extract response into ku0011Map"]
    CALL3 --> CALL4["mapper.scResultCheck - Check SC result for errors"]
    
    CALL4 --> PATTN["tkHoshikiPtnCdNetSaki = paramMap tk_hoshiki_ptn_cd_net_saki"]
    PATTN --> IS_NET{tkHoshikiPtnCdNetSaki == 51<br/>Fiber Optic Connection<br/>ODR_HOSHISIKI_PTN_CD_NET}
    
    IS_NET -->|true - Fiber Optic| MANS["Get mans_kojiak_stat_cd from ku0011Map<br/>Maintenance project status code"]
    MANS --> MANS_NULL{ku0011Map != null?}
    MANS_NULL -->|yes| MANS_CHK{kojikaishaketteizumi=160 <= status <= kojikanryozumi=200}
    MANS_NULL -->|no| SKIP_MANS["ku0011Map is null, skip status check"]
    
    IS_NET -->|false - Other delivery methods| NORMAL["Get kojiak_stat from ku0011Map<br/>Standard project status"]
    NORMAL --> NORM_NULL{ku0011Map != null?}
    NORM_NULL -->|yes| NORM_CHK{kojikaishaketteizumi=160 <= status <= kojikanryozumi=200}
    NORM_NULL -->|no| SKIP_NORM["ku0011Map is null, skip status check"]
    
    MANS_CHK -->|true - Status in 160-200 range| DONE_TRUE["return true<br/>Unbilled - VLAN-ID needs allocation"]
    MANS_CHK -->|false| DONE_TRUE
    MANS_NULL --> SKIP_MANS2["ku0011Map is null, skip status check"]
    
    NORM_CHK -->|true - Status in 160-200 range| DONE_FALSE["return false<br/>Billed status - VLAN-ID handled elsewhere"]
    NORM_CHK -->|false| DONE_TRUE2["return true<br/>Unbilled - VLAN-ID needs allocation"]
    NORM_NULL --> SKIP_NORM2["ku0011Map is null, skip status check"]
    
    MANS_CHK --> DONE_MANS["Check complete"]
    SKIP_MANS2 --> DONE_MANS
    SKIP_NORM2 --> DONE_MANS
    NORM_CHK --> DONE_NORM["Check complete"]
    
    DONE_MANS --> END(["checkKojiAnkenStatus ends"])
    DONE_NORM --> END
    
    DONE_FALSE --> END
    DONE_TRUE --> END
    DONE_TRUE2 --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramMap` | `HashMap<String, Object>` | The parameter map carrying the service contract context. Contains `kojiak_no` (construction project number, 工事案件番号) used to query the project's current status, and `tk_hoshiki_ptn_cd_net_saki` (transmission destination delivery pattern code for network, 伝送先提供方式パターンコード（ネット）先) which determines the service delivery method — "51" for fiber-optic connections (光コンセント) versus other methods. |

**External state read by this method (instance/static fields):**

| Field | Type | Business Description |
|-------|------|---------------------|
| `keepReqParam` | `ThreadLocal<IRequestParameterReadWrite>` | Session-scoped request parameter holder — carries the SC request/response parameter context across the call chain. Used by `mapper.setEKU0011A010` and `mapper.getEKU0011A010`. |
| `keepFixedText` | `ThreadLocal<String>` | Session-scoped fixed text holder — contains user-configurable string data passed through the service request. Used by `mapper.setEKU0011A010` and `mapper.getEKU0011A010`. |
| `keepSesHandle` | `ThreadLocal<SessionHandle>` | Session handle holder — carries the session management handle for SC invocation. Used by `scCall.run`. |

**Resolved constants used in this method:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `KOJIAK_STAT_KOJIKAISHAKETTEIZUMI` | `"160"` | Construction project status: Contractor Company Decision Complete (工事会社決定済) |
| `KOJIAK_STAT_KOJIKANRYOZUMI` | `"200"` | Construction project status: Construction Complete (工事完了済) |
| `JKKAdchgMapperCC.COND_KEY_KOJIAK_NO` | `"cond_key_kojiak_no"` | Condition map key for construction project number |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKAdchgMapperCC.getInstance` | JKKAdchgMapperCC | - | Retrieves the singleton mapper instance for construction project data mapping |
| R | `ServiceComponentRequestInvoker.<init>` | - | - | Creates a new SC request invoker for SC calls |
| R | `JKKAdchgMapperCC.setEKU0011A010` | JKKAdchgMapperCC | KK_T_ODR_HAKKO_JOKEN (implied by SC) | Maps input conditions into the SC request map for construction project inquiry |
| R | `ServiceComponentRequestInvoker.run` | EKK0011A010SC | KK_T_OPSVKEI_ISP, KK_T_CONSTRUCTION_PROJECT (implied) | Executes the EKU0011A010 SC (Construction Project Inquiry / 工事案件照会) to query the current project status |
| R | `JKKAdchgMapperCC.getEKU0011A010` | JKKAdchgMapperCC | KK_T_CONSTRUCTION_PROJECT (implied) | Extracts the SC response into a HashMap (ku0011Map) containing construction project details |
| R | `JKKAdchgMapperCC.scResultCheck` | JKKAdchgMapperCC | - | Validates the SC result for errors; throws if error detected |

### Additional service component called within this method:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `ServiceComponentRequestInvoker.run` (invoke) | EKK0011A010SC | KK_T_CONSTRUCTION_PROJECT (工事案件マスタ) | Service Component call that reads construction project record by `kojiak_no` and returns the project status field. This SC performs a single-record SELECT on the construction project master table. |

**How the SC Call works:**
- The `EKU0011A010` SC code follows the naming convention `EKK0011A010SC`, where `EKK0011` represents the service area (Construction Project Information) and `A010` represents the inquiry (照会) transaction.
- The SC performs a database lookup on the construction project master table (KK_T_CONSTRUCTION_PROJECT / 工事案件マスタ) using the `kojiak_no` (construction project number) as the search key.
- The returned data includes the `kojiak_stat` field (工事案件ステータス) for standard services and `mans_kojiak_stat_cd` (マンション工事案件状態コード) for condominium maintenance services.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `scResultCheck` [-], `getEKU0011A010` [R], `setEKU0011A010` [-], `run` [-], `getInstance` [R]

### Callers:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `JKKAdchgVLanGetCC.execute` (L114) | `JKKAdchgVLanGetCC.execute` -> `checkKojiAnkenStatus` | `scResultCheck [-]`, `getEKU0011A010 [R] KK_T_CONSTRUCTION_PROJECT`, `setEKU0011A010 [-]`, `run [-] EKK0011A010SC` |

### Call chain context:
The `execute` method in `JKKAdchgVLanGetCC` is the **screen entry point** for VLAN-ID allocation. It is typically called from a CBS (Composite Business Service) layer corresponding to a screen (likely KKSV0004 or similar construction/VLAN management screen). The `execute` method:
1. First checks if a service contract line already has VLAN-ID allocated via `checkSvcKeiKaisenUcwk`
2. Then calls `checkKojiAnkenStatus` to determine if VLAN-ID allocation should proceed based on construction project status
3. If the status indicates the VLAN-ID is already handled (status 160-200), VLAN-ID is NOT allocated here — it will be assigned by batch processing later
4. If the status indicates the VLAN-ID needs allocation, the method proceeds to allocate a VLAN-ID for the circuit

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize mapper and SC invoker (L201-L207)

This block initializes the mapper singleton and creates the service component request invoker.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = JKKAdchgMapperCC.getInstance()` // Get mapper singleton [-> Constructor: JKKAdchgMapperCC] |
| 2 | SET | `scCall = new ServiceComponentRequestInvoker()` // Create SC request invoker |

**Block 2** — [SET] Build condition map for SC query (L210-L213)

This block constructs a condition map with the construction project number extracted from `paramMap`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `condMap = new HashMap<String, String>()` // Create condition map |
| 2 | SET | `condMap.put(JKKAdchgMapperCC.COND_KEY_KOJIAK_NO, (String)paramMap.get("kojiak_no"))` // [-> COND_KEY_KOJIAK_NO = "cond_key_kojiak_no"] Map construction project number |

**Block 3** — [CALL] Execute SC inquiry: EKU0011A010 Construction Project Inquiry (L216-L219)

This block invokes the SC to query construction project status. The `setEKU0011A010` maps conditions to the SC request, `scCall.run` executes the SC, `getEKU0011A010` extracts the response, and `scResultCheck` validates the result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `reqMap = mapper.setEKU0011A010(keepReqParam.get(), keepFixedText.get(), condMap)` // Map conditions into SC request [-> Keep reqParam from ThreadLocal, keepFixedText from ThreadLocal] |
| 2 | CALL | `resMap = scCall.run(reqMap, keepSesHandle.get())` // Execute EKU0011A010 SC [-> Keep sesHandle from ThreadLocal] |
| 3 | SET | `ku0011Map = mapper.getEKU0011A010(keepReqParam.get(), keepFixedText.get(), resMap)` // Extract response to ku0011Map |
| 4 | CALL | `mapper.scResultCheck(keepReqParam.get())` // Check SC result for errors [-> Throws if error] |

**Block 4** — [SET] Retrieve delivery method pattern code (L222-L223)

This block extracts the transmission destination delivery pattern code (提供方式パターンコード), which determines the service delivery method (e.g., fiber-optic connection "51" vs. other methods).

| # | Type | Code |
|---|------|------|
| 1 | SET | `tkHoshikiPtnCdNetSaki = (String)paramMap.get("tk_hoshiki_ptn_cd_net_saki")` // Delivery pattern code for network destination (伝送先提供方式パターンコード（ネット）先) |

**Block 5** — [IF-ELSE] Delivery method branching: Fiber Optic (code 51) vs. Other (L225-L255)

This is the main decision point. Code "51" (光コンセント / Fiber Optic Connection, ODR_HOSHISIKI_PTN_CD_NET = "51") indicates a fiber-optic delivery method where the status is retrieved from the maintenance project status field (マンション工事案件状態コード). For other delivery methods (FTTH, Mail, etc.), the status is retrieved from the standard project status field (工事案件ステータス).

### Block 5.1** — [IF] Fiber Optic path: `tkHoshikiPtnCdNetSaki == "51"` (L228-L243)

For fiber-optic connections, retrieve the maintenance project status code from the response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `status = (String)ku0011Map.get(EKU0011A010CBSMsg1List.MANS_KOJIAK_STAT_CD)` // [-> MANS_KOJIAK_STAT_CD = "mans_kojiak_stat_cd"] Get maintenance project status code (マンション工事案件状態コード) |
| 2 | IF | `KOJIAK_STAT_KOJIKAISHAKETTEIZUMI.compareTo(status) <= 0 && KOJIAK_STAT_KOJIKANRYOZUMI.compareTo(status) >= 0` // [-> KOJIAK_STAT_KOJIKAISHAKETTEIZUMI = "160", KOJIAK_STAT_KOJIKANRYOZUMI = "200"] |

**Block 5.1.1** — [IF-THEN] Status in 160-200 range (L231-L234)

The status is between 160 (Contractor Company Decision Complete / 工事会社決定済) and 200 (Construction Complete / 工事完了済). This means the VLAN-ID will be allocated by batch processing. Return `true` to signal that VLAN-ID allocation is needed from this method's perspective (i.e., the current circuit does not have one yet).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false` // Status is 160-200: VLAN-ID handled by other processing [160: 工事会社決定済 〜 200: 工事完了済] |

**Block 5.1.2** — [IF-ELSE] ku0011Map is null (L229-L243)

If the response map is null (e.g., project not found), skip the status check entirely and fall through to the final `return true`.

### Block 5.2** — [ELSE] Other delivery methods path (L246-L255)

For non-fiber-optic connections (e.g., standard FTTH, Mail, ENUM), retrieve the standard construction project status field (工事案件ステータス) instead of the maintenance-specific field.

| # | Type | Code |
|---|------|------|
| 1 | SET | `status = (String)ku0011Map.get(EKU0011A010CBSMsg1List.KOJIAK_STAT)` // [-> KOJIAK_STAT = "kojiak_stat"] Get standard project status (工事案件ステータス) |
| 2 | IF | `KOJIAK_STAT_KOJIKAISHAKETTEIZUMI.compareTo(status) <= 0 && KOJIAK_STAT_KOJIKANRYOZUMI.compareTo(status) >= 0` // [-> KOJIAK_STAT_KOJIKAISHAKETTEIZUMI = "160", KOJIAK_STAT_KOJIKANRYOZUMI = "200"] |

**Block 5.2.1** — [IF-THEN] Status in 160-200 range (L249-L252)

The status is between 160 (Contractor Company Decision Complete / 工事会社決定済) and 200 (Construction Complete / 工事完了済). Return `false` — VLAN-ID is already handled by batch processing.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false` // Status is 160-200: VLAN-ID handled by other processing [160: 工事会社決定済 〜 200: 工事完了済] |

**Block 5.2.2** — [IF-ELSE] ku0011Map is null (L247-L255)

If the response map is null, skip the status check and proceed to `return true`.

**Block 6** — [RETURN] Default: allocate VLAN-ID (L261)

If none of the above conditions cause an early return (i.e., status is outside the 160-200 range, or ku0011Map was null), the method returns `true`, indicating the construction project has not yet reached a billed status, and VLAN-ID allocation is needed here.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // Unbilled status: VLAN-ID allocation needed [true = 未払出のステータス] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kojiak_no` | Field | Construction project number (工事案件番号) — unique identifier for a construction project record |
| `kojiak_stat` | Field | Construction project status (工事案件ステータス) — current state of the construction project in the standard flow |
| `mans_kojiak_stat_cd` | Field | Maintenance project status code (マンション工事案件状態コード) — project status for condominium (multi-dwelling) maintenance construction projects |
| `tk_hoshiki_ptn_cd_net_saki` | Field | Transmission destination delivery pattern code for network (伝送先提供方式パターンコード（ネット）先) — identifies the service delivery method (e.g., "51" = fiber-optic connection / 光コンセント) |
| VLAN-ID | Business term | Virtual LAN identifier — a network segmentation tag assigned to a circuit for ISP service provisioning |
| 新設工事 | Business term | New installation construction (新設工事) — initial deployment work for new service contracts |
| 工事案件ステータス | Business term | Construction project status — tracks the progress of a construction project through its lifecycle (120: Registration Complete -> ... -> 160: Contractor Decision -> ... -> 200: Construction Complete) |
| VLAN-ID払出済 | Business term | VLAN-ID already allocated — status indicating the VLAN-ID has been or will be assigned by other processing |
| 未払出 | Business term | Unbilled/Unallocated — status indicating VLAN-ID has not yet been assigned |
| 光コンセント | Business term | Fiber-optic connection (光コンセント) — delivery method code "51" for fiber-to-the-home services |
| EKU0011A010 | SC Code | Construction Project Inquiry SC (工事案件照会 SC) — service component for querying construction project details |
| EKK0011A010SC | SC Code | Service component class code for EKU0011A010 (Construction Project Inquiry) |
| KK_T_CONSTRUCTION_PROJECT | DB | Construction project master table (工事案件マスタ) — stores construction project records including status codes |
| JKKAdchgVLanGetCC | Class | VLAN-ID Allocation Common Component — the parent class containing VLAN-ID allocation business logic |
| 工事会社決定済 | Business term | Contractor Company Decision Complete — status code 160, indicating the contractor has made their decision |
| 工事完了済 | Business term | Construction Complete — status code 200, indicating construction work is finished |
| マンション工事案件 | Business term | Condominium (multi-dwelling) construction project — construction for apartment buildings where multiple units are served |
| 提供方式パターンコード | Business term | Delivery pattern code — classifies how service is delivered to the customer (fiber-optic, standard, etc.) |
| ServiceComponentRequestInvoker | Class | SC request invoker — executes Service Component calls with request/response mapping and session management |
| JKKAdchgMapperCC | Class | Mapper common component — handles SC request/response parameter mapping and result validation |
| K-Opticom | Business term | K-Opticom — Japanese broadband ISP service brand (K-Opticom eo Hikari Phone) |
| eo 顧客基幹システム | Business term | eo Customer Core System — the core business system for managing service contracts and construction projects |
