---
# System prepended metadata

title: 全部風險事件STS407W
tags: [STS]

---

###### tags: `STS`
# 全部風險事件STS407W 
------------------------------


```
風險事件選案按下[執行]後

1.[步驟1&步驟2]參數將儲存於 BBI_RMS_TASK_SEL_CASE_PARAM
2.[步驟3]使用者所選擇的[風險事件]會記錄於 BBI_RMS_TASK_SEL_EVENT_PARAMS
3.[系統資料區]選案選出結果紀錄在 BBI_RMS_TASK_SEL_CASE_LIST

```


---

<font color="red">1.[步驟1&步驟2]參數將儲存於 BBI_RMS_TASK_SEL_CASE_PARAM</font>
```
這支程式RiskEventScoreModelParameter會去繼承TaskParameter interface 
(中華提到未來會提供interface應該指的是這個)
寫參數的方式大概如下圖
```
圖1(將前端參數等等..放到RiskEventScoreModelParameter)
![](https://i.imgur.com/fa0frd9.png)

圖2(RiskEventScoreModelParameter實作介面)
![](https://i.imgur.com/vJuyw2r.png)

圖3 (TaskParameter interface)
![](https://i.imgur.com/2rAN3oC.png)


<font color="red">2.[步驟3]使用者所選擇的[風險事件]會記錄於BBI_RMS_TASK_SEL_EVENT_PARAMS</font>
```

TaskScheduleServiceImpl實作 TaskScheduleService-> createTask
PS.TaskScheduleService管理及排程所有 Task 的服務由中華開發

舊程式寫法如下
```
![](https://i.imgur.com/NJjZr7a.png)



<font color="red">（待更新）3.[系統資料區]選案選出結果紀錄在 BBI_RMS_TASK_SEL_CASE_LIST</font>
```
(STS-23H-407W)第18頁的系統資料區欄位應該有錯誤，前面那些欄位是401W的
全部風險風險事件資料區欄位(舊系統)顯示如下:

(01)序號
(02)統一編號
(03)稅籍編號
(04)機關代號
(05)公司名稱
(06)派案編號
(07)風險總分
(08)風險排名
(09)試查
<<下面共用欄位401~406皆會顯示>>
(10)應稅銷售額合計數
(11)進貨及費用金額合計(44欄)
(12)加值率(BRM302W)
(13)實繳稅額合計數
(14)累計留抵稅額 acuDtnCrTax
(15)最近一年營所申報書類別 taxRtnTp
(16)最近一年純益率 netPfRate
(17)最近一年期末存貨 pdEInvn
```

```java
//資料區欄位邏輯(對應舊程式)
SelectCaseServiceImpl.queryBusinessList
```

```sql
select bgm.BAN,          --(02)統一編號
       bgm.BAN_NM,       --(05)公司名稱
       tr.RISK_EVENT_NO,--風險事件
       tr.BL_YM as B_DATE, -- 風險事件起始時間
       bgm.VAT_LOSN,     --(03)稅籍編號
       bgm.BAN_ADDR_HSN_CD||substr(bgm.VAT_LOSN,1,2) --(04)機關代號
       from JMD_BGMT001 bgm join BBI_RDB_VAT_TPR_RISK_VAL tr 
       on bgm.BAN=tr.IDN_BAN join BBI_RMS_SEL_CASE_TEMP sct 
       on sct.BAN=tr.IDN_BAN
```

```sql
        SELECT /*  USE_HASH(A B C D E)*/ A.BAN,   
        B.TXL_S_AMT_TOT,  --(10)應稅銷售額合計數
        B.PE_AMT_TOT,     --(11)進貨及費用金額合計(44欄)
        B.SALE_AMT_RATE,  --(12)加值率(BRM302W)
        B.ACT_PAID_TAX,   --(13)實繳稅額合計數
        C.ACU_DTN_CR_TAX, --(14)累計留抵稅額
        D.TAX_RTN_TP,       --FLAG1 (15)最近一年營所申報書類別
        D.NET_PF_RATE,      --FLAG1 (16)最近一年純益率
        E.PD_E_INVN,        --FLAG1 (17)最近一年期末存貨
        F.TAX_RTN_TP_L,     --FLAG2 (15)最近一年營所申報書類別
        F.NET_PF_RATE_L,    --FLAG2 (16)最近一年純益率
        G.PD_E_INVN_L       --FLAG2 (17)最近一年期末存貨
            FROM AP_BI.BBI_RMS_SEL_CASE_TEMP A  
            LEFT JOIN  
            (SELECT BAN,  
            SUM(TXL_S_AMT_TOT) AS TXL_S_AMT_TOT,  
            SUM(PE_AMT_TOT) AS PE_AMT_TOT,   
            SUM(ACT_PAID_TAX) AS ACT_PAID_TAX,  
            (SUM(CASE  
            WHEN NVL(JMD_BRMT001.SALE_AMT_TOTAL,'0') =0  
            OR (NVL(JMD_BRMT001.PE_PRS_T_AMT,'0')   NVL(JMD_BRMT001.IM_XMP_PRS_AMT,'0')) =0  
            OR (NVL(JMD_BRMT001.SALE_AMT_TOTAL,'0')- NVL(JMD_BRMT001.PE_PRS_T_AMT,'0')   
            - NVL(JMD_BRMT001.IM_XMP_PRS_AMT,'0'))=0  
            THEN 0  
            WHEN NVL(JMD_BRMT001.SALE_AMT_TOTAL,'0')                                    =0  
            AND NVL(JMD_BRMT001.PE_PRS_T_AMT,'0') NVL(JMD_BRMT001.IM_XMP_PRS_AMT,'0') <> 0  
            THEN 100  
            ELSE ((JMD_BRMT001.SALE_AMT_TOTAL-JMD_BRMT001.PE_PRS_T_AMT-JMD_BRMT001.IM_XMP_PRS_AMT)  
            / JMD_BRMT001.SALE_AMT_TOTAL)*100  
            //END ))  / COUNT(BAN) AS SALE_AMT_RATE  
            END ))  / DECODE(COUNT(BAN),0,NULLIF(COUNT(BAN),0),COUNT(BAN)) AS SALE_AMT_RATE  
            //測試 END ))  / DECODE(0,0,NULLIF(0,0),COUNT(BAN)) AS SALE_AMT_RATE  
            FROM AP_JMD.JMD_BRMT001  WHERE BL_YM  BETWEEN ? AND ?  
            GROUP BY BAN  
            ) B ON A.BAN = B.BAN    
            LEFT JOIN  
            (SELECT BAN,  
            ACU_DTN_CR_TAX AS ACU_DTN_CR_TAX  
            FROM AP_JMD.JMD_BRMT060 WHERE ACU_DTN_CR_TAX IS NOT NULL  
            ) C ON A.BAN = C.BAN  
            LEFT JOIN  
            (SELECT BAN,  
            TAX_RTN_TP AS TAX_RTN_TP,  
            NET_PF_RATE AS NET_PF_RATE  
            FROM AP_JMD.JMD_PRCT001 WHERE TO_CHAR(DATA_YR,'YYYY') = ?  
            ) D ON A.BAN = D.BAN  
            LEFT JOIN  
            (SELECT BAN,   
            SUM(PD_E_INVN) AS PD_E_INVN  
            FROM AP_JMD.JMD_PRCT003 WHERE TO_CHAR(DATA_YR,'YYYY') = ? AND PD_E_INVN IS NOT NULL  
            GROUP BY BAN  
            ) E ON A.BAN = E.BAN  
            
            
            LEFT JOIN  
            (SELECT BAN,  
            TAX_RTN_TP AS TAX_RTN_TP_L,    
            NET_PF_RATE AS NET_PF_RATE_L  
            FROM AP_JMD.JMD_PRCT001 WHERE TO_CHAR(DATA_YR,'YYYY') = ?  
            ) F ON A.BAN = F.BAN  
            LEFT JOIN  
            (SELECT BAN,   
            SUM(PD_E_INVN) AS PD_E_INVN_L  
            FROM AP_JMD.JMD_PRCT003 WHERE TO_CHAR(DATA_YR,'YYYY') = ? AND PD_E_INVN IS NOT NULL  
            GROUP BY BAN  
            ) G ON A.BAN = G.BAN  
             WHERE A.SEL_BATCH_NO_TEMP = ? ;
```


