Browse Source

上海人寿首页险种数量接口提交

kouchengxing 4 years ago
parent
commit
d53aeb6971

+ 56 - 1
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/api/IndexApiController.java

@@ -65,7 +65,7 @@ public class IndexApiController extends BaseController {
                             if(object!=null){
                                 JSONObject source = object.getJSONObject("_source");
                                 xaxisData.add(source.getStr("kindname"));
-                                khnum.add(source.getStr("kindname"));
+                                khnum.add(source.getStr("khnum"));
                                 bdtotalPrem.add(source.getStr("tatolprem"));
                             }
 
@@ -94,6 +94,61 @@ public class IndexApiController extends BaseController {
         return AjaxResult.success("险种数据返回成功!",data);
     }
 
+    @GetMapping("/bdNumDis")
+    @ResponseBody
+    public AjaxResult bdNumDis() {
+        // 获取索引的别名,字段,创建时间
+        HttpConfig config = HttpConfig.custom().url("http://"+esHost+":"+esPort+"/shanglifeecif.bdnum_distribution/_search?");
+        String jsonStr = null;
+        List seriesData = new ArrayList();//客户数量和保单数量
+        try {
 
+            jsonStr = HttpClientUtil.get(config);
+            if(StringUtils.isNotEmpty(jsonStr)){
+                JSONObject jsonObject = JSONUtil.parseObj(jsonStr);
+                jsonObject = jsonObject.getJSONObject("hits");
+                if(jsonObject!=null){
+                    JSONArray hits = jsonObject.getJSONArray("hits");
+                    if(hits!=null && hits.size()>0){
+                        for (Object o:hits) {
+                            JSONObject object = JSONUtil.parseObj(o);
+                            if(object!=null){
+                                JSONObject source = object.getJSONObject("_source");
+                                Map map = new HashMap();
+                                String labelname = source.getStr("labelname").trim();
+                                map.put(source.getStr("bdnum"),source.getStr("labelname"));
+                                if("无保单".equals(labelname)){
+                                    seriesData.add(0,map);
+                                }else if("1件保单".equals(labelname)){
+                                    seriesData.add(1,map);
+                                }else if("2件保单".equals(labelname)){
+                                    seriesData.add(2,map);
+                                }else if("3-5件保单".equals(labelname)){
+                                    seriesData.add(3,map);
+                                }else if("6-10件保单".equals(labelname)){
+                                    seriesData.add(4,map);
+                                }else if("11-20件保单".equals(labelname)){
+                                    seriesData.add(5,map);
+                                }else if("21-50件保单".equals(labelname)){
+                                    seriesData.add(6,map);
+                                }else{
+                                    seriesData.add(7,map);
+                                }
+                            }
+
+                        }
+
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error("获取数据失败");
+        }
+
+        Map data = new HashMap();
+        data.put("seriesData",seriesData);
+        return AjaxResult.success("保单件数分布数据返回成功!",data);
+    }
 
 }