# Business Logic — JKKKddiKeishaInfoCC.extractSvcKeiStateKei() [169 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKddiKeishaInfoCC` |
| Layer | CC/Common Component — Shared business logic component |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKddiKeishaInfoCC.extractSvcKeiStateKei()

This method extracts active net-service contracts from a list of all service contracts (caanMsg objects) for display to KDDI customer care operators. Specifically, it filters service contracts that belong to net service types (Home type, Metro type, or Mansion type — price group codes `02`, `03`, or `04`) and whose status indicates the customer is under an active contract relationship. The method identifies contracts in the states of "agreement completed" (`030`), "service in progress" (`100`), or "suspended/cut-off" (`210`), as described by the Javadoc: 契約中(契約手続中、契約中、中断中)のネット契約のサービス契約を抽出する ("Extract service contracts of net contracts during contract processing, under contract, or suspended").

The method implements a conditional filtering pattern with a special exception: for service contracts in the "inspection completed" (`020`) or "agreement completed" (`030`) status, it cross-references K-Opticom work case data (工事案件) to determine whether there is an active work case in progress for new construction that carries a temporary cancel flag. If such a work case exists (indicating the customer is temporarily cancelled during the construction workflow), the method intentionally skips counting that contract as active — even though its status would normally qualify. This prevents double-counting of service lines during temporary cancellations in the work order lifecycle.

The method delegates to two CBS (Contract-Based Service) queries to enrich its filtering decision with downstream work case data. It serves as a shared utility within the KDDI customer information reference screen (KDDI向け契約者情報参照), providing filtered lists that downstream operations screens rely on for contract display and processing. It is called by `getKddiKeishaInfo()` which aggregates all customer information for display.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["extractSvcKeiStateKei<br/>handle, param, fixedText, svcKeiList"])

    START --> INIT["Init: list=new LinkedList, statusList=[030, 100, 210]<br/>kojiStatList=[140-190]"]

    INIT --> LOOP["for each caanMsgData in svcKeiList"]

    LOOP --> PRCCHECK{"prc_grp_cd in PRC_GRP_CD_NET<br/>(02, 03, 04)"}

    PRCCHECK -->|No| LOOPCHECK{"More items?"}

    PRCCHECK -->|Yes| GETSVC["svcKeiNo = getNullToStr(caanMsg.getString(PRC_GRP_CD))]"]
    GETSVC --> EXTRACTWORK["Call getEKU0081B010<br/>Get contract work list"]

    EXTRACTWORK --> WORKNULL{"cAANMsgCust != null AND length > 0"}

    WORKNULL -->|No| CHECKSTATUS

    WORKNULL -->|Yes| WORKLOOP["for each cAANMsgCust[k]"]

    WORKLOOP --> GETKOJI["kojiakNo = getNullToStr(getString(KOJIAK_NO))]"]
    GETKOJI --> EXTRACTDETAIL["Call getEKU0011A010<br/>Get work approval details"]

    EXTRACTDETAIL --> KOJIDETAIL{"cAANMsgKoji != null"}

    KOJIDETAIL -->|No| WORKNEXT["k++"]

    KOJIDETAIL -->|Yes| GETFIELDS["kojiakStat = getNullToStr(getString(KOJIAK_STAT))]"]
    GETFIELDS --> GETFIELDS2["kojiakSbtCd = getNullToStr(getString(KOJIAK_SBT_CD))]"]
    GETFIELDS2 --> CHECKWORKSTAT{"kojiStatList.contains(kojiakStat)<br/>AND<br/>kojiakSbtCd = CD00577_NEWESTA (001)"}

    CHECKWORKSTAT -->|Yes| SETCNCL["kjKrCnclFlg = getNullToStr(getString(KJ_KR_CNCL_FLG))]"]
    SETCNCL --> BREAKWORK["Break work loop"]

    CHECKWORKSTAT -->|No| WORKNEXT

    BREAKWORK --> WORKNEXT
    WORKNEXT --> WORKCHECK{"More work entries?"}

    WORKCHECK -->|Yes| WORKLOOP
    WORKCHECK -->|No| CHECKSTATUS

    CHECKSTATUS --> MAINCOND{"(statusCd=020 AND isShosaOK)<br/>OR<br/>statusList.contains(statusCd)"}

    MAINCOND -->|No| LOOPCHECK

    MAINCOND -->|Yes| STATUS020OR030{"statusCd=020 OR 030?"}

    STATUS020OR030 -->|Yes| CNCLFLGCHK{"kjKrCnclFlg != 1?"}

    CNCLFLGCHK -->|Yes| ADDRESULT["list.add(caanMsgData)<br/>Add to result"]
    CNCLFLGCHK -->|No| SKIP["Skip - in-progress work with temp cancel"]

    STATUS020OR030 -->|No| ADDRESULT

    ADDRESULT --> LOOPCHECK
    SKIP --> LOOPCHECK

    LOOPCHECK -->|Yes| LOOP
    LOOPCHECK -->|No| RETURN["Return list"]

    RETURN --> END(["End"])

    style START fill:#e1f5fe
    style END fill:#e1f5fe
    style ADDRESULT fill:#c8e6c9
    style SKIP fill:#ffcdd2
    style BREAKWORK fill:#ffe0b2
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for executing CBS queries. Carries the transaction context and connection information used when calling downstream CBS methods like `getEKU0081B010` and `getEKU0011A010`. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object used to pass and retrieve data between the calling screen and CBS layer. Used in CBS calls to supply filtering parameters (e.g., service contract number). |
| 3 | `fixedText` | `String` | Fixed text / filter criteria string passed to CBS methods. Used as an additional filtering or identification parameter when querying work case data. |
| 4 | `svcKeiList` | `List<CAANMsg>` | The master list of all service contracts to filter. Each `CAANMsg` represents a single service contract line item containing fields such as price group code, service contract status, and service contract number. This is the primary input dataset. |

