|
@@ -76,23 +76,11 @@ public class CustomerApiController {
|
|
|
String mobile//客户手机号
|
|
|
) {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
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>();
|
|
|
- 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.如果没有客户信息以外的查询条件,只需要查询客户信息
|
|
|
|
|
@@ -217,16 +205,6 @@ 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\":\"关注官微\"}},");
|
|
|
}
|
|
@@ -336,117 +314,6 @@ public class CustomerApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询保单信息返回客户Id
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List queryInsurancearrangement(String policybelong,String payS,String payE,String fadate,
|
|
|
- String productname,String insuredAmountS,String insuredAmountE) throws Exception {
|
|
|
-
|
|
|
- List<String> customerIds = new ArrayList<String>();
|
|
|
-
|
|
|
- //拼装查询条件
|
|
|
- StringBuilder builder =new StringBuilder();
|
|
|
- builder.append("{");
|
|
|
- builder.append("\"query\": {");//query开始
|
|
|
- builder.append("\"bool\": {");//boot开始
|
|
|
- builder.append("\"must\": [");//must开始
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(policybelong)){
|
|
|
- builder.append("{\"prefix\": { \"policybelong\": \""+policybelong+"\"}},");
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(fadate)){
|
|
|
- builder.append("{\"prefix\": { \"padate\": \""+fadate+"\"}},");
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(productname)){
|
|
|
- builder.append("{\"prefix\": { \"risk_categories\": \""+productname+"\"}},");
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(payS) && StringUtils.isNotEmpty(payE)){
|
|
|
- builder.append("{\"range\":{\"prem\":{\"gt\":\""+payS+"\",\"lt\":\""+payE+"\"}}},");
|
|
|
- }else{
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(payS)){
|
|
|
- builder.append("{\"range\":{\"prem\":{\"gt\":\""+payS+"\"}}},");
|
|
|
- }
|
|
|
- if(StringUtils.isNotEmpty(payE)){
|
|
|
- builder.append("{\"range\":{\"prem\":{\"lt\":\""+payE+"\"}}},");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(insuredAmountS) && StringUtils.isNotEmpty(insuredAmountE)){
|
|
|
- builder.append("{\"range\":{\"Risk\":{\"gt\":\""+insuredAmountS+"\",\"lt\":\""+insuredAmountE+"\"}}},");
|
|
|
- }else{
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(payS)){
|
|
|
- builder.append("{\"range\":{\"Risk\":{\"gt\":\""+insuredAmountS+"\"}}},");
|
|
|
- }
|
|
|
- if(StringUtils.isNotEmpty(payE)){
|
|
|
- builder.append("{\"range\":{\"Risk\":{\"lt\":\""+insuredAmountE+"\"}}},");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(policybelong) || StringUtils.isNotEmpty(payS) || StringUtils.isNotEmpty(payE)
|
|
|
- || StringUtils.isNotEmpty(insuredAmountS) || StringUtils.isNotEmpty(insuredAmountE)
|
|
|
- || StringUtils.isNotEmpty(productname) || StringUtils.isNotEmpty(fadate) ){
|
|
|
- builder.delete(builder.length()-1,builder.length());
|
|
|
- }
|
|
|
-
|
|
|
- builder.append("],");//must结束
|
|
|
- builder.append("\"must_not\": [ ],");//must_not
|
|
|
- builder.append("\"should\": [ ]");//should
|
|
|
- builder.append("}");//boot结束
|
|
|
- builder.append("},");//query结束
|
|
|
- //builder.append("\"from\": "+pageNum+",");//第几页
|
|
|
- builder.append("\"size\": 1000,");//查询几个
|
|
|
- //builder.append(" \"sort\": [{\"created_time\":{\"order\":\"desc\"}}],");//排序
|
|
|
- builder.append(" \"aggs\": {}");//
|
|
|
- builder.append("}");
|
|
|
-
|
|
|
- HttpEntity entity = new NStringEntity(builder.toString(), ContentType.APPLICATION_JSON);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- String result = EntityUtils.toString(response.getEntity());
|
|
|
- JSONObject jsonObject = JSON.parseObject(result);
|
|
|
- JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
- JSONArray hitsList = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
- String scroll_id = jsonObject.getString("_scroll_id");
|
|
|
-
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("scroll_id",scroll_id);
|
|
|
- obj.put("scroll","1m");
|
|
|
- if (hitsList.size() != 0) {
|
|
|
-
|
|
|
- // 这里填写你的业务逻辑,即对每一条数据的处理
|
|
|
- for (int i = 0; i <hitsList.size() ; i++) {
|
|
|
- JSONObject json = (JSONObject)hitsList.get(i);
|
|
|
- JSONObject jsonOb = JSON.parseObject(json.getString("_source"));
|
|
|
- if(StringUtils.isNotEmpty(jsonOb.getString("applicantscustid"))){
|
|
|
- customerIds.add(jsonOb.getString("applicantscustid"));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- // 继续向后查询
|
|
|
- /* entity = new NStringEntity(JSONUtil.toJsonStr(obj), ContentType.APPLICATION_JSON);
|
|
|
- scriptRequest = new Request("GET", "/_search/scroll?");
|
|
|
- scriptRequest.setEntity(entity);
|
|
|
- response = restClient.performRequest(scriptRequest);
|
|
|
- result = EntityUtils.toString(response.getEntity());
|
|
|
- jsonObject = JSON.parseObject(result);
|
|
|
- hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
- hitsList = JSON.parseArray(hitsobject.get("hits").toString());*/
|
|
|
- }
|
|
|
-
|
|
|
- return customerIds;
|
|
|
- }
|
|
|
-
|
|
|
@GetMapping("/getCustomerById")
|
|
|
@ResponseBody
|
|
|
public AjaxResult getCustomerById(String id) {
|
|
@@ -628,11 +495,8 @@ public class CustomerApiController {
|
|
|
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");
|
|
|
|
|
|
-
|
|
|
-
|
|
|
if(i==0){
|
|
|
insureDay = DateUtils.getDateDifDay(new Date(),padate);
|
|
|
}
|
|
@@ -672,7 +536,6 @@ public class CustomerApiController {
|
|
|
if(mpremMap.containsKey(m)){
|
|
|
double tprem = Double.parseDouble(mpremMap.get(m).toString());
|
|
|
tprem+=_source.getDouble("prem");
|
|
|
- //mpremMap.put(m,mprem);
|
|
|
mpremMap.put(m,df.format(tprem));
|
|
|
edata[Integer.parseInt(m)-1] = df.format(tprem);
|
|
|
adata[Integer.parseInt(m)-1] = df.format(tprem);
|
|
@@ -691,7 +554,6 @@ public class CustomerApiController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //String risk_categories = _source.getString("risk_categories");
|
|
|
String risk_categories_name = _source.getString("risk_categories_name");
|
|
|
|
|
|
if(majorCategorie.containsKey(risk_categories_name)){
|
|
@@ -706,9 +568,20 @@ public class CustomerApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
+ }else{
|
|
|
+ //客户的所有保单缴费期满且承保期限已满正常终止的客户,需要加上累计保费
|
|
|
+ if("终止".equals(_source.getString("policystate"))){
|
|
|
+ String norenewal = _source.getString("norenewal")==null?"":_source.getString("norenewal").trim();//续保次数
|
|
|
+ String payendyear = _source.getString("payendyear")==null?"":_source.getString("payendyear").trim();//缴费年期
|
|
|
+ Date pmdate = _source.getDate("pmdate");//终保日期
|
|
|
+ if(norenewal.equals(payendyear) && currentDateTime.compareTo(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,pmdate))>0){
|
|
|
+ if(_source.containsKey("sumprem")){
|
|
|
+ sumprem+=_source.getDouble("sumprem");
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -721,7 +594,6 @@ public class CustomerApiController {
|
|
|
map.put("lineBarChartData",lineBarChartData);
|
|
|
//查询理赔信息
|
|
|
scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?size=100&pretty=true&q=lpscutid:"+scustid);
|
|
|
-
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
|
jsonObject = JSON.parseObject(result);
|
|
@@ -730,7 +602,6 @@ public class CustomerApiController {
|
|
|
Map insuranceclaimthread = new HashMap();
|
|
|
List insuranceclaimthreads = new ArrayList<>();
|
|
|
double claimAmount = 0;//理赔总金额
|
|
|
- //String claimType = "";//理赔类型
|
|
|
Set<String> claimTypeSet = new HashSet<>();//理赔类型
|
|
|
for (int i = 0; i <array.size() ; i++) {
|
|
|
JSONObject json = (JSONObject)array.get(i);
|
|
@@ -739,7 +610,6 @@ public class CustomerApiController {
|
|
|
if(claimSource.containsKey("ccamt")){
|
|
|
claimAmount+=claimSource.getDouble("ccamt");
|
|
|
}
|
|
|
- //claimType +="," + claimSource.getString("accidenttype");
|
|
|
claimTypeSet.add(claimSource.getString("accidenttype"));
|
|
|
insuranceclaimthreads.add(claimSource);
|
|
|
}
|
|
@@ -751,6 +621,21 @@ public class CustomerApiController {
|
|
|
mpInfo.put("sumprem",df.format(sumprem));//累计保费
|
|
|
mpInfo.put("handedinprem",df.format(handedinprem));//已交保费
|
|
|
mpInfo.put("insureDay",(insureDay/365) +"年"+(insureDay%365)+"天");
|
|
|
+ //保障天数需要加上退保之前的天数
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.surrenderprotectiontemp/_search?pretty=true&q=scustid:"+scustid);
|
|
|
+ response = restClient.performRequest(scriptRequest);
|
|
|
+ result = EntityUtils.toString(response.getEntity());
|
|
|
+ jsonObject = JSON.parseObject(result);
|
|
|
+ hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
+ array = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
+ for (int i = 0; i <array.size() ; i++) {
|
|
|
+ JSONObject json = (JSONObject)array.get(i);
|
|
|
+ JSONObject tbSource = JSON.parseObject(json.getString("_source"));
|
|
|
+ if(tbSource.containsKey("tbday")){
|
|
|
+ guaranteeDay+=tbSource.getInteger("tbday");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
mpInfo.put("guaranteeDay",guaranteeDay>insureDay?insureDay+"天":guaranteeDay+"天");
|
|
|
map.put("custInfo",mpInfo);
|
|
|
map.put("majorCategorie",majorCategorie);
|
|
@@ -927,16 +812,6 @@ 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\":\"关注官微\"}},");
|
|
|
}
|
|
@@ -1095,25 +970,6 @@ public class CustomerApiController {
|
|
|
customer.setCustClass("无");
|
|
|
}
|
|
|
|
|
|
- /*if(mp.containsKey("policybelong")){
|
|
|
- String policybelong = jsonOb.getString("policybelong");
|
|
|
- switch (policybelong){
|
|
|
- case "00":
|
|
|
- customer.setPolicyBelong("总部团险个单业务");
|
|
|
- case "01":
|
|
|
- customer.setPolicyBelong("上分团险个单业务");
|
|
|
- case "02":
|
|
|
- customer.setPolicyBelong("个险渠道");
|
|
|
- case "03":
|
|
|
- customer.setPolicyBelong("银保渠道");
|
|
|
- case "05":
|
|
|
- customer.setPolicyBelong("网销渠道");
|
|
|
- case "06":
|
|
|
- customer.setPolicyBelong("健康险事业部");
|
|
|
- }
|
|
|
-
|
|
|
- }*/
|
|
|
-
|
|
|
customers.add(customer);
|
|
|
}
|
|
|
|