Procházet zdrojové kódy

客户概览保费折线图修改

kouchengxing před 4 roky
rodič
revize
411ac81633

+ 56 - 20
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/api/CustomerApiController.java

@@ -62,8 +62,8 @@ public class CustomerApiController {
 
 
 
-
         try {
+            logger.info("进客户列表时间:"+DateUtils.getTime());
 
             //1.如果存在保单信息的查询条件,需要先查询保单信息然后通过保单关联出客户信息
             //处理保单查询条件
@@ -227,9 +227,10 @@ public class CustomerApiController {
 
             map.put("list",listMap);
             map.put("total",total);
-
+            logger.info("出客户列表时间:"+DateUtils.getTime());
             return AjaxResult.success(map);
         } catch (Exception e) {
+            logger.info("列表报错时间:"+DateUtils.getTime());
             e.printStackTrace();
             return AjaxResult.error();
         }
@@ -308,6 +309,7 @@ public class CustomerApiController {
 
         Request scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?scroll=1m");
         scriptRequest.setEntity(entity);
+
         Response response = restClient.performRequest(scriptRequest);
 //        Response response= restClient.performRequest("GET", "/shanglifeecif.insurancearrangement/_search?scroll=1m",Collections.<String, String>emptyMap(),entity);
 
@@ -350,7 +352,7 @@ public class CustomerApiController {
     public AjaxResult getCustomerById(String id) {
         // 获取索引的别名,字段,创建时间http://10.32.2.231:9200/shanglifeecif.individual/default_type_/1
       try {
-
+           logger.info("进客户详情时间:"+DateUtils.getTime());
             Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");
           Request scriptRequest = new Request("GET", "/shanglifeecif.individual/default_type_/"+id+"?pretty=true");
@@ -451,9 +453,10 @@ public class CustomerApiController {
               partytimeline.add(mp);
            }
            map.put("partytimeline",partytimeline);
-
+            logger.info("出客户详情时间:"+DateUtils.getTime());
             return AjaxResult.success(map);
         } catch (Exception e) {
+            logger.info("客户详情报错时间:"+DateUtils.getTime());
             e.printStackTrace();
             return AjaxResult.error();
         }
@@ -464,10 +467,12 @@ public class CustomerApiController {
     public AjaxResult getCustomerOverViewById(String id) {
         // 获取索引的别名,字段,创建时间http://10.32.2.231:9200/shanglifeecif.individual/default_type_/1
         try {
+            logger.info("进客户概览时间:"+DateUtils.getTime());
             Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");
             Request scriptRequest = new Request("GET", "shanglifeecif.individual/default_type_/"+id+"?pretty=true");
             Response response = restClient.performRequest(scriptRequest);
+
             String result = EntityUtils.toString(response.getEntity());
             Map map = new HashMap();
             JSONObject jsonObject = JSON.parseObject(result);
@@ -494,40 +499,68 @@ public class CustomerApiController {
 
             //概览投保时间和保费折线图
             Map expectedData = new HashMap();
-            List edata = new ArrayList();
+            Double[] edata = new Double[12];
             expectedData.put("name","");
 
             Map actaulData = new HashMap();
-            List adata = new ArrayList();
+            Double[] adata = new Double[12];
             actaulData.put("name","");
             List xaxisData = new ArrayList();
+            xaxisData.add("1");
+            xaxisData.add("2");
+            xaxisData.add("3");
+            xaxisData.add("4");
+            xaxisData.add("5");
+            xaxisData.add("6");
+            xaxisData.add("7");
+            xaxisData.add("8");
+            xaxisData.add("9");
+            xaxisData.add("10");
+            xaxisData.add("11");
+            xaxisData.add("12");
             long insureDay = 0;//投保时长
             int guaranteeDay = 0;//享受保障天数
 
-            List majorCategories = new ArrayList();
-            Map a = new HashMap();//意外伤害险
-            Map u = new HashMap();//万能保险
-            Map r = new HashMap();//年金保险
-            Map s = new HashMap();//重疾保险
-            Map l = new HashMap();//人寿保险
-            Map h = new HashMap();//健康险
+
             Map majorCategorie = new HashMap();
+
+            Map mpremMap = new HashMap();
             for (int i = 0; i <array.size() ; i++) {
                 JSONObject json = (JSONObject)array.get(i);
                 JSONObject _source = (JSONObject) json.get("_source");
+                Date padate = _source.getDate("padate");
+
+                //xaxisData.add(DateUtils.parseDateToStr("MM",padate));
+
                 if(_source.containsKey("prem")){
                     prem+=_source.getDouble("prem");
-                    edata.add(_source.getDouble("prem"));
-                    adata.add(_source.getDouble("prem"));
+                    String m = DateUtils.parseDateToStr("M", padate);
+
+
+                    if(mpremMap.containsKey(m)){
+                        double tprem = Double.parseDouble(mpremMap.get(m).toString());
+                        tprem+=_source.getDouble("prem");
+                        //mpremMap.put(m,mprem);
+                        edata[Integer.parseInt(m)-1] = tprem;
+                        adata[Integer.parseInt(m)-1] = tprem;
+                    }else{
+                        mpremMap.put(m,_source.getDouble("prem"));
+                        edata[Integer.parseInt(m)-1] = _source.getDouble("prem");
+                        adata[Integer.parseInt(m)-1] = _source.getDouble("prem");
+                    }
+
+                    //edata.add(_source.getDouble("prem"));
+                    //adata.add(_source.getDouble("prem"));
                 }
-                Date padate = _source.getDate("padate");
+
+
                 if(i==0){
                     insureDay = DateUtils.getDateDifDay(new Date(),padate);
                 }
                 if("有效".equals(_source.getString("policystate"))){
                     guaranteeDay+=_source.getInteger("agrmntage");
                 }
-                xaxisData.add(DateUtils.parseDateToStr("MM",padate));
+
                 //String risk_categories = _source.getString("risk_categories");
                 String risk_categories_name = _source.getString("risk_categories_name");
 
@@ -537,11 +570,12 @@ public class CustomerApiController {
                         risk += _source.getDouble("risk");
                     }
                     majorCategorie.put(risk_categories_name,risk);
+                }else{
+                    if(_source.containsKey("risk")){
+                        majorCategorie.put(risk_categories_name,_source.getDouble("risk"));
+                    }
                 }
 
-                if(_source.containsKey("risk")){
-                    majorCategorie.put(risk_categories_name,_source.getDouble("risk"));
-                }
             }
 
             expectedData.put("data",edata);
@@ -582,8 +616,10 @@ public class CustomerApiController {
             mpInfo.put("guaranteeDay",guaranteeDay);
             map.put("custInfo",mpInfo);
             map.put("majorCategorie",majorCategorie);
+            logger.info("出客户概览时间:"+DateUtils.getTime());
             return AjaxResult.success(map);
         } catch (Exception e) {
+            logger.info("客户概览报错时间:"+DateUtils.getTime());
             e.printStackTrace();
             return AjaxResult.error();
         }

+ 14 - 4
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/api/IndexApiController.java

@@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.arronlong.httpclientutil.HttpClientUtil;
 import com.arronlong.httpclientutil.common.HttpConfig;
+import com.dgtis.common.core.utils.DateUtils;
 import com.dgtis.common.core.utils.StringUtils;
 import com.dgtis.common.core.web.controller.BaseController;
 import com.dgtis.common.core.web.domain.AjaxResult;
@@ -51,13 +52,14 @@ public class IndexApiController extends BaseController {
         List xaxisData = new ArrayList();//存放险种
         List seriesData = new ArrayList();//客户数量和保单数量
         try {
-
+            logger.info("进险种类别时间:"+DateUtils.getTime());
             Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");
+
             Request scriptRequest = new Request("GET", "/shanglifeecif.riskcode_statistics/_search?pretty=true");
 
             Response response = restClient.performRequest(scriptRequest);
-
+            logger.info("险种类别请求响应时间:"+DateUtils.getTime());
             /*Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");*/
 //            Response response = restClient.performRequest("GET", "shanglifeecif.riskcode_statistics/_search?", paramMap);
@@ -104,6 +106,7 @@ public class IndexApiController extends BaseController {
                 }
             }
         } catch (Exception e) {
+            logger.info("险种类别报错时间:"+DateUtils.getTime());
             e.printStackTrace();
             return AjaxResult.error("获取数据失败");
         }
@@ -111,6 +114,7 @@ public class IndexApiController extends BaseController {
         Map data = new HashMap();
         data.put("xaxisData",xaxisData);
         data.put("seriesData",seriesData);
+        logger.info("出险种类别时间:"+DateUtils.getTime());
         return AjaxResult.success("险种数据返回成功!",data);
     }
 
@@ -120,12 +124,13 @@ public class IndexApiController extends BaseController {
         // 获取索引的别名,字段,创建时间
         Map[] seriesData = new HashMap[8];
         try {
-
+            logger.info("进保单件数时间:"+DateUtils.getTime());
             Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");
             Request scriptRequest = new Request("GET", "/shanglifeecif.bdnum_distribution/_search?pretty=true");
 
             Response response = restClient.performRequest(scriptRequest);
+            logger.info("保单件数请求响应时间:"+DateUtils.getTime());
 //            Response response = restClient.performRequest("GET", "shanglifeecif.bdnum_distribution/_search?", paramMap);
             String jsonStr = EntityUtils.toString(response.getEntity());
             if(StringUtils.isNotEmpty(jsonStr)){
@@ -171,12 +176,14 @@ public class IndexApiController extends BaseController {
                 }
             }
         } catch (Exception e) {
+            logger.error("保单件数出错时间:"+DateUtils.getTime());
             e.printStackTrace();
             return AjaxResult.error("获取数据失败");
         }
 
         Map data = new HashMap();
         data.put("seriesData",seriesData);
+        logger.info("出保单件数时间:"+DateUtils.getTime());
         return AjaxResult.success("保单件数分布数据返回成功!",data);
     }
 
@@ -197,12 +204,13 @@ public class IndexApiController extends BaseController {
         List seriesData = new ArrayList();//性别,年龄段数据
 
         try {
-
+            logger.info("进客户年龄段时间:"+DateUtils.getTime());
             Map<String, String> paramMap = new HashMap<String, String>();
             paramMap.put("pretty", "true");
             Request scriptRequest = new Request("GET", "/shanglifeecif.age_sex_distribution/_search?pretty=true");
 
             Response response = restClient.performRequest(scriptRequest);
+            logger.info("客户年龄段请求响应时间:"+DateUtils.getTime());
 //            Response response = restClient.performRequest("GET", "shanglifeecif.age_sex_distribution/_search?", paramMap);
             String jsonStr = EntityUtils.toString(response.getEntity());
             if(StringUtils.isNotEmpty(jsonStr)){
@@ -255,6 +263,7 @@ public class IndexApiController extends BaseController {
                 }
             }
         } catch (Exception e) {
+            logger.info("客户年龄段报错时间:"+DateUtils.getTime());
             e.printStackTrace();
             return AjaxResult.error("获取数据失败");
         }
@@ -263,6 +272,7 @@ public class IndexApiController extends BaseController {
         data.put("legendData",legendData);
         data.put("xaxisData",xaxisData);
         data.put("seriesData",seriesData);
+        logger.info("出客户年龄段时间:"+DateUtils.getTime());
         return AjaxResult.success("客户年龄段性别分布数据返回成功!",data);
     }
 

+ 13 - 6
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/config/ElasticSearchConfig.java

@@ -11,8 +11,11 @@ import org.apache.http.client.config.RequestConfig;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
 import org.apache.http.message.BasicHeader;
+import org.elasticsearch.client.Node;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -31,6 +34,8 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class ElasticSearchConfig {
 
+    private static final Logger log = LoggerFactory.getLogger(ElasticSearchConfig.class);
+
     @Value("${elasticsearch.hostlist}")
     private String hostlist;
 
@@ -41,9 +46,9 @@ public class ElasticSearchConfig {
     private String esName;
 
     /**
-     * 超时时间设为5分钟
+     * 超时时间设为15秒
      */
-    private static final int TIME_OUT = 5 * 60 * 1000;
+    private static final int TIME_OUT = 15 * 1000;
 
 
     @Bean
@@ -77,9 +82,10 @@ public class ElasticSearchConfig {
         // 如果自定义socket超时时间,则应相应地调整最大重试超时时间。
 //        builder.set.setMaxRetryTimeoutMillis(10000);
         builder.setFailureListener(new RestClient.FailureListener() {
-            public void onFailure(HttpHost host) {
-                //设置一个监听程序,每次节点发生故障时都会收到通知,这样就可以采取相应的措施。
-                //Used internally when sniffing on failure is enabled.(这句话没搞懂啥意思)
+            @Override
+            public void onFailure(Node node) {
+                super.onFailure(node);
+                log.warn("ES节点连接失败,节点名称:"+node.getName()+" 节点地址:"+node.getHost());
             }
         });
         builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
@@ -90,7 +96,8 @@ public class ElasticSearchConfig {
 //                return requestConfigBuilder.setSocketTimeout(TIME_OUT);
                 return requestConfigBuilder
                         .setConnectTimeout(TIME_OUT)
-                        .setSocketTimeout(TIME_OUT);
+                        .setSocketTimeout(TIME_OUT)
+                        .setConnectionRequestTimeout(TIME_OUT);
             }
         });
         /*builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {