123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- CREATE TABLE shanghailifeecif.edorinfo(
- contno string DEFAULT NULL COMMENT '保单号',
- edortype string DEFAULT NULL COMMENT '管理机构',
- lppostaladdress string DEFAULT NULL COMMENT '原客户地址',
- lcpostaladdress string DEFAULT NULL COMMENT '现客户地址',
- lpmobile string DEFAULT NULL COMMENT '原手机号',
- lcmobile string DEFAULT NULL COMMENT '现手机号 ',
- lpidtype string DEFAULT NULL COMMENT '原证件类型',
- lcidtype string DEFAULT NULL COMMENT '现证件类型 ',
- lpidno string DEFAULT NULL COMMENT '原证件号码',
- lcidno string DEFAULT NULL COMMENT '现证件号码 ',
- EDORAPPDATE string DEFAULT NULL COMMENT '保全申请日期',
- EDORCVALIDATE string DEFAULT NULL COMMENT '保全生效日期 '
- )
- COMMENT '保全'
- STORED AS csvfile;
- CREATE TABLE shanghailifeecif.audit_edorlist(
- managecom varchar2(200) DEFAULT NULL COMMENT '管理机构', -- dialect: ORACLE
- managename varchar2(200) DEFAULT NULL COMMENT '管理机构名称', -- dialect: ORACLE
- salechnl varchar2(200) DEFAULT NULL COMMENT '销售渠道', -- dialect: ORACLE
- salechnlname varchar2(64) DEFAULT NULL COMMENT '销售渠道名称', -- dialect: ORACLE
- selltype varchar2(64) DEFAULT NULL COMMENT '合作渠道代码', -- dialect: ORACLE
- selltypename varchar2(64) DEFAULT NULL COMMENT '合作渠道名称', -- dialect: ORACLE
- contno varchar2(200) DEFAULT NULL COMMENT '保单号', -- dialect: ORACLE
- riskcodes varchar2(200) DEFAULT NULL COMMENT '险种代码', -- dialect: ORACLE
- risknames varchar2(200) DEFAULT NULL COMMENT '险种名称', -- dialect: ORACLE
- risktypes varchar2(64) DEFAULT NULL COMMENT '险种类型', -- dialect: ORACLE
- signdate timestamp DEFAULT NULL COMMENT '承保日期',
- appntname varchar2(200) DEFAULT NULL COMMENT '投保人', -- dialect: ORACLE
- prem decimal(10,2) DEFAULT NULL COMMENT '保费',
- edorname varchar2(256) DEFAULT NULL COMMENT '保全类型', -- dialect: ORACLE
- edoracceptno varchar2(256) DEFAULT NULL COMMENT '保全受理号', -- dialect: ORACLE
- edorno varchar2(256) DEFAULT NULL COMMENT '批单号', -- dialect: ORACLE
- edorvalidate timestamp DEFAULT NULL COMMENT '保全生效日期',
- customerhandleflag varchar2(64) DEFAULT NULL COMMENT '是否亲办', -- dialect: ORACLE
- operator varchar2(256) DEFAULT NULL COMMENT '操作人', -- dialect: ORACLE
- approveoperator varchar2(256) DEFAULT NULL COMMENT '审批人', -- dialect: ORACLE
- getmoney decimal(10,2) DEFAULT NULL COMMENT '保全退补费金额',
- cusappdate timestamp DEFAULT NULL COMMENT '客户申请日期',
- payyears varchar2(64) DEFAULT NULL COMMENT '缴费年期', -- dialect: ORACLE
- agentname varchar2(256) DEFAULT NULL COMMENT '代理人姓名', -- dialect: ORACLE
- edorstate varchar2(64) DEFAULT NULL COMMENT '保全状态', -- dialect: ORACLE
- ins_time timestamp DEFAULT NULL
- )
- COMMENT '保全清单';
- ======================================================================
- =================================目的表结构=================================
- ======================================================================
- CREATE TABLE PartyTimeLine(
- TripID string NOT NULL COMMENT '旅程ID' ,
- PartyID string NOT NULL COMMENT '参与方ID' ,
- Name string COMMENT '参与方名称' ,
- PCertID string COMMENT '参与方证件号码' ,
- PPhone string COMMENT '参与方手机' ,
- PRole string COMMENT '参与方角色 投保人、被保人、受益人' ,
- Scenario string COMMENT '场景 投保 保全 报案 咨询 投诉 其他' ,
- SDate DATE COMMENT '发生日期' ,
- ThreadID string COMMENT '关联ID 可关联至更详细信息,如保单ID、报案ID等' ,
- ParentID string COMMENT '父ID 如报案对应的保单ID' ,
- Describe string COMMENT '描述' ,
- Channel string COMMENT '来源' ,
- EndDate DATE COMMENT '完成日期' ,
- CREATED_BY string COMMENT '创建人' ,
- CREATED_TIME DATE COMMENT '创建时间' ,
- UPDATED_BY string COMMENT '更新人' ,
- UPDATED_TIME DATE COMMENT '更新时间'
- ) COMMENT '参与方事件 '
- STORED AS ES
- with shard number 10
- replication 1;
- ==================================================初始化数据====================================================================
- DROP SEQUENCE IF EXISTS globaleTripID_sequence;
- CREATE OR REPLACE PROCEDURE init_partytimeline_main() -- 创建主存储过程
- IS
- DECLARE
- partytimeline_count int
- strsql string
- BEGIN
- --1.从保全清单表中初始化 参与事件
- select count(0) into partytimeline_count from PartyTimeLine;
- partytimeline_count:=partytimeline_count+1;
- DBMS_OUTPUT.PUT_LINE(partytimeline_count);
- init_insuranceclaimthread_edorlist(partytimeline_count)
-
- --2.从保全表中初始化 参与事件
- select count(0) into partytimeline_count from PartyTimeLine;
- partytimeline_count:=partytimeline_count+1;
- DBMS_OUTPUT.PUT_LINE(partytimeline_count);
- init_insuranceclaimthread_edorinfo(partytimeline_count)
-
- -- 3.初始化理赔相关信息
- select count(0) into partytimeline_count from PartyTimeLine;
- partytimeline_count:=partytimeline_count+1;
- DBMS_OUTPUT.PUT_LINE(partytimeline_count);
- init_insuranceclaimthread_insuranceclaimthread(partytimeline_count)
-
- -- 4.初始化投保赔相关信息
- select count(0) into partytimeline_count from PartyTimeLine;
- partytimeline_count:=partytimeline_count+1;
- DBMS_OUTPUT.PUT_LINE(partytimeline_count);
- init_insuranceclaimthread_InsuranceArrangement(partytimeline_count)
-
- partytimeline_count:=partytimeline_count+1;
- DBMS_OUTPUT.PUT_LINE(partytimeline_count);
- -- 用于以后更新时是用的序列
- strsql:='
- CREATE SEQUENCE globaleTripID_sequence
- INCREMENT BY 1
- START WITH '|| partytimeline_count||'
- NOMAXVALUE
- NOMINVALUE
- NOCYCLE
- CACHE 1;
- '
- EXECUTE IMMEDIATE strsql
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_partytimeline_main',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_partytimeline_main',sqlerrm(),sqlcode())
- END;
- /*audit_edorlist 表
- managecom varchar2(200) DEFAULT NULL COMMENT '管理机构', -- dialect: ORACLE
- managename varchar2(200) DEFAULT NULL COMMENT '管理机构名称', -- dialect: ORACLE
- salechnl varchar2(200) DEFAULT NULL COMMENT '销售渠道', -- dialect: ORACLE
- salechnlname varchar2(64) DEFAULT NULL COMMENT '销售渠道名称', -- dialect: ORACLE
- selltype varchar2(64) DEFAULT NULL COMMENT '合作渠道代码', -- dialect: ORACLE
- selltypename varchar2(64) DEFAULT NULL COMMENT '合作渠道名称', -- dialect: ORACLE
- contno varchar2(200) DEFAULT NULL COMMENT '保单号', -- dialect: ORACLE
- riskcodes varchar2(200) DEFAULT NULL COMMENT '险种代码', -- dialect: ORACLE
- risknames varchar2(200) DEFAULT NULL COMMENT '险种名称', -- dialect: ORACLE
- risktypes varchar2(64) DEFAULT NULL COMMENT '险种类型', -- dialect: ORACLE
- signdate timestamp DEFAULT NULL COMMENT '承保日期',
- appntname varchar2(200) DEFAULT NULL COMMENT '投保人', -- dialect: ORACLE
- prem decimal(10,2) DEFAULT NULL COMMENT '保费',
- edorname varchar2(256) DEFAULT NULL COMMENT '保全类型', -- dialect: ORACLE
- edoracceptno varchar2(256) DEFAULT NULL COMMENT '保全受理号', -- dialect: ORACLE
- edorno varchar2(256) DEFAULT NULL COMMENT '批单号', -- dialect: ORACLE
- edorvalidate timestamp DEFAULT NULL COMMENT '保全生效日期',
- customerhandleflag varchar2(64) DEFAULT NULL COMMENT '是否亲办', -- dialect: ORACLE
- operator varchar2(256) DEFAULT NULL COMMENT '操作人', -- dialect: ORACLE
- approveoperator varchar2(256) DEFAULT NULL COMMENT '审批人', -- dialect: ORACLE
- getmoney decimal(10,2) DEFAULT NULL COMMENT '保全退补费金额',
- cusappdate timestamp DEFAULT NULL COMMENT '客户申请日期',
- payyears varchar2(64) DEFAULT NULL COMMENT '缴费年期', -- dialect: ORACLE
- agentname varchar2(256) DEFAULT NULL COMMENT '代理人姓名', -- dialect: ORACLE
- edorstate varchar2(64) DEFAULT NULL COMMENT '保全状态', -- dialect: ORACLE
- ins_time timestamp DEFAULT NULL
- */
- CREATE TABLE PartyTimeLine_edor_tmp(
- id string,
- contno string comment '保单号',
- PartyID string COMMENT '参与方ID' ,
- appntname string COMMENT '参与方名称' ,
- PCertID string COMMENT '参与方证件号码' ,
- PPhone string COMMENT '参与方手机' ,
- cusappdate DATE COMMENT '客户申请日期' ,
- edoracceptno string COMMENT '保全受理号' ,
- edorvalidate DATE COMMENT '保全生效日期'
- ) COMMENT '参与方保全事件临时表 '
- STORED AS ES
- with shard number 10
- replication 1;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
- CREATE OR REPLACE PROCEDURE init_insuranceclaimthread_edorlist(partytimeline_count OUT int)
- IS
- BEGIN
- --初始化临时表
- delete from PartyTimeLine_edor_tmp;
- insert into PartyTimeLine_edor_tmp(
- id,
- contno,
- appntname,
- cusappdate,
- edoracceptno,
- edorvalidate
- )
- SELECT
- row_number()over(),
- contno,
- appntname,
- cusappdate,
- edoracceptno,
- edorvalidate
- from shanghailifeecif.audit_edorlist;
- --更新临时表信息
- UPDATE PartyTimeLine_edor_tmp a SET (
- PartyID ,-- 参与方ID
- PCertID ,-- 参与方证件号码
- PPhone
- ) = (
- select
- ApplicantID ,
- AppCertID ,
- AppPhone
- from shanglifeecif.InsuranceArrangement b
- where b.PolicyNo = a.contno
- ) WHERE 1=1 ;
- --更新参与方事件表
- insert into PartyTimeLine(
- TripID,
- PartyID, --参与方id
- Name,
- PCertID,
- PPhone,
- PRole,
- Scenario,
- SDate,
- ThreadID,
- ParentID,
- EndDate,
- CREATED_BY,
- CREATED_TIME
- )
- SELECT
- row_number()over(),
- PartyID,
- appntname,
- PCertID,
- PPhone,
- '投保人',
- '保全',
- cusappdate,
- edoracceptno,
- contno,
- edorvalidate,
- 'admin',
- sysdate
- from PartyTimeLine_edor_tmp where PartyID is not null;
- --已经存在的数据行数
- select count(0) into partytimeline_count from PartyTimeLine
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_insuranceclaimthread_edorlist',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_insuranceclaimthread_edorlist',sqlerrm(),sqlcode())
- END;
- =============================================================================================================================================================
- ============================================================根据edorinfo更新========================================================================================
- ==========================================================================================================================================================
- --------------------------------根据edorinfo更新 保全----------------------------------------
- /*
- contno string DEFAULT NULL COMMENT '保单号',
- edortype string DEFAULT NULL COMMENT '管理机构',
- lppostaladdress string DEFAULT NULL COMMENT '原客户地址',
- lcpostaladdress string DEFAULT NULL COMMENT '现客户地址',
- lpmobile string DEFAULT NULL COMMENT '原手机号',
- lcmobile string DEFAULT NULL COMMENT '现手机号 ',
- lpidtype string DEFAULT NULL COMMENT '原证件类型',
- lcidtype string DEFAULT NULL COMMENT '现证件类型 ',
- lpidno string DEFAULT NULL COMMENT '原证件号码',
- lcidno string DEFAULT NULL COMMENT '现证件号码 ',
- EDORAPPDATE string DEFAULT NULL COMMENT '保全申请日期',
- EDORCVALIDATE string DEFAULT NULL COMMENT '保全生效日期 '
- */
- CREATE OR REPLACE PROCEDURE init_insuranceclaimthread_edorinfo(partytimeline_count OUT int)
- IS
- BEGIN
- --初始化临时表
- delete from PartyTimeLine_edor_tmp;
- insert into PartyTimeLine_edor_tmp(
- id,
- contno,
- PPhone,
- PCertID,
- edoracceptno ,
- edorvalidate
- )
- SELECT
- row_number()over(),
- contno,
- lcmobile,
- lcidno,
- EDORAPPDATE,
- EDORCVALIDATE
- from shanghailifeecif.edorinfo;
- --更新临时表信息
- UPDATE PartyTimeLine_edor_tmp a SET (
- PartyID ,-- 参与方ID
- appntname
- ) = (
- select
- ApplicantID ,
- appname--投保人名称
- from shanglifeecif.InsuranceArrangement b
- where b.PolicyNo = a.contno
- ) WHERE 1=1 ;
- --更新参与方事件表
- insert into PartyTimeLine(
- TripID,
- PartyID, --参与方id
- Name,
- PCertID,
- PPhone,
- PRole,
- Scenario,
- SDate,
- ThreadID,
- ParentID,
- EndDate,
- CREATED_BY,
- CREATED_TIME
- )
- SELECT
- row_number()over() +partytimeline_count,
- PartyID,
- appntname,
- PCertID,
- PPhone,
- '投保人',
- '保全',
- cusappdate,
- edoracceptno,
- contno,
- edorvalidate,
- 'admin',
- sysdate
- from PartyTimeLine_edor_tmp where PartyID is not null;
- --已经存在的数据行数
- select count(0) into partytimeline_count from PartyTimeLine
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_insuranceclaimthread_edorinfo',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_insuranceclaimthread_edorinfo',sqlerrm(),sqlcode())
- END;
- =============================================================================================================================================================
- ============================================================根据insuranceclaimthread更新理赔========================================================================================
- ==========================================================================================================================================================
- CREATE OR REPLACE PROCEDURE init_insuranceclaimthread_insuranceclaimthread(partytimeline_count OUT int)
- IS
- BEGIN
- --初始化临时表、
- insert into PartyTimeLine(
- TripID,
- PartyID, --参与方id
- Name,
- PCertID,
- PPhone,
- PRole,
- Scenario,
- SDate,
- ThreadID,
- ParentID,
- EndDate,
- CREATED_BY,
- CREATED_TIME
- )
- SELECT
- row_number()over() +partytimeline_count,
- applicantid,
- appname,
- appcertid,
- appphone,
- '投保人',
- '报案',
- crdate,
- icthreadid,
- policyno,
- csdate,
- 'admin',
- sysdate
- from qxp.insuranceclaimthread where applicantid is not null;
- --已经存在的数据行数
- select count(0) into partytimeline_count from PartyTimeLine;
-
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_insuranceclaimthread_insuranceclaimthread',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_insuranceclaimthread_insuranceclaimthread',sqlerrm(),sqlcode())
- END;
- =============================================================================================================================================================
- ============================================================根据InsuranceArrangement更新投保========================================================================================
- ==========================================================================================================================================================
- CREATE OR REPLACE PROCEDURE init_insuranceclaimthread_InsuranceArrangement(partytimeline_count OUT int)
- IS
- BEGIN
- --初始化临时表、
- insert into PartyTimeLine(
- TripID,
- PartyID, --参与方id
- Name,
- PCertID,
- PPhone,
- PRole,
- Scenario,
- SDate,
- ThreadID,
- ParentID,
- EndDate,
- CREATED_BY,
- CREATED_TIME
- )
- SELECT
- row_number()over() +partytimeline_count,
- applicantid,
- appname,
- appcertid,
- appphone,
- '投保人',
- '投保',
- PADate,
- PANo,
- PolicyNo,
- PMDate ,
- 'admin',
- sysdate
- from shanglifeecif.InsuranceArrangement where applicantid is not null;
- --已经存在的数据行数
- select count(0) into partytimeline_count from PartyTimeLine
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_insuranceclaimthread_InsuranceArrangement',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_insuranceclaimthread_InsuranceArrangement',sqlerrm(),sqlcode())
- END;
- ================================================数据解析============================================================================================
- --保全号是唯一的 是不重复的
- --从 audit_edorlist 的表中插入的数据为 619006
- --有1060个数据 因为查不到保单无法进入数据库
- --带edorinfo 一共插入 619685
- --带理赔和保单一共插入 2086136 保单总数 1520720
- SELECT count(1) FROM audit_edorlist ; --620066
- SELECT count(1) FROM (
- SELECT contno FROM audit_edorlist GROUP BY contno
- ); --根据保单 去重550805
- SELECT count(1) FROM (
- SELECT contno,cusappdate FROM audit_edorlist GROUP BY contno,cusappdate
- );--根据保单和申请时间 去重 591350
- SELECT count(1) a,contno FROM audit_edorlist GROUP BY contno,cusappdate ORDER BY a DESC;
- --查询重复最多的数据
- SELECT * FROM audit_edorlist WHERE contno = '2018020800060078';
- SELECT count(1) FROM PartyTimeLine WHERE scenario = "保全" ; --619713
- SELECT count(1) FROM PartyTimeLine WHERE Scenario ='投保' ; --1466423
- SELECT count(1) FROM PartyTimeLine WHERE Scenario ='报案' ; --11490
- SELECT count(1) FROM PartyTimeLine; --2097626
- SELECT count(1) FROM shanglifeecif.InsuranceArrangement; --1520720
- SELECT count(1) FROM shanglifeecif.insuranceclaimthread; --13957
- --
|