12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028 |
- CREATE TABLE policy_information(
- contno varchar2(200) DEFAULT NULL COMMENT '保单号',
- riskcode varchar2(200) DEFAULT NULL COMMENT '险种代码',
- riskname varchar2(200) DEFAULT NULL COMMENT '险种名称',
- riskperiod varchar2(200) DEFAULT NULL COMMENT '险种分类',
- risktype varchar2(200) DEFAULT NULL COMMENT '险种设计类型',
- payintv varchar2(200) DEFAULT NULL COMMENT '缴费方式',
- security varchar2(200) not NULL COMMENT '保障年期',
- payendyear number not NULL COMMENT '缴费期间',
- payendyearflag varchar2(200) not NULL COMMENT '缴费年期单位',
- insuyer number not NULL COMMENT '保险年期',
- insuyerflag varchar2(200) not NULL COMMENT '保险年期单位',
- paycount number not NULL COMMENT '续保次数',
- signdate timestamp not NULL COMMENT '承保日期',
- cvalidate timestamp not NULL COMMENT '生效日期',
- enddate timestamp not NULL COMMENT '保单终止日期',
- modifydate timestamp not null comment '更新时间',
- prem number not null COMMENT '保费',
- appflag varchar2(200) not NULL COMMENT '保单状态',
- customerno varchar2(200) not null comment '客户号',
- name varchar2(200) not null comment '客户姓名',
- sex varchar2(200) not null comment '客户性别',
- birthday timestamp not null comment '客户出生日期',
- idtype varchar2(200) not null comment '客户证件类型',
- idno varchar2(200) not null comment '客户证件号',
- insuredno varchar2(200) not null comment '被保人号',
- insuredname varchar2(200) not null comment '被保人姓名',
- insuredsex varchar2(200) not null comment '被保人性别',
- insuredbirthday timestamp not null comment '被保人出生日期',
- insuredidtype varchar2(200) not null comment '被保人证件类型',
- insuredidno varchar2(200) not null comment '被保人证件号码',
- relationtoappnt varchar2(200) not null comment '与投保人关系',
- salechnl varchar2(200) not null comment '销售渠道',
- salecom varchar2(200) not null comment '业绩归属',
- salechannels varchar2(200) not NULL COMMENT '二级业绩归属',
- customgetpoldate timestamp not null comment '客户投保日期',
- prem_js number not null comment 'prem_js'
- )
- COMMENT '投保清单'
- STORED AS CSVFILE ;
- LOAD DATA INPATH '/tmp/myData/policy_information.txt' OVERWRITE INTO TABLE qxp.policy_information;
- TRUNCATE TABLE individual_search;
- DROP TABLE IF EXISTS individual_search;
- CREATE TABLE qxp.individual_search(
- indid string DEFAULT NULL COMMENT '个体ID',
- custid string DEFAULT NULL COMMENT '全局客户号',
- SCustID string DEFAULT NULL COMMENT '客户号',
- created_by string DEFAULT NULL COMMENT '创建人',
- created_time timestamp DEFAULT NULL COMMENT '创建时间',
- updated_by string DEFAULT NULL COMMENT '更新人',
- updated_time timestamp DEFAULT NULL COMMENT '更新时间',
- name string DEFAULT NULL COMMENT '名称',
- birthday date DEFAULT NULL COMMENT '出生日期',
- nobirth string DEFAULT NULL COMMENT '出生国家',
- sobirth string DEFAULT NULL COMMENT '出生省份',
- cobirth string DEFAULT NULL COMMENT '出生城市',
- homeadress string DEFAULT NULL COMMENT '籍贯',
- dday date DEFAULT NULL COMMENT '死亡日期',
- gender string DEFAULT NULL COMMENT '性别',
- ethnic string DEFAULT NULL COMMENT '民族',
- nation string DEFAULT NULL COMMENT '国籍',
- regresidence string DEFAULT NULL COMMENT '户口所在地',
- maritalstat string DEFAULT NULL COMMENT '婚姻状况',
- maritalstatdate date DEFAULT NULL COMMENT '婚姻状况日期',
- offspring string DEFAULT NULL COMMENT '生育状况',
- support string DEFAULT NULL COMMENT '赡养状况',
- empstat string DEFAULT NULL COMMENT '就业状况',
- empstatdate string DEFAULT NULL COMMENT '就业状况日期',
- raid string DEFAULT NULL COMMENT '居住地址',
- ral string DEFAULT NULL COMMENT '居住地址不分段',
- al string DEFAULT NULL COMMENT '曾用地址不分段',
- coadress int DEFAULT NULL COMMENT '地址登录数量',
- pmphone string DEFAULT NULL COMMENT '常用手机',
- mhone string DEFAULT NULL COMMENT '曾用手机',
- sophone int DEFAULT NULL COMMENT '手机登录数量',
- height decimal(8,2) DEFAULT NULL COMMENT '身高',
- weight decimal(8,2) DEFAULT NULL COMMENT '体重',
- cillness string DEFAULT NULL COMMENT '当前疾病',
- pillness string DEFAULT NULL COMMENT '曾患疾病',
- bmi decimal(8,2) DEFAULT NULL COMMENT 'BMI体制指数',
- evadate date DEFAULT NULL COMMENT '健康评估日期',
- cohevaluation int DEFAULT NULL COMMENT '健康评估登录数量',
- hphone string DEFAULT NULL COMMENT '家庭电话',
- occupation string DEFAULT NULL COMMENT '职业',
- odate date DEFAULT NULL COMMENT '职业时间',
- employer string DEFAULT NULL COMMENT '工作单位',
- wphone string DEFAULT NULL COMMENT '工作电话',
- empdate date DEFAULT NULL COMMENT '工作单位时间',
- idcard string DEFAULT NULL COMMENT '身份证',
- passport string DEFAULT NULL COMMENT '护照',
- dlicense string DEFAULT NULL COMMENT '驾驶证',
- education string DEFAULT NULL COMMENT '最高学历',
- university string DEFAULT NULL COMMENT '毕业学校',
- edate date DEFAULT NULL COMMENT '学历时间',
- wechat string DEFAULT NULL COMMENT '微信',
- weibo string DEFAULT NULL COMMENT '微博',
- email string DEFAULT NULL COMMENT '邮箱',
- qq string DEFAULT NULL COMMENT 'QQ',
- tiktok string DEFAULT NULL COMMENT '抖音',
- saccount1 string DEFAULT NULL COMMENT '社交账号1',
- sa1cat string DEFAULT NULL COMMENT '社交账号1类别',
- saccount2 string DEFAULT NULL COMMENT '社交账号2',
- sa2cat string DEFAULT NULL COMMENT '社交账号2类别',
- ctype string DEFAULT NULL COMMENT '首选联系方式',
- father string DEFAULT NULL COMMENT '父亲',
- mother string DEFAULT NULL COMMENT '母亲',
- mate string DEFAULT NULL COMMENT '配偶',
- child1 string DEFAULT NULL COMMENT '子女1',
- child2 string DEFAULT NULL COMMENT '子女2',
- cochild int DEFAULT NULL COMMENT '子女登录数量',
- fmhistory string DEFAULT NULL COMMENT '家族病史',
- rpid string DEFAULT NULL COMMENT '房产',
- rpdescribe string DEFAULT NULL COMMENT '房产描述',
- corp int DEFAULT NULL COMMENT '房产登录数量',
- vid string DEFAULT NULL COMMENT '车辆',
- vdescribe string DEFAULT NULL COMMENT '车辆描述',
- covehicle int DEFAULT NULL COMMENT '车辆登录数量',
- anniversary1 date DEFAULT NULL COMMENT '纪念日1',
- a1describe string DEFAULT NULL COMMENT '纪念日1类型',
- anniversary2 date DEFAULT NULL COMMENT '纪念日2',
- a2describe string DEFAULT NULL COMMENT '纪念日2类型',
- soanniversary int DEFAULT NULL COMMENT '纪念日登录数量',
- custtype string DEFAULT NULL COMMENT '客户类型',
- bankname string DEFAULT NULL COMMENT '开户银行',
- tobankcard string DEFAULT NULL COMMENT '银行卡类型',
- accname string DEFAULT NULL COMMENT '账户名',
- bankaccno string DEFAULT NULL COMMENT '银行帐号',
- cobaccount int DEFAULT NULL COMMENT '账户登录数量',
- sotlirisk decimal(32,8) DEFAULT NULL COMMENT '传统寿险种保额合计',
- soairisk decimal(32,8) DEFAULT NULL COMMENT '意外类险种保额合计',
- sosiirisk decimal(32,8) DEFAULT NULL COMMENT '重疾类险种保额合计',
- somcirisk decimal(32,8) DEFAULT NULL COMMENT '医疗费用类险种保额合计',
- someirisk decimal(32,8) DEFAULT NULL COMMENT '医疗补贴类险种保额合计',
- soefirisk decimal(32,8) DEFAULT NULL COMMENT '教育金类险种保额合计',
- sopirisk decimal(32,8) DEFAULT NULL COMMENT '养老金类险种保额合计',
- sowmirisk decimal(32,8) DEFAULT NULL COMMENT '财富管理险种保额合计',
- custclass int DEFAULT NULL COMMENT '客户等级',
- convalue int DEFAULT NULL COMMENT '贡献度分',
- awarded3 int DEFAULT NULL COMMENT '家庭加分',
- awarded2 int DEFAULT NULL COMMENT '续期加分',
- awarded1 int DEFAULT NULL COMMENT '保单加分',
- sovalue int DEFAULT NULL COMMENT '总分值',
- enddate date DEFAULT NULL COMMENT '客户等级失效日期',
- systemtag1 string DEFAULT NULL COMMENT '系统标签域1',
- systemtag2 string DEFAULT NULL COMMENT '系统标签域2',
- systemtag3 string DEFAULT NULL COMMENT '系统标签域3',
- cocommunication int DEFAULT NULL COMMENT '接触次数',
- lcdate date DEFAULT NULL COMMENT '最近接触时间',
- lctype string DEFAULT NULL COMMENT '最近接触类型',
- cocomplaint int DEFAULT NULL COMMENT '投诉次数',
- lcptdate date DEFAULT NULL COMMENT '最近投诉时间',
- lcptreason string DEFAULT NULL COMMENT '最近投诉原因',
- lcptlink string DEFAULT NULL COMMENT '最近投诉环节',
- lcptresult string DEFAULT NULL COMMENT '最近投诉处理结果',
- lcptduration decimal(8,2) DEFAULT NULL COMMENT '最近投诉处理时长',
- lcptperson string DEFAULT NULL COMMENT '最近投诉人',
- soppremium decimal(32,8) DEFAULT NULL COMMENT '累计已缴保费',
- lappdate date DEFAULT NULL COMMENT '最近投保日期',
- cndate date DEFAULT NULL COMMENT '最近报案日期',
- cnstatus string DEFAULT NULL COMMENT '最近报案状态',
- cocnotification int DEFAULT NULL COMMENT '报案登录数量',
- fadate date DEFAULT NULL COMMENT '首次投保日期',
- ladate date DEFAULT NULL COMMENT '最近投保日期',
- lpno string DEFAULT NULL COMMENT '最近保险单号',
- lpstate string DEFAULT NULL COMMENT '最近保单状态',
- lpname string DEFAULT NULL COMMENT '最近投保险种名称',
- copolicy int DEFAULT NULL COMMENT '保单登录数量',
- iaccno1 string DEFAULT NULL COMMENT '保险账户1',
- iaccno2 string DEFAULT NULL COMMENT '保险账户2',
- iaccno3 string DEFAULT NULL COMMENT '保险账户3',
- soiaccount1 decimal(32,8) DEFAULT NULL COMMENT '保险账户1余额',
- soiaccount2 decimal(32,8) DEFAULT NULL COMMENT '保险账户2余额',
- soiaccount3 decimal(32,8) DEFAULT NULL COMMENT '保险账户3余额',
- coiaccount int DEFAULT NULL COMMENT '保险账户登录数量',
- Label1 string COMMENT 'Label1' ,
- Label2 string COMMENT 'Label2' ,
- Label3 string COMMENT 'Label3' ,
- Label4 string COMMENT 'Label4' ,
- Label5 string COMMENT 'Label5' ,
- Label6 string COMMENT 'Label6' ,
- Label7 string COMMENT 'Label7' ,
- Label8 string COMMENT 'Label8' ,
- Label9 string COMMENT 'Label9' ,
- Label10 string COMMENT 'Label10' ,
- Label11 string COMMENT 'Label11' ,
- Label12 string COMMENT 'Label12' ,
- Label13 string COMMENT 'Label13' ,
- Label14 string COMMENT 'Label14' ,
- Label15 string COMMENT 'Label15' ,
- Label16 string COMMENT 'Label16' ,
- Label17 string COMMENT 'Label17' ,
- Label18 string COMMENT 'Label18' ,
- Label19 string COMMENT 'Label19' ,
- Label20 string COMMENT 'Label20' ,
- Label21 string COMMENT 'Label21' ,
- Label22 string COMMENT 'Label22' ,
- Label23 string COMMENT 'Label23' ,
- Label24 string COMMENT 'Label24' ,
- Label25 string COMMENT 'Label25' ,
- Label26 string COMMENT 'Label26' ,
- Label27 string COMMENT 'Label27' ,
- Label28 string COMMENT 'Label28' ,
- Label29 string COMMENT 'Label29' ,
- Label30 string COMMENT 'Label30' ,
- Label31 string COMMENT 'Label31' ,
- Label32 string COMMENT 'Label32' ,
- Label33 string COMMENT 'Label33' ,
- Label34 string COMMENT 'Label34' ,
- Label35 string COMMENT 'Label35' ,
- Label36 string COMMENT 'Label36' ,
- Label37 string COMMENT 'Label37' ,
- Label38 string COMMENT 'Label38' ,
- Label39 string COMMENT 'Label39' ,
- Label40 string COMMENT 'Label40' ,
- Label41 string COMMENT 'Label41' ,
- Label42 string COMMENT 'Label42' ,
- Label43 string COMMENT 'Label43' ,
- Label44 string COMMENT 'Label44' ,
- Label45 string COMMENT 'Label45' ,
- Label46 string COMMENT 'Label46' ,
- Label47 string COMMENT 'Label47' ,
- Label48 string COMMENT 'Label48' ,
- Label49 string COMMENT 'Label49' ,
- Label50 string COMMENT 'Label50' ,
- Label51 string COMMENT 'Label51' ,
- Label52 string COMMENT 'Label52' ,
- Label53 string COMMENT 'Label53' ,
- Label54 string COMMENT 'Label54' ,
- Label55 string COMMENT 'Label55' ,
- Label56 string COMMENT 'Label56' ,
- Label57 string COMMENT 'Label57' ,
- Label58 string COMMENT 'Label58' ,
- Label59 string COMMENT 'Label59' ,
- Label60 string COMMENT 'Label60' ,
- Label61 string COMMENT 'Label61' ,
- Label62 string COMMENT 'Label62' ,
- Label63 string COMMENT 'Label63' ,
- Label64 string COMMENT 'Label64' ,
- Label65 string COMMENT 'Label65' ,
- Label66 string COMMENT 'Label66' ,
- Label67 string COMMENT 'Label67' ,
- Label68 string COMMENT 'Label68' ,
- Label69 string COMMENT 'Label69' ,
- Label70 string COMMENT 'Label70' ,
- Label71 string COMMENT 'Label71' ,
- Label72 string COMMENT 'Label72' ,
- Label73 string COMMENT 'Label73' ,
- Label74 string COMMENT 'Label74' ,
- Label75 string COMMENT 'Label75' ,
- Label76 string COMMENT 'Label76' ,
- Label77 string COMMENT 'Label77' ,
- Label78 string COMMENT 'Label78' ,
- Label79 string COMMENT 'Label79' ,
- Label80 string COMMENT 'Label80' ,
- Label81 string COMMENT 'Label81' ,
- Label82 string COMMENT 'Label82' ,
- Label83 string COMMENT 'Label83' ,
- Label84 string COMMENT 'Label84' ,
- Label85 string COMMENT 'Label85' ,
- Label86 string COMMENT 'Label86' ,
- Label87 string COMMENT 'Label87' ,
- Label88 string COMMENT 'Label88' ,
- Label89 string COMMENT 'Label89' ,
- Label90 string COMMENT 'Label90' ,
- Label91 string COMMENT 'Label91' ,
- Label92 string COMMENT 'Label92' ,
- Label93 string COMMENT 'Label93' ,
- Label94 string COMMENT 'Label94' ,
- Label95 string COMMENT 'Label95' ,
- Label96 string COMMENT 'Label96' ,
- Label97 string COMMENT 'Label97' ,
- Label98 string COMMENT 'Label98' ,
- Label99 string COMMENT 'Label99' ,
- Label100 string COMMENT 'Label100' ,
- Label101 string COMMENT 'Label101' ,
- Label102 string COMMENT 'Label102' ,
- Label103 string COMMENT 'Label103' ,
- Label104 string COMMENT 'Label104' ,
- Label105 string COMMENT 'Label105' ,
- Label106 string COMMENT 'Label106' ,
- Label107 string COMMENT 'Label107' ,
- Label108 string COMMENT 'Label108' ,
- Label109 string COMMENT 'Label109' ,
- Label110 string COMMENT 'Label110' ,
- Label111 string COMMENT 'Label111' ,
- Label112 string COMMENT 'Label112' ,
- Label113 string COMMENT 'Label113' ,
- Label114 string COMMENT 'Label114' ,
- Label115 string COMMENT 'Label115' ,
- Label116 string COMMENT 'Label116' ,
- Label117 string COMMENT 'Label117' ,
- Label118 string COMMENT 'Label118' ,
- Label119 string COMMENT 'Label119' ,
- Label120 string COMMENT 'Label120'
- )
- COMMENT '个人信息'
- STORED AS ES
- with shard number 10
- replication 1;
- DROP SEQUENCE IF EXISTS globaleCusId_sequence;
- CREATE SEQUENCE globaleCusId_sequence
- INCREMENT BY 1
- START WITH 1
- NOMAXVALUE
- NOMINVALUE
- NOCYCLE
- CACHE 1;
- !set plsqlUseSlash true
- CREATE OR REPLACE PROCEDURE test_insert_individual_search_1()
- IS
- DECLARE
-
- TYPE main_columns_type IS RECORD (scustid string, name string,gender string,birthday timestamp,idtype int,idcard string)
- mainrecord main_columns_type
-
- t_record t_customer_class%ROWTYPE
- cnt int
- cnt_t int
- custid_tmp string
- CURSOR main_cursor IS
-
- select scustid ,name,gender ,birthday,idtype,idcard
- from (
- SELECT
- CUSTOMERNO AS scustid,
- NAME AS name,
- sex AS gender,
- BIRTHDAY AS birthday,
- IDTYPE AS idtype ,
- IDNO AS idcard
- FROM
- policy_information
- UNION
- SELECT
- INSUREDNO AS scustid,
- INSUREDNAME AS name,
- INSUREDSEX AS gender,
- INSUREDBIRTHDAY AS birthday,
- INSUREDIDTYPE AS idtype ,
- INSUREDIDNO AS idcard
- FROM
- policy_information
- ) tmpTable
- WHERE scustid IS NOT NULL
- group by scustid ,name,gender ,birthday,idtype,idcard
- LIMIT 0,100;
- BEGIN
- OPEN main_cursor;
- LOOP
- FETCH main_cursor INTO mainrecord;
-
- if mainrecord.idtype !=0 then
- mainrecord.idcard := null
- end if
-
- select count(1) into cnt from individual_search where scustid = mainrecord.scustid and name = mainrecord.name and birthday = mainrecord.birthday
- and gender = mainrecord.gender and idcard = mainrecord.idcard
- if cnt ==0 then
-
- custid_tmp:='CP'||lpad(globaleCusId_sequence.nextval,10,'0')
-
- select count(1) into cnt_t from t_customer_class where CUSTOMER_ID = mainrecord.scustid ;
- if cnt_t ==0 then
- t_record.CLASS_VALUE:=0;
- t_record.CONTRIBUTION_VALUE:=0;
- t_record.Awarded3:=0;
- t_record.AWARDED2:=0;
- t_record.AWARDED1:=0;
- t_record.TOTAL_VALUE:=0;
- t_record.end_date:=null;
- else
-
- end if
-
- Insert into individual_search(
- CREATED_BY ,
- CREATED_TIME ,
- UPDATED_BY ,
- UPDATED_TIME ,
-
- CustID ,
- SCustID,
- Name ,
- Birthday ,
- Gender ,
-
- IDCard ,
-
- CustClass ,
- ConValue ,
- Awarded3 ,
- Awarded2 ,
- Awarded1 ,
- SOValue ,
- EndDate
- )values(
- 'qxp' ,
- SYSDATE ,
- NULL ,
- SYSDATE ,
-
- custid_tmp,
- mainrecord.scustid,
- mainrecord.Name,
- mainrecord.Birthday,
- mainrecord.gender,
-
- mainrecord.IDCard,
-
- t_record.CLASS_VALUE,
- t_record.CONTRIBUTION_VALUE,
- t_record.Awarded3,
- t_record.AWARDED2,
- t_record.AWARDED1,
- t_record.TOTAL_VALUE,
- t_record.end_date
- )
- end if
- cnt :=0
- EXIT WHEN main_cursor%NOTFOUND
- END LOOP;
- CLOSE main_cursor;
- END;
- CREATE OR REPLACE PROCEDURE test_etl_main_1()
- IS
- BEGIN
- test_insert_individual_search_2();
- test_up_t_customers_class_1();
- END;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE test_insert_individual_search_2()
- IS
- DECLARE
- BEGIN
- MERGE INTO individual_search is1 using
- (
- SELECT scustid ,name,gender ,birthday, idcard
- FROM (
- SELECT
- customerno AS scustid,
- name AS name,
- sex AS gender,
- birthday AS birthday,
- idtype AS idtype ,
- idno AS idcard
- FROM
- policy_information
- WHERE customerno IS NOT NULL AND idtype=0
- UNION
- SELECT
- insuredno AS scustid,
- insuredname AS name,
- insuredsex AS gender,
- insuredbirthday AS birthday,
- insuredidtype AS idtype ,
- insuredidno AS idcard
- FROM
- policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=0
- ) tmpTable
- LIMIT IN 0,100000
- ) is2 on (is2.scustid = is1.scustid and is2.name = is1.name
- and is2.gender = is1.gender and is2.birthday = is1.birthday and is2.idcard = is1.idcard)
- WHEN NOT MATCHED THEN INSERT (
- scustid,
- name,
- gender,
- birthday,
- idcard,
-
- custid,
- indid,
- created_time,
- created_by
- ) VALUES (
- is2.scustid,
- is2.name,
- is2.gender,
- is2.birthday,
- is2.idcard,
- 'CP'||lpad(globaleCusId_sequence.nextval,10,'0'),
- globaleCusId_sequence.CURRVAL,
- sysdate,
- 'qxp'
- )
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('test_insert_individual_search_2',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('test_insert_individual_search_2',sqlerrm(),sqlcode())
- END;
- =============================================================================================================================================================
- ==============================================================利用行号全部插入用户数据==========================================================================
- =============================================================================================================================================================
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE init_individual_search_main()
- IS
- DECLARE
- individual_count int
- strsql string
- BEGIN
-
-
- init_individual_search_0(individual_count);
-
- individual_count:=individual_count+1;
- init_individual_search_1(individual_count);
-
- individual_count:=individual_count+1;
- init_individual_search_3(individual_count);
-
- individual_count:=individual_count+1;
- init_individual_search_other(individual_count);
-
- individual_count:=individual_count+1;
-
- strsql:='
- DROP SEQUENCE IF EXISTS globaleCusId_sequence;
- CREATE SEQUENCE globaleCusId_sequence
- INCREMENT BY 1
- START WITH '|| individual_count||'
- NOMAXVALUE
- NOMINVALUE
- NOCYCLE
- CACHE 1;
- ';
- EXECUTE IMMEDIATE strsql
-
- test_up_t_customers_class_1();
-
-
- up_health_insurance_listing_1();
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_individual_search_main',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_individual_search_main',sqlerrm(),sqlcode())
- END;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE init_individual_search_0( individual_count OUT int)
- IS
- BEGIN
-
-
- insert into individual_search1 (
- indid,
- custid,
- scustid,
- name,
- gender,
- birthday,
- idcard,
- created_time,
- created_by
- )
- SELECT
- row_number()over(),
- 'CP'||lpad(row_number()over(),10,'0'),
- scustid ,
- name,
- gender ,
- birthday,
- idcard ,
-
- sysdate,
- 'qxp'
- FROM (
- SELECT
- customerno AS scustid,
- name AS name,
- sex AS gender,
- birthday AS birthday,
- idtype AS idtype ,
- idno AS idcard
- FROM
- policy_information
- WHERE customerno IS NOT NULL AND idtype=0
- UNION
- SELECT
- insuredno AS scustid,
- insuredname AS name,
- insuredsex AS gender,
- insuredbirthday AS birthday,
- insuredidtype AS idtype ,
- insuredidno AS idcard
- FROM
- policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=0
- ) tmpTable
-
- select count(0) into individual_count from individual_search1
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_individual_search_0',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_individual_search_0',sqlerrm(),sqlcode())
- END;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE init_individual_search_1(individual_count INOUT int)
- IS
- BEGIN
-
-
- insert into individual_search1 (
- indid,
- custid,
-
- scustid,
- name,
- gender,
- birthday,
- passport,
-
-
- created_time,
- created_by
- )
- SELECT
- row_number()over()+individual_count,
- 'CP'||lpad(row_number()over()+individual_count,10,'0'),
- scustid ,
- name,
- gender ,
- birthday,
- idcard ,
- sysdate,
- 'qxp'
- FROM (
- SELECT
- customerno AS scustid,
- name AS name,
- sex AS gender,
- birthday AS birthday,
- idtype AS idtype ,
- idno AS idcard
- FROM
- policy_information
- WHERE customerno IS NOT NULL AND idtype=1
- UNION
- SELECT
- insuredno AS scustid,
- insuredname AS name,
- insuredsex AS gender,
- insuredbirthday AS birthday,
- insuredidtype AS idtype ,
- insuredidno AS idcard
- FROM
- policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=1
- ) tmpTable
-
- select count(0) into individual_count from individual_search1
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_individual_search_1',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_individual_search_1',sqlerrm(),sqlcode())
- END;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE init_individual_search_3(individual_count INOUT int)
- IS
- BEGIN
-
-
- insert into individual_search1(
- indid,
- custid,
- scustid,
- name,
- gender,
- birthday,
- dlicense,
- created_time,
- created_by
- )
- SELECT
- row_number()over()+individual_count,
- 'CP'||lpad(row_number()over()+individual_count,10,'0'),
-
- scustid ,
- name,
- gender ,
- birthday,
- idcard ,
-
- sysdate,
- 'qxp'
- FROM (
- SELECT
- customerno AS scustid,
- name AS name,
- sex AS gender,
- birthday AS birthday,
- idtype AS idtype ,
- idno AS idcard
- FROM
- policy_information
- WHERE customerno IS NOT NULL AND idtype=3
- UNION
- SELECT
- insuredno AS scustid,
- insuredname AS name,
- insuredsex AS gender,
- insuredbirthday AS birthday,
- insuredidtype AS idtype ,
- insuredidno AS idcard
- FROM
- policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype=3
- ) tmpTable
-
- select count(0) into individual_count from individual_search1
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_individual_search_3',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_individual_search_3',sqlerrm(),sqlcode())
- END;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE init_individual_search_other(individual_count INOUT int)
- IS
- BEGIN
-
-
- insert into individual_search1(
- indid,
- custid,
-
- scustid,
- name,
- gender,
- birthday,
-
-
- created_time,
- created_by
- )
- SELECT
- row_number()over()+individual_count,
- 'CP'||lpad(row_number()over()+individual_count,10,'0'),
- scustid ,
- name,
- gender ,
- birthday,
- sysdate,
- 'qxp'
- FROM (
- SELECT
- customerno AS scustid,
- name AS name,
- sex AS gender,
- birthday AS birthday,
- idtype AS idtype ,
- idno AS idcard
- FROM
- policy_information
- WHERE customerno IS NOT NULL AND idtype not in (0,1,3)
- UNION
- SELECT
- insuredno AS scustid,
- insuredname AS name,
- insuredsex AS gender,
- insuredbirthday AS birthday,
- insuredidtype AS idtype ,
- insuredidno AS idcard
- FROM
- policy_information
- WHERE insuredno IS NOT NULL AND insuredidtype in (0,1,3)
- ) tmpTable
-
- select count(0) into individual_count from individual_search1
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('init_individual_search_other',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('init_individual_search_other',sqlerrm(),sqlcode())
- END;
- !set plsqlUseSlash true
- SET plsql.catch.hive.exception=true;
- CREATE OR REPLACE PROCEDURE test_up_t_customers_class_1()
- IS
- BEGIN
- UPDATE individual_search1 a SET (
- CustClass ,
- ConValue ,
- Awarded3 ,
- Awarded2 ,
- Awarded1 ,
- SOValue ,
- EndDate
- ) = (
- select
- CLASS_VALUE ,
- CONTRIBUTION_VALUE ,
- AWARDED3,
- AWARDED2,
- AWARDED1,
- TOTAL_VALUE,
- END_DATE
- from t_customer_class b
- where b.CUSTOMER_ID = a.scustid;
- ) WHERE 1=1 ;
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('test_up_t_customers_class_1',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('test_up_t_customers_class_1',sqlerrm(),sqlcode())
- END;
- /
- DROP TABLE IF EXISTS occupation_tmp;
- CREATE TABLE occupation_tmp(
- scustid string not NULL COMMENT '客户号',
- OccupationId string DEFAULT NULL COMMENT '名称',
- Occupation string DEFAULT NULL COMMENT '出生日期' ,
- HomeAdress string DEFAULT NULL COMMENT '籍贯'
- )
- COMMENT 'occupation_tmp 客户职业临时表' STORED AS ES
- with shard number 10
- replication 1;
- CREATE OR REPLACE PROCEDURE up_health_insurance_listing_1()
- IS
- BEGIN
-
- delete occupation_tmp;
-
- insert into occupation_tmp(
- scustid,
- OccupationId,
- Occupation,
- HomeAdress
- )
- select
- appntno,
- appntoccupationcode ,
- appntoccupationname ,
- APPNTHOMEADDRESS
- from HEALTH_INSURANCE_LISTING
- WHERE appntoccupationcode is not null
- and appntoccupationname is not null
- group by appntno,appntoccupationcode,appntoccupationname,APPNTHOMEADDRESS
-
- UPDATE individual_search1 a SET (
- OccupationId ,
- Occupation,
- HomeAdress
- ) = (
- select
- OccupationId ,
- Occupation,
- APPNTHOMEADDRESS
- from occupation_tmp b
- where b.scustid = a.scustid
- ) WHERE 1=1 ;
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('up_health_insurance_listing_1',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('up_health_insurance_listing_1',sqlerrm(),sqlcode())
- END;
- =======================================================================================================================================
- ===================================================用户关系信息解析插入====================================================================
- =======================================================================================================================================
- CREATE OR REPLACE PROCEDURE up_individual_relationship()
- IS
- BEGIN
-
-
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('up_individual_relationship',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('up_individual_relationship',sqlerrm(),sqlcode())
- END;
- =======================================================================================================================================
- ===================================================用户上游客户ID去重临时表====================================================================
- =======================================================================================================================================
- DROP TABLE IF EXISTS scustid_unique_tmp;
- CREATE TABLE scustid_unique_tmp(
- scustid string COMMENT '上游客户号' ,
- indid string COMMENT '客户号'
- )
- COMMENT '用户上游客户ID去重临时表'
- STORED AS ES
- with shard number 10
- replication 1;
- CREATE OR REPLACE PROCEDURE up_scustid_unique_tmp()
- IS
- BEGIN
-
- delete from scustid_unique_tmp;
-
- insert into scustid_unique_tmp(scustid,indid)
- select scustid,min(indid) from individual_search1 group by scustid;
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- log_exception('up_scustid_unique_tmp',sqlerrm(),sqlcode())
- WHEN Others THEN
- log_exception('up_scustid_unique_tmp',sqlerrm(),sqlcode())
- END;
- =====================================================================================================================
- 1,105,462
- 1,105,500
- 1,119,154
- 1,119,154
- row_number()over() 行号
|