|
@@ -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, "客户数据");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|