123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- 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 ,
- policybelong ,
- payendyear ,
-
- agrmntage ,
-
- created_by ,
- created_time
- )
- SELECT
- row_number()over(),
- CONTNO,
- CVALIDATE,
- ENDDATE,
- PAYCOUNT,
- PAYINTV,
- CUSTOMERNO,
- NAME,
- IDNO,
- insuredno,
- INSUREDNAME,
- INSUREDIDNO,
- RISKCODE,
- SALECOM,
- PAYENDYEAR,
-
- 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,
- 'admin',
- sysdate()
- FROM policy_information
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- risk_categories,
- risk_categories_name
- ) = (
-
- select
- b.kindcode,
- (CASE b.kindcode
- WHEN 'A' THEN '意外伤害险'
- WHEN 'U' THEN '万能保险'
- WHEN 'R' THEN '年金保险'
- WHEN 'S' THEN '重疾保险'
- WHEN 'L' THEN '人寿保险'
- WHEN 'H' THEN '健康险'
- END) AS kindname
- from lmriskapp b WHERE a.productid = b.riskcode
-
- ) WHERE 1=1;
-
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- applicantid
- ) = (
- select
- c.indid
- from (
- select
- row_number()over(PARTITION BY b.scustid) rn,
- b.indid,
- b.scustid
- from shanglifeecif.individual b
- ) c
- WHERE c.scustid = a.applicantscustid and c.rn=1
- ) WHERE 1=1 ;
- UPDATE shanglifeecif.insurancearrangement a SET (
- insuredid
- ) = (
- select
- c.indid
- from (
- select
- row_number()over(PARTITION BY b.scustid) rn,
- b.indid,
- b.scustid
- from shanglifeecif.individual b
- ) c
- WHERE c.scustid = a.insuredscustid and c.rn=1
- ) WHERE 1=1 ;
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- pano ,
- pisdate ,
- padate ,
- policystate ,
- prem ,
- productname ,
- agentchannel
- ) = (
- select
- PRTNO,
- SIGNDATE,
- POLAPPLYDATE,
- appflag,
- PREM,
- RISKNAME,
- SELLTYPE
- from INSURANCEINFO b
- where b.contno = a.policyno
- ) WHERE 1=1 ;
- END;
- /
- DROP TABLE IF EXISTS shanglifeecif.insurancearrangement_health_tmp;
- CREATE TABLE shanglifeecif.insurancearrangement_health_tmp(
- id string,
- orderid string DEFAULT NULL COMMENT '用于分组的排序号',
- contno string DEFAULT NULL COMMENT '保单号',
- AGENTGROUP string DEFAULT NULL COMMENT '承保分公司',
- SALECHANNELS string DEFAULT NULL COMMENT '销售渠道',
- AMNT string DEFAULT NULL COMMENT '总保额',
- AGENTCODE string DEFAULT NULL COMMENT'业务员名称'
- ) COMMENT '保单处理个险承保清单自助分析 数据临时表 '
- STORED AS ES
- with shard number 10
- replication 1;
- CREATE OR REPLACE PROCEDURE shanglifeecif.up_insurancearrangement_health_insurance_listing()
- IS
- BEGIN
-
- delete from shanglifeecif.insurancearrangement_health_tmp;
-
- insert into shanglifeecif.insurancearrangement_health_tmp (
- id,
- orderid,
- contno,
- agentgroup,
- SALECHANNELS,
- AMNT,
- AGENTCODE
- ) select
- row_number()over(),
- row_number()over(PARTITION BY contno),
- contno,
- agentgroup,
- SALECHANNELS,
- AMNT,
- AGENTCODE
- from HEALTH_INSURANCE_LISTING
-
- UPDATE shanglifeecif.insurancearrangement a SET (
- pwcomp ,
- schannel ,
- risk ,
- spname
- ) = (
- select
- b.AGENTGROUP,
- b.SALECHANNELS,
- b.AMNT,
- b.AGENTCODE
- from shanglifeecif.insurancearrangement_health_tmp b
- where b.contno = a.policyno
- and b.orderid = 1
- ) WHERE 1=1 ;
- END;
- /
- 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;
- /
- CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement()
- IS
- BEGIN
-
- shanglifeecif.init_insurancearrangement_policy_information();
-
- shanglifeecif.up_insurancearrangement_health_insurance_listing();
-
- shanglifeecif.up_insurancearrangement_other();
- END;
- /
- BEGIN
- shanglifeecif.init_insurancearrangement();
- end
|