**Instance fields / external state read:**
- `PRC_GRP_CD_NET` (from `JKKSvcConst`) — List of net-service price group codes: `["02" (Home type), "03" (Metro type), "04" (Mansion type)]`. Used to determine which service contracts are net-type.
- `CD00577_NEWESTA` (`JKKStrConst`) — Work case type code `"001"` representing "New Construction". Used to identify new construction work cases during temporary cancel exception handling.
- `CD00474_140` through `CD00474_190` (`JKKStrConst`) — Work case status codes `"140"` through `"190"` representing the in-progress work lifecycle stages: Request Received, Home Survey Completed, Construction Company Decided, Indoor Equipment Pre-registration, Temporary Key Issuance, On-site Work Completed.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getNullToStr` | N/A | - | Local utility: converts null String values to empty strings to prevent NPE. Pure read/transformation. |
| R | `CAANMsg.getString` (PRC_GRP_CD) | N/A | - | Reads price group code field from the CAANMsg object (in-memory data). |
| R | `CAANMsg.getString` (SVC_KEI_STAT) | N/A | - | Reads service contract status code from the CAANMsg object (in-memory data). |
| R | `CAANMsg.getString` (SVC_KEI_NO) | N/A | - | Reads service contract number from the CAANMsg object (in-memory data). |
| R | `getEKU0081B010` | EKU0081B010 | Contract Work Summary Entity | Calls CBS to retrieve contract work case list for a given service contract number. Returns array of work case records. |
| R | `CAANMsg.getString` (KOJIAK_NO) | N/A | - | Reads work case number from the contract work summary CAANMsg (in-memory data). |
| R | `getEKU0011A010` | EKU0011A010 | Work Approval Details Entity | Calls CBS to retrieve detailed work case approval information for a given work case number. Returns work status, work type code, and temporary cancel flag. |
| R | `CAANMsg.getString` (KOJIAK_STAT) | N/A | - | Reads work case status code from work approval details CAANMsg (in-memory data). |
| R | `CAANMsg.getString` (KOJIAK_SBT_CD) | N/A | - | Reads work case type code from work approval details CAANMsg (in-memory data). |
| R | `CAANMsg.getString` (KJ_KR_CNCL_FLG) | N/A | - | Reads temporary cancel flag from work approval details CAANMsg (in-memory data). |
| R | `isShosaOK` | N/A | - | Local validation method: checks if processing/inspection is OK for the given service contract. Used as supplementary condition for "inspection completed" status contracts. |
| R | `getEKU0011A010` | EKU0011A010 | KK_T_KOJIAK_* (Work case tables) | The CBS `getEKU0011A010` queries work approval detail tables including work case status, type, and cancel flags. |
| R | `getEKU0081B010` | EKU0081B010 | KK_T_KOJIAK_SVC_* (Work-case-to-service linking) | The CBS `getEKU0081B010` queries the contract work summary linking service contracts to work cases. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | JKKKddiKeishaInfoCC.getKddiKeishaInfo() | `getKddiKeishaInfo` -> `extractSvcKeiStateKei` | `getEKU0081B010 [R] KK_T_KOJIAK_SVC_*`, `getEKU0011A010 [R] KK_T_KOJIAK_*`, `isShosaOK [-]`, `getNullToStr [R]` |

**Notes:**
- This method is a private utility with a single direct caller: `getKddiKeishaInfo()` within the same class.
- No screen or batch entry points were found calling this method directly. It is always invoked as part of the `getKddiKeishaInfo()` aggregation flow.
- The method performs read-only data enrichment: it queries work case data to supplement its in-memory filtering decision, but never writes or modifies any data.

## 6. Per-Branch Detail Blocks

**Block 1** — INIT (Local Variables) `(L4963)`

> Initialize local variables and build lookup lists for filtering criteria.

| # | Type | Code |
|---|------|------|
| 1 | SET | `list = new LinkedList<CAANMsg>()` // Empty result accumulator |
| 2 | SET | `statusList = new LinkedList<String>()` // Contract status whitelist |
| 3 | SET | `statusList.add("030")` // [-> CD00474 style: 030 "agreement completed"] |
| 4 | SET | `statusList.add("100")` // [-> 100 "service in progress"] |
| 5 | SET | `statusList.add("210")` // [-> 210 "suspended/cut-off"] |
| 6 | SET | `kojiakNo = ""` // 工事案件番号 (Work case number) |
| 7 | SET | `kojiakStat = ""` // 工事案件ステータス (Work case status) |
| 8 | SET | `kojiakSbtCd = ""` // 工事案件種類コード (Work case type code) |
| 9 | SET | `kjKrCnclFlg = ""` // 工事仮キャンセルフラグ (Work temporary cancel flag) |
| 10 | SET | `kojiStatList = new LinkedList<String>()` // Work status whitelist |
| 11 | SET | `kojiStatList.add(CD00474_140="140")` // 工事案件ステータス: 依頼済 (Work case status: Request received) [-> JKKStrConst.java:3779] |
| 12 | SET | `kojiStatList.add(CD00474_150="150")` // 工事案件ステータス: 宅内調査完了済 (Work case status: Home survey completed) [-> JKKStrConst.java:3781] |
| 13 | SET | `kojiStatList.add(CD00474_160="160")` // 工事案件ステータス: 工事会社決定済 (Work case status: Construction company decided) [-> JKKStrConst.java:3783] |
| 14 | SET | `kojiStatList.add(CD00474_170="170")` // 工事案件ステータス: 宅内機器予定登録済 (Work case status: Indoor equipment pre-registration completed) [-> JKKStrConst.java:3785] |
| 15 | SET | `kojiStatList.add(CD00474_180="180")` // 工事案件ステータス: 仮鍵開発行依存済 (Work case status: Temporary key issuance dependency) [-> JKKStrConst.java:3787] |
| 16 | SET | `kojiStatList.add(CD00474_190="190")` // 工事案件ステータス: 現場作業完了済 (Work case status: On-site work completed) [-> JKKStrConst.java:3789] |

**Block 2** — FOR LOOP `(svcKeiList)` `(L5014)`

> Iterate over each service contract in the input list to evaluate and potentially add it to the result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0; i < svcKeiList.size(); i++` // Loop over all service contracts |
| 2 | SET | `caanMsgData = svcKeiList.get(i)` // Current service contract entry |

