123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- package com.dgtis.data.api;
- import com.alibaba.fastjson.JSON;
- 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.web.domain.AjaxResult;
- import org.apache.http.HttpEntity;
- import org.apache.http.entity.ContentType;
- import org.apache.http.nio.entity.NStringEntity;
- import org.apache.http.util.EntityUtils;
- import org.elasticsearch.client.Request;
- import org.elasticsearch.client.Response;
- import org.elasticsearch.client.RestClient;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.*;
- import java.text.DecimalFormat;
- import java.util.*;
- /**
- * @description:客户信息列表api
- * @author:qxm
- * @date:2021/1/22 10:24
- */
- @Controller
- @RequestMapping("/customer")
- 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,
- String education,//学历
- String policybelong,//业绩归属
- String payS,String payE, //年缴费区间
- String fadate,//投保年份
- String productname,//险种类别
- String insuredAmountS,String insuredAmountE,//保额区间
- String ageS,String ageE,//年龄区间
- String gender,//性别
- String sobirth,//省份
- String NOVPolicy,//保单件数
- String custtype,//客户类型 投保人
- String SCustID,// 核心客户号
- String custclass,//客户等级
- String participantsDateS,String participantsDateE,//参与方时间
- String PIncomeS,String PIncomeE,//年收入区间
- String Insured,//投保对象
- String lp,//理赔
- String yx,//有效
- String gzgw,//关注官微
- String zcgw//注册官微
- ) {
- try {
- logger.info("进客户列表时间:"+DateUtils.getTime());
- //1.如果存在保单信息的查询条件,需要先查询保单信息然后通过保单关联出客户信息
- //处理保单查询条件
- List<String> customerIds = new ArrayList<String>();
- if(StringUtils.isNotEmpty(policybelong) || 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.如果没有客户信息以外的查询条件,只需要查询客户信息
- // 获取索引的别名,字段,创建时间
- String beginBirthDay = "";
- String endBirthDay = "";
- if(StringUtils.isNotEmpty(ageS)){
- String year = DateUtils.getYYYY();
- int bYear = Integer.parseInt(year)-Integer.parseInt(ageS);
- endBirthDay = bYear+"-"+DateUtils.getMMDD();
- }
- if(StringUtils.isNotEmpty(ageE)){
- String year = DateUtils.getYYYY();
- int bYear = Integer.parseInt(year)-Integer.parseInt(ageE);
- beginBirthDay = bYear+"-"+DateUtils.getMMDD();
- }
- //拼装查询条件
- StringBuilder builder =new StringBuilder();
- builder.append("{");
- builder.append("\"query\":{");//query开始
- builder.append("\"bool\":{");//boot开始
- builder.append("\"must\":[");//must开始
- if(StringUtils.isNotEmpty(gender)){
- builder.append("{\"prefix\":{\"gender\":"+gender+"}},");
- }
- if(StringUtils.isNotEmpty(NOVPolicy)){
- builder.append("{\"prefix\":{\"label25\":\""+NOVPolicy+"\"}},");
- }
- if(StringUtils.isNotEmpty(custclass)){
- builder.append("{\"term\":{\"custclass\":\""+custclass+"\"}},");
- }
- if(StringUtils.isNotEmpty(sobirth)){
- builder.append("{\"wildcard\":{\"sobirth\":\"*"+sobirth+"*\"}},");//模糊匹配
- }
- if(StringUtils.isNotEmpty(SCustID)){
- builder.append("{\"wildcard\":{\"scustid\":\"*"+SCustID+"*\"}},");//模糊匹配
- }
- if(StringUtils.isNotEmpty(custtype)){
- builder.append("{\"prefix\":{\"custtype\":\""+custtype+"\"}},");
- }
- if(StringUtils.isNotEmpty(beginBirthDay) && StringUtils.isNotEmpty(endBirthDay)){
- builder.append("{\"range\":{\"birthday\":{\"gte\":\""+beginBirthDay+"\",\"lte\":\""+endBirthDay+"\"}}},");
- }else{
- if(StringUtils.isNotEmpty(beginBirthDay)){
- builder.append("{\"range\":{\"birthday\":{\"gte\":\""+beginBirthDay+"\"}}},");
- }
- if(StringUtils.isNotEmpty(endBirthDay)){
- builder.append("{\"range\":{\"birthday\":{\"lte\":\""+endBirthDay+"\"}}},");
- }
- }
- if(StringUtils.isNotEmpty(PIncomeS) && StringUtils.isNotEmpty(PIncomeE)){
- builder.append("{\"range\":{\"PIncome\":{\"gte\":\""+PIncomeS+"\",\"lte\":\""+PIncomeE+"\"}}},");
- }else{
- if(StringUtils.isNotEmpty(PIncomeS)){
- builder.append("{\"range\":{\"PIncome\":{\"gte\":\""+PIncomeS+"\"}}},");
- }
- if(StringUtils.isNotEmpty(PIncomeE)){
- builder.append("{\"range\":{\"PIncome\":{\"lte\":\""+PIncomeE+"\"}}},");
- }
- }
- if(StringUtils.isNotEmpty(education)){
- String[] edus = education.split("&");
- builder.append("{\"terms\":{\"education\":[");
- for (String edu:edus) {
- builder.append("\""+edu+"\",");
- }
- builder.delete(builder.length()-1,builder.length());
- builder.append ("]}},");
- }
- if(customerIds.size()>0){
- builder.append("{\"terms\":{\"_id\":[");
- for (String id:customerIds) {
- builder.append("\""+id+"\",");
- }
- builder.delete(builder.length()-1,builder.length());
- builder.append ("]}},");
- }
- if(StringUtils.isNotEmpty(gzgw)){
- builder.append("{\"prefix\":{\"label73\":\"关注官微\"}},");
- }
- if(StringUtils.isNotEmpty(zcgw)){
- builder.append("{\"prefix\":{\"label74\":\"注册官微\"}},");
- }
- 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) || customerIds.size()>0){
- 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-1)*10)+",");//第几页
- builder.append("\"size\":"+pageSize+",");//查询几个
- 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.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");
- 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");
- JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
- List listMap = new ArrayList<>();
- Map map = new HashMap();
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- Map mp = new HashMap();
- mp.put("id",json.getString("_id"));
- JSONObject jsonOb = JSON.parseObject(json.getString("_source"));
- mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
- 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"))));
- }else{
- mp.put("birthday", "");
- mp.put("age","");
- }
- listMap.add(mp);
- }
- long total = hitsobject.getLong("total");
- map.put("list",listMap);
- map.put("total",total);
- logger.info("出客户列表时间:"+DateUtils.getTime());
- return AjaxResult.success(map);
- } catch (Exception e) {
- logger.info("列表报错时间:"+DateUtils.getTime());
- e.printStackTrace();
- return AjaxResult.error();
- }
- }
- /**
- * 查询保单信息返回客户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("applicantid"))){
- customerIds.add(jsonOb.getString("applicantid"));
- }
- }
- // 继续向后查询
- /* 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) {
- // 获取索引的别名,字段,创建时间http://10.32.2.231:9200/shanglifeecif.individual/default_type_/1
- try {
- 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");
- Response response = restClient.performRequest(scriptRequest);
- // Response response = restClient.performRequest("GET", "/shanglifeecif.individual/default_type_/"+id, paramMap);
- 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));
- //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("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,source.getString("birthday"))));
- }else{
- mpInfo.put("birthday","");
- 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);
- response = restClient.performRequest(scriptRequest);
- result = EntityUtils.toString(response.getEntity());
- jsonObject = JSON.parseObject(result);
- JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
- JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
- List relationship = new ArrayList<>();
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- Map mp = new HashMap();
- mp.put("id",json.getString("_id"));
- mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
- relationship.add(mp);
- }
- map.put("relationship",relationship);
- query =new HashMap();
- query.put("applicantid",indid);
- scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?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");
- array = JSON.parseArray(hitsobject.get("hits").toString());
- List insuranceclaimthread = new ArrayList<>();
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- Map mp = new HashMap();
- mp.put("id",json.getString("_id"));
- mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
- insuranceclaimthread.add(mp);
- }
- 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);
- 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());
- List insurancearrangement = new ArrayList<>();
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- Map mp = new HashMap();
- mp.put("id",json.getString("_id"));
- mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
- insurancearrangement.add(mp);
- }
- map.put("insurancearrangement",insurancearrangement);
- scriptRequest = new Request("GET", "/shanglifeecif.partytimeline/_search?pretty=true&sort=sdate:asc&q=partyid:"+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());
- List partytimeline = new ArrayList<>();
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- Map mp = new HashMap();
- mp.put("id",json.getString("_id"));
- mp.putAll(JSON.parseObject(json.getString("_source"),Map.class));
- partytimeline.add(mp);
- }
- map.put("partytimeline",partytimeline);
- logger.info("出客户详情时间:"+DateUtils.getTime());
- return AjaxResult.success(map);
- } catch (Exception e) {
- logger.info("客户详情报错时间:"+DateUtils.getTime());
- e.printStackTrace();
- return AjaxResult.error();
- }
- }
- @GetMapping("/getCustomerOverViewById")
- @ResponseBody
- public AjaxResult getCustomerOverViewById(String id) {
- // 获取索引的别名,字段,创建时间http://10.32.2.231:9200/shanglifeecif.individual/default_type_/1
- try {
- 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");
- 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").substring(0,10));
- mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,source.getString("birthday"))));
- }else{
- mpInfo.put("birthday","");
- mpInfo.put("age","");
- }
- scriptRequest = new Request("GET", "/shanglifeecif.insurancearrangement/_search?pretty=true&sort=padate:asc&q=applicantscustid:"+scustid);
- response = restClient.performRequest(scriptRequest);
- result = EntityUtils.toString(response.getEntity());
- jsonObject = JSON.parseObject(result);
- JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
- JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
- DecimalFormat df = new DecimalFormat("######0.00");//保留两位小数
- double prem = 0;//标准保费
- //概览投保时间和保费折线图
- Map expectedData = new HashMap();
- String[] edata = new String[12];
- expectedData.put("name","");
- Map actaulData = new HashMap();
- String[] adata = new String[12];
- actaulData.put("name","");
- List xaxisData = new ArrayList();
- xaxisData.add("1");
- xaxisData.add("2");
- xaxisData.add("3");
- xaxisData.add("4");
- xaxisData.add("5");
- xaxisData.add("6");
- xaxisData.add("7");
- xaxisData.add("8");
- xaxisData.add("9");
- xaxisData.add("10");
- xaxisData.add("11");
- xaxisData.add("12");
- long insureDay = 0;//投保时长
- int guaranteeDay = 0;//享受保障天数
- Map majorCategorie = new HashMap();
- Map mpremMap = new HashMap();
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- JSONObject _source = (JSONObject) json.get("_source");
- Date padate = _source.getDate("padate");
- //xaxisData.add(DateUtils.parseDateToStr("MM",padate));
- if(_source.containsKey("prem")){
- prem+=_source.getDouble("prem");
- String m = DateUtils.parseDateToStr("M", padate);
- 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);
- }else{
- mpremMap.put(m,df.format(_source.getDouble("prem")));
- edata[Integer.parseInt(m)-1] = df.format(_source.getDouble("prem"));
- adata[Integer.parseInt(m)-1] = df.format(_source.getDouble("prem"));
- }
- //edata.add(_source.getDouble("prem"));
- //adata.add(_source.getDouble("prem"));
- }
- if(i==0){
- insureDay = DateUtils.getDateDifDay(new Date(),padate);
- }
- if("有效".equals(_source.getString("policystate"))){
- guaranteeDay+=_source.getInteger("agrmntage");
- }
- //String risk_categories = _source.getString("risk_categories");
- String risk_categories_name = _source.getString("risk_categories_name");
- if(majorCategorie.containsKey(risk_categories_name)){
- double risk = Double.parseDouble(majorCategorie.get(risk_categories_name).toString());
- if(_source.containsKey("risk")){
- risk += _source.getDouble("risk");
- }
- majorCategorie.put(risk_categories_name,risk);
- }else{
- if(_source.containsKey("risk")){
- majorCategorie.put(risk_categories_name,_source.getDouble("risk"));
- }
- }
- }
- expectedData.put("data",edata);
- actaulData.put("data",adata);
- Map lineBarChartData = new HashMap();
- lineBarChartData.put("expectedData",expectedData);
- lineBarChartData.put("actaulData",actaulData);
- lineBarChartData.put("xaxisData",xaxisData);
- map.put("lineBarChartData",lineBarChartData);
- //查询理赔信息
- scriptRequest = new Request("GET", "/shanglifeecif.insuranceclaimthread/_search?pretty=true&q=lpscutid:"+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());
- Map insuranceclaimthread = new HashMap();
- List insuranceclaimthreads = new ArrayList<>();
- double claimAmount = 0;//理赔总金额
- String claimType = "";//理赔类型
- for (int i = 0; i <array.size() ; i++) {
- JSONObject json = (JSONObject)array.get(i);
- JSONObject claimSource = JSON.parseObject(json.getString("_source"));
- if(claimSource.containsKey("ccamt")){
- claimAmount+=claimSource.getDouble("ccamt");
- }
- claimType = claimSource.getString("accidenttype");
- insuranceclaimthreads.add(claimSource);
- }
- insuranceclaimthread.put("isClaim",insuranceclaimthreads.size()>0?"是":"否");
- insuranceclaimthread.put("claimAmount",df.format(claimAmount));
- insuranceclaimthread.put("claimType",claimType);
- map.put("insuranceclaimthread",insuranceclaimthread);
- mpInfo.put("prem",df.format(prem));
- mpInfo.put("insureDay",insureDay);
- mpInfo.put("guaranteeDay",guaranteeDay);
- map.put("custInfo",mpInfo);
- map.put("majorCategorie",majorCategorie);
- logger.info("出客户概览时间:"+DateUtils.getTime());
- return AjaxResult.success(map);
- } catch (Exception e) {
- logger.info("客户概览报错时间:"+DateUtils.getTime());
- e.printStackTrace();
- return AjaxResult.error();
- }
- }
- }
|