Browse Source

客户详情接口完善

kouchengxing 4 years ago
parent
commit
3817aa1b45

+ 106 - 46
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/api/CustomerApiController.java

@@ -147,7 +147,7 @@ public class CustomerApiController {
                 builder.append("{\"term\":{\"custclass\":\""+custclass+"\"}},");
             }
             if(StringUtils.isNotEmpty(sobirth)){
-                builder.append("{\"wildcard\":{\"ral\":\"*"+sobirth+"*\"}},");//模糊匹配
+                builder.append("{\"wildcard\":{\"sobirth\":\"*"+sobirth+"*\"}},");//模糊匹配
             }
 
             if(StringUtils.isNotEmpty(SCustID)){
@@ -240,9 +240,10 @@ public class CustomerApiController {
                     || StringUtils.isNotEmpty(beginBirthDay) || StringUtils.isNotEmpty(endBirthDay) || StringUtils.isNotEmpty(education)
                     || StringUtils.isNotEmpty(PIncomeS) || StringUtils.isNotEmpty(PIncomeE) || (StringUtils.isNotEmpty(gzgw) && "0".equals(gzgw))
                     || (StringUtils.isNotEmpty(zcgw) && "0".equals(zcgw)) || StringUtils.isNotEmpty(yx)
-                    || (StringUtils.isNotEmpty(lp) && "0".equals(lp) || StringUtils.isNotEmpty(deptCode) ||
+                    || (StringUtils.isNotEmpty(lp) && "0".equals(lp)) || StringUtils.isNotEmpty(deptCode) ||
                     StringUtils.isNotEmpty(participantsDateS) || StringUtils.isNotEmpty(participantsDateE) ||
-                    StringUtils.isNotEmpty(policybelong) )){
+                    StringUtils.isNotEmpty(policybelong) || StringUtils.isNotEmpty(name) || StringUtils.isNotEmpty(mobile)
+                    ){
                 builder.delete(builder.length()-1,builder.length());
             }
 
@@ -613,14 +614,23 @@ public class CustomerApiController {
 
             Map mpremMap = new HashMap();
             int firstDate = 1;//定义第一次长期险获取
+            String yyyy = "";
+            //获取最近年份
+            if(array!=null && array.size()>0){
+                JSONObject json = (JSONObject) array.get(array.size()-1);
+                JSONObject _source = (JSONObject) json.get("_source");
+                Date padate = _source.getDate("padate");
+                yyyy = DateUtils.parseDateToStr(DateUtils.YYYY, padate);
+            }
             for (int i = 0; i <array.size() ; i++) {
                 JSONObject json = (JSONObject)array.get(i);
                 JSONObject _source = (JSONObject) json.get("_source");
+                String padateStr = _source.getString("padate");
                 Date padate = _source.getDate("padate");
 
                 //xaxisData.add(DateUtils.parseDateToStr("MM",padate));
 
-                if(_source.containsKey("prem")){
+                if(_source.containsKey("prem") && padateStr.contains(yyyy)){
                     prem+=_source.getDouble("prem");
                     String m = DateUtils.parseDateToStr("M", padate);
 
@@ -720,7 +730,7 @@ public class CustomerApiController {
             mpInfo.put("prem",df.format(prem));
             mpInfo.put("sumprem",df.format(sumprem));
             mpInfo.put("insureDay",(insureDay/365) +"年"+(insureDay%365)+"天");
-            mpInfo.put("guaranteeDay",guaranteeDay>insureDay?(insureDay/365) +"年"+(insureDay%365)+"天":(guaranteeDay/365) +"年"+(guaranteeDay%365)+"天");
+            mpInfo.put("guaranteeDay",guaranteeDay>insureDay?insureDay+"天":guaranteeDay+"天");
             map.put("custInfo",mpInfo);
             map.put("majorCategorie",majorCategorie);
             logger.info("出客户概览时间:"+DateUtils.getTime());
@@ -733,45 +743,63 @@ public class CustomerApiController {
     }
 
     @GetMapping("/export")
-    public void export(HttpServletResponse response, HttpServletRequest request,String education,//学历
-                       String policybelong,//业绩归属
-                       String payS,String payE,  //年缴费区间
-                       String fadate,//投保年份
-                       String productname,//险种类别
-                       String  insuredAmountS,String  insuredAmountE,//保额区间
-                       String  ageS,String ageE,//年龄区间
-                       String gender,//性别
-                       String sobirth,//省份
-                       String NOVPolicy,//保单件数
-                       String custtype,//客户类型  投保人
-                       String  SCustID,// 核心客户号
-                       String custclass,//客户等级
-                       String participantsDateS,String participantsDateE,//参与方时间
-                       String PIncomeS,String PIncomeE,//年收入区间
-                       String   Insured,//投保对象
-                       String   lp,//理赔
-                       String   yx,//有效
-                       String gzgw,//关注官微
-                       String zcgw//注册官微
+    public void export(HttpServletResponse response, HttpServletRequest request,
+           String education,//学历
+           String policybelong,//业绩归属
+           String payS,String payE,  //年缴费区间
+           String fadate,//投保年份
+           String productname,//险种类别
+           String insuredAmountS,String  insuredAmountE,//保额区间
+           String ageS,String ageE,//年龄区间
+           String gender,//性别
+           String sobirth,//省份
+           String NOVPolicy,//保单件数
+           String custtype,//客户类型  投保人
+           String SCustID,// 核心客户号
+           String custclass,//客户等级
+           String participantsDateS,String participantsDateE,//参与方时间
+           String PIncomeS,String PIncomeE,//年收入区间
+           String Insured,//投保对象
+           String lp,//理赔
+           String yx,//有效
+           String gzgw,//关注官微
+           String zcgw,//注册官微
+           String name,//客户姓名
+           String idcard,//客户证件号码
+           String mobile//客户手机号
     ) {
         logger.info("导出进时间:"+DateUtils.getTime());
-        String beginBirthDay = "";
-        String endBirthDay = "";
-        if(StringUtils.isNotEmpty(ageS)){
-            String year = DateUtils.getYYYY();
-            int bYear = Integer.parseInt(year)-Integer.parseInt(ageS);
-            endBirthDay = bYear+"-"+DateUtils.getMMDD();
-        }
-
-        if(StringUtils.isNotEmpty(ageE)){
-            String year = DateUtils.getYYYY();
-            int bYear = Integer.parseInt(year)-Integer.parseInt(ageE);
-            beginBirthDay = bYear+"-"+DateUtils.getMMDD();
-        }
         try{
             Long userId = SecurityUtils.getUserId();
             SysUser sysUser = userService.selectUserById(userId);
             String deptCode = sysUser.getDept().getDeptCode();
+            //1.如果存在保单信息的查询条件,需要先查询保单信息然后通过保单关联出客户信息
+            //处理保单查询条件
+            /*List<String> customerIds = new ArrayList<String>();
+            if(StringUtils.isNotEmpty(payS) || StringUtils.isNotEmpty(payE)
+                    || StringUtils.isNotEmpty(insuredAmountS) || StringUtils.isNotEmpty(insuredAmountE)
+                    || StringUtils.isNotEmpty(productname) || StringUtils.isNotEmpty(fadate)){
+                customerIds = queryInsurancearrangement(policybelong,payS,payE,fadate,productname,insuredAmountS,insuredAmountE);
+            }*/
+
+
+            //2.如果没有客户信息以外的查询条件,只需要查询客户信息
+
+            // 获取索引的别名,字段,创建时间
+            String beginBirthDay = "";
+            String endBirthDay = "";
+            if(StringUtils.isNotEmpty(ageS)){
+                String year = DateUtils.getYYYY();
+                int bYear = Integer.parseInt(year)-Integer.parseInt(ageS);
+                endBirthDay = bYear+"-"+DateUtils.getMMDD();
+            }
+
+            if(StringUtils.isNotEmpty(ageE)){
+                String year = DateUtils.getYYYY();
+                int bYear = Integer.parseInt(year)-Integer.parseInt(ageE);
+                beginBirthDay = bYear+"-"+DateUtils.getMMDD();
+            }
+
             //拼装查询条件
             StringBuilder builder =new StringBuilder();
             builder.append("{");
@@ -787,6 +815,17 @@ public class CustomerApiController {
                 builder.append("{\"prefix\":{\"policybelong\":\""+policybelong+"\"}},");
             }
 
+            //客户姓名
+            if(StringUtils.isNotEmpty(name)){
+                builder.append("{\"wildcard\":{\"name\":\"*"+name+"*\"}},");
+            }
+
+            //客户手机
+            if(StringUtils.isNotEmpty(mobile)){
+                builder.append("{\"wildcard\":{\"pmphone\":\"*"+mobile+"*\"}},");
+            }
+
+
             if(StringUtils.isNotEmpty(gender)){
                 builder.append("{\"prefix\":{\"gender\":"+gender+"}},");
             }
@@ -797,7 +836,7 @@ public class CustomerApiController {
                 builder.append("{\"term\":{\"custclass\":\""+custclass+"\"}},");
             }
             if(StringUtils.isNotEmpty(sobirth)){
-                builder.append("{\"wildcard\":{\"ral\":\"*"+sobirth+"*\"}},");//模糊匹配
+                builder.append("{\"wildcard\":{\"sobirth\":\"*"+sobirth+"*\"}},");//模糊匹配
             }
 
             if(StringUtils.isNotEmpty(SCustID)){
@@ -863,6 +902,15 @@ public class CustomerApiController {
                 builder.append ("]}},");
             }
 
+            /*if(customerIds.size()>0){
+                builder.append("{\"terms\":{\"scustid\":[");
+                for (String id:customerIds) {
+                    builder.append("\""+id+"\",");
+                }
+                builder.delete(builder.length()-1,builder.length());
+                builder.append ("]}},");
+            }*/
+
 
             if(StringUtils.isNotEmpty(gzgw) && "0".equals(gzgw)){
                 builder.append("{\"prefix\":{\"label73\":\"关注官微\"}},");
@@ -881,9 +929,9 @@ public class CustomerApiController {
                     || StringUtils.isNotEmpty(beginBirthDay) || StringUtils.isNotEmpty(endBirthDay) || StringUtils.isNotEmpty(education)
                     || StringUtils.isNotEmpty(PIncomeS) || StringUtils.isNotEmpty(PIncomeE) || (StringUtils.isNotEmpty(gzgw) && "0".equals(gzgw))
                     || (StringUtils.isNotEmpty(zcgw) && "0".equals(zcgw)) || StringUtils.isNotEmpty(yx)
-                    || (StringUtils.isNotEmpty(lp) && "0".equals(lp) || StringUtils.isNotEmpty(deptCode) ||
-                    StringUtils.isNotEmpty(participantsDateS) || StringUtils.isNotEmpty(participantsDateE))
-                    || StringUtils.isNotEmpty(policybelong)
+                    || (StringUtils.isNotEmpty(lp) && "0".equals(lp)) || StringUtils.isNotEmpty(deptCode) ||
+                    StringUtils.isNotEmpty(participantsDateS) || StringUtils.isNotEmpty(participantsDateE) ||
+                    StringUtils.isNotEmpty(policybelong) || StringUtils.isNotEmpty(name) || StringUtils.isNotEmpty(mobile)
                     ){
                 builder.delete(builder.length()-1,builder.length());
             }
@@ -911,7 +959,19 @@ public class CustomerApiController {
             }
 
             builder.append("],");
-            builder.append("\"should\":[]");//should
+            builder.append("\"should\":[");
+
+            //客户证件号码
+            if(StringUtils.isNotEmpty(idcard)){
+                builder.append("{\"wildcard\":{\"idcard\":\"*"+idcard+"*\"}},");
+                builder.append("{\"wildcard\":{\"passport\":\"*"+idcard+"*\"}},");
+                builder.append("{\"wildcard\":{\"dlicense\":\"*"+idcard+"*\"}},");
+                builder.append("{\"wildcard\":{\"otheridnumber\":\"*"+idcard+"*\"}},");
+                builder.delete(builder.length()-1,builder.length());
+            }
+
+
+            builder.append("]");//should
             builder.append("}");//boot结束
             builder.append("},");//query结束
             builder.append("\"from\":\"0\",");//第几页
@@ -959,9 +1019,9 @@ public class CustomerApiController {
                     customer.setNum(jsonOb.getString("label25"));
                     String ral = jsonOb.getString("ral");
                     if(StringUtils.isNotBlank(ral)){
-                        List list = AddressResolutionUtil.addressResolution(ral);
+                        List<Map> list = AddressResolutionUtil.addressResolution(ral);
                         if(list!=null && list.size()>0){
-                            customer.setProvince(list.get(0).toString());
+                            customer.setProvince(list.get(0).get("province").toString());
                         }
                     }
                     if(mp.containsKey("birthday")){
@@ -1051,7 +1111,7 @@ public class CustomerApiController {
             header.put("education", "学历");
             header.put("vaild", "是否有效客户");
             header.put("policyBelong", "业绩归属");
-            header.put("pIncome", "年收入");
+            header.put("pIncome", "年收入(万)");
             header.put("num", "保单件数");
             CsvUtil.export(request, response, "customer", header, customers);
             logger.info("导出出时间:"+DateUtils.getTime());