|
@@ -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();
|
|
|
-
|
|
|
- String deptCode = sysUser.getDept().getDeptCode();*/
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ String deptCode = sysUser.getDept().getDeptCode();
|
|
|
|
|
|
|
|
|
List<String> customerIds = new ArrayList<String>();
|
|
@@ -108,9 +114,9 @@ public class CustomerApiController {
|
|
|
builder.append("\"bool\":{");
|
|
|
builder.append("\"must\":[");
|
|
|
|
|
|
-
|
|
|
- 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(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");
|
|
|
-
|
|
|
+ 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);
|
|
|
-
|
|
|
-
|
|
|
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\": {");
|
|
|
- builder.append("\"bool\": {");
|
|
|
- builder.append("\"must\": [");
|
|
|
- builder.append("],");
|
|
|
- builder.append("\"must_not\": [ ],");
|
|
|
- builder.append("\"should\": [ ]");
|
|
|
- builder.append("}");
|
|
|
- builder.append("},");
|
|
|
-
|
|
|
- builder.append("\"size\": 1000,");
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
-
|
|
|
- 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"));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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(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));
|
|
|
-
|
|
|
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);
|
|
|
-
|
|
|
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 {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ 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++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -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\":{");
|
|
|
- builder.append("\"bool\":{");
|
|
|
- builder.append("\"must\":[");
|
|
|
-
|
|
|
-
|
|
|
- builder.append("{\"prefix\":{\"policybelong\":"+deptCode+"}},");
|
|
|
- }*/
|
|
|
- builder.append("],");
|
|
|
- builder.append("\"must_not\":[");
|
|
|
- builder.append("],");
|
|
|
- builder.append("\"should\":[]");
|
|
|
- builder.append("}");
|
|
|
- builder.append("},");
|
|
|
-
|
|
|
-
|
|
|
- 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|