123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement_main()
- IS
- BEGIN
- DELETE FROM shanglifeecif.insurancearrangement;
-
- shanglifeecif.init_insurancearrangement_policy_information();
-
- shanglifeecif.update_risk_categories();
-
-
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement_policy_information()
- IS
- BEGIN
- INSERT INTO shanglifeecif.insurancearrangement(
- iaid ,
- policyno ,
- pindate ,
- pmdate ,
- norenewal ,
- payment ,
- applicantscustid ,
- appname ,
- appcertid ,
- insuredscustid ,
- insname ,
- inscertid ,
- productid ,
- productname,
- policybelong ,
- payendyear ,
- policystate,
- prem,
- sumprem,
- Risk,
- NPDate,
- PADate,
- pisdate,
- AgentOrg,
- schannel,
- schannelname,
- salecomname,
- POService,
- PWComp,
- security ,
- agrmntage ,
- salesperson,
- SPName,
- renewalDate,
- created_by ,
- created_time
- )
- SELECT
- row_number()over(),
- trim(CONTNO) as CONTNO,
- trim(CVALIDATE) as CVALIDATE,
- trim(ENDDATE) as ENDDATE,
- PAYCOUNT,
- trim(PAYINTV) as PAYINTV,
- trim(CUSTOMERNO) as CUSTOMERNO,
- trim(NAME) as NAME,
- trim(IDNO) as IDNO,
- trim(insuredno) as insuredno,
- trim(INSUREDNAME) as INSUREDNAME,
- trim(INSUREDIDNO) as INSUREDIDNO,
- trim(RISKCODE) as RISKCODE,
- trim(RISKNAME) as RISKNAME,
- trim(SALECOM) as SALECOM,
- PAYENDYEAR,
- trim(APPFLAG) as APPFLAG,
- prem,
- sumprem,
- AMNT,
- trim(PAYTODATE) as PAYTODATE,
- trim(polapplydate) as polapplydate,
- trim(SIGNDATE) as SIGNDATE,
- trim(AGENTCOM) as AGENTCOM,
- trim(SALECHNL) as SALECHNL,
- trim(SALECHNLNAME) as SALECHNLNAME,
- trim(salecomname) as salecomname,
- trim(PRESERVATIONFLAG) as PRESERVATIONFLAG,
- "上海人寿上海分公司",
- trim(security) as security,
- case
- when security ='终身' then 42720
- when security = '至100周岁' then 36500
- when security = '至80周岁' then 29200
- when security = '70年' then 25550
- when security = '至70周岁' then 25550
- when security = '至65周岁' then 23725
- when security = '至60周岁' then 21900
- when security = '30年' then 10950
- when security = '20年' then 7300
- when security = '10年' then 3650
- when security = '6年' then 2190
- when security = '5年' then 1825
- when security = '1年' then 365
- when security = '180天' then 180
- when security = '6月' then 180
- when security = '90天' then 90
- when security = '3月' then 90
- when security = '1月' then 30
- when security = '30天' then 30
- when security = '15天' then 15
- when security = '7天' then 7
- end,
- trim(AGENTCODE) as AGENTCODE,
- trim(AGENTNAME) as AGENTNAME,
- trim(paytodate) as paytodate,
- 'admin',
- sysdate()
- FROM policy_information;
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- pano ,
-
-
-
-
-
- agentchannel
- ) = (
- select
- trim(b.PRTNO) as PRTNO,
-
-
-
-
-
- trim(b.SELLTYPE) as SELLTYPE
- from INSURANCEINFO b
- where b.contno = a.policyno
- ) WHERE 1=1 ;
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
- WHEN Others THEN
- INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
- END;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.update_risk_categories()
- IS
- BEGIN
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- risk_categories_name
- ) = (
- select
- kindtype
- from riskkind b WHERE a.productid = b.riskcode
- ) WHERE 1=1;
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
- WHEN Others THEN
- INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
- END;
- /
- 万能保险总保额,总客户数,拥有3-5保单数量的客户数
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.up_insurancearrangement_other()
- IS
- BEGIN
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- policytype
- ) = (
- select
- c.CONTTYPE
- from (
- select
- row_number()over(PARTITION BY b.contno) rn,
- b.CONTTYPE,
- b.contno
- from PERSONAL_INSURANCE b
- ) c
- WHERE c.contno = a.policyno and c.rn=1
- ) WHERE 1=1 ;
- UPDATE shanglifeecif.insurancearrangement a SET (
- poservice
- ) = (
- SELECT
- IF(count(b.CONTNO) >0,1,0)
- FROM AUDIT_EDORLIST b
- where b.contno = a.policyno
- ) WHERE 1=1 ;
- UPDATE shanglifeecif.insurancearrangement a SET (
- soinsured
- ) = (
- SELECT
- PEOPLES3
- FROM HEALTH_GROUP_LISTING b
- where b.contno = a.policyno
- ) WHERE 1=1 ;
- END;
- /
- BEGIN
- shanglifeecif.init_insurancearrangement();
- end
|