|
@@ -5,10 +5,14 @@ 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.poi.CsvUtil;
|
|
|
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 com.dgtis.data.service.ISysUserService;
|
|
|
+import com.dgtis.system.api.domain.SysUser;
|
|
|
+import com.mysql.cj.x.protobuf.MysqlxDatatypes;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.apache.http.nio.entity.NStringEntity;
|
|
@@ -22,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.text.DecimalFormat;
|
|
@@ -39,7 +44,8 @@ public class CustomerApiController {
|
|
|
private static Logger logger = LoggerFactory.getLogger(CustomerApiController.class);
|
|
|
@Autowired
|
|
|
private RestClient restClient;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
|
|
|
@GetMapping("/getCustomerList")
|
|
|
@ResponseBody
|
|
@@ -72,8 +78,8 @@ public class CustomerApiController {
|
|
|
try {
|
|
|
logger.info("进客户列表时间:"+DateUtils.getTime());
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
- /*SysUser sysUser = userService.selectUserById(userId);
|
|
|
- String deptCode = sysUser.getDept().getDeptCode();*/
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ String deptCode = sysUser.getDept().getDeptCode();
|
|
|
//1.如果存在保单信息的查询条件,需要先查询保单信息然后通过保单关联出客户信息
|
|
|
//处理保单查询条件
|
|
|
List<String> customerIds = new ArrayList<String>();
|
|
@@ -108,9 +114,9 @@ public class CustomerApiController {
|
|
|
builder.append("\"bool\":{");//boot开始
|
|
|
builder.append("\"must\":[");//must开始
|
|
|
//业绩归属字段
|
|
|
- /*if(StringUtils.isNotEmpty(deptCode)){
|
|
|
- builder.append("{\"prefix\":{\"policybelong\":"+deptCode+"}},");
|
|
|
- }*/
|
|
|
+ if(StringUtils.isNotEmpty(deptCode)){
|
|
|
+ builder.append("{\"prefix\":{\"policybelong\":\""+deptCode+"\"}},");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(gender)){
|
|
@@ -145,6 +151,19 @@ public class CustomerApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(participantsDateS) && StringUtils.isNotEmpty(participantsDateE)){
|
|
|
+ builder.append("{\"range\":{\"fadate\":{\"gte\":\""+participantsDateS+"\",\"lte\":\""+participantsDateE+"\"}}},");
|
|
|
+ }else{
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(beginBirthDay)){
|
|
|
+ builder.append("{\"range\":{\"fadate\":{\"gte\":\""+participantsDateS+"\"}}},");
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(endBirthDay)){
|
|
|
+ builder.append("{\"range\":{\"fadate\":{\"lte\":\""+participantsDateE+"\"}}},");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(StringUtils.isNotEmpty(PIncomeS) && StringUtils.isNotEmpty(PIncomeE)){
|
|
|
builder.append("{\"range\":{\"pincome\":{\"gte\":\""+PIncomeS+"\",\"lte\":\""+PIncomeE+"\"}}},");
|
|
|
}else{
|
|
@@ -203,7 +222,8 @@ 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) ||
|
|
|
customerIds.size()>0)){
|
|
|
builder.delete(builder.length()-1,builder.length());
|
|
|
}
|
|
@@ -240,14 +260,12 @@ public class CustomerApiController {
|
|
|
builder.append("\"aggs\":{}");//
|
|
|
builder.append("}");
|
|
|
|
|
|
- HttpEntity entity = new NStringEntity(builder.toString(), ContentType.APPLICATION_JSON);
|
|
|
|
|
|
- Request scriptRequest = new Request("GET", "/shanglifeecif.individual/_search?pretty=true&sort=scustid:asc");
|
|
|
-// Request scriptRequest = new Request("GET", "/shanglifeecif.individual/_search?q=%22{%22query%22:{%22bool%22:{%22must%22:[],%22must_not%22:[],%22should%22:[]}},%22from%22:11,%22size%22:10,%22sort%22:[{%22created_time%22:{%22order%22:%22desc%22}}],%22aggs%22:{}}%22");
|
|
|
+ HttpEntity entity = new NStringEntity(builder.toString(), ContentType.APPLICATION_JSON);
|
|
|
+ String url = "/shanglifeecif.individual/_search?pretty=true&sort=scustid:asc";
|
|
|
+ Request scriptRequest = new Request("GET", url);
|
|
|
scriptRequest.setEntity(entity);
|
|
|
Response response = restClient.performRequest(scriptRequest);
|
|
|
-// Response response= restClient.performRequest("GET", "/shanglifeecif.individual/_search",Collections.<String, String>emptyMap(),entity);
|
|
|
-
|
|
|
String result = EntityUtils.toString(response.getEntity());
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
|
JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
|
|
@@ -262,7 +280,7 @@ public class CustomerApiController {
|
|
|
mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
|
|
|
|
|
|
if(mp.containsKey("birthday")){
|
|
|
- mp.put("birthday", jsonOb.getString("birthday").substring(0,10));
|
|
|
+ mp.put("birthday", jsonOb.getString("birthday").length()>10?jsonOb.getString("birthday").substring(0,10):jsonOb.getString("birthday"));
|
|
|
mp.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,jsonOb.getString("birthday"))));
|
|
|
}else{
|
|
|
mp.put("birthday", "");
|
|
@@ -394,73 +412,6 @@ public class CustomerApiController {
|
|
|
return customerIds;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询保单信息返回客户Id
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List queryInsurancearrangementLp(String ly) 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开始
|
|
|
- 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.insuranceclaimthread/_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("lpscutid"))){
|
|
|
- customerIds.add(jsonOb.getString("lpscutid"));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- // 继续向后查询
|
|
|
- /* 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) {
|
|
@@ -469,10 +420,9 @@ public class CustomerApiController {
|
|
|
logger.info("进客户详情时间:"+DateUtils.getTime());
|
|
|
Map<String, String> paramMap = new HashMap<String, String>();
|
|
|
paramMap.put("pretty", "true");
|
|
|
- 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);
|
|
|
-// Response response = restClient.performRequest("GET", "/shanglifeecif.individual/default_type_/"+id, paramMap);
|
|
|
+ Response response = restClient.performRequest(scriptRequest);
|
|
|
String result = EntityUtils.toString(response.getEntity());
|
|
|
Map map = new HashMap();
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
@@ -483,10 +433,8 @@ public class CustomerApiController {
|
|
|
JSONObject source = JSON.parseObject(jsonObject.getString("_source"));
|
|
|
String scustid = source.getString("scustid");
|
|
|
mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
|
|
|
- //mpInfo.put("birthday",DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",JSON.parseObject(jsonObject.getString("_source")).getDate("birthday")));
|
|
|
if(mpInfo.containsKey("birthday")){
|
|
|
-
|
|
|
- mpInfo.put("birthday", source.getString("birthday").substring(0,10));
|
|
|
+ mpInfo.put("birthday", source.getString("birthday").length()>10?source.getString("birthday").substring(0,10):source.getString("birthday"));
|
|
|
mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,source.getString("birthday"))));
|
|
|
|
|
|
}else{
|
|
@@ -494,8 +442,6 @@ public class CustomerApiController {
|
|
|
mpInfo.put("age","");
|
|
|
}
|
|
|
map.put("custInfo",mpInfo);
|
|
|
-
|
|
|
-
|
|
|
Map query =new HashMap();
|
|
|
query.put("indid1",indid);
|
|
|
scriptRequest = new Request("GET", "/shanglifeecif.indrelationship/_search?pretty=true&q=indid1:"+indid);
|
|
@@ -518,7 +464,6 @@ public class CustomerApiController {
|
|
|
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);
|
|
|
result = EntityUtils.toString(response.getEntity());
|
|
|
jsonObject = JSON.parseObject(result);
|
|
|
hitsobject = (JSONObject) jsonObject.get("hits");
|
|
@@ -595,7 +540,7 @@ public class CustomerApiController {
|
|
|
String scustid = source.getString("scustid");
|
|
|
mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
|
|
|
if(mpInfo.containsKey("birthday")){
|
|
|
- mpInfo.put("birthday", source.getString("birthday").substring(0,10));
|
|
|
+ mpInfo.put("birthday", source.getString("birthday").length()>10?source.getString("birthday").substring(0,10):source.getString("birthday"));
|
|
|
mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,source.getString("birthday"))));
|
|
|
}else{
|
|
|
mpInfo.put("birthday","");
|
|
@@ -609,7 +554,7 @@ public class CustomerApiController {
|
|
|
JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
DecimalFormat df = new DecimalFormat("######0.00");//保留两位小数
|
|
|
double prem = 0;//标准保费
|
|
|
-
|
|
|
+ double sumprem = 0;//累计保费
|
|
|
//概览投保时间和保费折线图
|
|
|
Map expectedData = new HashMap();
|
|
|
String[] edata = new String[]{"0","0","0","0","0","0","0","0","0","0","0","0"};
|
|
@@ -638,6 +583,7 @@ public class CustomerApiController {
|
|
|
Map majorCategorie = new HashMap();
|
|
|
|
|
|
Map mpremMap = new HashMap();
|
|
|
+ int firstDate = 1;//定义第一次长期险获取
|
|
|
for (int i = 0; i <array.size() ; i++) {
|
|
|
JSONObject json = (JSONObject)array.get(i);
|
|
|
JSONObject _source = (JSONObject) json.get("_source");
|
|
@@ -667,12 +613,29 @@ public class CustomerApiController {
|
|
|
//adata.add(_source.getDouble("prem"));
|
|
|
}
|
|
|
|
|
|
+ if(_source.containsKey("sumprem")){
|
|
|
+ sumprem+=_source.getDouble("sumprem");
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(i==0){
|
|
|
insureDay = DateUtils.getDateDifDay(new Date(),padate);
|
|
|
}
|
|
|
if("有效".equals(_source.getString("policystate"))){
|
|
|
- guaranteeDay+=_source.getInteger("agrmntage");
|
|
|
+ Integer agrmntage = _source.getInteger("agrmntage");
|
|
|
+ //短期险
|
|
|
+ if(agrmntage<180){
|
|
|
+ Date pindate = _source.getDate("pindate");//起保日期
|
|
|
+ Date pmdate = _source.getDate("pmdate");//终保日期
|
|
|
+ guaranteeDay+=DateUtils.getDateDifDay(pmdate,pindate);
|
|
|
+ }else{
|
|
|
+ //获取第一次长期险的投保日期,使用当前日期减去投保日期获取保障天数
|
|
|
+ if(firstDate==1){
|
|
|
+ guaranteeDay+=DateUtils.getDateDifDay(new Date(),padate);
|
|
|
+ firstDate++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//String risk_categories = _source.getString("risk_categories");
|
|
@@ -726,6 +689,7 @@ public class CustomerApiController {
|
|
|
insuranceclaimthread.put("claimType",claimType);
|
|
|
map.put("insuranceclaimthread",insuranceclaimthread);
|
|
|
mpInfo.put("prem",df.format(prem));
|
|
|
+ mpInfo.put("sumprem",df.format(sumprem));
|
|
|
mpInfo.put("insureDay",insureDay);
|
|
|
mpInfo.put("guaranteeDay",guaranteeDay>insureDay?insureDay:guaranteeDay);
|
|
|
map.put("custInfo",mpInfo);
|
|
@@ -739,101 +703,330 @@ public class CustomerApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response) throws Exception
|
|
|
+ @GetMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, HttpServletRequest request)
|
|
|
{
|
|
|
+ logger.info("导出进时间:"+DateUtils.getTime());
|
|
|
|
|
|
- //拼装查询条件
|
|
|
- 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("}");
|
|
|
+ try{
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ String deptCode = sysUser.getDept().getDeptCode();
|
|
|
+ String url = "/shanglifeecif.individual/_search?sort=scustid:asc&&size=10000&scroll=5m";
|
|
|
+ if(StringUtils.isNotEmpty(deptCode)){
|
|
|
+ url = "/shanglifeecif.individual/_search?q=policybelong:"+deptCode+"&sort=scustid:asc&&size=10000&scroll=5m";
|
|
|
+ }
|
|
|
+ Request scriptRequest = new Request("GET", url);
|
|
|
+ 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>();
|
|
|
+ String scroll_id = jsonObject.getString("_scroll_id");
|
|
|
+ HttpEntity entity = new NStringEntity("{\n" +
|
|
|
+ " \"scroll_id\": \""+scroll_id+"\",\n" +
|
|
|
+ " \"scroll\": \"5m\"\n" +
|
|
|
+ "}", ContentType.APPLICATION_JSON);
|
|
|
+ while (array.size() != 0) {
|
|
|
+
|
|
|
+ // 这里填写你的业务逻辑,即对每一条数据的处理
|
|
|
+
|
|
|
+ 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"))?"男":"女");
|
|
|
+ customer.setCustType(jsonOb.getString("custtype"));
|
|
|
+ customer.setEducation(jsonOb.getString("education"));
|
|
|
+ customer.setVaild(StringUtils.isEmpty(jsonOb.getString("label91"))?"有效":"无效");
|
|
|
+ customer.setpIncome(jsonOb.getString("pincome"));
|
|
|
+ customer.setNum(jsonOb.getString("label25"));
|
|
|
+ if(mp.containsKey("birthday")){
|
|
|
+ String birthday = jsonOb.getString("birthday").length()>10?jsonOb.getString("birthday").substring(0,10):jsonOb.getString("birthday");
|
|
|
+ mp.put("birthday", birthday);
|
|
|
+ mp.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,jsonOb.getString("birthday"))));
|
|
|
+ customer.setBirthDay(birthday);
|
|
|
+ customer.setAge(DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,jsonOb.getString("birthday"))));
|
|
|
+ }
|
|
|
|
|
|
- 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("无");
|
|
|
- }
|
|
|
+ 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"));
|
|
|
+ }
|
|
|
|
|
|
- }else{
|
|
|
- customer.setCustClass("无");
|
|
|
- }
|
|
|
+ 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("无");
|
|
|
+ }
|
|
|
|
|
|
- customers.add(customer);
|
|
|
+ }else{
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 继续向后查询
|
|
|
+ scriptRequest = new Request("GET", "/_search/scroll");
|
|
|
+ scriptRequest.setEntity(entity);
|
|
|
+ responseData = restClient.performRequest(scriptRequest);
|
|
|
+ result = EntityUtils.toString(responseData.getEntity());
|
|
|
+ jsonObject = JSON.parseObject(result);
|
|
|
+ hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
+ array = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
+ }
|
|
|
+ Map<String, String> header = new LinkedHashMap<>();
|
|
|
+ header.put("scustId", "核心客户号");
|
|
|
+ header.put("custId", "客户号");
|
|
|
+ header.put("name", "姓名");
|
|
|
+ header.put("idType", "证件类型");
|
|
|
+ header.put("idCard", "证件号码");
|
|
|
+ header.put("sex", "性别");
|
|
|
+ header.put("age", "年龄");
|
|
|
+ header.put("birthDay", "出生日期");
|
|
|
+ header.put("custClass", "客户等级");
|
|
|
+ header.put("custType", "客户类型");
|
|
|
+ header.put("province", "省份");
|
|
|
+ header.put("education", "学历");
|
|
|
+ header.put("vaild", "是否有效客户");
|
|
|
+ header.put("policyBelong", "业绩归属");
|
|
|
+ header.put("pIncome", "年收入");
|
|
|
+ header.put("num", "保单件数");
|
|
|
+ CsvUtil.export(request, response, "customer", header, customers);
|
|
|
+ logger.info("导出出时间:"+DateUtils.getTime());
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info("导出出错:"+DateUtils.getTime());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
|
|
|
- util.exportExcel(response, customers, "客户数据");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出三要素疑似相同指姓名、性别、出生日期一致
|
|
|
+ * @param response
|
|
|
+ * @param request
|
|
|
+ */
|
|
|
+ @GetMapping("/exportSameOne")
|
|
|
+ public void exportSameOne(HttpServletResponse response, HttpServletRequest request)
|
|
|
+ {
|
|
|
+ logger.info("导出三要素进时间:"+DateUtils.getTime());
|
|
|
+
|
|
|
+ try{
|
|
|
+
|
|
|
+ Request scriptRequest = new Request("GET", "/shanglifeecif.samecustomer/_search?sort=name:asc&q=sametype:1&size=10000&scroll=5m");
|
|
|
+ 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>();
|
|
|
+ String scroll_id = jsonObject.getString("_scroll_id");
|
|
|
+ HttpEntity entity = new NStringEntity("{\n" +
|
|
|
+ " \"scroll_id\": \""+scroll_id+"\",\n" +
|
|
|
+ " \"scroll\": \"5m\"\n" +
|
|
|
+ "}", ContentType.APPLICATION_JSON);
|
|
|
+ while (array.size() != 0) {
|
|
|
+
|
|
|
+ // 这里填写你的业务逻辑,即对每一条数据的处理
|
|
|
+
|
|
|
+ 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")){
|
|
|
+ String birthday = jsonOb.getString("birthday").length()>10?jsonOb.getString("birthday").substring(0,10):jsonOb.getString("birthday");
|
|
|
+ mp.put("birthday", birthday);
|
|
|
+ customer.setBirthDay(birthday);
|
|
|
+ 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"));
|
|
|
+ }
|
|
|
+
|
|
|
+ customers.add(customer);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 继续向后查询
|
|
|
+ scriptRequest = new Request("GET", "/_search/scroll");
|
|
|
+ scriptRequest.setEntity(entity);
|
|
|
+ responseData = restClient.performRequest(scriptRequest);
|
|
|
+ result = EntityUtils.toString(responseData.getEntity());
|
|
|
+ jsonObject = JSON.parseObject(result);
|
|
|
+ hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
+ array = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
+ }
|
|
|
+ Map<String, String> header = new LinkedHashMap<>();
|
|
|
+ header.put("scustId", "核心客户号");
|
|
|
+ header.put("custId", "客户号");
|
|
|
+ header.put("name", "姓名");
|
|
|
+ header.put("idType", "证件类型");
|
|
|
+ header.put("idCard", "证件号码");
|
|
|
+ header.put("sex", "性别");
|
|
|
+ header.put("birthDay", "出生日期");
|
|
|
+ CsvUtil.export(request, response, "customer", header, customers);
|
|
|
+ logger.info("导出三要素出时间:"+DateUtils.getTime());
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info("导出三要素出错:"+DateUtils.getTime());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出两要素疑似相同指姓名、性别、出生日期一致
|
|
|
+ * @param response
|
|
|
+ * @param request
|
|
|
+ */
|
|
|
+ @GetMapping("/exportSameTwo")
|
|
|
+ public void exportSameTwo(HttpServletResponse response, HttpServletRequest request)
|
|
|
+ {
|
|
|
+ logger.info("导出两要素进时间:"+DateUtils.getTime());
|
|
|
+
|
|
|
+ try{
|
|
|
+
|
|
|
+ Request scriptRequest = new Request("GET", "/shanglifeecif.samecustomer/_search?sort=name:asc&q=sametype:2&size=10000&scroll=5m");
|
|
|
+ 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>();
|
|
|
+ String scroll_id = jsonObject.getString("_scroll_id");
|
|
|
+ HttpEntity entity = new NStringEntity("{\n" +
|
|
|
+ " \"scroll_id\": \""+scroll_id+"\",\n" +
|
|
|
+ " \"scroll\": \"5m\"\n" +
|
|
|
+ "}", ContentType.APPLICATION_JSON);
|
|
|
+ while (array.size() != 0) {
|
|
|
+
|
|
|
+ // 这里填写你的业务逻辑,即对每一条数据的处理
|
|
|
+
|
|
|
+ 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")){
|
|
|
+ String birthday = jsonOb.getString("birthday").length()>10?jsonOb.getString("birthday").substring(0,10):jsonOb.getString("birthday");
|
|
|
+ mp.put("birthday", birthday);
|
|
|
+ customer.setBirthDay(birthday);
|
|
|
+ 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"));
|
|
|
+ }
|
|
|
+
|
|
|
+ customers.add(customer);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 继续向后查询
|
|
|
+ scriptRequest = new Request("GET", "/_search/scroll");
|
|
|
+ scriptRequest.setEntity(entity);
|
|
|
+ responseData = restClient.performRequest(scriptRequest);
|
|
|
+ result = EntityUtils.toString(responseData.getEntity());
|
|
|
+ jsonObject = JSON.parseObject(result);
|
|
|
+ hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
+ array = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
+ }
|
|
|
+ Map<String, String> header = new LinkedHashMap<>();
|
|
|
+ header.put("scustId", "核心客户号");
|
|
|
+ header.put("custId", "客户号");
|
|
|
+ header.put("name", "姓名");
|
|
|
+ header.put("idType", "证件类型");
|
|
|
+ header.put("idCard", "证件号码");
|
|
|
+ header.put("sex", "性别");
|
|
|
+ header.put("birthDay", "出生日期");
|
|
|
+ CsvUtil.export(request, response, "customer", header, customers);
|
|
|
+
|
|
|
+ logger.info("导出两要素出时间:"+DateUtils.getTime());
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info("导出两要素出错:"+DateUtils.getTime());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|