# Business Logic — JKKKyoseiDslRunCC.executeKyoseiDsl() [211 LOC]

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

## 1. Role

### JKKKyoseiDslRunCC.executeKyoseiDsl()

This method orchestrates the **forced contract termination (forced cancellation) of DSL-based broadband services** in the K-Opticom customer core system. It serves as the central execution engine for bulk forced-termination processing, where contracts are terminated unilaterally — typically due to non-payment, service suspension, or other business-driven cancellation reasons. The method implements a **batch-routing design pattern**: it iterates over a list of target contracts (extracted from the request parameter), applies per-contract termination processing, and then conditionally routes to a shared household equipment update component when running in batch mode (identified by `KIDO_CD = "02"` — the batch startup code). It also implements a **delegation pattern**, forwarding per-contract work to `executeKyoseiDslProc()`, parameter analysis to `analyzeRequestKyoKaiParam()`, and household service contract number updates to `callJKKTkkkSvKeiNoUpdCC()`. The method aggregates results including successfully terminated contracts, contracts that could not be terminated (with reasons), and monthly household service update records, writing all back to the response parameter object for downstream consumers. Japanese comments describe this as 強制解約 (kyousei-kaiyaku — forced cancellation) processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKyoseiDsl(handle, param, fixedText)"])

    START --> INIT["Initialize mapper if null"]
    INIT --> OPE_DATE["Get operation date via JCCBPCommon.getOpeDate"]
    OPE_DATE --> SET_OPE["mapper.setOpeDate(oPE_DATE)"]
    SET_OPE --> ANALYZE["analyzeRequestKyoKaiParam(param)"]
    ANALYZE --> GET_KKSV["Get kksv016701CC from param.getData(KKSV016701CC)"]
    GET_KKSV --> GET_KAI["Get kaiTaiLst from paramHash.get(KAI_TAI_LST)"]
    GET_KAI --> INIT_LISTS["Initialize fukaKaiTaiLst, getsujiTakniSvkeiList, netKaiTaiLst, wk_Fuka_flg=false"]
    INIT_LISTS --> GET_KIDO["Get kidoCd from kksv016701CC.get(KIDO_CD)"]

    GET_KIDO --> FOR_START{"kaiTaiLst.size > 0?"}

    FOR_START -->|Yes| FOR_LOOP["for i = 0 to kaiTaiLst.size-1"]
    FOR_LOOP --> MAP_PUT["Set paramHash: SEIKY_KEI_NO, SVC_KEI_NO, MSKM_DTL_NO, REQYMD, SVC_DSL_KISAN_YMD, SVC_CHRG_ENDYMD"]
    MAP_PUT --> RESET_FIELDS["Reset: sodSvcKeiUcwkList, dslTelnoList, svcKeiUpdDtm"]
    RESET_FIELDS --> TRY_BLOCK["try: executeKyoseiDslProc(handle, param, paramHash, fixedText, kksv016701CC, fukaKaiTaiLst, netKaiTaiLst)"]
    TRY_BLOCK --> TRY_OK["statusCode = executeKyoseiDslProc(...)"]
    TRY_OK --> FOR_CHECK{"More items in kaiTaiLst?"}
    FOR_CHECK -->|Yes| FOR_LOOP
    FOR_CHECK -->|No| FOR_END

    FOR_START -->|No| POST_LOOP["Skip loop, go to batch check"]
    FOR_END --> BATCH_CHECK{"kidoCd == KIDO_CD_BAT (\"02\")?"}

    BATCH_CHECK -->|Yes| CALL_UPD["callJKKTkkkSvKeiNoUpdCC(handle, param, fixedText, netKaiTaiLst)"]
    BATCH_CHECK -->|No| SET_RESULT["Set processing result"]
    CALL_UPD --> SET_RESULT

    SET_RESULT --> CHECK_FUKA{"wk_Fuka_flg true?"}
    CHECK_FUKA -->|Yes| SET_FUKA["kksv016701CC.put(SYORI_RESULT, SYORI_RESULT_FUKA=\"1\")"]
    CHECK_FUKA -->|No| SET_OK["kksv016701CC.put(SYORI_RESULT, SYORI_RESULT_OK=\"0\")"]

    SET_FUKA --> SET_DATA["Set kksv016701CC fields: FUKA_KAI_TAI_LST, GETSUJI_TAKNI_SVKEI_LIST, NET_KAI_SVKEI_LIST"]
    SET_OK --> SET_DATA
    SET_DATA --> PARAM_SET["param.setData(KKSV016701CC, kksv016701CC)"]
    PARAM_SET --> SET_RC["param.setControlMapData(RETURN_CODE, statusCode formatted)"]
    SET_RC --> RETURN(["return param"])
