接触信息存储过程.sql 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. BEGIN
  2. shanglifeecif.init_communication_main();
  3. END;
  4. /
  5. CREATE OR REPLACE PROCEDURE shanglifeecif.init_communication_main() IS
  6. DECLARE
  7. BEGIN
  8. shanglifeecif.init_communication();
  9. shanglifeecif.init_communication_sp01();
  10. shanglifeecif.init_communication_sp02();
  11. END ;
  12. /
  13. CREATE OR REPLACE PROCEDURE shanglifeecif.init_communication() IS
  14. DECLARE
  15. BEGIN
  16. DELETE FROM shanglifeecif.communication;
  17. insert into shanglifeecif.communication (
  18. CommID,
  19. CPName,
  20. CPPhone,
  21. PolicyNo,
  22. CommTime,
  23. Reason,
  24. CommChannel,
  25. created_by ,-- '创建人',
  26. created_time -- '创建时间',
  27. ) select
  28. row_number()over(),
  29. econtactsName,
  30. econtactsPhone,
  31. contNos,
  32. startTime,
  33. reasonSecondName,
  34. '最近呼入' AS CommChannel,
  35. 'admin',
  36. sysdate()
  37. from cc_record_main WHERE contNos IS NOT null;
  38. END ;
  39. /
  40. CREATE OR REPLACE PROCEDURE shanglifeecif.init_communication_sp01() IS
  41. DECLARE
  42. BEGIN
  43. UPDATE shanglifeecif.communication sc set(
  44. sc.RSOApplicant,
  45. sc.CompLink,
  46. sc.CompReason,
  47. sc.ProcedureResult
  48. ) = (SELECT
  49. temp.complaintsRelation,
  50. temp.complaintsLink,
  51. temp.resultClassification,
  52. temp.procedureResult
  53. FROM (
  54. SELECT
  55. (CASE scac.complaintsRelation --201 本人 202 子女 203 配偶 204 父母 205 其他
  56. WHEN '201' THEN '本人'
  57. WHEN '202' THEN '子女'
  58. WHEN '203' THEN '配偶'
  59. WHEN '204' THEN '父母'
  60. WHEN '205' THEN '其他'
  61. END) AS complaintsRelation,
  62. (CASE scac.complaintsLink --:承保环节 : 211 销售环节 :212 、回访环节:213 、保全变更环节: 214 、理赔环节: 215 、售后服务环节: 216
  63. WHEN '211' THEN '承保环节'
  64. WHEN '212' THEN '销售环节'
  65. WHEN '213' THEN '回访环节'
  66. WHEN '214' THEN '保全变更环节'
  67. WHEN '215' THEN '理赔环节'
  68. WHEN '216' THEN '售后服务环节'
  69. END) AS complaintsLink,
  70. (CASE scac.resultClassification --:销售误导:101 代签名:102 理赔争议:103 服务人员态度:104 售后服务不满:105 售前服务不满:106 外部陌电骚扰:107
  71. WHEN '101' THEN '销售误导'
  72. WHEN '102' THEN '代签名'
  73. WHEN '103' THEN '理赔争议'
  74. WHEN '104' THEN '服务人员态度'
  75. WHEN '105' THEN '售后服务不满'
  76. WHEN '106' THEN '售前服务不满'
  77. WHEN '107' THEN '外部陌电骚扰'
  78. END) AS resultClassification,
  79. scac.procedureResult,
  80. row_number() over(partition by scac.productNos) rn,
  81. scac.productNos,
  82. scac.complaintsName
  83. FROM
  84. cc_action_complaints scac
  85. ) temp
  86. WHERE sc.PolicyNo = temp.productNos AND sc.CPName = temp.complaintsName AND temp.rn = 1)
  87. END ;
  88. /
  89. CREATE OR REPLACE PROCEDURE shanglifeecif.init_communication_sp02() IS
  90. DECLARE
  91. BEGIN
  92. UPDATE shanglifeecif.communication sc SET(
  93. IndID,
  94. CPCertID
  95. ) = (
  96. SELECT
  97. ApplicantID,
  98. AppCertID
  99. FROM (
  100. SELECT
  101. ApplicantID,
  102. AppCertID,
  103. row_number() over(partition by PolicyNo) rn,
  104. PolicyNo
  105. FROM
  106. shanglifeecif.InsuranceArrangement sia
  107. ) temp
  108. WHERE temp.PolicyNo = sc.PolicyNo AND sc.RSOApplicant = '本人' AND temp.rn = 1)
  109. END ;
  110. /
  111. BEGIN
  112. shanglifeecif.init_communication();
  113. shanglifeecif.init_communication_sp01();
  114. shanglifeecif.init_communication_sp02();
  115. END ;