Browse Source

测试环境bug修改

kouchengxing 4 years ago
parent
commit
80c4df1714

+ 0 - 26
dgtis-modules/dgtis-modules-data/pom.xml

@@ -78,12 +78,6 @@
         </dependency>
 
 
-       <!-- <dependency>
-            <groupId>org.elasticsearch.client</groupId>
-            <artifactId>transport</artifactId>
-            <version>7.6.2</version>
-        </dependency>-->
-
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpclient</artifactId>
@@ -102,26 +96,6 @@
             <version>5.3.8</version>
         </dependency>
 
-        <!--&lt;!&ndash; Java Low Level REST Client &ndash;&gt;
-        <dependency>
-            <groupId>org.elasticsearch.client</groupId>
-            <artifactId>elasticsearch-rest-client</artifactId>
-            <version>7.6.2</version>
-        </dependency>
-
-        &lt;!&ndash; Java High Level REST Client &ndash;&gt;
-        <dependency>
-            <groupId>org.elasticsearch.client</groupId>
-            <artifactId>elasticsearch-rest-high-level-client</artifactId>
-            <version>7.6.2</version>
-        </dependency>-->
-
-<!--        <dependency>-->
-<!--            <groupId>org.elasticsearch.client</groupId>-->
-<!--            <artifactId>rest</artifactId>-->
-<!--            <version>5.5.1</version>-->
-<!--        </dependency>-->
-        <!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client -->
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-client</artifactId>

+ 149 - 23
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/api/CustomerApiController.java

@@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.dgtis.common.core.utils.DateUtils;
 import com.dgtis.common.core.utils.StringUtils;
-import com.dgtis.common.core.utils.sql.EsJsonUtil;
+import com.dgtis.common.core.utils.poi.ExcelUtil;
 import com.dgtis.common.core.web.domain.AjaxResult;
+import com.dgtis.common.security.utils.SecurityUtils;
+import com.dgtis.data.domain.Customer;
 import org.apache.http.HttpEntity;
 import org.apache.http.entity.ContentType;
 import org.apache.http.nio.entity.NStringEntity;
@@ -20,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.text.DecimalFormat;
 import java.util.*;
 
