保单qxp.sql 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. --数据源 policy_information 表结构
  2. -- CREATE TABLE shanghailifeecif.policy_information(
  3. -- contno varchar2(200) DEFAULT NULL COMMENT '保单号', -- dialect: ORACLE
  4. -- riskcode varchar2(200) DEFAULT NULL COMMENT '险种代码', -- dialect: ORACLE
  5. -- riskname varchar2(200) DEFAULT NULL COMMENT '险种名称', -- dialect: ORACLE
  6. -- riskperiod varchar2(200) DEFAULT NULL COMMENT '险种分类', -- dialect: ORACLE
  7. -- risktype varchar2(200) DEFAULT NULL COMMENT '险种设计类型', -- dialect: ORACLE
  8. -- payintv varchar2(200) DEFAULT NULL COMMENT '缴费方式', -- dialect: ORACLE
  9. -- security varchar2(200) DEFAULT NULL COMMENT '保障年期', -- dialect: ORACLE
  10. -- payendyear decimal(10,2) DEFAULT NULL COMMENT '缴费年期',
  11. -- payendyearflag varchar2(200) DEFAULT NULL COMMENT '缴费年期单位', -- dialect: ORACLE
  12. -- insuyear decimal(10,2) DEFAULT NULL COMMENT '保险年期',
  13. -- insuyearflag varchar2(200) DEFAULT NULL COMMENT '保险年期单位', -- dialect: ORACLE
  14. -- paycount decimal(10,2) DEFAULT NULL COMMENT '续保次数',
  15. -- signdate string DEFAULT NULL COMMENT '承保日期',
  16. -- cvalidate string DEFAULT NULL COMMENT '保单生效日期',
  17. -- enddate string DEFAULT NULL COMMENT '保单终止日期',
  18. -- modifydate string DEFAULT NULL COMMENT '修改日期',
  19. -- prem decimal(10,2) DEFAULT NULL COMMENT '保费',
  20. -- appflag varchar2(200) DEFAULT NULL COMMENT '保单状态', -- dialect: ORACLE
  21. -- customerno varchar2(200) DEFAULT NULL COMMENT '客户号', -- dialect: ORACLE
  22. -- name varchar2(200) DEFAULT NULL COMMENT '客户姓名', -- dialect: ORACLE
  23. -- sex varchar2(200) DEFAULT NULL COMMENT '客户性别', -- dialect: ORACLE
  24. -- birthday string DEFAULT NULL COMMENT '客户出生日期',
  25. -- idtype varchar2(200) DEFAULT NULL COMMENT '证件类型', -- dialect: ORACLE
  26. -- idno varchar2(200) DEFAULT NULL COMMENT '证件号码', -- dialect: ORACLE
  27. -- insuredno varchar2(200) DEFAULT NULL COMMENT '被保人号', -- dialect: ORACLE
  28. -- insuredname varchar2(200) DEFAULT NULL COMMENT '被保人姓名', -- dialect: ORACLE
  29. -- insuredsex varchar2(200) DEFAULT NULL COMMENT '被保人性别', -- dialect: ORACLE
  30. -- insuredbirthday string DEFAULT NULL COMMENT '被保人出生日期',
  31. -- insuredidtype varchar2(200) DEFAULT NULL COMMENT '被保人证件类型', -- dialect: ORACLE
  32. -- insuredidno varchar2(200) DEFAULT NULL COMMENT '被保人证件号码', -- dialect: ORACLE
  33. -- relationtoappnt varchar2(200) DEFAULT NULL COMMENT '与投保人关系', -- dialect: ORACLE
  34. -- salechnl varchar2(200) DEFAULT NULL COMMENT '销售渠道', -- dialect: ORACLE
  35. -- salecom varchar2(200) DEFAULT NULL COMMENT '业绩归属', -- dialect: ORACLE
  36. -- salechannels varchar2(200) DEFAULT NULL COMMENT '二级业绩归属', -- dialect: ORACLE
  37. -- customgetpoldate string DEFAULT NULL COMMENT '客户投保日期',
  38. -- prem_js decimal(10,2) DEFAULT NULL COMMENT ''
  39. -- )
  40. ======================================================================================================================================================
  41. --创建保单表insurancearrangement
  42. DROP TABLE IF EXISTS insurancearrangement;
  43. CREATE TABLE insurancearrangement(
  44. iaid string NOT NULL COMMENT '保单ID',
  45. policyno string DEFAULT NULL COMMENT '保险单号 INSURANCEINFO.CONTNO',
  46. pano string DEFAULT NULL COMMENT '投保单号 INSURANCEINFO.PRTNO',
  47. agrmntage string DEFAULT NULL COMMENT '保险期限',
  48. pbinst string DEFAULT NULL COMMENT '受益分配方式',
  49. pwcomp string DEFAULT NULL COMMENT '承保分公司 HEALTH_INSURANCE_LISTING.AGENTGROUPAREA 营业区HEALTH_INSURANCE_LISTING.AGENTGROUP 营业部',
  50. pindate date DEFAULT NULL COMMENT '起保日期 POLICY_INFORMATION.CVALIDATE',
  51. pmdate date DEFAULT NULL COMMENT '终保日期 POLICY_INFORMATION.ENDDATE',
  52. pisdate date DEFAULT NULL COMMENT '签单日期 INSURANCEINFO.SIGNDATE',
  53. padate date DEFAULT NULL COMMENT '投保日期 INSURANCEINFO.POLAPPLYDATE',
  54. renewaldate date DEFAULT NULL COMMENT '续保日期',
  55. norenewal int DEFAULT NULL COMMENT '续保次数 POLICY_INFORMATION.PAYCOUNT',
  56. policytype string DEFAULT NULL COMMENT '保单类型 PERSONAL_INSURANCE.CONTTYPE,需上游给出类型枚举值',
  57. schannel string DEFAULT NULL COMMENT '销售渠道 HEALTH_INSURANCE_LISTING.SALECHANNELS 1 2 3 4 5',
  58. bsource string DEFAULT NULL COMMENT '业务来源',
  59. policystate string DEFAULT NULL COMMENT '保单状态 保单包括投保单的所处的状态,例如:录入、生效、批单等 INSURANCEINFO.APPFLAG code 0 1 2 4 9 B F',
  60. topay string DEFAULT NULL COMMENT '缴费类型',
  61. payment string DEFAULT NULL COMMENT '缴费方式 POLICY_INFORMATION.PAYINTV',
  62. risk double DEFAULT NULL COMMENT '总保额 HEALTH_INSURANCE_LISTING.AMNT(测试环境中,此表保单数据量较其他表如:POLICY_INFORMATION,INSURANCEINFO 缺少至少一个数据量级)',
  63. prem double DEFAULT NULL COMMENT '总保费 INSURANCEINFO.PREM',
  64. currency string DEFAULT NULL COMMENT '币种',
  65. npdate date DEFAULT NULL COMMENT '下次缴费日期',
  66. soinsured int DEFAULT NULL COMMENT '被保人数 HEALTH_GROUP_LISTING.PEOPLES3,团单',
  67. bsinsured double DEFAULT NULL COMMENT '基本保额 保险合同条款费率表中载明的单位保额。比如中国人寿的康宁终身保险就是这样,如果购买的基本保险金额是10万的话,那么大病的保险金额就是基本保险金额的2倍即20万;',
  68. insurvalue double DEFAULT NULL COMMENT '保单价值 保单价值,即保单现金价值。是指带有储蓄性质的人身bai保险单所具有的价值。保险人为履行合同责任通常提存责任准备金,如果您中途退保,即以该保单的责任准备金作为给付解约的退还金。被保险人要求解约或退保时,寿险公司应该发还的金额。
  69. 在长期寿险契约中,保险人为履行契约责任,通常需要提存一定数额的责任准备金。当被保险人于保险有效期内因故要求解约或退保时,保险人按规定,将提存的责任准备金减去解约扣除后的余额退还给被保险人,这部分余额即解约金,亦即退保时保单所具有的现金价值。',
  70. applicantid string DEFAULT NULL COMMENT '投保人 根据POLICY_INFORMATION.CUSTOMERNO关联individual上游客户号,再找到individualid',
  71. applicantscustid string DEFAULT NULL COMMENT '投保人上游客户号',
  72. appname string DEFAULT NULL COMMENT '投保人名称 POLICY_INFORMATION.NAME',
  73. appphone string DEFAULT NULL COMMENT '投保人手机',
  74. appcertid string DEFAULT NULL COMMENT '投保人证件号码 POLICY_INFORMATION.IDNO',
  75. insuredid string DEFAULT NULL COMMENT '主被保险人 客户号',
  76. insuredscustid string DEFAULT NULL COMMENT '主被保险人 上游客户号POLICY_INFORMATION.insuredno',
  77. insname string DEFAULT NULL COMMENT '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  78. insphone string DEFAULT NULL COMMENT '主被保险人手机',
  79. inscertid string DEFAULT NULL COMMENT '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  80. productid string DEFAULT NULL COMMENT '险种代码 POLICY_INFORMATION.RISKCODE',
  81. productname string DEFAULT NULL COMMENT '险种名称 INSURANCEINFO.RISKNAME',
  82. salesperson string DEFAULT NULL COMMENT '业务员',
  83. spname string DEFAULT NULL COMMENT '业务员名称 HEALTH_INSURANCE_LISTING.AGENTCODE',
  84. iaccount string DEFAULT NULL COMMENT '所属保险账户',
  85. branchcode string DEFAULT NULL COMMENT '机构代码',
  86. policybelong string DEFAULT NULL COMMENT '业绩归属 POLICY_INFORMATION.SALECOM',
  87. agentchannel string DEFAULT NULL COMMENT '代理渠道 INSURANCEINFO.SELLTYPE',
  88. agentorg string DEFAULT NULL COMMENT '代理机构',
  89. regtype string DEFAULT NULL COMMENT '户籍类型',
  90. pincome string DEFAULT NULL COMMENT '个人年收入',
  91. fincome double DEFAULT NULL COMMENT '家庭年收入',
  92. incomesource string DEFAULT NULL COMMENT '收入来源',
  93. socialinsurance string DEFAULT NULL COMMENT '是否有社保',
  94. oipolicy string DEFAULT NULL COMMENT '是否投保其他保险公司',
  95. oicompany string DEFAULT NULL COMMENT '其他保险公司',
  96. oicproduct string DEFAULT NULL COMMENT '其他保险公司险种',
  97. oiamount double DEFAULT NULL COMMENT '其他保险公司保额',
  98. drinking string DEFAULT NULL COMMENT '是否饮酒',
  99. dfavor string DEFAULT NULL COMMENT '饮酒喜好',
  100. poservice string DEFAULT NULL COMMENT '是否保全 投保人持有保单是否在AUDIT_EDORLIST.CONTNO存在',
  101. payendyear int DEFAULT NULL COMMENT '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  102. loanmoney double DEFAULT NULL COMMENT '保单质押贷款金额 AUDIT_LN_LIST.LNMONEY ',
  103. paydate date DEFAULT NULL COMMENT '缴至日期',
  104. created_by string DEFAULT NULL COMMENT '创建人',
  105. created_time date DEFAULT NULL COMMENT '创建时间',
  106. updated_by string DEFAULT NULL COMMENT '更新人',
  107. updated_time date DEFAULT NULL COMMENT '更新时间'
  108. )
  109. COMMENT '保单 确定参与方之间,参与方和保险公司之间的协议,使相关各方能在遵守一定的规则并履行相关义务的前提下进行产品或资源或服务的供给'
  110. STORED AS ES
  111. with shard number 10
  112. replication 1;
  113. ===================================================================================================================================================
  114. =============================================================存储主过程=============================================================================
  115. ===================================================================================================================================================
  116. CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement() -- 创建主存储过程
  117. IS
  118. BEGIN
  119. --根据policy_information 更新保单表
  120. shanglifeecif.init_insurancearrangement_policy_information();
  121. --根据health_insurance_listing 更新相关字段
  122. shanglifeecif.up_insurancearrangement_health_insurance_listing();
  123. --其他标的字段 更新
  124. shanglifeecif.up_insurancearrangement_other();
  125. EXCEPTION
  126. WHEN HIVE_EXCEPTION THEN
  127. log_exception('init_insurancearrangement',sqlerrm(),sqlcode())
  128. WHEN Others THEN
  129. log_exception('init_insurancearrangement',sqlerrm(),sqlcode())
  130. END;
  131. CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement_policy_information() -- 创建主存储过程
  132. IS
  133. BEGIN
  134. INSERT INTO shanglifeecif.insurancearrangement(
  135. iaid ,--'保单ID',
  136. policyno ,-- '保险单号 INSURANCEINFO.CONTNO',
  137. pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE',
  138. pmdate ,-- '终保日期 POLICY_INFORMATION.ENDDATE',
  139. norenewal ,-- '续保次数 POLICY_INFORMATION.PAYCOUNT',
  140. payment ,-- '缴费方式 POLICY_INFORMATION.PAYINTV',
  141. applicantscustid ,-- '投保人 上游客户号,再找到individualid',
  142. appname ,-- '投保人名称 POLICY_INFORMATION.NAME',
  143. appcertid ,-- '投保人证件号码 POLICY_INFORMATION.IDNO',
  144. insuredscustid ,-- '主被保险人 游客户号',
  145. insname ,-- '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  146. inscertid ,-- '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  147. productid ,-- '险种代码 POLICY_INFORMATION.RISKCODE',
  148. policybelong ,-- '业绩归属 POLICY_INFORMATION.SALECOM',
  149. payendyear ,-- '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  150. agrmntage ,--保险期限
  151. created_by ,-- '创建人',
  152. created_time -- '创建时间',
  153. )
  154. SELECT
  155. row_number()over(),
  156. CONTNO,--policyno ,-- '保险单号 INSURANCEINFO.CONTNO',
  157. CVALIDATE,--pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE',
  158. ENDDATE,--pmdate ,-- '终保日期 POLICY_INFORMATION.ENDDATE',
  159. PAYCOUNT,--norenewal ,-- '续保次数 POLICY_INFORMATION.PAYCOUNT',
  160. PAYINTV,--payment ,-- '缴费方式 POLICY_INFORMATION.PAYINTV',
  161. CUSTOMERNO,--applicantid ,-- '投保人 根据POLICY_INFORMATION.CUSTOMERNO关联individual上游客户号,再找到individualid',
  162. NAME,--appname ,-- '投保人名称 POLICY_INFORMATION.NAME',
  163. IDNO,--appcertid ,-- '投保人证件号码 POLICY_INFORMATION.IDNO',
  164. insuredno,--insuredid ,-- '主被保险人 insuredno',
  165. INSUREDNAME,--insname ,-- '主被保险人名称 POLICY_INFORMATION.INSUREDNAME',
  166. INSUREDIDNO,--inscertid ,-- '主被保险人证件号码 POLICY_INFORMATION.INSUREDIDNO',
  167. RISKCODE,--productid ,-- '险种代码 POLICY_INFORMATION.RISKCODE',
  168. SALECOM,--policybelong ,-- '业绩归属 POLICY_INFORMATION.SALECOM',
  169. PAYENDYEAR,--payendyear ,-- '缴费年期 POLICY_INFORMATION.PAYENDYEAR',
  170. case
  171. when security ='终身' then 42720
  172. when security = '至100周岁' then 36500
  173. when security = '至80周岁' then 29200
  174. when security = '70年' then 25550
  175. when security = '至70周岁' then 25550
  176. when security = '至65周岁' then 23725
  177. when security = '至60周岁' then 21900
  178. when security = '30年' then 10950
  179. when security = '20年' then 7300
  180. when security = '10年' then 3650
  181. when security = '6年' then 2190
  182. when security = '5年' then 1825
  183. when security = '1年' then 365
  184. when security = '180天' then 180
  185. when security = '6月' then 180
  186. when security = '90天' then 90
  187. when security = '3月' then 90
  188. when security = '1月' then 30
  189. when security = '30天' then 30
  190. when security = '15天' then 15
  191. when security = '7天' then 7
  192. end,
  193. 'admin',
  194. sysdate()
  195. FROM policy_information
  196. --更新投保人和被保人id 因为 scustid有重复所以需要去下重
  197. UPDATE shanglifeecif.insurancearrangement a SET (
  198. applicantid --'投保人ID',
  199. ) = (
  200. select
  201. c.indid
  202. from (
  203. select
  204. row_number()over(PARTITION BY b.scustid) rn,
  205. b.indid,
  206. b.scustid
  207. from shanglifeecif.individual b
  208. ) c
  209. WHERE c.scustid = a.applicantscustid and c.rn=1
  210. ) WHERE 1=1 ;
  211. UPDATE shanglifeecif.insurancearrangement a SET (
  212. insuredid --'投保人ID',
  213. ) = (
  214. select
  215. c.indid
  216. from (
  217. select
  218. row_number()over(PARTITION BY b.scustid) rn,
  219. b.indid,
  220. b.scustid
  221. from shanglifeecif.individual b
  222. ) c
  223. WHERE c.scustid = a.insuredscustid and c.rn=1
  224. ) WHERE 1=1 ;
  225. --更新INSURANCEINFO 表中的信息
  226. UPDATE shanglifeecif.insurancearrangement a SET (
  227. pano ,-- '投保单号 INSURANCEINFO.PRTNO',
  228. pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE',
  229. padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE',
  230. policystate ,--INSURANCEINFO,appflag
  231. prem ,-- '总保费 INSURANCEINFO.PREM',
  232. productname ,-- '险种名称 INSURANCEINFO.RISKNAME'
  233. agentchannel -- '代理渠道 INSURANCEINFO.SELLTYPE',
  234. ) = (
  235. select
  236. PRTNO,--pano ,-- '投保单号 INSURANCEINFO.PRTNO',
  237. SIGNDATE,--pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE',
  238. POLAPPLYDATE,--padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE',
  239. appflag,--policystate ,--INSURANCEINFO,appflag
  240. PREM,--prem ,-- '总保费 INSURANCEINFO.PREM',
  241. RISKNAME,--productname ,-- '险种名称 INSURANCEINFO.RISKNAME'
  242. SELLTYPE--agentchannel ,-- '代理渠道 INSURANCEINFO.SELLTYPE',
  243. from INSURANCEINFO b
  244. where b.contno = a.policyno
  245. ) WHERE 1=1 ;
  246. EXCEPTION
  247. WHEN HIVE_EXCEPTION THEN
  248. log_exception('init_insurancearrangement_policy_information',sqlerrm(),sqlcode())
  249. WHEN Others THEN
  250. log_exception('init_insurancearrangement_policy_information',sqlerrm(),sqlcode())
  251. END;
  252. ==============================================================================================================================================================
  253. --临时表
  254. CREATE TABLE shanglifeecif.insurancearrangement_health_tmp(
  255. id string,
  256. orderid string DEFAULT NULL COMMENT '用于分组的排序号',
  257. contno string DEFAULT NULL COMMENT '保单号',
  258. AGENTGROUP string DEFAULT NULL COMMENT '承保分公司',--pwcomp ,-- '承保分公司 HEALTH_INSURANCE_LISTING.AGENTGROUPAREA 营业区HEALTH_INSURANCE_LISTING.AGENTGROUP 营业部',
  259. SALECHANNELS string DEFAULT NULL COMMENT '销售渠道',--schannel ,-- '销售渠道 HEALTH_INSURANCE_LISTING.SALECHANNELS 1 2 3 4 5',
  260. AMNT string DEFAULT NULL COMMENT '总保额',--risk ,-- '总保额 HEALTH_INSURANCE_LISTING.AMNT(测试环境中,此表保单数据量较其他表如:POLICY_INFORMATION,INSURANCEINFO 缺少至少一个数据量级)',
  261. AGENTCODE string DEFAULT NULL COMMENT'业务员名称'--spname ,-- '业务员名称 HEALTH_INSURANCE_LISTING.AGENTCODE',
  262. ) COMMENT '保单处理个险承保清单自助分析 数据临时表 '
  263. STORED AS ES
  264. with shard number 10
  265. replication 1;
  266. CREATE OR REPLACE PROCEDURE shanglifeecif.up_insurancearrangement_health_insurance_listing() -- 创建主存储过程
  267. IS
  268. BEGIN
  269. --清空临时表数据
  270. delete from shanglifeecif.insurancearrangement_health_tmp;
  271. --初始化临时表
  272. insert into shanglifeecif.insurancearrangement_health_tmp (
  273. id,
  274. orderid,
  275. contno,
  276. agentgroup,
  277. SALECHANNELS,
  278. AMNT,
  279. AGENTCODE
  280. ) select
  281. row_number()over(),
  282. row_number()over(PARTITION BY contno),
  283. contno,
  284. agentgroup,
  285. SALECHANNELS,
  286. AMNT,
  287. AGENTCODE
  288. from HEALTH_INSURANCE_LISTING
  289. --根据临时表更新insurancearrangement 表
  290. UPDATE shanglifeecif.insurancearrangement a SET (
  291. pwcomp ,-- '承保分公司 HEALTH_INSURANCE_LISTING.AGENTGROUPAREA 营业区HEALTH_INSURANCE_LISTING.AGENTGROUP 营业部',
  292. schannel ,-- '销售渠道 HEALTH_INSURANCE_LISTING.SALECHANNELS 1 2 3 4 5',
  293. risk ,-- '总保额 HEALTH_INSURANCE_LISTING.AMNT(测试环境中,此表保单数据量较其他表如:POLICY_INFORMATION,INSURANCEINFO 缺少至少一个数据量级)',
  294. spname -- '业务员名称 HEALTH_INSURANCE_LISTING.AGENTCODE',
  295. ) = (
  296. select
  297. b.AGENTGROUP,--pwcomp ,-- '承保分公司 HEALTH_INSURANCE_LISTING.AGENTGROUPAREA 营业区HEALTH_INSURANCE_LISTING.AGENTGROUP 营业部',
  298. b.SALECHANNELS,--schannel ,-- '销售渠道 HEALTH_INSURANCE_LISTING.SALECHANNELS 1 2 3 4 5',
  299. b.AMNT,--risk ,-- '总保额 HEALTH_INSURANCE_LISTING.AMNT(测试环境中,此表保单数据量较其他表如:POLICY_INFORMATION,INSURANCEINFO 缺少至少一个数据量级)',
  300. b.AGENTCODE--spname ,-- '业务员名称 HEALTH_INSURANCE_LISTING.AGENTCODE',
  301. from shanglifeecif.insurancearrangement_health_tmp b
  302. where b.contno = a.policyno
  303. and b.orderid = 1
  304. ) WHERE 1=1 ;
  305. EXCEPTION
  306. WHEN HIVE_EXCEPTION THEN
  307. log_exception('up_insurancearrangement_health_insurance_listing',sqlerrm(),sqlcode())
  308. WHEN Others THEN
  309. log_exception('up_insurancearrangement_health_insurance_listing',sqlerrm(),sqlcode())
  310. END;
  311. =====================================================================================================================================
  312. ==============================================================================================================================================================
  313. CREATE OR REPLACE PROCEDURE shanglifeecif.up_insurancearrangement_other() -- 创建主存储过程
  314. IS
  315. BEGIN
  316. UPDATE shanglifeecif.insurancearrangement a SET (
  317. policytype -- '保单类型',
  318. ) = (
  319. select
  320. c.CONTTYPE
  321. from (
  322. select
  323. row_number()over(PARTITION BY b.contno) rn,
  324. b.CONTTYPE,
  325. b.contno
  326. from PERSONAL_INSURANCE b
  327. ) c
  328. WHERE c.contno = a.policyno and c.rn=1
  329. ) WHERE 1=1 ;
  330. UPDATE shanglifeecif.insurancearrangement a SET (
  331. poservice -- '是否保全',
  332. ) = (
  333. SELECT
  334. IF(count(b.CONTNO) >0,1,0)
  335. FROM AUDIT_EDORLIST b
  336. where b.contno = a.policyno
  337. ) WHERE 1=1 ;
  338. UPDATE shanglifeecif.insurancearrangement a SET (
  339. soinsured-- '被保人数',
  340. ) = (
  341. SELECT
  342. PEOPLES3
  343. FROM HEALTH_GROUP_LISTING b
  344. where b.contno = a.policyno
  345. ) WHERE 1=1 ;
  346. EXCEPTION
  347. WHEN HIVE_EXCEPTION THEN
  348. log_exception('up_insurancearrangement_other',sqlerrm(),sqlcode())
  349. WHEN Others THEN
  350. log_exception('up_insurancearrangement_other',sqlerrm(),sqlcode())
  351. END;
  352. =====================================================================================================================================
  353. --数据分析sql
  354. SELECT count(1) FROM shanghailifeecif.POLICY_INFORMATION ;
  355. --2185616
  356. SELECT count(1) FROM
  357. (
  358. SELECT count(1) FROM shanghailifeecif.POLICY_INFORMATION GROUP BY CONTNO
  359. );
  360. --1466424
  361. SELECT count(1) FROM shanghailifeecif.INSURANCEINFO GROUP BY CONTNO;
  362. --1520720
  363. SELECT count(1) FROM
  364. (
  365. SELECT count(1) FROM shanghailifeecif.INSURANCEINFO GROUP BY CONTNO
  366. );
  367. --1520720
  368. SELECT count(1) FROM shanghailifeecif.health_insurance_listing WHERE agentgrouparea IS NOT NULL;
  369. --121
  370. SELECT count(1) FROM shanghailifeecif.health_insurance_listing WHERE agentgroup IS NOT NULL;
  371. --10275
  372. SELECT count(1) FROM shanghailifeecif.health_insurance_listing WHERE agentgroup IS NULL;
  373. -- 0
  374. SELECT count(1) a,contno FROM shanghailifeecif.health_insurance_listing GROUP BY contno ORDER BY a DESC;
  375. --有重复
  376. SELECT count(1) a,prtno FROM shanghailifeecif.health_insurance_listing GROUP BY prtno ORDER BY a DESC;
  377. --有重复
  378. SELECT count(1) a,prtno,contno FROM shanghailifeecif.health_insurance_listing GROUP BY prtno,contno ORDER BY a DESC;
  379. --有重复
  380. SELECT * FROM shanghailifeecif.health_insurance_listing WHERE contno = 2018091700073388;
  381. --
  382. SELECT count(1) FROM shanghailifeecif.PERSONAL_INSURANCE;
  383. --3245
  384. SELECT count(contno) a, CONTNO,PRTNO FROM shanghailifeecif.PERSONAL_INSURANCE GROUP BY CONTNO,PRTNO ORDER BY a desc;
  385. --有重复
  386. SELECT * FROM shanghailifeecif.PERSONAL_INSURANCE WHERE CONTNO = 2020012900030408;
  387. SELECT conttype FROM shanghailifeecif.PERSONAL_INSURANCE GROUP BY conttype;
  388. --只有首年
  389. SELECT count(1) FROM shanghailifeecif.AUDIT_EDORLIST;
  390. --620066
  391. SELECT count(contno) a, CONTNO FROM shanghailifeecif.AUDIT_EDORLIST GROUP BY CONTNO ORDER BY a desc;
  392. --最多重复61条记录
  393. SELECT * FROM shanghailifeecif.AUDIT_EDORLIST WHERE CONTNO = 2018020800060078;
  394. SELECT count(1) FROM shanghailifeecif.AUDIT_LN_LIST;
  395. --44
  396. SELECT count(contno) a, CONTNO FROM shanghailifeecif.AUDIT_LN_LIST GROUP BY CONTNO ORDER BY a desc;
  397. --有重复
  398. SELECT * FROM shanghailifeecif.AUDIT_EDORLIST WHERE CONTNO = 2018081600056398
  399. SELECT * FROM shanghailifeecif.AUDIT_LN_LIST WHERE LNMONEY IS NOT NULL;
  400. --LNMONEY 都为空
  401. 执行时间 2492s 插入 2185616 条数据