**Block 2.1** — IF `(PRC_GRP_CD_NET.contains(prc_grp_cd))` `(L5023)`

> [PRC_GRP_CD_NET = ["02" (Home type), "03" (Metro type), "04" (Mansion type)] -> JKKSvcConst.java]
> Check if the service contract's price group code is a net-service type. Only net-type contracts are processed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `prc_grp_cd = getNullToStr(caanMsgData.getString(EKK0251B005CBSMsg1List.PRC_GRP_CD))` // Get price group code |
| 2 | SET | `statusCd = getNullToStr(caanMsgData.getString(EKK0251B005CBSMsg1List.SVC_KEI_STAT))` // Get service contract status |
| 3 | SET | `svcKeiNo = getNullToStr(caanMsgData.getString(EKK0251B005CBSMsg1List.SVC_KEI_NO))` // Get service contract number |
| 4 | CALL | `cAANMsgCust = getEKU0081B010(handle, param, fixedText, svcKeiNo)` // Extract contract work summary info (工事案件一覧照会情報取得) |

**Block 2.1.1** — IF `(cAANMsgCust != null)` `(L5039)`

> Check if the contract work summary query returned data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cAANMsgCust != null` // Guard against null return from CBS call |

**Block 2.1.1.1** — IF `(cAANMsgCust.length != 0)` `(L5042)`

> Check if the work case array is non-empty.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cAANMsgCust.length != 0` // Non-empty work case list |

**Block 2.1.1.1.1** — FOR LOOP `(cAANMsgCust[k])` `(L5045)`

> Iterate over each work case record linked to this service contract.

