|
@@ -77,6 +77,10 @@ public class CustomerApiController {
|
|
|
) {
|
|
|
|
|
|
try {
|
|
|
+ //模糊查询渠道
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ String deptCode = sysUser.getDept().getDeptCode();
|
|
|
logger.info("进客户列表时间:"+DateUtils.getTime());
|
|
|
/*Long userId = SecurityUtils.getUserId();
|
|
|
SysUser sysUser = userService.selectUserById(userId);
|
|
@@ -254,6 +258,11 @@ public class CustomerApiController {
|
|
|
builder.append("],");
|
|
|
builder.append("\"should\":[");
|
|
|
|
|
|
+ if(StringUtils.isNotEmpty(deptCode)){
|
|
|
+ //
|
|
|
+ builder.append("{\"wildcard\":{\"salecom\":\"*"+deptCode+"*\"}}");
|
|
|
+ }
|
|
|
+
|
|
|
//客户证件号码
|
|
|
if(StringUtils.isNotEmpty(idcard)){
|
|
|
builder.append("{\"wildcard\":{\"idcard\":\"*"+idcard+"*\"}},");
|
|
@@ -273,7 +282,7 @@ public class CustomerApiController {
|
|
|
builder.append("\"aggs\":{}");//
|
|
|
builder.append("}");
|
|
|
|
|
|
-
|
|
|
+ logger.info(builder.toString());
|
|
|
HttpEntity entity = new NStringEntity(builder.toString(), ContentType.APPLICATION_JSON);
|
|
|
String url = "/shanglifeecif.individual/_search?pretty=true";
|
|
|
Request scriptRequest = new Request("GET", url);
|
|
@@ -317,8 +326,15 @@ public class CustomerApiController {
|
|
|
@GetMapping("/getCustomerById")
|
|
|
@ResponseBody
|
|
|
public AjaxResult getCustomerById(String id) {
|
|
|
+
|
|
|
// 获取索引的别名,字段,创建时间http://10.32.2.231:9200/shanglifeecif.individual/default_type_/1
|
|
|
try {
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ String deptCode = "";
|
|
|
+ if(StringUtils.isNotEmpty( sysUser.getDept().getDeptCode())){
|
|
|
+ deptCode = sysUser.getDept().getDeptCode();
|
|
|
+ }
|
|
|
logger.info("进客户详情时间:"+DateUtils.getTime());
|
|
|
Map<String, String> paramMap = new HashMap<String, String>();
|
|
|
paramMap.put("pretty", "true");
|
|
@@ -328,23 +344,12 @@ public class CustomerApiController {
|
|
|
String result = EntityUtils.toString(response.getEntity());
|
|
|
Map map = new HashMap();
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
|
- Map mpInfo = new HashMap();
|
|
|
- String indid = jsonObject.getString("_id");
|
|
|
-
|
|
|
- mpInfo.put("id",indid);
|
|
|
JSONObject source = JSON.parseObject(jsonObject.getString("_source"));
|
|
|
- String scustid = source.getString("scustid");
|
|
|
+ String indid = jsonObject.getString("_id");
|
|
|
String custtype = source.getString("custtype");
|
|
|
- mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
|
|
|
- if(mpInfo.containsKey("birthday")){
|
|
|
- mpInfo.put("birthday", source.getString("birthday"));
|
|
|
- mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD,source.getString("birthday"))));
|
|
|
-
|
|
|
- }else{
|
|
|
- mpInfo.put("birthday","");
|
|
|
- mpInfo.put("age","");
|
|
|
- }
|
|
|
- map.put("custInfo",mpInfo);
|
|
|
+ String scustid = source.getString("scustid");
|
|
|
+ Map mpInfo = getLables(jsonObject, deptCode);
|
|
|
+ map.put("custInfo",mpInfo);
|
|
|
Map query =new HashMap();
|
|
|
query.put("indid1",indid);
|
|
|
scriptRequest = new Request("GET", "/shanglifeecif.indrelationship/_search?pretty=true&q=indid1:"+scustid);
|
|
@@ -364,7 +369,12 @@ public class CustomerApiController {
|
|
|
map.put("relationship",relationship);
|
|
|
query =new HashMap();
|
|
|
query.put("applicantid",indid);
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?size=100&pretty=true&q=lpscutid:"+scustid);
|
|
|
+ //理赔查询
|
|
|
+ String lpqSearch = "lpscutid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ lpqSearch = "(lpscutid:"+scustid+"%20AND%20salecom:"+deptCode+")";
|
|
|
+ }
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?size=100&pretty=true&q="+lpqSearch);
|
|
|
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
@@ -380,12 +390,22 @@ public class CustomerApiController {
|
|
|
insuranceclaimthread.add(mp);
|
|
|
}
|
|
|
map.put("insuranceclaimthread",insuranceclaimthread);
|
|
|
+//合约信息
|
|
|
|
|
|
if("被保人".equals(custtype.trim())){
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q=insuredscustid:"+scustid);
|
|
|
+ String qSearch = "insuredscustid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ qSearch = "(insuredscustid:"+scustid+"%20AND%20policybelong:"+deptCode+")";
|
|
|
+ }
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q="+qSearch);
|
|
|
}else{
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q=applicantscustid:"+scustid);
|
|
|
+ String qSearch = "applicantscustid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ qSearch = "(applicantscustid:"+scustid+"%20AND%20policybelong:"+deptCode+")";
|
|
|
+ }
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q="+qSearch);
|
|
|
}
|
|
|
+ logger.info("合约信息请求参数"+scriptRequest.getEndpoint());
|
|
|
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
@@ -401,7 +421,14 @@ public class CustomerApiController {
|
|
|
insurancearrangement.add(mp);
|
|
|
}
|
|
|
map.put("insurancearrangement",insurancearrangement);
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.partytimeline/_search?size=100&pretty=true&sort=sdate:asc&q=partyid:"+scustid);
|
|
|
+ //接触信息添加渠道条件
|
|
|
+ //接触信息
|
|
|
+ String jcqSearch = "partyid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ jcqSearch = "(partyid:"+scustid+"%20AND%20salecom:"+deptCode+")";
|
|
|
+ }
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.partytimeline/_search?size=100&pretty=true&sort=sdate:asc&q="+jcqSearch);
|
|
|
+ logger.info("接触信息请求参数:",scriptRequest.getEndpoint());
|
|
|
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
@@ -417,7 +444,8 @@ public class CustomerApiController {
|
|
|
partytimeline.add(mp);
|
|
|
}
|
|
|
map.put("partytimeline",partytimeline);
|
|
|
- logger.info("出客户详情时间:"+DateUtils.getTime());
|
|
|
+ logger.info(scriptRequest.getEndpoint());
|
|
|
+ logger.info("出客户详情时间:"+DateUtils.getTime());
|
|
|
return AjaxResult.success(map);
|
|
|
} catch (Exception e) {
|
|
|
logger.info("客户详情报错时间:"+DateUtils.getTime());
|
|
@@ -429,30 +457,28 @@ public class CustomerApiController {
|
|
|
@GetMapping("/getCustomerOverViewById")
|
|
|
@ResponseBody
|
|
|
public AjaxResult getCustomerOverViewById(String id) {
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ String deptCode = sysUser.getDept().getDeptCode();
|
|
|
// 获取索引的别名,字段,创建时间http://10.32.2.231:9200/shanglifeecif.individual/default_type_/1
|
|
|
try {
|
|
|
logger.info("进客户概览时间:"+DateUtils.getTime());
|
|
|
|
|
|
- Request scriptRequest = new Request("GET", "shanglifeecif.individual/default_type_/"+id+"?pretty=true");
|
|
|
+ Request scriptRequest = new Request("GET", "/shanglifeecif.individual/default_type_/"+id+"?pretty=true");
|
|
|
Response response = restClient.performRequest(scriptRequest);
|
|
|
|
|
|
String result = EntityUtils.toString(response.getEntity());
|
|
|
Map map = new HashMap();
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
|
- Map mpInfo = new HashMap();
|
|
|
- String indid = jsonObject.getString("_id");
|
|
|
- mpInfo.put("id",indid);
|
|
|
JSONObject source = JSON.parseObject(jsonObject.getString("_source"));
|
|
|
String scustid = source.getString("scustid");
|
|
|
- mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
|
|
|
- if(mpInfo.containsKey("birthday")){
|
|
|
- mpInfo.put("birthday", source.getString("birthday"));
|
|
|
- mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD,source.getString("birthday"))));
|
|
|
- }else{
|
|
|
- mpInfo.put("birthday","");
|
|
|
- mpInfo.put("age","");
|
|
|
+ Map mpInfo = getLables(jsonObject, deptCode);
|
|
|
+ String jcqSearch = "applicantscustid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ jcqSearch = "(applicantscustid:"+scustid+"%20AND%20policybelong:"+deptCode+")";
|
|
|
}
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q=applicantscustid:"+scustid);
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?size=100&pretty=true&sort=padate:asc&q="+jcqSearch);
|
|
|
+ logger.info("insurancearrangement",scriptRequest.getEndpoint());
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
|
jsonObject = JSON.parseObject(result);
|
|
@@ -495,7 +521,12 @@ public class CustomerApiController {
|
|
|
Date nextYearTime = cal.getTime();
|
|
|
String currentDateTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,date);
|
|
|
String currentYear = DateUtils.parseDateToStr(DateUtils.YYYY,date);
|
|
|
+
|
|
|
+ Set<String> noivpolicyset= new HashSet<>();//失效保单
|
|
|
+ Set<String> novpolicyset= new HashSet<>();//有效保单
|
|
|
+
|
|
|
//获取最近年份
|
|
|
+ logger.info("getCustomerOverViewById",array.toJSONString());
|
|
|
for (int i = 0; i <array.size() ; i++) {
|
|
|
JSONObject json = (JSONObject)array.get(i);
|
|
|
JSONObject _source = (JSONObject) json.get("_source");
|
|
@@ -505,6 +536,7 @@ public class CustomerApiController {
|
|
|
insureDay = DateUtils.getDateDifDay(new Date(),padate);
|
|
|
}
|
|
|
if("有效".equals(_source.getString("policystate"))){
|
|
|
+ novpolicyset.add(_source.getString("iaid"));
|
|
|
|
|
|
if(_source.containsKey("sumprem")){
|
|
|
sumprem+=_source.getDouble("sumprem");
|
|
@@ -610,10 +642,14 @@ public class CustomerApiController {
|
|
|
Date pindate = _source.getDate("pindate");//起保日期
|
|
|
guaranteeDay+=DateUtils.getDateDifDay(pmdate,pindate);
|
|
|
}
|
|
|
+ noivpolicyset.add(_source.getString("iaid"));
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ mpInfo.put("noivpolicy",noivpolicyset.size());
|
|
|
+ mpInfo.put("novpolicy",novpolicyset.size());
|
|
|
|
|
|
expectedData.put("data",edata);
|
|
|
actaulData.put("data",adata);
|
|
@@ -623,7 +659,11 @@ public class CustomerApiController {
|
|
|
lineBarChartData.put("xaxisData",xaxisData);
|
|
|
map.put("lineBarChartData",lineBarChartData);
|
|
|
//查询理赔信息
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?size=100&pretty=true&q=lpscutid:"+scustid);
|
|
|
+ String lpqSearch = "lpscutid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ lpqSearch = "(lpscutid:"+scustid+"%20AND%20salecom:"+deptCode+")";
|
|
|
+ }
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?size=100&pretty=true&q="+lpqSearch);
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
|
jsonObject = JSON.parseObject(result);
|
|
@@ -652,7 +692,11 @@ public class CustomerApiController {
|
|
|
mpInfo.put("handedinprem",df.format(handedinprem));//已交保费
|
|
|
mpInfo.put("insureDay",(insureDay/365) +"年"+(insureDay%365)+"天");
|
|
|
//保障天数需要加上退保之前的天数
|
|
|
- scriptRequest = new Request("GET", "/shanglifeecif.tbcustomerinfo/_search?pretty=true&sort=sdate:asc&size=100&q=scustid:"+scustid);
|
|
|
+ String tbcustomerinfoSearch = "scustid:"+scustid;
|
|
|
+ if( StringUtils.isNotEmpty(deptCode)){
|
|
|
+ tbcustomerinfoSearch = "(scustid:"+scustid+"%20AND%20salecom:"+deptCode+")";
|
|
|
+ }
|
|
|
+ scriptRequest = new Request("GET", "/shanglifeecif.tbcustomerinfo/_search?pretty=true&sort=sdate:asc&size=100&q="+tbcustomerinfoSearch);
|
|
|
response = restClient.performRequest(scriptRequest);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
|
jsonObject = JSON.parseObject(result);
|
|
@@ -757,9 +801,10 @@ public class CustomerApiController {
|
|
|
) {
|
|
|
logger.info("导出进时间:"+DateUtils.getTime());
|
|
|
try{
|
|
|
- /* Long userId = SecurityUtils.getUserId();
|
|
|
+
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
SysUser sysUser = userService.selectUserById(userId);
|
|
|
- String deptCode = sysUser.getDept().getDeptCode();*/
|
|
|
+ String deptCode = sysUser.getDept().getDeptCode();
|
|
|
//1.如果存在保单信息的查询条件,需要先查询保单信息然后通过保单关联出客户信息
|
|
|
//处理保单查询条件
|
|
|
/*List<String> customerIds = new ArrayList<String>();
|
|
@@ -941,7 +986,10 @@ public class CustomerApiController {
|
|
|
|
|
|
builder.append("],");
|
|
|
builder.append("\"should\":[");
|
|
|
-
|
|
|
+ if(StringUtils.isNotEmpty(deptCode)){
|
|
|
+ //
|
|
|
+ builder.append("{\"wildcard\":{\"salecom\":\"*"+deptCode+"*\"}}");
|
|
|
+ }
|
|
|
//客户证件号码
|
|
|
if(StringUtils.isNotEmpty(idcard)){
|
|
|
builder.append("{\"wildcard\":{\"idcard\":\"*"+idcard+"*\"}},");
|
|
@@ -1594,4 +1642,72 @@ public class CustomerApiController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public Map getLables(JSONObject jsonObject,String deptCode ) throws Exception {
|
|
|
+ Map mpInfo = new HashMap();
|
|
|
+
|
|
|
+ JSONObject source = JSON.parseObject(jsonObject.getString("_source"));
|
|
|
+ String indid = jsonObject.getString("_id");
|
|
|
+ mpInfo.put("id",indid);
|
|
|
+
|
|
|
+
|
|
|
+ String salecom = source.getString("salecom");
|
|
|
+ //多渠道不显示标签 最高级全部显示 , 渠道不一样 不显示
|
|
|
+ if(StringUtils.isEmpty(deptCode)||deptCode.equals(salecom)){
|
|
|
+ //单渠道显示所有标签
|
|
|
+ mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
|
|
|
+ } else{
|
|
|
+ logger.info(jsonObject.toJSONString());
|
|
|
+ Map<String, Object> maps = JSON.parseObject(jsonObject.getString("_source"),Map.class);
|
|
|
+
|
|
|
+ List<String> publicLabels = new ArrayList<>();
|
|
|
+ publicLabels.add("label1");
|
|
|
+ publicLabels.add("label2");
|
|
|
+ publicLabels.add("label3");
|
|
|
+ publicLabels.add("label4");
|
|
|
+ publicLabels.add("label9");
|
|
|
+ publicLabels.add("label10");
|
|
|
+ publicLabels.add("label21");
|
|
|
+ publicLabels.add("Label67");
|
|
|
+ publicLabels.add("Label69");
|
|
|
+ publicLabels.add("Label70");
|
|
|
+ publicLabels.add("Label71");
|
|
|
+ publicLabels.add("Label74");
|
|
|
+ publicLabels.add("label77");
|
|
|
+ publicLabels.add("Label80");
|
|
|
+ publicLabels.add("Label96");
|
|
|
+ publicLabels.add("Label97");
|
|
|
+ publicLabels.add("Label100");
|
|
|
+ publicLabels.add("Label101");
|
|
|
+ publicLabels.add("Label103");
|
|
|
+ publicLabels.add("Label104");
|
|
|
+ publicLabels.add("Label105");
|
|
|
+ publicLabels.add("Label106");
|
|
|
+
|
|
|
+ for (Map.Entry<String, Object> entry : maps.entrySet()){
|
|
|
+ String key = entry.getKey();
|
|
|
+ if(key.startsWith("label")){
|
|
|
+ if(publicLabels.contains(key)){
|
|
|
+ //公用标签显示
|
|
|
+ mpInfo.put(key,entry.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ mpInfo.put(key,entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(mpInfo.containsKey("birthday")){
|
|
|
+ mpInfo.put("birthday", source.getString("birthday"));
|
|
|
+ mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD,source.getString("birthday"))));
|
|
|
+
|
|
|
+ }else{
|
|
|
+ mpInfo.put("birthday","");
|
|
|
+ mpInfo.put("age","");
|
|
|
+ }
|
|
|
+ return mpInfo;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|