@@ -35,6 +39,8 @@ public class CustomerApiController {
     private static Logger logger = LoggerFactory.getLogger(CustomerApiController.class);
     @Autowired
     private RestClient restClient;
+
+
     @GetMapping("/getCustomerList")
     @ResponseBody
     public AjaxResult getCustomerList(@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "10") int pageSize,
@@ -65,7 +71,9 @@ public class CustomerApiController {
 
         try {
             logger.info("进客户列表时间:"+DateUtils.getTime());
-
+            Long userId = SecurityUtils.getUserId();
+            /*SysUser sysUser = userService.selectUserById(userId);
+            String deptCode = sysUser.getDept().getDeptCode();*/
             //1.如果存在保单信息的查询条件,需要先查询保单信息然后通过保单关联出客户信息
             //处理保单查询条件
             List<String> customerIds = new ArrayList<String>();
@@ -75,13 +83,6 @@ public class CustomerApiController {
                 customerIds = queryInsurancearrangement(policybelong,payS,payE,fadate,productname,insuredAmountS,insuredAmountE);
             }
 
-            if(StringUtils.isNotEmpty(lp)){
-                if ("0".equals(lp)){
-                    customerIds = queryInsurancearrangementLp(lp);
-                }
-            }
-
-
 
             //2.如果没有客户信息以外的查询条件,只需要查询客户信息
 
@@ -106,6 +107,12 @@ public class CustomerApiController {
             builder.append("\"query\":{");//query开始
             builder.append("\"bool\":{");//boot开始
             builder.append("\"must\":[");//must开始
+            //业绩归属字段
+            /*if(StringUtils.isNotEmpty(deptCode)){
+                builder.append("{\"prefix\":{\"policybelong\":"+deptCode+"}},");
+            }*/
+
+
             if(StringUtils.isNotEmpty(gender)){
                 builder.append("{\"prefix\":{\"gender\":"+gender+"}},");
             }
@@ -123,7 +130,7 @@ public class CustomerApiController {
                 builder.append("{\"wildcard\":{\"scustid\":\"*"+SCustID+"*\"}},");//模糊匹配
             }
             if(StringUtils.isNotEmpty(custtype)){
-                builder.append("{\"prefix\":{\"custtype\":\""+custtype+"\"}},");
+                builder.append("{\"wildcard\":{\"custtype\":\"*"+custtype+"*\"}},");
             }
 
             if(StringUtils.isNotEmpty(beginBirthDay) && StringUtils.isNotEmpty(endBirthDay)){
@@ -155,7 +162,7 @@ public class CustomerApiController {
                     builder.append("{\"range\":{\"novpolicy\":{\"gt\":\""+yx+"\"}}},");
                 }else
                 {
-                    builder.append("{\"range\":{\"noivpolicy\":{\"gt\":\""+yx+"\"}}},");
+                    builder.append("{\"prefix\":{\"label91\":\"失效客户\"}},");
                 }
             }
 
@@ -179,25 +186,51 @@ public class CustomerApiController {
             }
 
 
-            if(StringUtils.isNotEmpty(gzgw)){
+            if(StringUtils.isNotEmpty(gzgw) && "0".equals(gzgw)){
                 builder.append("{\"prefix\":{\"label73\":\"关注官微\"}},");
             }
 
-            if(StringUtils.isNotEmpty(zcgw)){
+            if(StringUtils.isNotEmpty(zcgw) && "0".equals(zcgw)){
                 builder.append("{\"prefix\":{\"label74\":\"注册官微\"}},");
             }
 
+            if(StringUtils.isNotEmpty(lp) && "0".equals(lp)){
+                builder.append("{\"prefix\":{\"label57\":\"最近一次理赔类型\"}},");
+            }
 
             if(StringUtils.isNotEmpty(gender) || StringUtils.isNotEmpty(NOVPolicy) || StringUtils.isNotEmpty(custtype)
                     || StringUtils.isNotEmpty(custclass) || StringUtils.isNotEmpty(sobirth) || StringUtils.isNotEmpty(SCustID)
                     || StringUtils.isNotEmpty(beginBirthDay) || StringUtils.isNotEmpty(endBirthDay) || StringUtils.isNotEmpty(education)
-                    || StringUtils.isNotEmpty(PIncomeS) || StringUtils.isNotEmpty(PIncomeE) || StringUtils.isNotEmpty(gzgw)
-                    || StringUtils.isNotEmpty(zcgw) || StringUtils.isNotEmpty(yx) || customerIds.size()>0){
+                    || 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) ||
+                    customerIds.size()>0)){
                 builder.delete(builder.length()-1,builder.length());
             }
 
             builder.append("],");//must结束
-            builder.append("\"must_not\":[],");//must_not
+            builder.append("\"must_not\":[");//must_not
+            if(StringUtils.isNotEmpty(gzgw) && "1".equals(gzgw)){
+                builder.append("{\"prefix\":{\"label73\":\"关注官微\"}},");
+            }
+
+            if(StringUtils.isNotEmpty(zcgw) && "1".equals(zcgw)){
+                builder.append("{\"prefix\":{\"label74\":\"注册官微\"}},");
+            }
+
+            if(StringUtils.isNotEmpty(lp) && "1".equals(lp)){
+                builder.append("{\"prefix\":{\"label57\":\"最近一次理赔类型\"}},");
+            }
+
+            if(
+                    (StringUtils.isNotEmpty(gzgw) && "1".equals(gzgw))
+                    || (StringUtils.isNotEmpty(zcgw) && "1".equals(zcgw))
+                    || (StringUtils.isNotEmpty(lp) && "1".equals(lp))
+                ){
+                builder.delete(builder.length()-1,builder.length());
+            }
+
+            builder.append("],");
             builder.append("\"should\":[]");//should
             builder.append("}");//boot结束
             builder.append("},");//query结束
@@ -279,14 +312,14 @@ public class CustomerApiController {
         }
 
         if(StringUtils.isNotEmpty(payS) && StringUtils.isNotEmpty(payE)){
-            builder.append("{\"range\":{\"Prem\":{\"gt\":\""+payS+"\",\"lt\":\""+payE+"\"}}},");
+            builder.append("{\"range\":{\"prem\":{\"gt\":\""+payS+"\",\"lt\":\""+payE+"\"}}},");
         }else{
 
             if(StringUtils.isNotEmpty(payS)){
-                builder.append("{\"range\":{\"Prem\":{\"gt\":\""+payS+"\"}}},");
+                builder.append("{\"range\":{\"prem\":{\"gt\":\""+payS+"\"}}},");
             }
             if(StringUtils.isNotEmpty(payE)){
-                builder.append("{\"range\":{\"Prem\":{\"lt\":\""+payE+"\"}}},");
+                builder.append("{\"range\":{\"prem\":{\"lt\":\""+payE+"\"}}},");
             }
         }
 
@@ -482,7 +515,7 @@ public class CustomerApiController {
             map.put("relationship",relationship);
           query  =new HashMap();
           query.put("applicantid",indid);
-          scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?pretty=true&q=lpscutid:"+scustid);
+          scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?size=100&pretty=true&q=lpscutid:"+scustid);
 
           response = restClient.performRequest(scriptRequest);
 //          response= restClient.performRequest("GET", "/shanglifeecif.insuranceclaimthread/_search",Collections.<String, String>emptyMap(),entity);
@@ -500,9 +533,7 @@ public class CustomerApiController {
           }
           map.put("insuranceclaimthread",insuranceclaimthread);
 
-          query  =new HashMap();
-          query.put("applicantid",indid);
-          scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?pretty=true&sort=padate:asc&q=applicantscustid:"+scustid);
+          scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q=applicantscustid:"+scustid);
 
           response = restClient.performRequest(scriptRequest);
           result = EntityUtils.toString(response.getEntity());
@@ -708,6 +739,101 @@ public class CustomerApiController {
         }
     }
 
+    @PostMapping("/export")
+    public void export(HttpServletResponse response) throws Exception
+    {
+
+        //拼装查询条件
+        StringBuilder builder =new StringBuilder();
+        builder.append("{");
+        builder.append("\"query\":{");//query开始
+        builder.append("\"bool\":{");//boot开始
+        builder.append("\"must\":[");//must开始
+        //业绩归属字段
+        /*if(StringUtils.isNotEmpty(deptCode)){
+            builder.append("{\"prefix\":{\"policybelong\":"+deptCode+"}},");
+        }*/
+        builder.append("],");//must结束
+        builder.append("\"must_not\":[");//must_not
+        builder.append("],");
+        builder.append("\"should\":[]");//should
+        builder.append("}");//boot结束
+        builder.append("},");//query结束
+       // builder.append("\"from\":"+((pageNum-1)*10)+",");//第几页
+        //builder.append("\"size\":"+100+",");//查询几个
+        builder.append("\"sort\":[{\"scustid\":{\"order\":\"asc\"}}],");//排序
+        builder.append("\"aggs\":{}");//
+        builder.append("}");
+
+        HttpEntity entity = new NStringEntity(builder.toString(), ContentType.APPLICATION_JSON);
+        Request scriptRequest = new Request("GET", "/shanglifeecif.individual/_search?size=1000&pretty=true");
+        scriptRequest.setEntity(entity);
+        Response responseData = restClient.performRequest(scriptRequest);
+        String result = EntityUtils.toString(responseData.getEntity());
+        JSONObject jsonObject = JSON.parseObject(result);
+        JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
+        JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
+        List<Customer> customers = new ArrayList<Customer>();
+        for (int i = 0; i <array.size() ; i++) {
+            JSONObject json = (JSONObject)array.get(i);
+            Map mp = new HashMap();
+            Customer customer = new Customer();
+            json.getString("_source");
+            mp.put("id",json.getString("_id"));
+            JSONObject jsonOb = JSON.parseObject(json.getString("_source"));
+            mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
+            customer.setScustId(jsonOb.getString("scustid"));
+            customer.setCustId(jsonOb.getString("custid"));
+            customer.setName(jsonOb.getString("name"));
+            customer.setSex("0".equals(jsonOb.getString("gender"))?"男":"女");
+            if(mp.containsKey("birthday")){
+                mp.put("birthday", jsonOb.getString("birthday").substring(0,10));
+                mp.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,jsonOb.getString("birthday"))));
+                customer.setBirthDay(jsonOb.getString("birthday").substring(0,10));
+                customer.setAge(DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,jsonOb.getString("birthday"))));
+            }
+
+            if(mp.containsKey("idcard")){
+                customer.setIdType("身份证");
+                customer.setIdCard(jsonOb.getString("idcard"));
+            }else if(mp.containsKey("passport")){
+                customer.setIdType("护照");
+                customer.setIdCard(jsonOb.getString("passport"));
+            }else if(mp.containsKey("dlicense")){
+                customer.setIdType("驾驶证");
+                customer.setIdCard(jsonOb.getString("dlicense"));
+            }else if(mp.containsKey("othernumber")){
+                customer.setIdType("其它证件类型");
+                customer.setIdCard(jsonOb.getString("othernumber"));
+            }
+
+            if(mp.containsKey("custclass")){
+                String custclass = jsonOb.getString("custclass");
+                   switch (custclass){
+                       case "1":
+                           customer.setCustClass("钻石");
+                       case "2":
+                           customer.setCustClass("白金");
+                       case "3":
+                           customer.setCustClass("黄金");
+                       case "4":
+                           customer.setCustClass("普通");
+                        default:
+                            customer.setCustClass("无");
+                   }
+
+            }else{
+                customer.setCustClass("无");
+            }
+
+            customers.add(customer);
+        }
+
+        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
+        util.exportExcel(response, customers, "客户数据");
+
+    }
+
 
 
 }

