# Eo / Web / Webview / Crw03401sf

## Overview

The `CRW03401SF` module is the view logic component for the **Comprehensive Sales Inquiry Response Screen** (総合営業問合せ対応画面). It serves as the central hub for customer service representatives to manage incoming inquiries — viewing counts across work queues (MYBOX, QueueBOX, email), updating inquiry status (accept, reject, close, restart, forced acquisition), and opening popup sub-screens for tasks like creating new inquiries, sending emails, registering memos, escalating issues, and more.

The module lives in the `eo.web.webview.CRW03401SF` package and extends the framework's base web business logic class. It is wired into the X31 web framework through two XML configuration files (`WEBGAMEN_CRW034010PJP.xml` and `x31business_logic_CRW03401SF.xml`), which register the logic class for a specific screen flow.

## Key Classes and Interfaces

### CRW03401SFLogic

**Source:** [`CRW03401SFLogic.java`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java)

This is the sole class in the module and the primary controller for the inquiry response screen. It extends `JCCWebBusinessLogic` from the web framework common layer. The class has 36 methods and approximately 2,289 lines of code.

**Key methods:**

- **[`init()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:103)** — The main entry point for initial screen display. It fetches screen info from inherited data, initializes button/link states via `JCRWebCommon.resetButtonStatus()`, clears all data bean arrays (campaign, connection, progress, phone, billing), sets operation date and business-type parameter IDs for various services (equipment, progress, phone, campaign, regional, catalog), and if the service contract number (`SVC_KEI_NO`) and SYSID are already set in inherited data, it invokes the `CRSV0084` mapping cluster to load full screen data. After mapping, it calculates business processing fees, replaces "20991231" placeholder dates with blank values, and transfers main data to a dedicated tab via `getMainData()`. If no service contract is found, it returns early with just the next screen ID set.

- **[`display()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:527)** — Called when the user clicks the display button on the main screen. It fetches MYBOX, QueueBOX, and email item counts by delegating to `JCRWebCommon.getMyboxQueboxMailCnt()`.

- **[`refresh()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1687)** — Performs a full page refresh. It restores screen info, re-fetches the main display data, and calls `init()` to re-render the page. If the previous screen was the document delivery registration screen, it sets a confirmation message.

- **[`clickTab()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:699)** — Handles tab clicks on the inquiry response main screen. It refreshes item counts first, then checks if the clicked tab is the main tab — if so, it re-invokes `init()`. Otherwise, it registers the parent screen ID for all 15 child screen IDs and transfers inherited data to the target tab via `copyBeanToNextTab()`.

- **[`closeToiawase()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:945)** — Closes an inquiry by calling `JCRWebCommon.execClose()`, then refreshes the screen.

- **[`accept()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1516)** — Accepts (takes ownership of) an inquiry via `JCRWebCommon.execAccept()`, then refreshes.

- **[`reject()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1459)** — Rejects an inquiry via `JCRWebCommon.execReject()`, then refreshes.

- **[`getKyosei()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1573)** — Forces acquisition of an inquiry (takes it from another user) via `JCRWebCommon.execGetKyosei()`, then refreshes.

- **[`restart()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1630)** — Restarts a closed/rejected inquiry via `JCRWebCommon.execRestart()`, then refreshes.

- **[`insertEasyMemo()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:646)** — Updates a quick memo for the current inquiry via `JCRWebCommon.execInsertEasyMemo()`, then refreshes.

- **[`execute()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:582)** — Opens external system screens as popups. Delegates to `JCRWebCommon.execute()`.

- **[`clickLinkSeikyYm()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:285)** — Opens the billing detail popup screen (CHW00105). Extracts billing type number, target date, and billing number from the selected row, passes them as inherited data, and navigates.

- **[`clickLinkMyboxCnt()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:361)** — Opens the MYBOX list screen (CRW01301) as a popup with copied inherited data via `copyBeanToMyBOX()`.

- **[`clickLinkQueboxCnt()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:416)** — Opens the QueueBOX list screen (CRW01401) as a popup with copied inherited data via `copyBeanToQueBOX()`.

- **[`clickLinkMailCnt()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:471)** — Opens the quick email composition screen (CRW10301) as a popup via `copyBeanToSendMail()`.

- **[`transferToMain()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1754)** — Returns from a child screen back to the inquiry response main screen by copying bean data to initialize the main display.

