# Business Logic — JKKKddiKeishaInfoCC.setNetKeiyakuJotai() [122 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKddiKeishaInfoCC` |
| Layer | CC/Common Component — shared business logic component within the telecom order fulfillment suite |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKddiKeishaInfoCC.setNetKeiyakuJotai()

This method resolves and sets the **internet (Net) contract status** for a given service contract (サービス契約). It is responsible for determining the correct contract state to display based on the current service contract status (`svc_kei_stat`), the associated construction project agreement (工事案件) details, and any outstanding review (照会) conditions. The method retrieves the service contract data, looks up the project agreement information, applies a series of business rules to potentially override the raw status code (e.g., converting "Completed Receipt" (010) to "Active" (000), or flagging "Cancellation Completed" (910) when review fails or provisional cancellation conditions are met), and then writes the final resolved status code name to the `ccMsg` map as `out_prmt12` via the code name lookup service. It implements a **routing/dispatch** pattern — branching based on service contract status and project agreement fields — and serves as a **shared utility** called by `setNetKeiSmartValueMskmKh` when determining whether a customer is eligible for smart value (スマートバリュー) internet subscription. The method does not modify any database; it is purely a **read-and-transform** operation that prepares display data for the front-end screen.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setNetKeiyakuJotai"])

    START --> GET_STAT["Retrieve svcKeiStat from svcKeiData"]
    GET_STAT --> GET_NO["Retrieve svcKeiNo from svcKeiData"]

    GET_NO --> INIT_VARS["Initialize kojiakNo, kojiakStat, kojiakSbtCd, kjKrCnclFlg to empty string"]
    INIT_VARS --> BUILD_LIST["Build kojiStatList with statuses 140-190
(依頼中 through 現場作業完了済)"]

    BUILD_LIST --> GET_CUST["Call getEKU0081B010(handle, param, fixedText, svcKeiNo)
Get service contract_project overview"]
    GET_CUST --> CHECK_CUST_NULL{"cAANMsgCust != null"}

    CHECK_CUST_NULL -->|false| SKIP_BLOCK["Skip project data retrieval"]
    CHECK_CUST_NULL -->|true| CHECK_CUST_LEN{"cAANMsgCust.length != 0"}

    CHECK_CUST_LEN -->|false| SKIP_BLOCK
    CHECK_CUST_LEN -->|true| GET_KOJIAK_NO["Get kojiakNo from cAANMsgCust[0]"]

    GET_KOJIAK_NO --> GET_KOJI_DETAIL["Call getEKU0011A010(handle, param, fixedText, kojiakNo)
Get project agreement details"]
    GET_KOJI_DETAIL --> CHECK_KOJI_NULL{"cAANMsgKoji != null"}

    CHECK_KOJI_NULL -->|false| SKIP_DETAIL["Skip field extraction"]
    CHECK_KOJI_NULL -->|true| EXTRACT_FIELDS["Extract kojiakStat, kojiakSbtCd, kjKrCnclFlg"]

    EXTRACT_FIELDS --> SVC_STAT_010{"svcKeiStat == 010"}
    SKIP_BLOCK --> SVC_STAT_010
    SKIP_DETAIL --> SVC_STAT_010

    SVC_STAT_010 -->|true| MAP_010["svcKeiStat = 000
(Completed Receipt -> Active)"]
    SVC_STAT_010 -->|false| SVC_STAT_020_030{"svcKeiStat == 020 OR 030"}

    MAP_010 --> CHECK_CD_NAME["Call getEZM0171A010(handle, param, fixedText, CD01536, svcKeiStat)"]
    SVC_STAT_020_030 -->|false| CHECK_CD_NAME

    SVC_STAT_020_030 -->|true| IS_SHOSA["Call isShosaOK(handle, param, fixedText, svcKeiNo)"]
    IS_SHOSA --> SHOSA_FAIL{"isShosaOK == false
AND svcKeiStat == 020"}

    SHOSA_FAIL -->|true| MAP_REJECT["svcKeiStat = 910
(Review NG -> Cancellation Completed)"]
    SHOSA_FAIL -->|false| CHECK_KOJI_CONDITION{"kojiakSbtCd == 001
AND kojiStatList contains kojiakStat
AND kjKrCnclFlg == 1"}

    MAP_REJECT --> CHECK_CD_NAME
    CHECK_KOJI_CONDITION -->|true| MAP_KRCN["svcKeiStat = 910
(Provisional Cancellation New Setup -> Cancellation Completed)"]
    CHECK_KOJI_CONDITION -->|false| CHECK_CD_NAME

    MAP_KRCN --> CHECK_CD_NAME
    CHECK_CD_NAME --> PUT_MSG["ccMsg.put(out_prmt12, CD_DIV_NM from EZM0171A010)"]
    PUT_MSG --> END_NODE(["Return"])

    START --> GET_STAT
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle used for executing CBS (Component Business Service) calls and retrieving project agreement data. Carries transaction context and user authentication info. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object that holds screen input data. Passed to called methods for reading/writing request-scoped parameters (e.g., `fixedText`). |
| 3 | `fixedText` | `String` | Fixed text identifier used for display text lookups. Passed to CBS calls to resolve UI labels and messages in the correct locale. |
| 4 | `ccMsg` | `HashMap<String, Object>` | Common context message map that accumulates output data. This method writes the resolved contract status code name as `out_prmt12`. |
| 5 | `svcKeiData` | `CAANMsg` | Service contract data message carrying the core service contract fields including `svc_kei_stat` (status), `svc_kei_no` (contract number), and other contract attributes. Serves as the primary input for determining the internet contract state. |

**External state / instance fields read:** None directly — all state is accessed through parameter objects and called methods.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getNullToStr` | (Utility) | - | Null-safe string retrieval wrapper (local helper) |
| R | `JBSbatFUCaseFileRnkData.getString` | - | - | Reads string field from case file rank data object |
| R | `JBSbatFUMoveNaviData.getString` | - | - | Reads string field from move navigation data object |
| R | `JBSbatZMAdDataSet.getString` | - | - | Reads string field from zone master ad data set |
| R | `getEKU0081B010` | EKU0081B010 | SVKEI_KOJIAK (Service Contract Project Agreement) | Retrieves the service contract-Project Agreement overview — returns an array of CAANMsg containing project agreement no. (kojiak_no) |
| R | `getEKU0011A010` | EKU0011A010 | KOJIAK (Project Agreement) | Retrieves detailed Project Agreement data including status (kojiak_stat), type code (kojiak_sbt_cd), and provisional cancellation flag (kj_kr_cncl_flg) |
| R | `getEZM0171A010` | EZM0171A010 | ZM_M_CD (Code Master Table) | Looks up the code name (cd_div_nm) for a given code division (CD01536) and code value (svc_kei_stat). Returns the human-readable status label for display. |
| R | `getNullToStr` | (Utility) | - | Null-safe string retrieval wrapper (local helper) |
| - | `isShosaOK` | (Business Rule) | - | Business rule check: determines whether a review (照会/shousha) is OK. Returns true if no pending review exists for the contract. |
| R | `JESC0101B010TPMA.getString` | - | - | Reads string field from TPSM data object |
| R | `JESC0101B020TPMA.getString` | - | - | Reads string field from TPSM data object |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `setNetKeiSmartValueMskmKh` | `setNetKeiSmartValueMskmKh` -> `setNetKeiyakuJotai` | `getEZM0171A010 [R] ZM_M_CD`, `getEKU0081B010 [R] SVKEI_KOJIAK`, `getEKU0011A010 [R] KOJIAK` |

**Notes:** The caller `setNetKeiSmartValueMskmKh` is itself a private method on the same class. No direct screen/batch entry points were found within 8 hops — this method is exclusively invoked from the smart value determination flow, not from end-user screens directly.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(svcKeiStat retrieval)` (L2360)

> Retrieves the service contract status from the input message. Japanese comment: サービス契約ステータス取得 (Service contract status retrieval).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `svcKeiData.getString(EKK0251B005CBSMsg1List.SVC_KEI_STAT)` |
| 2 | CALL | `getNullToStr(...)` [-> `getNullToStr` is a null-safety wrapper] |
| 3 | SET | `svcKeiStat = result` // The service contract status code (010, 020, 030, etc.) |

**Block 2** — [SET] `(svcKeiNo retrieval)` (L2364)

> ANK-3136-00-00 added this line. Japanese comment: サービス契約番号 (Service contract number).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `svcKeiData.getString(EKK0251B005CBSMsg1List.SVC_KEI_NO)` |
| 2 | CALL | `getNullToStr(...)` |
| 3 | SET | `svcKeiNo = result` // Service contract number, used for lookups |

**Block 3** — [SET] `(Initialize project fields)` (L2371-L2381)

> OM-2018-0001092 MOD: Changed from null to empty string initialization for project-related variables. Japanese comments: 工事案件番号 (Project agreement number), 工事案件ステータス (Project status), 工事案件種別コード (Project type code), 工事仮キャンセルフラグ (Project provisional cancellation flag).

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiakNo = ""` // 工事案件番号 (Project agreement number) |
| 2 | SET | `kojiakStat = ""` // 工事案件ステータス (Project status) |
| 3 | SET | `kojiakSbtCd = ""` // 工事案件種別コード (Project type code) |
| 4 | SET | `kjKrCnclFlg = ""` // 工事仮キャンセルフラグ (Project provisional cancellation flag) |

**Block 4** — [SET] `(Build kojiStatList)` (L2383-L2394)

> Japanese comments describe each status value. Resolved from `JKKStrConst.CD00474_*`:
> - CD00474_140 = "140" — 工事案件ステータス: 依頼中 (Project status: Requested/Pending)
> - CD00474_150 = "150" — 工事案件ステータス: 宅内調査完了済 (Project status: Indoor survey completed)
> - CD00474_160 = "160" — 工事案件ステータス: 工事会社決定済 (Project status: Construction company decided)
> - CD00474_170 = "170" — 工事案件ステータス: 宅内機器予定登録済 (Project status: Indoor equipment scheduled registration completed)
> - CD00474_180 = "180" — 工事案件ステータス: 仮鍵開発依頼済 (Project status: Temporary key development request completed)
> - CD00474_190 = "190" — 工事案件ステータス: 現場作業完了済 (Project status: On-site work completed)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiStatList = new LinkedList<String>()` |
| 2 | EXEC | `kojiStatList.add(JKKStrConst.CD00474_140)` // [-> "140" 依頼中] |
| 3 | EXEC | `kojiStatList.add(JKKStrConst.CD00474_150)` // [-> "150" 宅内調査完了済] |
| 4 | EXEC | `kojiStatList.add(JKKStrConst.CD00474_160)` // [-> "160" 工事会社決定済] |
| 5 | EXEC | `kojiStatList.add(JKKStrConst.CD00474_170)` // [-> "170" 宅内機器予定登録済] |
| 6 | EXEC | `kojiStatList.add(JKKStrConst.CD00474_180)` // [-> "180" 仮鍵開発依頼済] |
| 7 | EXEC | `kojiStatList.add(JKKStrConst.CD00474_190)` // [-> "190" 現場作業完了済] |

**Block 5** — [CALL] `(Get service contract - project agreement overview)` (L2397)

> Japanese comment: サービス契約_工事案件一覧照会情報取得 (Service contract - project agreement list inquiry information retrieval).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cAANMsgCust = getEKU0081B010(handle, param, fixedText, svcKeiNo)` |

**Block 6** — [IF] `(cAANMsgCust != null)` (L2399)

> Japanese comment: (none — null check guard)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(cAANMsgCust != null)` |
| 2 | [Block 6.1] | See Block 6.1 below |

**Block 6.1** — [IF] `(cAANMsgCust.length != 0)` (L2401)

> OM-2018-0001092 ADD: Added length check. Japanese comment: (none)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(cAANMsgCust.length != 0)` |
| 2 | [Block 6.2] | See Block 6.2 below |

**Block 6.2** — [SET] `(Get project agreement number)` (L2404)

> Japanese comment: 工事案件番号を取得 (Retrieve project agreement number).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cAANMsgCust[0].getString(EKU0081B010CBSMsg1List.KOJIAK_NO)` // 工事案件番号 |
| 2 | CALL | `getNullToStr(...)` |
| 3 | SET | `kojiakNo = result` |

**Block 7** — [CALL] `(Get project agreement details)` (L2409)

> Japanese comment: 工事案件一意照会情報取得処理 (Single project agreement inquiry information retrieval processing).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cAANMsgKoji = getEKU0011A010(handle, param, fixedText, kojiakNo)` |

**Block 8** — [IF] `(cAANMsgKoji != null)` (L2411)

> Japanese comment: (none — null check guard)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(cAANMsgKoji != null)` |
| 2 | [Block 8.1] | See Block 8.1 below |

**Block 8.1** — [SET] `(Extract project fields)` (L2414-L2418)

> Japanese comments: 工事案件ステータスを取得 (Retrieve project status), 工事案件種別コードを取得 (Retrieve project type code), 工事仮キャンセルフラグを取得 (Retrieve project provisional cancellation flag).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cAANMsgKoji.getString(EKU0011A010CBSMsg1List.KOJIAK_STAT)` // 工事案件ステータス |
| 2 | CALL | `getNullToStr(...)` |
| 3 | SET | `kojiakStat = result` |
| 4 | CALL | `cAANMsgKoji.getString(EKU0011A010CBSMsg1List.KOJIAK_SBT_CD)` // 工事案件種別コード |
| 5 | CALL | `getNullToStr(...)` |
| 6 | SET | `kojiakSbtCd = result` |
| 7 | CALL | `cAANMsgKoji.getString(EKU0011A010CBSMsg1List.KJ_KR_CNCL_FLG)` // 工事仮キャンセルフラグ |
| 8 | CALL | `getNullToStr(...)` |
| 9 | SET | `kjKrCnclFlg = result` |

**Block 9** — [IF] `(svcKeiStat == "010" — 対象外(受払済))` (L2430)

> Japanese comment: 対象外(受払済)のサービス契約状態の場合 (If the service contract status is "out of scope" / "delivery completed"). When the status is "010" (Delivery Completed), it is remapped to "000" (Active).

| # | Type | Code |
|---|------|------|
| 1 | IF | `if("010".equals(svcKeiStat))` [-> "010" = 受払済/Completed Receipt] |
| 2 | SET | `svcKeiStat = "000"` [-> "000" = 契約中/Active] |

**Block 10** — [IF] `(svcKeiStat == "020" OR "030")` (L2448)

> Japanese comment: 「照会済」、「締結済」の場合 (If "Review completed" or "Agreement completed"). This block handles both status 020 (Review Completed) and 030 (Agreement Completed).

| # | Type | Code |
|---|------|------|
| 1 | IF | `if("020".equals(svcKeiStat) || "030".equals(svcKeiStat))` |
| 2 | [Block 10.1] | See Block 10.1 below |

**Block 10.1** — [IF] `(isShosaOK && svcKeiStat == "020")` (L2451)

> Japanese comment: 照会OUT以外、「照会済」の場合 (Except review OUT, when "Review completed"). If the review check fails AND the status is specifically 020, the contract status is set to "910" (Cancellation Completed).
>
> ANK-3136-00-00 MOD: This check was previously commented out as part of the v5.00.14 update.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isShosaOK(handle, param, fixedText, svcKeiNo)` // Review OK check |
| 2 | IF | `if(!isShosaOK(...) && "020".equals(svcKeiStat))` |
| 3 | SET | `svcKeiStat = "910"` // [-> 910 = 解約済/Cancellation Completed] — 照会OUTのため契約状態を「解約済」に編集 (Edit contract status to "Cancellation Completed" due to review OUT) |

**Block 10.2** — [ELSE-IF] `(kojiakSbtCd == "001" AND status in list AND kjKrCnclFlg == "1")` (L2457)

> Japanese comment: 照会済（照会OK）、締結済の場合 (When review completed (review OK), agreement completed). 工事案件ステータスが「依頼中」～「現場作業完了済」、工事種別コードが「新設」の場合、かつ 工事仮キャンセルフラグが「有」の場合 (When project status is "Requested" through "On-site work completed", project type code is "New Setup", and project provisional cancellation flag is "Present").
>
> In this case, the contract is set to "910" (Cancellation Completed) — provisional cancellation new setup contracts are treated as cancelled.

| # | Type | Code |
|---|------|------|
| 1 | IF | `else if("001".equals(kojiakSbtCd) && kojiStatList.contains(kojiakStat) && "1".equals(kjKrCnclFlg))` |
| 2 | SET | `svcKeiStat = "910"` // [-> 910 = 解約済/Cancellation Completed] — 仮キャンセル状態の新設工事に紐付く契約は「解約済」に編集 (Contracts linked to provisional cancellation new-setup projects are edited to "Cancellation Completed") |

**Block 11** — [CALL] `(Code name management lookup)` (L2466)

> Japanese comment: コード名称管理一意照会取得 (Code name management single inquiry retrieval). Looks up the human-readable label for the resolved status code.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cAANMsgCdNmKanri = getEZM0171A010(handle, param, fixedText, "CD01536", svcKeiStat)` |

**Block 12** — [SET] `(Write result to ccMsg)` (L2468)

> Japanese comment: (none — final write)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cAANMsgCdNmKanri.getString(EZM0171A010CBSMsg1List.CD_DIV_NM)` // コード区分名 (Code division name) |
| 2 | CALL | `getNullToStr(...)` |
| 3 | EXEC | `ccMsg.put("out_prmt12", result)` // Stores the resolved status code name |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_stat` | Field | Service contract status — a 3-digit code indicating the current state of a service contract (000=Active, 010=Delivery Completed, 020=Review Completed, 030=Agreement Completed, 910=Cancellation Completed) |
| `svc_kei_no` | Field | Service contract number — unique identifier for a service contract line item |
| `kojiak_no` | Field | Project agreement number — links a service contract to its associated construction/project agreement |
| `kojiak_stat` | Field | Project status — the current state of a construction project (140-190 range of values indicating progress stages) |
| `kojiak_sbt_cd` | Field | Project type code — classifies the type of project (e.g., "001" = 新設/New Setup) |
| `kj_kr_cncl_flg` | Field | Project provisional cancellation flag — "1" indicates the project has a provisional cancellation registered; empty string means no provisional cancellation |
| `out_prmt12` | Field | Output parameter 12 in the common context message map — holds the resolved internet contract status code name label |
| CD01536 | Constant | Code division identifier for service contract status codes — used with `getEZM0171A010` to look up human-readable status names |
| CD00474_140 | Constant | "140" — Project status: 依頼中 (Requested/Pending) |
| CD00474_150 | Constant | "150" — Project status: 宅内調査完了済 (Indoor survey completed) |
| CD00474_160 | Constant | "160" — Project status: 工事会社決定済 (Construction company decided) |
| CD00474_170 | Constant | "170" — Project status: 宅内機器予定登録済 (Indoor equipment scheduled registration completed) |
| CD00474_180 | Constant | "180" — Project status: 仮鍵開発依頼済 (Temporary key development request completed) |
| CD00474_190 | Constant | "190" — Project status: 現場作業完了済 (On-site work completed) |
| 000 | Status code | 契約中 (Active/Under Contract) |
| 010 | Status code | 受払済 (Delivery Completed) — maps to 000 (Active) in this method |
| 020 | Status code | 照会済 (Review Completed) — subject to review OK check |
| 030 | Status code | 締結済 (Agreement Completed) |
| 910 | Status code | 解約済 (Cancellation Completed) — result of failed review or provisional cancellation conditions |
| 001 | Status code | 新設 (New Setup) — project type code indicating a new installation project |
| 1 | Constant value | 工事仮キャンセルフラグ「有」 (Provisional cancellation flag "Present") |
| 照会 (Shousha) | Business term | Review/Inquiry — a validation step in the telecom contract workflow where the contract is reviewed before finalization |
| 工事案件 (Kojiak) | Business term | Construction project / Work project — the physical installation job associated with a telecom service contract |
| スマートバリュー (Smart Value) | Business term | NTT Docomo's bundled telecom service plan combining mobile, fixed-line, and internet services |
| NET (Net Keiyaku) | Business term | Internet contract — specifically refers to fixed-line internet (FTTH) service subscription |
| getEKU0081B010 | Method | Retrieves service contract - Project Agreement overview data |
| getEKU0011A010 | Method | Retrieves detailed single Project Agreement data |
| getEZM0171A010 | Method | Code name lookup — retrieves human-readable display name for a code value within a code division |
| isShosaOK | Method | Business rule: determines whether the review (照会) for a service contract is OK (no pending review) |