| # | Type | Code |
|---|------|------|
| 1 | SET | `k = 0; k < cAANMsgCust.length; k++` // Loop over work case entries |

**Block 2.1.1.1.1.1** — IF Block: Extract kojiakNo `(L5048)`

> Get the work case number from the current work case record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiakNo = getNullToStr(cAANMsgCust[k].getString(EKU0081B010CBSMsg1List.KOJIAK_NO))` // Get work case number (工事案件番号を取得) |
| 2 | CALL | `cAANMsgKoji = getEKU0011A010(handle, param, fixedText, kojiakNo)` // Contract work approval info extraction (工事案件一貫照会情報取得処理) |

**Block 2.1.1.1.1.2** — IF `(cAANMsgKoji != null)` `(L5053)`

> Check if the work approval details query returned data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cAANMsgKoji != null` // Guard against null return |

**Block 2.1.1.1.1.2.1** — Extract fields `(L5056)`

> Read work case status, type code, and temporary cancel flag from the work approval details.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiakStat = getNullToStr(cAANMsgKoji.getString(EKU0011A010CBSMsg1List.KOJIAK_STAT))` // Get work case status (工事案件ステータスを取得) |
| 2 | SET | `kojiakSbtCd = getNullToStr(cAANMsgKoji.getString(EKU0011A010CBSMsg1List.KOJIAK_SBT_CD))` // Get work case type code (工事案件種類コードを取得) |

**Block 2.1.1.1.1.2.2** — IF `(kojiStatList.contains(kojiakStat) AND kojiakSbtCd = CD00577_NEWESTA)` `(L5061)`

> [CD00577_NEWESTA = "001" (New Construction) -> JKKStrConst.java:2941]
> Check if the work case is in the "in-progress" status range (140-190) AND is of type "New Construction". If so, this is a work case actively under construction for new service setup.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kjKrCnclFlg = getNullToStr(cAANMsgKoji.getString(EKU0011A010CBSMsg1List.KJ_KR_CNCL_FLG))` // Get temporary cancel flag (工事仮キャンセルフラグを取得) |
| 2 | EXEC | `break` // Exit work case loop - found an in-progress new construction work case |

**Block 2.1.1.1.1.3** — ELSE fallthrough: No in-progress work case found `(L5097)`

> No in-progress work case was found for this service contract. Continue to the main status check.

| # | Type | Code |
|---|------|------|
| 1 | SET | (No action needed — variables remain as initialized) |

**Block 2.1.2** — IF `(Main Status Check)` `(L5086)`

> [IT1-2018-0000127 2018/07/26 ADD START]
> Primary filtering condition: Include the contract if (status is "inspection completed" AND inspection check passes) OR status is in the active status list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `condition = ("020".equals(statusCd) AND isShosaOK(handle, param, fixedText, svcKeiNo)) OR statusList.contains(statusCd)` |

**Block 2.1.2.1** — IF-ELSE: statusCd == "020" or "030" `(L5090)`

> Special handling for "inspection completed" (020) and "agreement completed" (030) status codes.

| # | Type | Code |
|---|------|------|
| 1 | SET | `if ("020".equals(statusCd) || "030".equals(statusCd))` // Status is inspection completed or agreement completed |

**Block 2.1.2.1.1** — IF `kjKrCnclFlg != "1"` `(L5094)`

> 工事案件の仮キャンセルフラグが有(値設定されている)以外の場合、カウントする // "Count unless the work case has a temporary cancel flag set (value assigned)."
> If the temporary cancel flag is NOT set to "1", add the contract to the result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `if (!("1".equals(kjKrCnclFlg)))` // Temporary cancel flag is not active |
| 2 | EXEC | `list.add(caanMsgData)` // Add to result — contract counts as active |

**Block 2.1.2.1.2** — ELSE: `kjKrCnclFlg == "1"` `(L5094)`

> 工事案件の仮キャンセルフラグが有(値設定されている) // "Work case has a temporary cancel flag set."
> Skip: do NOT add to result. This prevents double-counting a line that is temporarily cancelled during the construction workflow.

| # | Type | Code |
|---|------|------|
| 1 | (skip) | Do not add caanMsgData — contract excluded due to active temp cancel |

**Block 2.1.2.2** — ELSE: statusCd is NOT "020" or "030" `(L5098)`

> 契約中(契約手続中、契約中、中断中)のネット契約としてカウント // "Count as net contracts during contract (contract processing, under contract, suspended)."
> For statuses "100" (service in progress) and "210" (suspended/cut-off), always add the contract directly without work case check.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `list.add(caanMsgData)` // Add to result — unconditional count |