- **[`clickLinkMskmshoNoUk()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1804)** — Handles clicking the application document number (acceptance) link. Fetches the base URL from application constants, obtains a one-time password via `JCRWebCommon.getOnetPwdImgSys()`, and constructs the image system URL with the document number and password.

- **[`clickSaihakko()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1882)** — Handles the reissue button. Invokes the `CRSV0281` mapping cluster to verify the member is a master member (individual or corporate). If verification fails, it shows an error message. If successful, it sets the reissue open flag and opens the ID registration certificate reissue screen.

- **[`openCrw03410()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1993)** — Opens the ID registration certificate reissue information output screen (CRW03410) with URL info and web access credentials.

- **[`executeCis()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:2062)** — Handles the Power CIS button click, delegating to `JCRWebCommon.executeCis()`. Added for new electricity business support.

- **[`clickLinkTrank()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:2120)** — Opens the member rank screen (KKW00196) as a popup, copying bean data via `clickLinkTrank()`.

- **[`clickLinkVcms()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:2181)** — Opens the lease contract screen (KKW00198) as a popup, copying bean data via `clickLinkVcms()`.

- **[`openCrw10901()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:2242)** — Opens the SMS sending screen (CRW10901) as a popup via `copyBeanToSmsSend()`.

**Popup sub-screen openers** (most follow the same pattern: set parent screen ID, copy inherited data, set next screen ID in common info bean):

- [`openCrw00101Ins()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:780) — Inquiry input screen (CRW00101) as insert popup
- [`openCrw00101Upd()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:835) — Inquiry update screen (CRW00101) as edit popup
- [`openCrw04001()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:890) — Escalation execution screen (CRW04001) as popup
- [`openCrw03901()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1002) — Inquiry cancellation registration screen (CRW03901) as popup
- [`openCrw02603()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1057) — Customer editing screen (CRW02603) as popup
- [`openCrw00401()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1129) — Hot voice registration screen (CRW00401) as popup
- [`openCrw04101()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1184) — Document delivery registration screen (CRW04101) as popup
- [`openCrw02401()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1239) — Inquiry customer information list inquiry screen (CRW02401) as navigation
- [`openCrw00601()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1294) — Memo registration screen (CRW00601) as popup
- [`openCrw00701()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1349) — Email reply screen (CRW00701) as popup
- [`openCrw00801()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1404) — Email forward screen (CRW00801) as popup

**Internal helper:**