+ 126 - 0
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/domain/Customer.java

@@ -0,0 +1,126 @@
+package com.dgtis.data.domain;
+
+import com.dgtis.common.core.annotation.Excel;
+
+/**
+ * @author koucx
+ * @version 1.0
+ * @descption: TODO
+ * @company 神州数码通用软件(洛阳)有限公司
+ * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+ * @date 2021-03-03
+ * @since JDK1.8
+ */
+public class Customer {
+
+    /** 核心客户号 */
+    @Excel(name = "核心客户号")
+    private String scustId;
+
+    /** 客户号 */
+    @Excel(name = "客户号")
+    private String custId;
+
+    /** 姓名 */
+    @Excel(name = "姓名")
+    private String name;
+
+    /** 证件类型 */
+    @Excel(name = "证件类型")
+    private String idType;
+
+
+    /** 证件号码 */
+    @Excel(name = "证件号码")
+    private String idCard;
+
+    /** 性别 */
+    @Excel(name = "性别")
+    private String sex;
+
+    /** 出生日期 */
+    @Excel(name = "出生日期")
+    private String birthDay;
+
+
+    /** 年龄 */
+    @Excel(name = "年龄")
+    private int age;
+
+
+    /** 客户等级 */
+    @Excel(name = "客户等级")
+    private String custClass;
+
+    public String getScustId() {
+        return scustId;
+    }
+
+    public void setScustId(String scustId) {
+        this.scustId = scustId;
+    }
+
+    public String getCustId() {
+        return custId;
+    }
+
+    public void setCustId(String custId) {
+        this.custId = custId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getIdType() {
+        return idType;
+    }
+
+    public void setIdType(String idType) {
+        this.idType = idType;
+    }
+
+    public String getIdCard() {
+        return idCard;
+    }
+
+    public void setIdCard(String idCard) {
+        this.idCard = idCard;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
+
+    public String getBirthDay() {
+        return birthDay;
+    }
+
+    public void setBirthDay(String birthDay) {
+        this.birthDay = birthDay;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public String getCustClass() {
+        return custClass;
+    }
+
+    public void setCustClass(String custClass) {
+        this.custClass = custClass;
+    }
+}

+ 2 - 1
dgtis-modules/dgtis-modules-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<id     property="deptId"   column="dept_id"     />
 		<result property="parentId" column="parent_id"   />
 		<result property="deptName" column="dept_name"   />
+		<result property="deptCode" column="dept_code"   />
 		<result property="orderNum" column="order_num"   />
 		<result property="leader"   column="leader"      />
 		<result property="status"   column="dept_status" />
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	
 	<sql id="selectUserVo">
         select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, 
-        d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
+        d.dept_id,d.dept_code, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
         r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
         from sys_user u
 		    left join sys_dept d on u.dept_id = d.dept_id