参与方事件.sql 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. CREATE TABLE shanghailifeecif.edorinfo(
  2. contno string DEFAULT NULL COMMENT '保单号',
  3. edortype string DEFAULT NULL COMMENT '管理机构',
  4. lppostaladdress string DEFAULT NULL COMMENT '原客户地址',
  5. lcpostaladdress string DEFAULT NULL COMMENT '现客户地址',
  6. lpmobile string DEFAULT NULL COMMENT '原手机号',
  7. lcmobile string DEFAULT NULL COMMENT '现手机号 ',
  8. lpidtype string DEFAULT NULL COMMENT '原证件类型',
  9. lcidtype string DEFAULT NULL COMMENT '现证件类型 ',
  10. lpidno string DEFAULT NULL COMMENT '原证件号码',
  11. lcidno string DEFAULT NULL COMMENT '现证件号码 ',
  12. EDORAPPDATE string DEFAULT NULL COMMENT '保全申请日期',
  13. EDORCVALIDATE string DEFAULT NULL COMMENT '保全生效日期 '
  14. )
  15. COMMENT '保全'
  16. STORED AS csvfile;
  17. CREATE TABLE shanghailifeecif.audit_edorlist(
  18. managecom varchar2(200) DEFAULT NULL COMMENT '管理机构', -- dialect: ORACLE
  19. managename varchar2(200) DEFAULT NULL COMMENT '管理机构名称', -- dialect: ORACLE
  20. salechnl varchar2(200) DEFAULT NULL COMMENT '销售渠道', -- dialect: ORACLE
  21. salechnlname varchar2(64) DEFAULT NULL COMMENT '销售渠道名称', -- dialect: ORACLE
  22. selltype varchar2(64) DEFAULT NULL COMMENT '合作渠道代码', -- dialect: ORACLE
  23. selltypename varchar2(64) DEFAULT NULL COMMENT '合作渠道名称', -- dialect: ORACLE
  24. contno varchar2(200) DEFAULT NULL COMMENT '保单号', -- dialect: ORACLE
  25. riskcodes varchar2(200) DEFAULT NULL COMMENT '险种代码', -- dialect: ORACLE
  26. risknames varchar2(200) DEFAULT NULL COMMENT '险种名称', -- dialect: ORACLE
  27. risktypes varchar2(64) DEFAULT NULL COMMENT '险种类型', -- dialect: ORACLE
  28. signdate timestamp DEFAULT NULL COMMENT '承保日期',
  29. appntname varchar2(200) DEFAULT NULL COMMENT '投保人', -- dialect: ORACLE
  30. prem decimal(10,2) DEFAULT NULL COMMENT '保费',
  31. edorname varchar2(256) DEFAULT NULL COMMENT '保全类型', -- dialect: ORACLE
  32. edoracceptno varchar2(256) DEFAULT NULL COMMENT '保全受理号', -- dialect: ORACLE
  33. edorno varchar2(256) DEFAULT NULL COMMENT '批单号', -- dialect: ORACLE
  34. edorvalidate timestamp DEFAULT NULL COMMENT '保全生效日期',
  35. customerhandleflag varchar2(64) DEFAULT NULL COMMENT '是否亲办', -- dialect: ORACLE
  36. operator varchar2(256) DEFAULT NULL COMMENT '操作人', -- dialect: ORACLE
  37. approveoperator varchar2(256) DEFAULT NULL COMMENT '审批人', -- dialect: ORACLE
  38. getmoney decimal(10,2) DEFAULT NULL COMMENT '保全退补费金额',
  39. cusappdate timestamp DEFAULT NULL COMMENT '客户申请日期',
  40. payyears varchar2(64) DEFAULT NULL COMMENT '缴费年期', -- dialect: ORACLE
  41. agentname varchar2(256) DEFAULT NULL COMMENT '代理人姓名', -- dialect: ORACLE
  42. edorstate varchar2(64) DEFAULT NULL COMMENT '保全状态', -- dialect: ORACLE
  43. ins_time timestamp DEFAULT NULL
  44. )
  45. COMMENT '保全清单';
  46. ======================================================================
  47. =================================目的表结构=================================
  48. ======================================================================
  49. CREATE TABLE shanglifeecif.PartyTimeLine(
  50. TripID string NOT NULL COMMENT '旅程ID' ,
  51. PartyID string NOT NULL COMMENT '参与方ID' ,
  52. Name string COMMENT '参与方名称' ,
  53. PCertID string COMMENT '参与方证件号码' ,
  54. PPhone string COMMENT '参与方手机' ,
  55. PRole string COMMENT '参与方角色 投保人、被保人、受益人' ,
  56. Scenario string COMMENT '场景 投保 保全 报案 咨询 投诉 其他' ,
  57. SDate DATE COMMENT '发生日期' ,
  58. ThreadID string COMMENT '关联ID 可关联至更详细信息,如保单ID、报案ID等' ,
  59. ParentID string COMMENT '父ID 如报案对应的保单ID' ,
  60. Describe string COMMENT '描述' ,
  61. Channel string COMMENT '来源' ,
  62. EndDate DATE COMMENT '完成日期' ,
  63. CREATED_BY string COMMENT '创建人' ,
  64. CREATED_TIME DATE COMMENT '创建时间' ,
  65. UPDATED_BY string COMMENT '更新人' ,
  66. UPDATED_TIME DATE COMMENT '更新时间'
  67. ) COMMENT '参与方事件 '
  68. STORED AS ES
  69. with shard number 10
  70. replication 1;
  71. ==================================================初始化数据====================================================================
  72. DROP SEQUENCE IF EXISTS globaleTripID_sequence;
  73. CREATE OR REPLACE PROCEDURE shanglifeecif.init_partytimeline_main() -- 创建主存储过程
  74. IS
  75. DECLARE
  76. partytimeline_count int
  77. strsql string
  78. BEGIN
  79. --1.从保全清单表中初始化 参与事件
  80. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine;
  81. partytimeline_count:=partytimeline_count+1;
  82. DBMS_OUTPUT.PUT_LINE(partytimeline_count);
  83. init_PartyTimeLine_edorlist(partytimeline_count)
  84. --2.从保全表中初始化 参与事件
  85. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine;
  86. partytimeline_count:=partytimeline_count+1;
  87. DBMS_OUTPUT.PUT_LINE(partytimeline_count);
  88. init_PartyTimeLine_edorinfo(partytimeline_count)
  89. -- 3.初始化理赔相关信息
  90. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine;
  91. partytimeline_count:=partytimeline_count+1;
  92. DBMS_OUTPUT.PUT_LINE(partytimeline_count);
  93. init_PartyTimeLine_insuranceclaimthread(partytimeline_count)
  94. -- 4.初始化投保赔相关信息
  95. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine;
  96. partytimeline_count:=partytimeline_count+1;
  97. DBMS_OUTPUT.PUT_LINE(partytimeline_count);
  98. init_PartyTimeLine_InsuranceArrangement(partytimeline_count)
  99. --5.从cc通话中心表中初始化 理赔 保全 咨询 参与事件
  100. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine;
  101. partytimeline_count:=partytimeline_count+1;
  102. DBMS_OUTPUT.PUT_LINE(partytimeline_count);
  103. init_PartyTimeLine_cc(partytimeline_count)
  104. -- 用于以后更新时是用的序列
  105. strsql:='
  106. CREATE SEQUENCE globaleTripID_sequence
  107. INCREMENT BY 1
  108. START WITH '|| partytimeline_count||'
  109. NOMAXVALUE
  110. NOMINVALUE
  111. NOCYCLE
  112. CACHE 1;
  113. '
  114. EXECUTE IMMEDIATE strsql
  115. EXCEPTION
  116. WHEN HIVE_EXCEPTION THEN
  117. log_exception('init_partytimeline_main',sqlerrm(),sqlcode())
  118. WHEN Others THEN
  119. log_exception('init_partytimeline_main',sqlerrm(),sqlcode())
  120. END;
  121. /*audit_edorlist 表
  122. managecom varchar2(200) DEFAULT NULL COMMENT '管理机构', -- dialect: ORACLE
  123. managename varchar2(200) DEFAULT NULL COMMENT '管理机构名称', -- dialect: ORACLE
  124. salechnl varchar2(200) DEFAULT NULL COMMENT '销售渠道', -- dialect: ORACLE
  125. salechnlname varchar2(64) DEFAULT NULL COMMENT '销售渠道名称', -- dialect: ORACLE
  126. selltype varchar2(64) DEFAULT NULL COMMENT '合作渠道代码', -- dialect: ORACLE
  127. selltypename varchar2(64) DEFAULT NULL COMMENT '合作渠道名称', -- dialect: ORACLE
  128. contno varchar2(200) DEFAULT NULL COMMENT '保单号', -- dialect: ORACLE
  129. riskcodes varchar2(200) DEFAULT NULL COMMENT '险种代码', -- dialect: ORACLE
  130. risknames varchar2(200) DEFAULT NULL COMMENT '险种名称', -- dialect: ORACLE
  131. risktypes varchar2(64) DEFAULT NULL COMMENT '险种类型', -- dialect: ORACLE
  132. signdate timestamp DEFAULT NULL COMMENT '承保日期',
  133. appntname varchar2(200) DEFAULT NULL COMMENT '投保人', -- dialect: ORACLE
  134. prem decimal(10,2) DEFAULT NULL COMMENT '保费',
  135. edorname varchar2(256) DEFAULT NULL COMMENT '保全类型', -- dialect: ORACLE
  136. edoracceptno varchar2(256) DEFAULT NULL COMMENT '保全受理号', -- dialect: ORACLE
  137. edorno varchar2(256) DEFAULT NULL COMMENT '批单号', -- dialect: ORACLE
  138. edorvalidate timestamp DEFAULT NULL COMMENT '保全生效日期',
  139. customerhandleflag varchar2(64) DEFAULT NULL COMMENT '是否亲办', -- dialect: ORACLE
  140. operator varchar2(256) DEFAULT NULL COMMENT '操作人', -- dialect: ORACLE
  141. approveoperator varchar2(256) DEFAULT NULL COMMENT '审批人', -- dialect: ORACLE
  142. getmoney decimal(10,2) DEFAULT NULL COMMENT '保全退补费金额',
  143. cusappdate timestamp DEFAULT NULL COMMENT '客户申请日期',
  144. payyears varchar2(64) DEFAULT NULL COMMENT '缴费年期', -- dialect: ORACLE
  145. agentname varchar2(256) DEFAULT NULL COMMENT '代理人姓名', -- dialect: ORACLE
  146. edorstate varchar2(64) DEFAULT NULL COMMENT '保全状态', -- dialect: ORACLE
  147. ins_time timestamp DEFAULT NULL
  148. */
  149. CREATE TABLE shanglifeecif.PartyTimeLine_edor_tmp(
  150. id string,
  151. contno string comment '保单号',
  152. PartyID string COMMENT '参与方ID' ,
  153. appntname string COMMENT '参与方名称' ,
  154. PCertID string COMMENT '参与方证件号码' ,
  155. PPhone string COMMENT '参与方手机' ,
  156. cusappdate DATE COMMENT '客户申请日期' ,
  157. edoracceptno string COMMENT '保全受理号' ,
  158. edorvalidate DATE COMMENT '保全生效日期'
  159. ) COMMENT '参与方保全事件临时表 '
  160. STORED AS ES
  161. with shard number 10
  162. replication 1;
  163. !set plsqlUseSlash true
  164. SET plsql.catch.hive.exception=true;
  165. --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
  166. CREATE OR REPLACE PROCEDURE init_PartyTimeLine_edorlist(partytimeline_count OUT int)
  167. IS
  168. BEGIN
  169. --初始化临时表
  170. delete from shanglifeecif.PartyTimeLine_edor_tmp;
  171. insert into shanglifeecif.PartyTimeLine_edor_tmp(
  172. id,
  173. contno,
  174. appntname,
  175. cusappdate,
  176. edoracceptno,
  177. edorvalidate
  178. )
  179. SELECT
  180. row_number()over(),
  181. contno,
  182. appntname,
  183. cusappdate,
  184. edoracceptno,
  185. edorvalidate
  186. from audit_edorlist;
  187. --更新临时表信息
  188. UPDATE shanglifeecif.PartyTimeLine_edor_tmp a SET (
  189. PartyID ,-- 参与方ID
  190. PCertID ,-- 参与方证件号码
  191. PPhone
  192. ) = (
  193. select
  194. ApplicantID ,
  195. AppCertID ,
  196. AppPhone
  197. from shanglifeecif.InsuranceArrangement b
  198. where b.PolicyNo = a.contno
  199. ) WHERE 1=1 ;
  200. --更新参与方事件表
  201. insert into shanglifeecif.PartyTimeLine(
  202. TripID,
  203. PartyID, --参与方id
  204. Name,
  205. PCertID,
  206. PPhone,
  207. PRole,
  208. Scenario,
  209. SDate,
  210. ThreadID,
  211. ParentID,
  212. EndDate,
  213. CREATED_BY,
  214. CREATED_TIME
  215. )
  216. SELECT
  217. row_number()over(),
  218. PartyID,
  219. appntname,
  220. PCertID,
  221. PPhone,
  222. '投保人',
  223. '保全',
  224. cusappdate,
  225. edoracceptno,
  226. contno,
  227. edorvalidate,
  228. 'admin',
  229. sysdate
  230. from shanglifeecif.PartyTimeLine_edor_tmp where PartyID is not null;
  231. --已经存在的数据行数
  232. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine
  233. EXCEPTION
  234. WHEN HIVE_EXCEPTION THEN
  235. log_exception('init_PartyTimeLine_edorlist',sqlerrm(),sqlcode())
  236. WHEN Others THEN
  237. log_exception('init_PartyTimeLine_edorlist',sqlerrm(),sqlcode())
  238. END;
  239. =============================================================================================================================================================
  240. ============================================================根据edorinfo更新========================================================================================
  241. ==========================================================================================================================================================
  242. --------------------------------根据edorinfo更新 保全----------------------------------------
  243. /*
  244. contno string DEFAULT NULL COMMENT '保单号',
  245. edortype string DEFAULT NULL COMMENT '管理机构',
  246. lppostaladdress string DEFAULT NULL COMMENT '原客户地址',
  247. lcpostaladdress string DEFAULT NULL COMMENT '现客户地址',
  248. lpmobile string DEFAULT NULL COMMENT '原手机号',
  249. lcmobile string DEFAULT NULL COMMENT '现手机号 ',
  250. lpidtype string DEFAULT NULL COMMENT '原证件类型',
  251. lcidtype string DEFAULT NULL COMMENT '现证件类型 ',
  252. lpidno string DEFAULT NULL COMMENT '原证件号码',
  253. lcidno string DEFAULT NULL COMMENT '现证件号码 ',
  254. EDORAPPDATE string DEFAULT NULL COMMENT '保全申请日期',
  255. EDORCVALIDATE string DEFAULT NULL COMMENT '保全生效日期 '
  256. */
  257. CREATE OR REPLACE PROCEDURE shanglifeecif.init_PartyTimeLine_edorinfo(partytimeline_count OUT int)
  258. IS
  259. BEGIN
  260. --初始化临时表
  261. delete from shanglifeecif.PartyTimeLine_edor_tmp;
  262. insert into shanglifeecif.PartyTimeLine_edor_tmp(
  263. id,
  264. contno,
  265. PPhone,
  266. PCertID,
  267. edoracceptno ,
  268. edorvalidate
  269. )
  270. SELECT
  271. row_number()over(),
  272. contno,
  273. lcmobile,
  274. lcidno,
  275. EDORAPPDATE,
  276. EDORCVALIDATE
  277. from shanghailifeecif.edorinfo;
  278. --更新临时表信息
  279. UPDATE shanglifeecif.PartyTimeLine_edor_tmp a SET (
  280. PartyID ,-- 参与方ID
  281. appntname
  282. ) = (
  283. select
  284. ApplicantID ,
  285. appname--投保人名称
  286. from shanglifeecif.InsuranceArrangement b
  287. where b.PolicyNo = a.contno
  288. ) WHERE 1=1 ;
  289. --更新参与方事件表
  290. insert into shanglifeecif.PartyTimeLine(
  291. TripID,
  292. PartyID, --参与方id
  293. Name,
  294. PCertID,
  295. PPhone,
  296. PRole,
  297. Scenario,
  298. SDate,
  299. ThreadID,
  300. ParentID,
  301. EndDate,
  302. CREATED_BY,
  303. CREATED_TIME
  304. )
  305. SELECT
  306. row_number()over() +partytimeline_count,
  307. PartyID,
  308. appntname,
  309. PCertID,
  310. PPhone,
  311. '投保人',
  312. '保全',
  313. cusappdate,
  314. edoracceptno,
  315. contno,
  316. edorvalidate,
  317. 'admin',
  318. sysdate
  319. from shanglifeecif.PartyTimeLine_edor_tmp where PartyID is not null;
  320. --已经存在的数据行数
  321. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine
  322. EXCEPTION
  323. WHEN HIVE_EXCEPTION THEN
  324. log_exception('init_PartyTimeLine_edorinfo',sqlerrm(),sqlcode())
  325. WHEN Others THEN
  326. log_exception('init_PartyTimeLine_edorinfo',sqlerrm(),sqlcode())
  327. END;
  328. =============================================================================================================================================================
  329. ============================================================根据insuranceclaimthread更新理赔========================================================================================
  330. ==========================================================================================================================================================
  331. CREATE OR REPLACE PROCEDURE init_PartyTimeLine_insuranceclaimthread(partytimeline_count OUT int)
  332. IS
  333. BEGIN
  334. insert into shanglifeecif.PartyTimeLine(
  335. TripID,
  336. PartyID, --参与方id
  337. Name,
  338. PCertID,
  339. PPhone,
  340. PRole,
  341. Scenario,
  342. SDate,
  343. ThreadID,
  344. ParentID,
  345. EndDate,
  346. CREATED_BY,
  347. CREATED_TIME
  348. )
  349. SELECT
  350. row_number()over() +partytimeline_count,
  351. applicantid,
  352. appname,
  353. appcertid,
  354. appphone,
  355. '投保人',
  356. '报案',
  357. crdate,
  358. icthreadid,
  359. policyno,
  360. csdate,
  361. 'admin',
  362. sysdate
  363. from shanglifeecif.insuranceclaimthread where applicantid is not null;
  364. --已经存在的数据行数
  365. select count(0) into partytimeline_count from shanglifeecif.PartyTimeLine;
  366. EXCEPTION
  367. WHEN HIVE_EXCEPTION THEN
  368. log_exception('init_PartyTimeLine_insuranceclaimthread',sqlerrm(),sqlcode())
  369. WHEN Others THEN
  370. log_exception('init_PartyTimeLine_insuranceclaimthread',sqlerrm(),sqlcode())
  371. END;
  372. =============================================================================================================================================================
  373. ============================================================根据InsuranceArrangement更新投保========================================================================================
  374. ==========================================================================================================================================================
  375. CREATE OR REPLACE PROCEDURE init_PartyTimeLine_InsuranceArrangement(partytimeline_count OUT int)
  376. IS
  377. BEGIN
  378. --初始化临时表、
  379. insert into PartyTimeLine(
  380. TripID,
  381. PartyID, --参与方id
  382. Name,
  383. PCertID,
  384. PPhone,
  385. PRole,
  386. Scenario,
  387. SDate,
  388. ThreadID,
  389. ParentID,
  390. EndDate,
  391. CREATED_BY,
  392. CREATED_TIME
  393. )
  394. SELECT
  395. row_number()over() +partytimeline_count,
  396. applicantid,
  397. appname,
  398. appcertid,
  399. appphone,
  400. '投保人',
  401. '投保',
  402. PADate,
  403. PANo,
  404. PolicyNo,
  405. PMDate ,
  406. 'admin',
  407. sysdate
  408. from shanglifeecif.InsuranceArrangement where applicantid is not null;
  409. --已经存在的数据行数
  410. select count(0) into partytimeline_count from PartyTimeLine
  411. EXCEPTION
  412. WHEN HIVE_EXCEPTION THEN
  413. log_exception('init_PartyTimeLine_InsuranceArrangement',sqlerrm(),sqlcode())
  414. WHEN Others THEN
  415. log_exception('init_PartyTimeLine_InsuranceArrangement',sqlerrm(),sqlcode())
  416. END;
  417. ==================================================================================================================================================
  418. ===========================================================根据cc_record_main表插入 保全 理赔 咨询=========================================================
  419. ==================================================================================================================================================
  420. CREATE TABLE PartyTimeLine_cc_tmp(
  421. id string,
  422. ThreadID string comment '记录id',
  423. ParentID string comment '父ID 保单号 ',
  424. PartyID string COMMENT '参与方ID' ,
  425. Name string COMMENT '参与方名称' ,
  426. PCertID string COMMENT '参与方证件号码' ,
  427. PPhone string COMMENT '参与方手机' ,
  428. PRole string COMMENT '参与方角色' ,
  429. EndDate DATE COMMENT '完成日期'
  430. ) COMMENT '呼叫中心临时表'
  431. STORED AS ES
  432. with shard number 10
  433. replication 1;
  434. CREATE OR REPLACE PROCEDURE init_PartyTimeLine_cc(partytimeline_count OUT int)
  435. IS
  436. BEGIN
  437. --清除临时表数据
  438. delete from PartyTimeLine_cc_tmp;
  439. -- 插入临时中间表
  440. insert into PartyTimeLine_cc_tmp(
  441. id ,
  442. ThreadID,-- string comment ' 记录id',
  443. ParentID ,--string comment '保单号 '
  444. --PartyID ,--string COMMENT '参与方ID' ,
  445. Name ,-- string COMMENT '参与方名称' ,
  446. --PCertID ,--string COMMENT '参与方证件号码' ,
  447. PPhone ,--string COMMENT '参与方手机' ,
  448. --PRole ,--string COMMENT '参与方角色' ,
  449. EndDate --DATE COMMENT '完成日期'
  450. )
  451. SELECT
  452. row_number()over(),
  453. recordinfo_id,
  454. contNos,
  455. econtactsName,
  456. econtactsPhone,
  457. startTime
  458. from shanghailifeecif.cc_record_main where contNos is not null;
  459. --更新用户id 和 角色
  460. UPDATE PartyTimeLine_cc_tmp a SET (
  461. PartyID ,--string COMMENT '参与方ID' ,
  462. PCertID ,--string COMMENT '参与方证件号码' ,
  463. PRole --string COMMENT '参与方角色' ,
  464. ) = (
  465. select
  466. b.ApplicantID ,
  467. b.appcertid,--投保人名称
  468. '投保人'
  469. from (
  470. SELECT
  471. policyno,
  472. row_number()over(partition by policyno ) tmpfiled,
  473. ApplicantID ,
  474. appname,--投保人名称
  475. appcertid --证件号
  476. FROM qxp.insurancearrangement
  477. )b
  478. where b.policyno = a.ParentID AND b.appname = a.name AND b.tmpfiled=1
  479. ) WHERE a.PartyID IS null ;
  480. UPDATE PartyTimeLine_cc_tmp a SET (
  481. PartyID ,--string COMMENT '参与方ID' ,
  482. PCertID ,--string COMMENT '参与方证件号码' ,
  483. PRole --string COMMENT '参与方角色' ,
  484. ) = (
  485. select
  486. b.insuredid ,
  487. b.inscertid,--投保人名称
  488. '被保人'
  489. from (
  490. SELECT
  491. policyno,
  492. row_number()over(partition by policyno ) tmpfiled,
  493. insuredid ,
  494. insname,--被保人名称
  495. inscertid --证件号
  496. FROM qxp.insurancearrangement
  497. )b
  498. where b.policyno = a.ParentID AND b.insname = a.name AND b.tmpfiled=1
  499. ) WHERE a.PartyID IS null ;
  500. --插入到主表中去
  501. insert into PartyTimeLine(
  502. TripID,
  503. PartyID, --参与方id
  504. Name,
  505. PCertID,
  506. PPhone,
  507. PRole,
  508. Scenario,
  509. SDate,
  510. ThreadID,
  511. ParentID,
  512. EndDate,
  513. CREATED_BY,
  514. CREATED_TIME
  515. )
  516. SELECT
  517. row_number()over() +partytimeline_count,
  518. PartyID,
  519. Name,
  520. PCertID,
  521. PPhone,
  522. PRole,
  523. '咨询',
  524. EndDate,
  525. ThreadID,
  526. ParentID,
  527. EndDate ,
  528. 'admin',
  529. sysdate
  530. from PartyTimeLine_cc_tmp where PartyID is not null;
  531. --已经存在的数据行数
  532. select count(0) into partytimeline_count from PartyTimeLine;
  533. EXCEPTION
  534. WHEN HIVE_EXCEPTION THEN
  535. log_exception('init_PartyTimeLine_cc',sqlerrm(),sqlcode())
  536. WHEN Others THEN
  537. log_exception('init_PartyTimeLine_cc',sqlerrm(),sqlcode())
  538. END;
  539. ==================================================================================================================================================
  540. ===========================================================更新投诉到事件表中=========================================================
  541. ==================================================================================================================================================
  542. ==================================================================================================================================================
  543. ===========================================================更新用户主表最后接触方式=========================================================
  544. ==================================================================================================================================================
  545. ===================================================================数据解析========================================================================
  546. --保全号是唯一的 是不重复的
  547. --从 audit_edorlist 的表中插入的数据为 619006
  548. --有1060个数据 因为查不到保单无法进入数据库
  549. --带edorinfo 一共插入 619685
  550. --带理赔和保单一共插入 2086136 保单总数 1520720
  551. SELECT count(1) FROM audit_edorlist ; --620066
  552. SELECT count(1) FROM (
  553. SELECT contno FROM audit_edorlist GROUP BY contno
  554. ); --根据保单 去重550805
  555. SELECT count(1) FROM (
  556. SELECT contno,cusappdate FROM audit_edorlist GROUP BY contno,cusappdate
  557. );--根据保单和申请时间 去重 591350
  558. SELECT count(1) a,contno FROM audit_edorlist GROUP BY contno,cusappdate ORDER BY a DESC;
  559. --查询重复最多的数据
  560. SELECT * FROM audit_edorlist WHERE contno = '2018020800060078';
  561. SELECT count(1) FROM PartyTimeLine WHERE scenario = "保全" ; --619713
  562. SELECT count(1) FROM PartyTimeLine WHERE Scenario ='投保' ; --1466423
  563. SELECT count(1) FROM PartyTimeLine WHERE Scenario ='报案' ; --11490
  564. SELECT count(1) FROM PartyTimeLine WHERE Scenario ='咨询' ; --14
  565. SELECT count(1) FROM PartyTimeLine; --2097626
  566. SELECT count(1) FROM shanglifeecif.InsuranceArrangement; --1520720
  567. SELECT count(1) FROM shanglifeecif.insuranceclaimthread; --13957
  568. --