```

**Block flow description:**

1. **Initialization**: Lazily instantiates `mapper` if null, retrieves the operational date from `JCCBPCommon.getOpeDate`, and stores it in the mapper.
2. **Parameter analysis**: Delegates to `analyzeRequestKyoKaiParam(param)` to extract and validate the forced-termination target list from the request.
3. **List preparation**: Extracts the target contract list (`kaiTaiLst`), the response container (`kksv016701CC`), and the startup code (`kidoCd`). Initializes lists for non-terminable contracts, household service updates, and internet-terminated contracts.
4. **Per-contract termination loop**: Iterates over each target contract in `kaiTaiLst`, populating `paramHash` with per-contract identifiers and dates, resetting instance fields, and calling `executeKyoseiDslProc()` inside a try-catch block to isolate service-layer errors. On exception, stores the problematic contract data in `BUSINESS_ERROR_INFO` and re-throws.
5. **Batch equipment update**: When `kidoCd == "02"` (batch mode), calls `callJKKTkkkSvKeiNoUpdCC()` to synchronize household service contract numbers with the home equipment management system.
6. **Result aggregation**: Sets the processing result flag (`"0"` = success, `"1"` = some contracts were non-terminable), populates output lists, sets the return code, and returns the parameter object.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for the current transaction context. Carries the database connection and transaction management state. |
| 2 | `param` | `IRequestParameterReadWrite` | Request/response parameter object that carries the forced-termination target list (`KAI_TAI_LST`), startup code (`KIDO_CD`), and output fields. It is both read (for inputs) and written to (for results) throughout processing. |
| 3 | `fixedText` | `String` | Fixed service message text — a message string used for logging or status output in batch operations. Passed through to called methods for consistent message formatting. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `mapper` | `JKKKyoseiDslRunMapperCC` | Mapper object that holds service-layer invocation configuration and operational date. Lazily initialized if null. |
| `wk_Fuka_flg` | `boolean` | Processing result flag — set to `true` when at least one contract cannot be terminated (resolves to 強制解約不可 — forced termination not possible). |
| `sodSvcKeiUcwkList` | `ArrayList<HashMap<String, Object>>` | Service contract detail number list used by SOD (Service Order Data) component. Reset each iteration. |
| `dslTelnoList` | `ArrayList<String>` | Phone number list for Skyma (speed) updates. Added in Step 2 quality enhancement (ANK-4494). |
| `svcKeiUpdDtm` | `String` | Service contract update date-time string. Reset each iteration. |
| `kidoCd` | `String` | Startup code — determines execution mode. `"02"` indicates batch startup (業務起動). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBPCommon.getOpeDate` | JCCBPCommon | Operational date | Reads the current operation date from system configuration |
| R | `JKKKyoseiDslRunCC.getDayOfBefore` | JKKKyoseiDslRunCC | - | Reads/transforms a date string by subtracting a day (date calculation utility) |
| - | `JKKKyoseiDslRunMapperCC.setOpeDate` | JKKKyoseiDslRunMapperCC | - | Sets the operation date into the mapper for subsequent SC calls |
| - | `JKKKyoseiDslRunCC.analyzeRequestKyoKaiParam` | JKKKyoseiDslRunCC | - | Analyzes and extracts forced-termination parameters from the request object (internal analysis) |
| C | `executeKyoseiDslProc` | N/A | SOD (Service Order Data) | Core per-contract forced-termination processing — creates service order data, updates contract status, handles DSL line termination. Contains all the actual CRUD operations against SOD/contract tables. |
| C | `callJKKTkkkSvKeiNoUpdCC` | JKKTkkkSvKeiNoUpdCC | Household service contract update tables | Creates/updates household service contract records for equipment synchronization in batch mode |
| - | `IRequestParameterReadWrite.setData` | - | - | Sets the consolidated result object (`KKSV016701CC`) back into the response parameter |
| - | `IRequestParameterReadWrite.setControlMapData` | - | - | Sets the formatted return code into the control map for the calling screen/batch |

**How to classify:**
- **R** (Read): `getOpeDate`, `getDayOfBefore` — retrieve system data or transform dates
- **C** (Create): `executeKyoseiDslProc` — creates SOD records and performs termination processing; `callJKKTkkkSvKeiNoUpdCC` — creates household service contract update records
- **U** (Update): Embedded within `executeKyoseiDslProc` — updates service contract status, billing end dates, etc.
- **EXEC**: `setData`, `setControlMapData` — parameter object methods for result output

