Browse Source

sql完善提交,rest查询方式修改

kouchengxing 4 years ago
parent
commit
23cfb89bfe

+ 33 - 0
dgtis-common/dgtis-common-core/src/main/java/com/dgtis/common/core/utils/DateUtils.java

@@ -3,6 +3,7 @@ package com.dgtis.common.core.utils;
 import java.lang.management.ManagementFactory;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import org.apache.commons.lang3.time.DateFormatUtils;
 
@@ -155,4 +156,36 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         // long sec = diff % nd % nh % nm / ns;
         return day + "天" + hour + "小时" + min + "分钟";
     }
+
+
+    /**
+     *根据出生日期计算年龄
+     * @param birthDay
+     * @return
+     * @throws Exception
+     */
+    public static  int getAge(Date birthDay) throws Exception {
+        Calendar cal = Calendar.getInstance();
+        if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算
+            throw new IllegalArgumentException(
+                    "The birthDay is before Now.It's unbelievable!");
+        }
+        int yearNow = cal.get(Calendar.YEAR);  //当前年份
+        int monthNow = cal.get(Calendar.MONTH);  //当前月份
+        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); //当前日期
+        cal.setTime(birthDay);
+        int yearBirth = cal.get(Calendar.YEAR);
+        int monthBirth = cal.get(Calendar.MONTH);
+        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
+        int age = yearNow - yearBirth;   //计算整岁数
+        if (monthNow <= monthBirth) {
+            if (monthNow == monthBirth) {
+                if (dayOfMonthNow < dayOfMonthBirth) age--;//当前日期在生日之前,年龄减一
+            }else{
+                age--;//当前月份在生日之前,年龄减一
+
+            }
+        }
+            return age;
+    }
 }

+ 49 - 0
dgtis-common/dgtis-common-core/src/main/java/com/dgtis/common/core/utils/sql/EsJsonUtil.java

@@ -0,0 +1,49 @@
+package com.dgtis.common.core.utils.sql;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author koucx
+ * @version 1.0
+ * @descption: TODO
+ * @company 神州数码通用软件(洛阳)有限公司
+ * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+ * @date 2021-01-26
+ * @since JDK1.8
+ */
+public class EsJsonUtil {
+
+
+    /**
+     * 拼装结构
+     * @param map
+     * @return
+     */
+    public static String QuerygetMust(Map map){
+       Map search = new HashMap();
+
+        Map query = new HashMap();
+        Map bool = new HashMap();
+        List must = new ArrayList();
+        Map term = new HashMap();
+        Map param = new HashMap();
+        param.putAll(map);
+        term.put("term",param);
+        must.add(term);
+        List must_not = new ArrayList();
+        List should = new ArrayList();
+        bool.put("must",must);
+//        bool.put("must_not",must_not);
+//        bool.put("should",should);
+        query.put("bool",bool);
+        search.put("query",query);
+        return JSONObject.toJSONString(search);
+    }
+
+}

+ 30 - 8
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/api/CustomerApiController.java

@@ -7,7 +7,11 @@ import com.arronlong.httpclientutil.HttpClientUtil;
 import com.arronlong.httpclientutil.common.HttpConfig;
 import com.arronlong.httpclientutil.exception.HttpProcessException;
 import com.dgtis.common.core.utils.DateUtils;
