init_insurancearrangement_policy_information.sql 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement_policy_information() -- 创建主存储过程
  2. IS
  3. BEGIN
  4. INSERT INTO shanglifeecif.insurancearrangement(
  5. iaid ,--'保单ID',
  6. policyno ,-- '保险单号 INSURANCEINFO.CONTNO',
  7. pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE',
  8. pmdate ,-- '终保日期 POLICY_INFORMATION.ENDDATE',
  9. norenewal ,-- '续保次数 POLICY_INFORMATION.PAYCOUNT',
  10. payment ,-- '缴费方式 POLICY_INFORMATION.PAYINTV',
  11. applicantscustid ,-- '投保人 上游客户号,再找到individualid',
  12. appname ,-- '投保人名称 POLICY_INFORMATION.NAME',
  13. appcertid ,-- '投保人证件号码 POLICY_INFORMATION.IDNO',
  14. insuredscustid ,-- '主被保险人 游客户号',
  15. insname ,-- '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  16. inscertid ,-- '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  17. productid ,-- '险种代码 POLICY_INFORMATION.RISKCODE',
  18. productname,--险种名称
  19. policybelong ,-- '业绩归属 POLICY_INFORMATION.SALECOM',
  20. payendyear ,-- '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  21. policystate,--保单状态
  22. prem,--保费
  23. sumprem, --累计保费,
  24. Risk,--保额
  25. NPDate,--下次缴费日期
  26. PADate,--投保日期
  27. pisdate,--签单日期
  28. AgentOrg,--代理机构
  29. schannel,--销售渠道
  30. schannelname,--销售渠道中文
  31. salecomname,--业绩归属中文
  32. POService,--保全标志
  33. PWComp,--承保分公司
  34. security ,--保险期原始值
  35. agrmntage ,--保险期限
  36. salesperson,--业务员标识代码
  37. SPName,--业务员名称
  38. renewalDate,--续保日期
  39. created_by ,-- '创建人',
  40. created_time -- '创建时间',
  41. )
  42. SELECT
  43. row_number()over(),
  44. trim(CONTNO) as CONTNO,--policyno ,-- '保险单号 INSURANCEINFO.CONTNO',
  45. trim(CVALIDATE) as CVALIDATE,--pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE',
  46. trim(ENDDATE) as ENDDATE,--pmdate ,-- '终保日期 POLICY_INFORMATION.ENDDATE',
  47. PAYCOUNT,--norenewal ,-- '续保次数 POLICY_INFORMATION.PAYCOUNT',
  48. trim(PAYINTV) as PAYINTV,--payment ,-- '缴费方式 POLICY_INFORMATION.PAYINTV',
  49. trim(CUSTOMERNO) as CUSTOMERNO,--applicantid ,-- '投保人 根据POLICY_INFORMATION.CUSTOMERNO关联individual上游客户号,再找到individualid',
  50. trim(NAME) as NAME,--appname ,-- '投保人名称 POLICY_INFORMATION.NAME',
  51. trim(IDNO) as IDNO,--appcertid ,-- '投保人证件号码 POLICY_INFORMATION.IDNO',
  52. trim(insuredno) as insuredno,--insuredid ,-- '主被保险人 insuredno',
  53. trim(INSUREDNAME) as INSUREDNAME,--insname ,-- '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  54. trim(INSUREDIDNO) as INSUREDIDNO,--inscertid ,-- '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  55. trim(RISKCODE) as RISKCODE,--productid ,-- '险种代码 POLICY_INFORMATION.RISKCODE',
  56. trim(RISKNAME) as RISKNAME, --productname 险种名称
  57. trim(SALECOM) as SALECOM,--policybelong ,-- '业绩归属 POLICY_INFORMATION.SALECOM',
  58. PAYENDYEAR,--payendyear ,-- '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  59. trim(APPFLAG) as APPFLAG, --保单状态
  60. prem,--保费
  61. sumprem,--累计保费
  62. AMNT,--保额
  63. trim(PAYTODATE) as PAYTODATE,--下次缴费日期
  64. trim(polapplydate) as polapplydate,--投保日期
  65. trim(SIGNDATE) as SIGNDATE,--签单日期
  66. trim(AGENTCOM) as AGENTCOM,--代理机构
  67. trim(SALECHNL) as SALECHNL,--销售渠道
  68. trim(SALECHNLNAME) as SALECHNLNAME,--销售渠道中文
  69. trim(salecomname) as salecomname,--业绩归属中文
  70. trim(PRESERVATIONFLAG) as PRESERVATIONFLAG,--保全标志
  71. "上海人寿上海分公司",
  72. trim(security) as security, --保险期原始值
  73. case
  74. when security ='终身' then 42720
  75. when security = '至100周岁' then 36500
  76. when security = '至80周岁' then 29200
  77. when security = '70年' then 25550
  78. when security = '至70周岁' then 25550
  79. when security = '至65周岁' then 23725
  80. when security = '至60周岁' then 21900
  81. when security = '30年' then 10950
  82. when security = '20年' then 7300
  83. when security = '10年' then 3650
  84. when security = '6年' then 2190
  85. when security = '5年' then 1825
  86. when security = '1年' then 365
  87. when security = '180天' then 180
  88. when security = '6月' then 180
  89. when security = '90天' then 90
  90. when security = '3月' then 90
  91. when security = '1月' then 30
  92. when security = '30天' then 30
  93. when security = '15天' then 15
  94. when security = '7天' then 7
  95. end,
  96. trim(AGENTCODE) as AGENTCODE,--代理人代码
  97. trim(AGENTNAME) as AGENTNAME,--代理人名称
  98. trim(paytodate) as paytodate,--续保日期
  99. 'admin',
  100. sysdate()
  101. FROM dsj.policy_information;
  102. --更新INSURANCEINFO 表中的信息
  103. UPDATE shanglifeecif.insurancearrangement a SET (
  104. pano ,-- '投保单号 INSURANCEINFO.PRTNO',
  105. --pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE',
  106. --padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE',
  107. --policystate ,--INSURANCEINFO,appflag
  108. --prem ,-- '总保费 INSURANCEINFO.PREM',
  109. --productname ,-- '险种名称 INSURANCEINFO.RISKNAME'
  110. agentchannel -- '代理渠道 INSURANCEINFO.SELLTYPE',
  111. ) = (
  112. select
  113. trim(b.PRTNO) as PRTNO,--pano ,-- '投保单号 INSURANCEINFO.PRTNO',
  114. --SIGNDATE,--pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE',
  115. --POLAPPLYDATE,--padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE',
  116. --appflag,--policystate ,--INSURANCEINFO,appflag
  117. --PREM,--prem ,-- '总保费 INSURANCEINFO.PREM',
  118. --RISKNAME,--productname ,-- '险种名称 INSURANCEINFO.RISKNAME'
  119. trim(b.SELLTYPE) as SELLTYPE--agentchannel ,-- '代理渠道 INSURANCEINFO.SELLTYPE',
  120. from dsj.INSURANCEINFO b
  121. where b.contno = a.policyno
  122. ) WHERE 1=1 ;
  123. dbms_output.put_line('init_insurancearrangement_policy_information函数跑批完成!');
  124. EXCEPTION
  125. WHEN HIVE_EXCEPTION THEN
  126. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  127. WHEN Others THEN
  128. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  129. END;