The actual database operations (CRUD on SOD tables, contract tables, billing tables) are performed inside `executeKyoseiDslProc()`, which delegates to multiple SC/CBS components for the low-level data access.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKBpCommon.runKyoseiDsl()` | `JKKBpCommon.runKyoseiDsl()` → `JKKKyoseiDslRunCC.executeKyoseiDsl()` | `executeKyoseiDslProc [C] SOD`, `callJKKTkkkSvKeiNoUpdCC [C] Household service tables`, `setData [-]`, `getDayOfBefore [R]`, `getOpeDate [R]` |

**Notes:**
- The pre-computed code analysis graph indicates no screen or batch entry points within 8 hops. The direct caller `JKKBpCommon.runKyoseiDsl()` is a Common Business Service (CBS) that acts as the entry point for forced DSL termination processing.
- Terminal operations from this method flow through `executeKyoseiDslProc()` to the SC/CBS layer, where actual SOD (Service Order Data) creation, contract status updates, and billing adjustments occur.
- In batch mode (`KIDO_CD_BAT = "02"`), the method additionally calls `callJKKTkkkSvKeiNoUpdCC()` which propagates to `JKKTkkkSvKeiNoUpdCC.updTkkkSvKeiNo()`.

## 6. Per-Branch Detail Blocks

### Block 1 — IF (lazy initialization of mapper) (L755-758)

> Initializes the mapper instance if it has not been created yet. This follows a lazy-initialization pattern.

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.mapper = new JKKKyoseiDslRunMapperCC()` |

### Block 2 — EXEC (get operation date) (L762-764)

> Retrieves the current operational date from the system-wide date management component. The comment references BLT-2013-0000241.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `oPE_DATE = JCCBPCommon.getOpeDate(null)` |
| 2 | SET | `mapper.setOpeDate(oPE_DATE)` |

### Block 3 — EXEC (parameter analysis) (L768-769)

> Delegates to the internal analysis method to parse the request and extract forced-termination target data.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramHash = analyzeRequestKyoKaiParam(param)` |
| 2 | CALL | `kksv016701CC = (HashMap<String, Object>) param.getData(KKSV016701CC)` |

### Block 4 — EXEC (extract target list and initialize working lists) (L773-788)

> Extracts the forced-termination target list, initializes working lists for non-terminable contracts, household service updates, and internet-terminated contracts. Resets the non-terminable flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kaiTaiLst = (ArrayList<HashMap<String, Object>>) paramHash.get(KAI_TAI_LST)` |
| 2 | SET | `fukaKaiTaiLst = new ArrayList<HashMap<String, Object>>()` — 強制解約不可対象者リスト (Non-terminable contract list) |
| 3 | SET | `getsujiTakniSvkeiList = new ArrayList<HashMap<String, Object>>()` — 宅内サービス契約番号更新情報(月次)リスト (Monthly household service contract number update list) |
| 4 | SET | `netKaiTaiLst = new ArrayList<HashMap<String, String>>()` — ネット解約対象者リスト (Internet termination target list) |
| 5 | SET | `this.wk_Fuka_flg = false` — 強制解約不可フラグ初期化 (Non-terminable flag initialization) |
| 6 | SET | `this.kidoCd = (String) kksv016701CC.get(KIDO_CD)` — 起動コード取得 (Startup code retrieval) [-> `KIDO_CD = "KIDO_CD"`] |

### Block 5 — FOR (per-contract termination loop) (L792-856)

