partytimeline_ts.sql 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.partytimeline_ts()
  2. IS
  3. DECLARE
  4. p_count int
  5. BEGIN
  6. insert into shanglifeecif.partytimeline (
  7. TripID,
  8. PolicyNo,
  9. PartyID,
  10. name,
  11. PRole,
  12. Scenario,
  13. SDate,
  14. DESCRIBE,
  15. created_by ,
  16. created_time
  17. ) SELECT
  18. reflect("java.util.UUID", "randomUUID"),
  19. max(ac.productnos),
  20. max(i.customerno),
  21. max(ac.complaintsname),
  22. '投保人'||CASE max(ac.complaintsrelation)
  23. WHEN '201' THEN ''
  24. WHEN '202' THEN '子女'
  25. WHEN '203' THEN '配偶'
  26. WHEN '204' THEN '父母'
  27. WHEN '205' THEN '其他关系'
  28. END AS complaintsrelation,
  29. '投诉',
  30. ac.inserttime ,
  31. CASE max(ac.resultclassification)
  32. WHEN '101' THEN '销售纠纷'
  33. WHEN '102' THEN '理赔纠纷'
  34. WHEN '103' THEN '退保纠纷'
  35. WHEN '104' THEN '承保纠纷'
  36. WHEN '105' THEN '续收续保纠纷'
  37. WHEN '106' THEN '保全纠纷'
  38. WHEN '107' THEN '其他'
  39. END as resultclassification,
  40. 'admin',
  41. sysdate
  42. FROM dsj.cc_action_complaints ac
  43. LEFT JOIN dsj.policy_information i ON ac.productnos = i.contno
  44. WHERE ac.productnos IS NOT NULL AND i.customerno IS NOT NULL
  45. GROUP BY ac.inserttime ;
  46. dbms_output.put_line('partytimeline_ts函数跑批完成!');
  47. EXCEPTION
  48. WHEN HIVE_EXCEPTION THEN
  49. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  50. WHEN Others THEN
  51. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  52. END;