- **[`getMainData()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:1862)** — Transfers the inquiry status name (`SHINSA_STA_NM`) to the dedicated tab's `STATUS` field.

- **[`receiveMessageWeb()`](source/koptWebB/src/eo/web/webview/CRW03401SF/CRW03401SFLogic.java:88)** — Overridden from the parent class; simply returns `false`. This appears to be a hook that the framework may call but is not actively used by this module.

## How It Works

### Screen lifecycle

```mermaid
flowchart TD
    Main["CRW03401SFLogic"]
    Main --> init["init"]
    Main --> refresh["refresh"]
    Main --> clickTab["clickTab"]
    Main --> display["display"]
    Main --> insertEasyMemo["insertEasyMemo"]

    init --> invoke["invokeService CRSV0084"]
    init --> getMainData["getMainData"]

    clickTab --> tabMain["Main tab re-init"]
    clickTab --> tabChild["Child tab navigation"]

    subgraph Popups["Popup Screens"]
        Ins["Inquiry Input"]
        Upd["Inquiry Update"]
        Esc["Escalation"]
        Cncl["Cancellation"]
        CustEdit["Customer Edit"]
        Memo["Memo"]
        MailR["Email Reply"]
        MailF["Email Forward"]
        Hot["Hot Voice"]
        Doc["Document"]
        Sms["SMS Send"]
        IdRe["ID Reissue"]
    end

    subgraph Queries["Inquiry Screens"]
        Seiky["Billing Detail"]
        Mybox["MYBOX List"]
        Quebox["QueueBOX List"]
        MailCnt["Email Send"]
        CustList["Customer List"]
    end

    subgraph StatusOps["Status Operations"]
        Close["Close"]
        Reject["Reject"]
        Accept["Accept"]
        Kyosei["Forced Acquire"]
        Rst["Restart"]
    end

    subgraph CrossSys["Cross-system Links"]
        Cis["Power CIS"]
        Trank["Member Rank"]
        Vcms["Lease Contract"]
        Mskmsho["App Doc Number"]
        Exec["Other Systems"]
    end

    Main --> Ins
    Main --> Upd
    Main --> Esc
    Main --> Cncl
    Main --> CustEdit
    Main --> Memo
    Main --> MailR
    Main --> MailF
    Main --> Hot
    Main --> Doc
    Main --> Sms
    Main --> IdRe
    Main --> Seiky
    Main --> Mybox
    Main --> Quebox
    Main --> MailCnt
    Main --> CustList
    Main --> Close
    Main --> Reject
    Main --> Accept
    Main --> Kyosei
    Main --> Rst
    Main --> Cis
    Main --> Trank
    Main --> Vcms
    Main --> Mskmsho
    Main --> Exec
```

### The init() flow in detail

When the user first loads the inquiry response screen, `init()` orchestrates the following:

1. **Inherited data acquisition** — Calls `JCRWebCommon.getScreenInfo()` to restore screen context from previous navigation.

2. **Service form bean preparation** — Clears all data bean arrays for campaign, connection, progress, phone, and billing message lists. Resets button/link states via `JCRWebCommon.resetButtonStatus()`. Sets the operation date and parameter IDs for six business types (equipment, progress, phone, campaign, regional, catalog).

3. **Conditional service invocation** — If the inherited data does NOT contain a service contract number (`SVC_KEI_NO`) or SYSID, the screen is being launched from a menu (not from a child screen). In this case, it sets the next screen ID/name and returns `true` immediately — no data fetching occurs.

4. **Full data fetch** — If the service contract number and SYSID ARE set (meaning the user arrived from the inquiry history screen), it builds a mapping cluster (`CRSV0084_CRSV0084OPDBMapper`) with ~23 mapping setter methods and invokes the service. The mapping cluster extracts data from the service form bean and populates the `dataMap`.

5. **Post-processing** — After the service returns, it reads mapping results back into the bean via getter methods, calculates business processing fees (`JCRWebCommon.getJimFee()`), replaces "20991231" placeholder dates with blanks for multiple date fields, and transfers the inquiry status to the dedicated tab.

6. **Next screen setup** — Sets the next screen ID/name for returning to the main inquiry response screen.

### Status change operations

Methods like `closeToiawase()`, `accept()`, `reject()`, `getKyosei()`, `restart()`, and `insertEasyMemo()` all follow the same pattern:
1. Build a param array with the service form bean and common info bean
2. Delegate to the corresponding `JCRWebCommon.execXXX()` method
3. Call `refresh()` to update the entire screen with fresh data

This ensures that after any status change, the counts, buttons, and inquiry details reflect the new state.

### Tab navigation

The `clickTab()` method handles switching between tabs on the inquiry response main screen. If the user clicks the main tab itself, it re-invokes `init()` to reload all data. For any other tab, it:
1. Refreshes MYBOX/QueueBOX/mail counts
2. Registers all 15 child screen IDs with the parent tab ID for proper data passing
3. Copies the bean data to the target tab via `copyBeanToNextTab()`

### External system links

Several methods open links to external systems in popups or new windows:
- **Power CIS** (`executeCis()`) — Opens the power customer information system
- **Member rank** (`clickLinkTrank()`) — Opens the member rank inquiry screen
- **Lease contract** (`clickLinkVcms()`) — Opens the lease contract screen
- **Application document** (`clickLinkMskmshoNoUk()`) — Opens an image system with a one-time password
- **Reissue** (`clickSaihakko()` / `openCrw03410()`) — Verifies master member status via CRSV0281 service, then opens the ID certificate reissue screen
- **SMS** (`openCrw10901()`) — Opens the SMS sending screen

## Data Model

This module does not define its own entity or DTO classes. Instead, it works entirely with the X31 framework's data bean architecture:

- **`X31SDataBeanAccess`** — The service form bean that holds all input/output data for the screen. The module accesses fields via `sendMessageString()` and `sendMessageBoolean()` calls with constant keys from `CRW03407SFConst`.

- **`X31SDataBeanAccessArray`** — Used for list data such as campaign message lists, connection info lists, progress lists, phone lists, and billing lists.

- **`HashMap<String, Object>`** — Used as a data map for the mapping cluster's `invokeService()` calls. Input data goes into `dataMap`, output results come back in `outputMap`.

- **`HashMap<Object, String>`** — Used for parameter maps that hold the usecase ID and other invocation metadata.

Key constant namespaces used by this module:

| Constant source | Purpose |
|---|---|
| `CRW03407SFConst` | Screen data field keys (service contract number, SYSID, billing details, dates, status names, etc.) |
| `JCRScreenConst` | Screen IDs for child screens (CRW01301, CRW01401, CRW00101, CRW04001, etc.) |
| `JACScreenConst` | Billing detail screen ID (CHW00105) |
| `CommonInfoCFConst` | Shared form bean keys (NEXT_SCREEN_ID, NEXT_SCREEN_NAME) |
| `JPCModelConstant` | Function codes for service invocation (FUNC_CD_1, FUNC_CD_2) |
| `JCRStrConst` | System strings (REPLACE_MSG_OPERATION_NAME_SHIRYO, work parameter IDs) |
| `JPCOnlineMessageConstant` | Message codes (EKB4390__I, EKB1040_JW) |

## Dependencies and Integration

### Direct package dependencies

The module depends on the following packages in the codebase:

- **`eo.web.webview.common`** — Shared web logic helpers (`JCRWebCommon`, `JCCWebCommon`)
- **`eo.web.webview.CRW03407SF`** — Constants for screen data field definitions
- **`eo.web.webview.CRW01201SF`** — Tab constant (`CURRENTTAB`)
- **`eo.web.webview.CommonInfoCF`** — Shared form bean constants
- **`eo.web.webview.mapping`** — DB mapper classes (`CRSV0084_CRSV0084OPDBMapper`, `CRSV0281_CRSV0281OPDBMapper`)
- **`eo.common.constant`** — System-wide constants (message codes, model function codes, string constants)
- **`eo.common.util`** — Utility functions (`JCRUtilCommon`)
- **`eo.business.common`** — Business common utilities
- **`eo.business.service`** — Service layer interfaces
- **`eo.ejb.common`** — EJB common utilities
- **`eo.web.webview.KKW01101SF`**, **`KKW00127SF`**, **`KKW05001SF`**, **`FUW09905SF`**, **`FUW00162SF`**, **`CommonInfoCF`** — Referenced via constants for screen IDs

### Cross-module relationships

The module is referenced by two XML configuration files:

- **`WEBGAMEN_CRW034010PJP.xml`** — Registers the screen flow and action mappings for this logic class
- **`x31business_logic_CRW03401SF.xml`** — Configures the business logic bean in the X31 framework

### Framework integration

The module is built on the **Fujitsu Futurity X31 web framework**. It extends `JCCWebBusinessLogic` and uses the framework's:
- `X31SDataBeanAccess` / `X31SDataBeanAccessArray` for data binding
- `X31CID` for event identification
- `X31CWebConst` for framework constant keys
- `X33SException` for exception handling
- `invokeService()` method from the parent class for service invocation

## Notes for Developers

### Standard 6-step pattern

Every action method in this module follows a consistent 6-step structure, matching the X31 framework's web business logic conventions:

1. **Acquire inherited data** — Call `JCRWebCommon.getScreenInfo()` if needed
2. **Set service form bean** — Initialize button/link states, clear arrays, set parameters
3. **Invoke service** — Build mapping cluster, call `invokeService()` or delegate to `JCRWebCommon`
4. **Set service results** — Read mapping results back into beans
5. **Set inherited data** — Register parent screen IDs for child screens
6. **Set shared form bean** — Set next screen ID/name for navigation

Methods that don't need a step leave a comment: `// なし。` (not applicable).

### When refresh() is called

After any **status-altering operation** (close, accept, reject, forced acquire, restart, memo update), the method calls `refresh()` at the end. This ensures the screen shows the latest inquiry details and count numbers. Methods that merely open sub-screens do NOT call refresh — they navigate away instead.

### Mapping clusters

The `CRSV0084_CRSV0084OPDBMapper` is used in `init()` with ~23 setter and ~13 getter methods. The `CRSV0281_CRSV0281OPDBMapper` is used in `clickSaihakko()` for member verification. These mapping clusters handle the serialization between data beans and the service layer's data maps.

### Date placeholder handling

The module replaces `"20991231"` with blank values for display on multiple date fields using `JZMWebCommon.replaceTendymd()`. This is a convention where "20991231" represents an unset or open-ended date in the database.

### Adding new popup screens

To add a new popup screen:
1. Create the new method (following the pattern: get beans, set parent screen ID, set screen info via `JCRWebCommon.setScreenInfo()`, set next screen in common bean)
2. Add the screen ID to the `clickTab()` method's list of registered child screens
3. Define constants in `JCRScreenConst` for the new screen ID

### Adding new cross-system links

New external system links should follow the pattern of `clickLinkMskmshoNoUk()` or `executeCis()` — obtain one-time passwords if needed, construct the URL, set URL and display flags on the bean, and set the next screen back to the main inquiry response screen.