**Block 2.1.3** — ELSE: Main condition not met `(L5086)`

> The status does not qualify for inclusion. Skip this service contract.

| # | Type | Code |
|---|------|------|
| 1 | (skip) | Contract not added to result |

**Block 3** — RETURN `(L5118)`

> Return the filtered list of active net service contracts.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return list` // Return the filtered result list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — unique identifier for a service contract line item |
| `svc_kei_stat` | Field | Service contract status — indicates the current state of a service contract (020: inspection completed, 030: agreement completed, 100: service in progress, 210: suspended/cut-off) |
| `prc_grp_cd` | Field | Price group code — classifies the billing group type of a service contract (02: Home type, 03: Metro type, 04: Mansion type for net services) |
| `kojiak_no` | Field | Work case number — unique identifier for a construction/work case linked to a service contract |
| `kojiak_stat` | Field | Work case status — indicates the current stage of a work case in the construction workflow (140-190: request received through on-site work completed) |
| `kojiak_sbt_cd` | Field | Work case type code — classifies the type of work case (001: New Construction, 002: Removal/Deletion) |
| `kj_kr_cncl_flg` | Field | Temporary cancel flag — flag indicating whether a work case has been temporarily cancelled during the construction process (1 = temporary cancel active) |
| ITNM_ (prefix) | Prefix | Internal parameter name prefix — used for cross-system parameter passing |
| CAANMsg | Class | Common Application ANd Message — a message wrapper object used throughout the system to carry structured business data between components |
| KOJIAK (工事案件) | Domain term | Work case / Construction case — represents a field installation, modification, or cancellation work order in the telecom service lifecycle |
| SVC_KEI (サービス契約) | Domain term | Service contract — a contractual agreement for a telecom service (net, tel, TV, etc.) |
| EKK0251B005CBSMsg1List | Class | CBS message list constant class — field name constants for service contract data from CBS query EKK0251B005 |
| EKU0081B010 | CBS | Contract Work Summary CBS — service component that retrieves the list of work cases linked to a given service contract |
| EKU0011A010 | CBS | Work Approval Details CBS — service component that retrieves detailed work case information including status, type code, and cancel flags |
| PRC_GRP_CD_NET_HM | Constant | Price group code for eo Light Net Home Type = "02" [-> JKKSvcConst.java:68] |
| PRC_GRP_CD_NET_MZ | Constant | Price group code for eo Light Net Metro Type = "03" [-> JKKSvcConst.java:71] |
| PRC_GRP_CD_NET_MT | Constant | Price group code for eo Light Net Mansion Type = "04" [-> JKKSvcConst.java:74] |
| CD00474_140 | Constant | Work case status: Request Received = "140" [-> JKKStrConst.java:3779] |
| CD00474_150 | Constant | Work case status: Home Survey Completed = "150" [-> JKKStrConst.java:3781] |
| CD00474_160 | Constant | Work case status: Construction Company Decided = "160" [-> JKKStrConst.java:3783] |
| CD00474_170 | Constant | Work case status: Indoor Equipment Pre-registration = "170" [-> JKKStrConst.java:3785] |
| CD00474_180 | Constant | Work case status: Temporary Key Issuance = "180" [-> JKKStrConst.java:3787] |
| CD00474_190 | Constant | Work case status: On-site Work Completed = "190" [-> JKKStrConst.java:3789] |
| CD00577_NEWESTA | Constant | Work case type: New Construction = "001" [-> JKKStrConst.java:2941] |
| JKKKddiKeishaInfoCC | Class | KDDI Customer Information Common Component — shared CC for KDDI customer info reference screens |
| getEKU0081B010 | Method | Calls CBS EKU0081B010 to get work case list for a service contract |
| getEKU0011A010 | Method | Calls CBS EKU0011A010 to get work case approval details for a work case |
| isShosaOK | Method | Validation method that checks if processing/inspection is OK for a service contract |
| getNullToStr | Method | Utility that returns an empty string for null inputs to prevent NPE |
| SessionHandle | Class | Database session handle carrying transaction context |
| IRequestParameterReadWrite | Interface | Request parameter interface for screen-to-CBS data passing |
| net contract | Domain term | Internet service contract (eo Light) — as opposed to phone (tel), TV, or mobile contracts |
| Home type / Metro type / Mansion type | Domain term | Residential service delivery types: single-family homes, urban apartment buildings, and mansion (condominium) apartments respectively |
| 工事仮キャンセル (temporary cancel) | Domain term | A temporary cancellation flag set on a work case when a customer cancels during the construction workflow, allowing the system to distinguish between truly terminated and temporarily paused contracts |