+import com.dgtis.common.core.utils.sql.EsJsonUtil;
 import com.dgtis.common.core.web.domain.AjaxResult;
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.util.EntityUtils;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.RestClient;
@@ -20,10 +24,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @description:客户信息列表api
@@ -59,7 +60,8 @@ public class CustomerApiController {
                 mp.put("id",json.getString("_id"));
                 JSONObject jsonOb = JSON.parseObject(json.getString("_source"));
                 mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
-                mp.put("birthday", DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",jsonOb.getDate("birthday")));
+                mp.put("birthday", DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", jsonOb.getDate("birthday")));
+                mp.put("age",DateUtils.getAge(jsonOb.getDate("birthday")));
                 listMap.add(mp);
             }
             long total = hitsobject.getLong("total");
@@ -82,16 +84,35 @@ public class CustomerApiController {
 
             Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");
-            Response response = restClient.performRequest("GET", "shanglifeecif.individual/default_type_/"+id, paramMap);
+            Response response = restClient.performRequest("GET", "/shanglifeecif.individual/default_type_/"+id, paramMap);
             String result = EntityUtils.toString(response.getEntity());
             Map map = new HashMap();
             JSONObject jsonObject = JSON.parseObject(result);
             Map mpInfo = new HashMap();
-            mpInfo.put("id",jsonObject.getString("_id"));
+          String indid = jsonObject.getString("_id");
+          mpInfo.put("id",indid);
             mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
             mpInfo.put("birthday",DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",JSON.parseObject(jsonObject.getString("_source")).getDate("birthday")));
             map.put("custInfo",mpInfo);
-            map.put("custInfo1",null);
+
+
+          Map query  =new HashMap();
+          query.put("indid1",indid);
+          HttpEntity entity = new NStringEntity(EsJsonUtil.QuerygetMust(query), ContentType.APPLICATION_JSON);
+          response= restClient.performRequest("GET", "/shanglifeecif.indrelationship/_search",Collections.<String, String>emptyMap(),entity);
+          result = EntityUtils.toString(response.getEntity());
+          jsonObject = JSON.parseObject(result);
+          JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
+          JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
+          List relationship = new ArrayList<>();
+          for (int i = 0; i <array.size() ; i++) {
+              JSONObject json = (JSONObject)array.get(i);
+              Map mp = new HashMap();
+              mp.put("id",json.getString("_id"));
+              mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
+              relationship.add(mp);
+          }
+            map.put("relationship",relationship);
             map.put("custInfo2",null);
             map.put("custInfo3",null);
             map.put("custInfo4",null);
@@ -129,4 +150,5 @@ public class CustomerApiController {
         }
     }
 
+
 }

+ 57 - 47
sql-achievement/存储过程/个人信息开发qxp.sql

@@ -453,7 +453,7 @@ DROP SEQUENCE IF EXISTS globaleCusId_sequence;
 !set plsqlUseSlash true
 SET plsql.catch.hive.exception=true; --使用HIVE_EXCEPTION捕获Hive异常
 --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
-CREATE OR REPLACE PROCEDURE init_individual_main() -- 初始化 数据全部插入
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_main() -- 初始化 数据全部插入
 IS    
 DECLARE
 	individual_count int
@@ -461,17 +461,17 @@ DECLARE
 BEGIN
 	--先验是否一个客户id有多条记录对应不通的证件类别
 	--初始化 身份证 用户
-	init_individual_0(individual_count);
+	shanglifeecif.init_individual_0(individual_count);
 
 	--初始化  护照用户
 	individual_count:=individual_count+1;
-	init_individual_1(individual_count);
+	shanglifeecif.init_individual_1(individual_count);
 	--初始化 驾照用户
 	individual_count:=individual_count+1;
-	init_individual_3(individual_count);
+	shanglifeecif.init_individual_3(individual_count);
 	--其他 证件类型用户
 	individual_count:=individual_count+1;
-	init_individual_other(individual_count);
+	shanglifeecif.init_individual_other(individual_count);
 
 	--初始化 全局序列
 	individual_count:=individual_count+1;
@@ -490,10 +490,10 @@ BEGIN
 	EXECUTE IMMEDIATE strsql
 
 	--更新用户等级信息
-	up_t_customers_class_1();
+	shanglifeecif.up_t_customers_class_1();
 	
 	--更新职业信息
-	up_health_insurance_listing_1();
+	shanglifeecif.up_health_insurance_listing_1();
 
 	EXCEPTION
 			WHEN HIVE_EXCEPTION THEN 
@@ -510,12 +510,12 @@ END;
 !set plsqlUseSlash true
 SET plsql.catch.hive.exception=true; --使用HIVE_EXCEPTION捕获Hive异常
 --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
-CREATE OR REPLACE PROCEDURE init_individual_0( individual_count OUT int) -- 初始化 省份证
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_0( individual_count OUT int) -- 初始化 省份证
 IS    
 BEGIN
 	
 	--查询出此次处理的数据并出表中
-	insert into individual (
+	insert into shanglifeecif.individual (
 		indid,
 		custid,
 
@@ -539,7 +539,7 @@ BEGIN
 		idcard ,
 		
 		sysdate,
-		'qxp'
+		'admin'
 		FROM (
 			SELECT
 				customerno AS scustid,--投保人
@@ -564,7 +564,7 @@ BEGIN
 			WHERE insuredno IS NOT NULL AND insuredidtype=0
 			) tmpTable
 	--已经存在的数据行数
-	select count(0) into individual_count from individual
+	select count(0) into individual_count from shanglifeecif.individual
 	EXCEPTION
 			WHEN HIVE_EXCEPTION THEN 
 				 log_exception('init_individual_0',sqlerrm(),sqlcode())
@@ -576,12 +576,12 @@ END;
 !set plsqlUseSlash true
 SET plsql.catch.hive.exception=true; --使用HIVE_EXCEPTION捕获Hive异常
 --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
-CREATE OR REPLACE PROCEDURE init_individual_1(individual_count INOUT  int) -- 初始化 护照
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_1(individual_count INOUT  int) -- 初始化 护照
 IS    
 BEGIN
 	
 	--查询出此次处理的数据并出表中
-	insert into individual (
+	insert into shanglifeecif.individual (
 			indid,
 			custid,
 		 	
@@ -606,7 +606,7 @@ BEGIN
 		idcard ,
 
 		sysdate,
-		'qxp'
+		'admin'
 		FROM (
 			SELECT
 				customerno AS scustid,--投保人
@@ -632,7 +632,7 @@ BEGIN
 			) tmpTable
 
 	--已经存在的数据行数
-	select count(0) into individual_count from individual
+	select count(0) into individual_count from shanglifeecif.individual
 
 	EXCEPTION
 			WHEN HIVE_EXCEPTION THEN 
@@ -643,12 +643,12 @@ END;
 !set plsqlUseSlash true
 SET plsql.catch.hive.exception=true; --使用HIVE_EXCEPTION捕获Hive异常
 --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
-CREATE OR REPLACE PROCEDURE init_individual_3(individual_count INOUT  int) -- 初始化 护照
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_3(individual_count INOUT  int) -- 初始化 护照
 IS    
 BEGIN
 	
 	--查询出此次处理的数据并出表中
-	insert into individual(
+	insert into shanglifeecif.individual(
 		indid,
 		custid,
 
@@ -672,7 +672,7 @@ BEGIN
 		idcard ,
 		
 		sysdate,
-		'qxp'
+		'admin'
 		FROM (
 			SELECT
 				customerno AS scustid,--投保人
@@ -698,7 +698,7 @@ BEGIN
 			) tmpTable
 
 	--已经存在的数据行数
-	select count(0) into individual_count from individual
+	select count(0) into individual_count from shanglifeecif.individual
 
 	EXCEPTION
 			WHEN HIVE_EXCEPTION THEN 
@@ -710,12 +710,12 @@ END;
 !set plsqlUseSlash true
 SET plsql.catch.hive.exception=true; --使用HIVE_EXCEPTION捕获Hive异常
 --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
-CREATE OR REPLACE PROCEDURE init_individual_other(individual_count INOUT  int) -- 初始化 护照
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_individual_other(individual_count INOUT  int) -- 初始化出了以上三种证件信息
 IS    
 BEGIN
 	
 	--查询出此次处理的数据并出表中
-	insert into individual(
+	insert into shanglifeecif.individual(
 			indid,
 			custid,
 		 
@@ -736,7 +736,7 @@ BEGIN
 		gender ,
 		birthday,
 		sysdate,
-		'qxp'
+		'admin'
 		FROM (
 			SELECT
 				customerno AS scustid,--投保人
@@ -762,23 +762,19 @@ BEGIN
 			) tmpTable
 
 	--已经存在的数据行数
-	select count(0) into individual_count from individual
+	select count(0) into individual_count from shanglifeecif.individual
+
 
-	EXCEPTION
-			WHEN HIVE_EXCEPTION THEN 
-				 log_exception('init_individual_other',sqlerrm(),sqlcode())
-			WHEN Others THEN
-				 log_exception('init_individual_other',sqlerrm(),sqlcode())
 END;
 
 --创建存储过程 插入individual_search 
 !set plsqlUseSlash true
 SET plsql.catch.hive.exception=true; --使用HIVE_EXCEPTION捕获Hive异常
 --set plsql.compile.dml.check.semantic=false; --禁止编译过程对PL/SQL内部语法进行检查。
-CREATE OR REPLACE PROCEDURE up_t_customers_class_1() -- 创建存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.up_t_customers_class_1() -- 创建存储过程
 IS    
 BEGIN
-	UPDATE individual a SET (
+	UPDATE shanglifeecif.individual a SET (
 			CustClass	,--	客户等级
 			ConValue	,--	贡献度分
 			Awarded3	,--	家庭加分2
@@ -788,10 +784,17 @@ BEGIN
 			EndDate,	--	客户等级失效日期
 			Height,		--身高
 			Weight,		--体重
+			BMI,
 			PIncome,	--个人年收入
 			FIncome,	--家庭年收入
 			IncomeSource,	--收入来源
-			SIStatus	--社保情况
+			SIStatus,	--社保情况
+			Ethnic,  --民族情况
+			Nation, --国籍
+			MaritalStat, --婚姻
+			Employer,--工作单位
+			Education,--学历
+			Dday--死亡日期
 		) = (
 			select 
 					CLASS_VALUE	,--客户等级
@@ -803,12 +806,19 @@ BEGIN
 					END_DATE, --失效日期
 					STATURE,	--身高
 					AVOIRDUPOIS,--体重
+					BMI,
 					YEARINCOME,	--个人年收入
 					FAMILYYEARSALARY,	--家庭年收入
 					INCOMESOURCE,	--收入来源
-					SOCIALINSUFLAG	--社保情况
-
-				from shanghailifeecif.t_customer_class b
+					SOCIALINSUFLAG,	--社保情况
+					NATIONALITY, --民族情况
+					NATIVEPLACE, --国籍
+					MARRIAGE,--婚姻
+					GRPNAME,--工作单位名称
+					DEGREE,--学历
+					DEATHDATE--死亡日期
+
+				from t_customer_class b
 				where b.CUSTOMER_ID = a.scustid;
 		) WHERE 1=1 ;
 	EXCEPTION
@@ -818,8 +828,8 @@ BEGIN
 				 log_exception('up_t_customers_class_1',sqlerrm(),sqlcode())
 END;
 /
-DROP TABLE IF EXISTS occupation_tmp;
-CREATE  TABLE occupation_tmp(
+DROP TABLE IF EXISTS shanglifeecif.occupation_tmp;
+CREATE  TABLE shanglifeecif.occupation_tmp(
   scustid string not NULL COMMENT '客户号',   
   OccupationId string DEFAULT NULL COMMENT '名称', 
   Occupation string DEFAULT NULL COMMENT '出生日期' ,
@@ -829,13 +839,13 @@ CREATE  TABLE occupation_tmp(
 with shard number 10
 replication 1;
 --根据HEALTH_INSURANCE_LISTING表更新
-CREATE OR REPLACE PROCEDURE up_health_insurance_listing_1() -- 创建存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.up_health_insurance_listing_1() -- 创建存储过程
 IS    
 BEGIN
 	--清楚临时表数据
-	delete occupation_tmp;
+	delete shanglifeecif.occupation_tmp;
 	--插入去重数据到临时表
-	insert into occupation_tmp(
+	insert into shanglifeecif.occupation_tmp(
 		scustid,
 		OccupationId,
 		Occupation,
@@ -853,7 +863,7 @@ BEGIN
 
 	--更新个人信息表
 
-	UPDATE individual a SET (
+	UPDATE shanglifeecif.individual a SET (
 		OccupationId	,--	职业代码
 		Occupation,	--	职业名称
 		HomeAdress
@@ -862,7 +872,7 @@ BEGIN
 			OccupationId	,--职业代码
 			Occupation,--职业名称
 			HomeAdress 
-		from occupation_tmp b
+		from shanglifeecif.occupation_tmp b
 		where b.scustid = a.scustid 
 	) WHERE 1=1 ;
 	EXCEPTION
@@ -896,8 +906,8 @@ END;
 =======================================================================================================================================
 
 
-DROP TABLE IF EXISTS scustid_unique_tmp;
-CREATE  TABLE scustid_unique_tmp( 
+DROP TABLE IF EXISTS shanglifeecif.scustid_unique_tmp;
+CREATE  TABLE shanglifeecif.scustid_unique_tmp( 
 	scustid string    COMMENT '上游客户号' ,
    	indid string COMMENT '客户号' 
 )
@@ -907,15 +917,15 @@ with shard number 10
 replication 1;
 
 --更新individual 的用户关系
-CREATE OR REPLACE PROCEDURE up_scustid_unique_tmp() -- 创建存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.up_scustid_unique_tmp() -- 创建存储过程
 IS    
 BEGIN
 	--清楚临时表数据
-	delete from scustid_unique_tmp;
+	delete from shanglifeecif.scustid_unique_tmp;
 
 	--插入临时表数据
-	insert into scustid_unique_tmp(scustid,indid)
-		select scustid,min(indid) from individual group by scustid;
+	insert into shanglifeecif.scustid_unique_tmp(scustid,indid)
+		select scustid,min(indid) from shanglifeecif.individual group by scustid;
 
 	EXCEPTION
 			WHEN HIVE_EXCEPTION THEN 

+ 28 - 28
sql-achievement/存储过程/保单qxp.sql

@@ -121,17 +121,17 @@ replication 1;
 =============================================================存储主过程=============================================================================
 ===================================================================================================================================================
 
-CREATE OR REPLACE PROCEDURE init_insurancearrangement() -- 创建主存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement() -- 创建主存储过程
 IS    
 BEGIN
 	--根据policy_information 更新保单表
-	init_insurancearrangement_policy_information();
+	shanglifeecif.init_insurancearrangement_policy_information();
 
 	--根据health_insurance_listing 更新相关字段
-	up_insurancearrangement_health_insurance_listing();
+	shanglifeecif.up_insurancearrangement_health_insurance_listing();
 
 	--其他标的字段 更新
-	up_insurancearrangement_other();
+	shanglifeecif.up_insurancearrangement_other();
 
 	EXCEPTION
 		WHEN HIVE_EXCEPTION THEN 
@@ -144,11 +144,11 @@ END;
 
 
 
-CREATE OR REPLACE PROCEDURE init_insurancearrangement_policy_information() -- 创建主存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.init_insurancearrangement_policy_information() -- 创建主存储过程
 IS    
 BEGIN
 
-INSERT INTO insurancearrangement(
+INSERT INTO shanglifeecif.insurancearrangement(
   iaid ,--'保单ID', 
   policyno ,-- '保险单号 INSURANCEINFO.CONTNO', 
   pindate ,-- '起保日期 POLICY_INFORMATION.CVALIDATE', 
@@ -211,13 +211,13 @@ SELECT
 		when security = '15天' then 15
 		when security = '7天' then 7
 	end,
-	'koucx',
+	'admin',
 	sysdate() 
-	FROM shanghailifeecif.policy_information 
+	FROM policy_information 
 
 	--更新投保人和被保人id  因为 scustid有重复所以需要去下重
 
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		applicantid --'投保人ID',
 	) = (
 	   select
@@ -227,13 +227,13 @@ SELECT
 				row_number()over(PARTITION BY b.scustid) rn,
 				b.indid,
 				b.scustid
-			from individual b
+			from shanglifeecif.individual b
 	   ) c
 	   WHERE c.scustid  = a.applicantscustid and c.rn=1
 	) WHERE 1=1 ;
 
 
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		insuredid --'投保人ID',
 	) = (
 	   select
@@ -243,14 +243,14 @@ SELECT
 				row_number()over(PARTITION BY b.scustid) rn,
 				b.indid,
 				b.scustid
-			from individual b
+			from shanglifeecif.individual b
 	   ) c
 	   WHERE c.scustid  = a.insuredscustid and c.rn=1
 	) WHERE 1=1 ;
 
 	--更新INSURANCEINFO 表中的信息
 
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		pano ,-- '投保单号 INSURANCEINFO.PRTNO',  
 		pisdate ,-- '签单日期 INSURANCEINFO.SIGNDATE', 
 		padate ,-- '投保日期 INSURANCEINFO.POLAPPLYDATE', 
@@ -267,7 +267,7 @@ SELECT
 			PREM,--prem ,-- '总保费 INSURANCEINFO.PREM', 
 			RISKNAME,--productname ,-- '险种名称	 INSURANCEINFO.RISKNAME'
 			SELLTYPE--agentchannel ,-- '代理渠道 INSURANCEINFO.SELLTYPE', 
-		from shanghailifeecif.INSURANCEINFO b
+		from INSURANCEINFO b
 		where b.contno  = a.policyno
 	) WHERE 1=1 ;
 
@@ -289,7 +289,7 @@ END;
 
 --临时表
 
-CREATE TABLE insurancearrangement_health_tmp(
+CREATE TABLE shanglifeecif.insurancearrangement_health_tmp(
     id string,
     orderid string  DEFAULT NULL COMMENT '用于分组的排序号',
     contno string DEFAULT NULL COMMENT '保单号',
@@ -303,14 +303,14 @@ with shard number 10
 replication 1;
 
 
-CREATE OR REPLACE PROCEDURE up_insurancearrangement_health_insurance_listing() -- 创建主存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.up_insurancearrangement_health_insurance_listing() -- 创建主存储过程
 IS    
 BEGIN
 	--清空临时表数据
-	delete from insurancearrangement_health_tmp;
+	delete from shanglifeecif.insurancearrangement_health_tmp;
 
 	--初始化临时表
-	insert into insurancearrangement_health_tmp (
+	insert into shanglifeecif.insurancearrangement_health_tmp (
 		id,
 		orderid,
 		contno,
@@ -326,10 +326,10 @@ BEGIN
 		SALECHANNELS,
 		AMNT,
 		AGENTCODE
-	from shanghailifeecif.HEALTH_INSURANCE_LISTING
+	from HEALTH_INSURANCE_LISTING
 
 	--根据临时表更新insurancearrangement 表
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		pwcomp ,-- '承保分公司 HEALTH_INSURANCE_LISTING.AGENTGROUPAREA 营业区HEALTH_INSURANCE_LISTING.AGENTGROUP 营业部', 
 		schannel ,-- '销售渠道 HEALTH_INSURANCE_LISTING.SALECHANNELS 1 2 3 4 5',
 		risk ,-- '总保额 HEALTH_INSURANCE_LISTING.AMNT(测试环境中,此表保单数据量较其他表如:POLICY_INFORMATION,INSURANCEINFO 缺少至少一个数据量级)', 
@@ -340,7 +340,7 @@ BEGIN
 			b.SALECHANNELS,--schannel ,-- '销售渠道 HEALTH_INSURANCE_LISTING.SALECHANNELS 1 2 3 4 5',
 			b.AMNT,--risk ,-- '总保额 HEALTH_INSURANCE_LISTING.AMNT(测试环境中,此表保单数据量较其他表如:POLICY_INFORMATION,INSURANCEINFO 缺少至少一个数据量级)', 
 			b.AGENTCODE--spname ,-- '业务员名称 HEALTH_INSURANCE_LISTING.AGENTCODE', 
-		from insurancearrangement_health_tmp b
+		from shanglifeecif.insurancearrangement_health_tmp b
 		where b.contno  = a.policyno
 		and b.orderid = 1
 	) WHERE 1=1 ;
@@ -360,13 +360,13 @@ END;
 
 ==============================================================================================================================================================
 
-CREATE OR REPLACE PROCEDURE up_insurancearrangement_other() -- 创建主存储过程
+CREATE OR REPLACE PROCEDURE shanglifeecif.up_insurancearrangement_other() -- 创建主存储过程
 IS    
 BEGIN
 	
 
 
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		policytype  -- '保单类型', 
 	) = (
 	   select
@@ -376,27 +376,27 @@ BEGIN
 				row_number()over(PARTITION BY b.contno) rn,
 				b.CONTTYPE,
 				b.contno
-			from shanghailifeecif.PERSONAL_INSURANCE b
+			from PERSONAL_INSURANCE b
 	   ) c
 	   WHERE c.contno  = a.policyno and c.rn=1
 	) WHERE 1=1 ;
 
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		poservice	  -- '是否保全', 
 	) = (
 	   SELECT
 	   	IF(count(b.CONTNO) >0,1,0)
-	   FROM shanghailifeecif.AUDIT_EDORLIST b
+	   FROM AUDIT_EDORLIST b
 	   where b.contno  = a.policyno
 	) WHERE 1=1 ;
 
 
-	UPDATE insurancearrangement a SET (
+	UPDATE shanglifeecif.insurancearrangement a SET (
 		soinsured-- '被保人数', 
 	) = (
 	   SELECT
 	   		PEOPLES3
-	   FROM shanghailifeecif.HEALTH_GROUP_LISTING b
+	   FROM HEALTH_GROUP_LISTING b
 	   where b.contno  = a.policyno
 	) WHERE 1=1 ;
 

+ 23 - 0
sql-achievement/存储过程/保单件数分布统计.sql

@@ -0,0 +1,23 @@
+CREATE TABLE shanglifeecif.bdnum_distribution(
+    id string,
+    labelName string  DEFAULT NULL COMMENT '保单件数名称',
+    bdnum string DEFAULT NULL COMMENT '保单件数'
+) COMMENT '保单件数分布'
+STORED AS ES
+with shard number 10
+replication 1;
+
+CREATE OR REPLACE PROCEDURE shanglifeecif.bdnum_distribution() IS
+DECLARE
+BEGIN
+	delete from shanglifeecif.bdnum_distribution;
+	insert into shanglifeecif.bdnum_distribution (
+		id,
+		labelName,
+		bdnum
+	) SELECT row_number()over(),t.labelName,t.bdnum FROM (
+		SELECT si.label25 labelName,count(1) bdnum FROM shanglifeecif.individual si GROUP BY si.label25 
+	) t
+	
+	
+END	;

+ 25 - 0
sql-achievement/存储过程/年龄段性别分布统计.sql

@@ -0,0 +1,25 @@
+CREATE  TABLE shanglifeecif.age_sex_distribution(
+  id string DEFAULT NULL, 
+  labelname string DEFAULT NULL COMMENT '阶段名称', 
+  gender string DEFAULT NULL COMMENT '性别', 
+  cusnum string DEFAULT NULL COMMENT '客户数量'
+)
+COMMENT '年龄段性别分布'
+STORED AS ES
+with shard number 10
+replication 1;
+
+CREATE OR REPLACE PROCEDURE shanglifeecif.age_sex_distribution() IS
+DECLARE
+BEGIN
+	delete from shanglifeecif.age_sex_distribution;
+	insert into shanglifeecif.age_sex_distribution (
+		id,
+		labelName,
+		gender,
+		cusNum
+	) SELECT row_number()over(),t.labelName,t.gender,t.cusNum FROM (
+	SELECT si.label4 labelName,si.gender,count(1) cusNum FROM shanglifeecif.individual si GROUP BY si.label4,si.gender
+	) t
+			
+END	;

sql-achievement/存储过程/险种大类.sql → sql-achievement/存储过程/险种大类统计.sql