> Main processing loop: iterates over each contract in the forced-termination target list, sets per-contract parameters in `paramHash`, resets instance fields, and executes termination processing inside a try-catch block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kaitaiHash = kaiTaiLst.get(i)` — 強制解約対象者リスト取得 (Get target from list) |
| 2 | SET | `paramHash.put(SEIKY_KEI_NO, kaitaiHash.get(SEIKY_KEI_NO))` — 請求契約番号 (Billing contract number) |
| 3 | SET | `paramHash.put(SVC_KEI_NO, kaitaiHash.get(SVC_KEI_NO))` — サービス契約番号 (Service contract number) |
| 4 | SET | `paramHash.put(MSKM_DTL_NO, kaitaiHash.get(MSKM_DTL_NO))` — 申込明細番号 (Application detail number) |
| 5 | SET | `paramHash.put(REQYMD, kaitaiHash.get(REQYMD))` — 依頼年月日 (Request date) |
| 6 | SET | `paramHash.put(SVC_DSL_KISAN_YMD, kaitaiHash.get(SVC_CHRG_ENDYMD))` — サービス解約起算年月日 (Service termination calculation date) [-> `SVC_DSL_KISAN_YMD = "SVC_DSL_KISAN_YMD"`] |
| 7 | SET | `paramHash.put(SVC_CHRG_ENDYMD, getDayOfBefore((String) kaitaiHash.get(SVC_CHRG_ENDYMD)))` — サービス課金終了年月日 (Service billing end date) — date minus 1 day [-> `SVC_CHRG_ENDYMD = "SVC_CHRG_ENDYMD"`] |
| 8 | SET | `this.sodSvcKeiUcwkList = new ArrayList<HashMap<String, Object>>()` — SODCC用サービス契約内訳番号リスト (SOD service contract detail list) |
| 9 | SET | `this.dslTelnoList = new ArrayList<String>()` — 電話番号スキーマ更新用電話番号リスト (Phone number list for schema updates) [ANK-4494 Step2] |
| 10 | SET | `this.svcKeiUpdDtm = ""` — サービス契約更新年月日時クリア (Reset service contract update datetime) |

**Block 5.1 — TRY-CATCH (per-contract execution with error isolation) (L805-840)**

> Wraps the core termination processing in a try-catch to isolate service-layer errors. On exception, stores the problematic contract data in `BUSINESS_ERROR_INFO` and re-throws, preventing one failed contract from silently corrupting batch processing.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `statusCode = executeKyoseiDslProc(handle, param, paramHash, fixedText, kksv016701CC, fukaKaiTaiLst, netKaiTaiLst)` — メイン処理の実行 (Main processing execution) |
| 2 | SET (on catch) | `kksv016701CC.put(BUSINESS_ERROR_INFO, kaitaiHash)` — エラー情報として強制解約対象者リストの対象データを設定 (Set target contract data as error information) [-> `BUSINESS_ERROR_INFO = "BUSINESS_ERROR_INFO"`] |
| 3 | EXEC (on catch) | `throw e` — エラー再スロー (Re-throw exception) |

### Block 6 — IF (batch mode equipment update) (L917-920)

> When running in batch mode (`KIDO_CD_BAT = "02"`), calls the shared household service contract number update component to synchronize equipment information. This replaced the older inlined ONU/home equipment logic (OM-2016-0001720).

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `KIDO_CD_BAT.equals(kidoCd)` — 起動コードがバッチ起動か (Is startup code batch?) [-> `KIDO_CD_BAT = "02"` (業務起動/Batch startup)] |
| 2 | CALL (true branch) | `getsujiTakniSvkeiList = callJKKTkkkSvKeiNoUpdCC(handle, param, fixedText, netKaiTaiLst)` — 宅内サービス契約番号更新情報を出力 (Output household service contract update info) |

### Block 7 — IF-ELSE (processing result flag) (L924-932)

> Sets the processing result flag based on whether any contracts were non-terminable.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `wk_Fuka_flg` — 強制解約あり (Non-terminable contracts exist) |
| 2 | SET (true) | `kksv016701CC.put(SYORI_RESULT, SYORI_RESULT_FUKA)` — 強制解約不可あり (Has non-terminable contracts) [-> `SYORI_RESULT_FUKA = "1"`] |
| 3 | SET (false) | `kksv016701CC.put(SYORI_RESULT, SYORI_RESULT_OK)` — 強制解約正常終了 (Forced termination completed normally) [-> `SYORI_RESULT_OK = "0"`] |

### Block 8 — EXEC (set output data into response) (L936-945)

> Populates the response container with all result data and sets the return code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kksv016701CC.put(FUKA_KAI_TAI_LST, fukaKaiTaiLst)` — 強制解約不可対象者リスト設定 (Set non-terminable contract list) [-> `FUKA_KAI_TAI_LST = "FUKA_KAI_TAI_LST"`] |
| 2 | SET | `kksv016701CC.put(GETSUJI_TAKNI_SVKEI_LIST, getsujiTakniSvkeiList)` — 宅内サービス契約番号更新情報(月次)リスト設定 (Set monthly household service contract update list) [-> `GETSUJI_TAKNI_SVKEI_LIST = "GETSUJI_TAKNI_SVKEI_LIST"`] |
| 3 | SET | `kksv016701CC.put(NET_KAI_SVKEI_LIST, netKaiTaiLst)` — ネットで解約したリスト設定 (Set internet-terminated contract list) [-> `NET_KAI_SVKEI_LIST = "NET_KAI_SVKEI_LIST"`] |
| 4 | EXEC | `param.setData(KKSV016701CC, kksv016701CC)` — 処理結果書き戻し (Write back processing results) [-> `KKSV016701CC = "KKSV016701CC"`] |
| 5 | SET | `formedCode = String.format("%1$04d", statusCode)` — リターンコードの整形 (Format return code as 4-digit zero-padded) |
| 6 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formedCode)` — リターンコードの設定 (Set return code in control map) |
| 7 | RETURN | `return param` — 処理完了 (Processing complete) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kyousei-kaiyaku` (強制解約) | Business term | Forced cancellation/termination — unilateral contract termination initiated by the provider, typically due to non-payment or service policy violations |
| `SEIKY_KEI_NO` (請求契約番号) | Field | Billing contract number — the primary contract identifier used for invoicing and billing purposes |
| `SVC_KEI_NO` (サービス契約番号) | Field | Service contract number — identifies a specific service subscription under a billing contract |
| `MSKM_DTL_NO` (申込明細番号) | Field | Application detail number — identifies the specific application/sub-order within a service contract |
| `KAI_TAI_LST` (解約対象者リスト) | Field | Termination target list — the list of contracts selected for forced termination processing |
| `FUKA_KAI_TAI_LST` (解約不可対象者リスト) | Field | Non-terminable contract list — contracts that could not be terminated, with reasons for failure |
| `FUKA_RESON` (解約不可理由) | Field | Reason for non-termination — codes indicating why a contract could not be cancelled (e.g., "01" = request cancellation, "02" = contract processing in progress, "03" = eo TV/KCN) |
| `KIDO_CD` (起動コード) | Field | Startup code — identifies the execution mode. "02" = batch startup (業務起動) |
| `SYORI_RESULT` (処理結果) | Field | Processing result — "0" = all contracts terminated normally, "1" = some contracts were non-terminable |
| `wk_Fuka_flg` (処理結果フラグ) | Field | Internal processing result flag — set to `true` when any contract encounters a non-terminable condition |
| `getsujiTakniSvkeiList` (宅内サービス契約番号更新情報(月次)リスト) | Field | Monthly household service contract number update list — equipment synchronization records for home devices (ONU, set-top boxes) |
| `netKaiTaiLst` (ネット解約対象者リスト) | Field | Internet termination target list — contracts terminated specifically for internet service |
| `NET_KAI_SVKEI_LIST` | Field | Internet-terminated service contract number list — output container for internet termination records |
| `SVC_CHRG_ENDYMD` (サービス課金終了年月日) | Field | Service billing end date — the final date on which the customer is billed for the service |
| `SVC_DSL_KISAN_YMD` (サービス解約起算年月日) | Field | Service termination calculation date — the date from which service termination is calculated |
| `REQYMD` (依頼年月日) | Field | Request date — the date the termination request was made |
| `OPE_DATE` (作業日付) | Field | Operational date — the system date used as the reference date for all processing operations |
| `BUSINESS_ERROR_INFO` (業務エラー情報) | Field | Business error information — stores the contract data of the contract that caused a service-layer error |
| SOD | Acronym | Service Order Data — the telecom order fulfillment entity that tracks service activation, modification, and cancellation records |
| SC | Acronym | Service Component — a service layer component that handles business logic and data access for a specific operation |
| CBS | Acronym | Common Business Service — a business service that encapsulates shared business logic across multiple screens/use cases |
| CC | Acronym | Common Component — a reusable component class that provides shared functionality across the application |
| DSL | Acronym | Digital Subscriber Line — broadband internet technology using telephone lines |
| ONU | Business term | Optical Network Unit — fiber-to-the-home terminal equipment that converts optical signals to electrical signals for home use. Service code: `C012` |
| NTTCp (NTT卸対応) | Business term | NTT wholesale correspondence — handling for NTT's wholesale business model, specifically "工事中なし対応" (without construction work) |
| `KKTK_SVC_CD_ONU` | Field | K-Opticom Telecom service code for ONU equipment — value `"C012"` |
| `KIDO_CD_BAT` | Field | Batch startup code constant — value `"02"`, used to determine if processing is running in batch mode |
| `PRG_STAT_KYOKAI_FIN` | Field | Program status code for forced termination completion — value `"2203"` |
| `IDO_RSN_CD_KYOKAI_TAINO` | Field | Deterioration reason code for non-payment termination — value `"01"` |
| `DSLTEL` / `dslTelnoList` | Field | Phone number list for Skyma (speed) schema updates — used for bidirectional phone service (双方向番ポ) Step 2/3 |
| `svcKeiUpdDtm` | Field | Service contract update date-time — tracks when service contract information was last updated |
| `sodSvcKeiUcwkList` | Field | SOD service contract detail number list — used by the SOD component for contract detail processing |
| K-Opticom | Business term | Japanese broadband telecommunications provider; the customer core system (顧客基幹システム) processes customer service contracts, billing, and termination |
