保单信息存储过程.sql 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement() -- 创建主存储过程
  2. IS
  3. BEGIN
  4. --根据policy_information 更新保单表
  5. shanglifeecif.init_insurancearrangement_policy_information();
  6. --更新险种大类
  7. shanglifeecif.update_risk_categories();
  8. END;
  9. /
  10. CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement_policy_information() -- 创建主存储过程
  11. IS
  12. BEGIN
  13. INSERT INTO shanglifeecif.insurancearrangement(
  14. iaid ,--'保单ID',
  15. policyno ,-- '保险单号 INSURANCEINFO.CONTNO',
  16. pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE',
  17. pmdate ,-- '终保日期 POLICY_INFORMATION.ENDDATE',
  18. norenewal ,-- '续保次数 POLICY_INFORMATION.PAYCOUNT',
  19. payment ,-- '缴费方式 POLICY_INFORMATION.PAYINTV',
  20. applicantscustid ,-- '投保人 上游客户号,再找到individualid',
  21. appname ,-- '投保人名称 POLICY_INFORMATION.NAME',
  22. appcertid ,-- '投保人证件号码 POLICY_INFORMATION.IDNO',
  23. insuredscustid ,-- '主被保险人 游客户号',
  24. insname ,-- '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  25. inscertid ,-- '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  26. productid ,-- '险种代码 POLICY_INFORMATION.RISKCODE',
  27. productname,--险种名称
  28. policybelong ,-- '业绩归属 POLICY_INFORMATION.SALECOM',
  29. payendyear ,-- '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  30. policystate,--保单状态
  31. prem,--保费
  32. Risk,--保额
  33. NPDate,--下次缴费日期
  34. PADate,--投保日期
  35. pisdate,--签单日期
  36. AgentOrg,--代理机构
  37. schannel,--销售渠道
  38. POService,--保全标志
  39. PWComp,--承保分公司
  40. agrmntage ,--保险期限
  41. created_by ,-- '创建人',
  42. created_time -- '创建时间'
  43. )
  44. SELECT
  45. row_number()over(),
  46. trim(CONTNO) as CONTNO,--policyno ,-- '保险单号 INSURANCEINFO.CONTNO',
  47. trim(CVALIDATE) as CVALIDATE,--pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE',
  48. trim(ENDDATE) as ENDDATE,--pmdate ,-- '终保日期 POLICY_INFORMATION.ENDDATE',
  49. PAYCOUNT,--norenewal ,-- '续保次数 POLICY_INFORMATION.PAYCOUNT',
  50. trim(PAYINTV) as PAYINTV,--payment ,-- '缴费方式 POLICY_INFORMATION.PAYINTV',
  51. trim(CUSTOMERNO) as CUSTOMERNO,--applicantid ,-- '投保人 根据POLICY_INFORMATION.CUSTOMERNO关联individual上游客户号,再找到individualid',
  52. trim(NAME) as NAME,--appname ,-- '投保人名称 POLICY_INFORMATION.NAME',
  53. trim(IDNO) as IDNO,--appcertid ,-- '投保人证件号码 POLICY_INFORMATION.IDNO',
  54. trim(insuredno) as insuredno,--insuredid ,-- '主被保险人 insuredno',
  55. trim(INSUREDNAME) as INSUREDNAME,--insname ,-- '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  56. trim(INSUREDIDNO) as INSUREDIDNO,--inscertid ,-- '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  57. trim(RISKCODE) as RISKCODE,--productid ,-- '险种代码 POLICY_INFORMATION.RISKCODE',
  58. trim(RISKNAME) as RISKNAME, --productname 险种名称
  59. trim(SALECOM) as SALECOM,--policybelong ,-- '业绩归属 POLICY_INFORMATION.SALECOM',
  60. PAYENDYEAR,--payendyear ,-- '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  61. trim(APPFLAG) as APPFLAG, --保单状态
  62. prem,--保费
  63. AMNT,--保额
  64. trim(PAYTODATE) as PAYTODATE,--下次缴费日期
  65. trim(CUSTOMGETPOLDATE) as CUSTOMGETPOLDATE,--投保日期
  66. trim(SIGNDATE) as SIGNDATE,--签单日期
  67. trim(AGENTCOM) as AGENTCOM,--代理机构
  68. trim(SALECHNL) as SALECHNL,--销售渠道
  69. trim(PRESERVATIONFLAG) as PRESERVATIONFLAG,--保全标志
  70. "上海人寿上海分公司",
  71. case
  72. when security ='终身' then 42720
  73. when security = '至100周岁' then 36500
  74. when security = '至80周岁' then 29200
  75. when security = '70年' then 25550
  76. when security = '至70周岁' then 25550
  77. when security = '至65周岁' then 23725
  78. when security = '至60周岁' then 21900
  79. when security = '30年' then 10950
  80. when security = '20年' then 7300
  81. when security = '10年' then 3650
  82. when security = '6年' then 2190
  83. when security = '5年' then 1825
  84. when security = '1年' then 365
  85. when security = '180天' then 180
  86. when security = '6月' then 180
  87. when security = '90天' then 90
  88. when security = '3月' then 90
  89. when security = '1月' then 30
  90. when security = '30天' then 30
  91. when security = '15天' then 15
  92. when security = '7天' then 7
  93. end,
  94. 'admin',
  95. sysdate()
  96. FROM shanghailifeecif.policy_information
  97. --更新INSURANCEINFO 表中的信息
  98. UPDATE shanglifeecif.insurancearrangement a SET (
  99. pano ,-- '投保单号 INSURANCEINFO.PRTNO',
  100. --pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE',
  101. --padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE',
  102. --policystate ,--INSURANCEINFO,appflag
  103. --prem ,-- '总保费 INSURANCEINFO.PREM',
  104. --productname ,-- '险种名称 INSURANCEINFO.RISKNAME'
  105. agentchannel -- '代理渠道 INSURANCEINFO.SELLTYPE',
  106. ) = (
  107. select
  108. trim(b.PRTNO) as PRTNO,--pano ,-- '投保单号 INSURANCEINFO.PRTNO',
  109. --SIGNDATE,--pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE',
  110. --POLAPPLYDATE,--padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE',
  111. --appflag,--policystate ,--INSURANCEINFO,appflag
  112. --PREM,--prem ,-- '总保费 INSURANCEINFO.PREM',
  113. --RISKNAME,--productname ,-- '险种名称 INSURANCEINFO.RISKNAME'
  114. trim(b.SELLTYPE) as SELLTYPE--agentchannel ,-- '代理渠道 INSURANCEINFO.SELLTYPE',
  115. from shanghailifeecif.INSURANCEINFO b
  116. where b.contno = a.policyno
  117. ) WHERE 1=1 ;
  118. END;
  119. /
  120. CREATE OR REPLACE PROCEDURE shanglifeecif.update_risk_categories() -- 创建主存储过程
  121. IS
  122. BEGIN
  123. --更新险种大类
  124. UPDATE shanglifeecif.insurancearrangement a SET (
  125. risk_categories,
  126. risk_categories_name
  127. ) = (
  128. select
  129. b.kindcode,
  130. (CASE b.kindcode
  131. WHEN 'A' THEN '意外伤害险'
  132. WHEN 'U' THEN '万能保险'
  133. WHEN 'R' THEN '年金保险'
  134. WHEN 'S' THEN '重疾保险'
  135. WHEN 'L' THEN '人寿保险'
  136. WHEN 'H' THEN '健康险'
  137. END) AS kindname
  138. from lmriskapp b WHERE a.productid = b.riskcode
  139. ) WHERE 1=1;
  140. END;