|
|
@@ -6,14 +6,21 @@ 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.data.util.AddressResolutionUtil;
|
|
|
import com.dgtis.system.api.domain.SysUser;
|
|
|
-import com.mysql.cj.x.protobuf.MysqlxDatatypes;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.apache.commons.lang3.mutable.Mutable;
|
|
|
+import org.apache.commons.lang3.mutable.MutableBoolean;
|
|
|
+import org.apache.commons.lang3.mutable.MutableInt;
|
|
|
+import org.apache.commons.lang3.mutable.MutableObject;
|
|
|
+import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
|
+import org.apache.commons.lang3.tuple.ImmutableTriple;
|
|
|
+import org.apache.commons.lang3.tuple.Pair;
|
|
|
+import org.apache.commons.lang3.tuple.Triple;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.apache.http.nio.entity.NStringEntity;
|
|
|
@@ -25,6 +32,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -32,9 +40,10 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.BiConsumer;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @description:客户信息列表api
|
|
|
@@ -318,6 +327,188 @@ public class CustomerApiController {
|
|
|
}
|
|
|
map.put("partytimeline",partytimeline);
|
|
|
logger.info(scriptRequest.getEndpoint());
|
|
|
+
|
|
|
+ //202508 新增续期标签信息和保单信息
|
|
|
+ JSONObject renewalNode = (JSONObject) map.computeIfAbsent("renewalNode", k -> new JSONObject(true));
|
|
|
+
|
|
|
+ //1.标签信息
|
|
|
+ List<String> labelDescs = (List<String>) renewalNode.computeIfAbsent("labelDescs", k -> Lists.newArrayList());
|
|
|
+
|
|
|
+ Stream.of(mpInfo.get("label130"), mpInfo.get("label131"), mpInfo.get("label132"))
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(Object::toString)
|
|
|
+ .forEach(labelDescs::add);
|
|
|
+
|
|
|
+ Request esRequest = new Request(HttpMethod.GET.name(), "/shanglifeecif.customerno_insurance_policies_info/_search");
|
|
|
+ esRequest.addParameter("pretty", "true");
|
|
|
+ esRequest.setJsonEntity(String.format("{\"query\": {\"bool\": {\"filter\": [{\"term\": {\"customer_no\": \"%s\"}}]}}, \"from\": 0, \"size\": 1000}", scustid));
|
|
|
+ Response esResponse = restClient.performRequest(esRequest);
|
|
|
+ String responseStr = EntityUtils.toString(esResponse.getEntity());
|
|
|
+
|
|
|
+ Optional<List<JSONObject>> optional = Optional.ofNullable(responseStr)
|
|
|
+ .map(JSON::parseObject)
|
|
|
+ .map(j -> j.getJSONObject("hits"))
|
|
|
+ .map(j -> j.getJSONArray("hits"))
|
|
|
+ .map(hits -> hits.stream()
|
|
|
+ .filter(o -> o instanceof JSONObject)
|
|
|
+ .map(o -> (JSONObject) o)
|
|
|
+ .map(j -> j.getJSONObject("_source"))
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ List<JSONObject> _sources = optional.get();
|
|
|
+
|
|
|
+ LinkedList<Triple<Pair<String, String>, MutableInt, Mutable<String>>> triples = Lists.newLinkedList();
|
|
|
+ //a.交费时间
|
|
|
+ triples.add(new ImmutableTriple<>(new ImmutablePair<>("a", "30天内交费"), new MutableInt(), new MutableObject<>()));
|
|
|
+ triples.add(new ImmutableTriple<>(new ImmutablePair<>("b", "31-50天交费"), new MutableInt(), new MutableObject<>()));
|
|
|
+ triples.add(new ImmutableTriple<>(new ImmutablePair<>("c", "50-60天交费"), new MutableInt(), new MutableObject<>()));
|
|
|
+ triples.add(new ImmutableTriple<>(new ImmutablePair<>("d", "逾期交费"), new MutableInt(), new MutableObject<>()));
|
|
|
+
|
|
|
+ BiConsumer<Triple<Pair<String, String>, MutableInt, Mutable<String>>, JSONObject> consumer = (triple, jsonObj) -> {
|
|
|
+ String type = triple.getLeft().getKey();
|
|
|
+ MutableInt num = triple.getMiddle();
|
|
|
+ Mutable<String> date = triple.getRight();
|
|
|
+ Optional.of("pay_period_num_".concat(type))
|
|
|
+ .map(jsonObj::getInteger)
|
|
|
+ .ifPresent(num::add);
|
|
|
+ Optional.of("pay_period_date_".concat(type))
|
|
|
+ .map(jsonObj::getString)
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .map(d -> Optional.ofNullable(date.getValue())
|
|
|
+ .filter(_d -> _d.compareTo(d) > 0)
|
|
|
+ .orElse(d))
|
|
|
+ .ifPresent(date::setValue);
|
|
|
+ };
|
|
|
+
|
|
|
+ //b.是否存在暂停扣费
|
|
|
+ MutableInt stopFeeNum = new MutableInt();
|
|
|
+
|
|
|
+ //c.是否存在收费退费
|
|
|
+ MutableInt refundFeeNum = new MutableInt();
|
|
|
+
|
|
|
+ //d.多次联系不上
|
|
|
+ MutableBoolean failedContacted = new MutableBoolean();
|
|
|
+
|
|
|
+ //e.是否存在多张保单
|
|
|
+ MutableInt withinPayPeriodNum = new MutableInt();
|
|
|
+
|
|
|
+ //f_1.是否存在保单挂起_保全挂起中
|
|
|
+ MutableInt bqHangupNum = new MutableInt();
|
|
|
+
|
|
|
+ //f_2是否存在保单挂起_理赔挂起中
|
|
|
+ MutableInt lpHangupNum = new MutableInt();
|
|
|
+
|
|
|
+ _sources.forEach(_source -> {
|
|
|
+ triples.forEach(triple -> consumer.accept(triple, _source));
|
|
|
+
|
|
|
+ Optional.ofNullable(_source.getString("policy_label_2"))
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .ifPresent(s -> stopFeeNum.increment());
|
|
|
+
|
|
|
+ Optional.ofNullable(_source.getString("policy_label_3"))
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .ifPresent(s -> refundFeeNum.increment());
|
|
|
+
|
|
|
+ Optional.ofNullable(_source.getString("policy_label_4"))
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .ifPresent(s -> failedContacted.setTrue());
|
|
|
+
|
|
|
+ Optional.ofNullable(_source.getString("is_within_pay_period"))
|
|
|
+ .filter("Y"::equals)
|
|
|
+ .ifPresent(s -> withinPayPeriodNum.increment());
|
|
|
+
|
|
|
+ Optional.ofNullable(_source.getString("policy_label_5"))
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .ifPresent(s -> bqHangupNum.increment());
|
|
|
+
|
|
|
+ Optional.ofNullable(_source.getString("policy_label_6"))
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .ifPresent(s -> lpHangupNum.increment());
|
|
|
+ });
|
|
|
+
|
|
|
+ triples.stream()
|
|
|
+ .max((t1, t2) -> {
|
|
|
+ int cmp = t1.getMiddle().compareTo(t2.getMiddle());
|
|
|
+ if (cmp != 0) {
|
|
|
+ return cmp;
|
|
|
+ }
|
|
|
+ String date1 = t1.getRight().getValue();
|
|
|
+ String date2 = t2.getRight().getValue();
|
|
|
+ if (date1 == null && date2 == null) {
|
|
|
+ return 0;
|
|
|
+ } else if (date1 == null) {
|
|
|
+ return -1;
|
|
|
+ } else if (date2 == null) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return date1.compareTo(date2);
|
|
|
+ })
|
|
|
+ .ifPresent(triple -> {
|
|
|
+ Pair<String, String> pair = triple.getLeft();
|
|
|
+ String type = pair.getKey();
|
|
|
+ String desc = pair.getValue();
|
|
|
+ Integer num = triple.getMiddle().getValue();
|
|
|
+ if (num > 0) {
|
|
|
+ if ("d".equals(type)) {
|
|
|
+ labelDescs.add(desc.concat("(").concat(num.toString()).concat("次)"));
|
|
|
+ } else {
|
|
|
+ labelDescs.add(desc);
|
|
|
+ triple = triples.getLast();
|
|
|
+ desc = triple.getLeft().getValue();
|
|
|
+ num = triple.getMiddle().getValue();
|
|
|
+ if (num > 0) {
|
|
|
+ labelDescs.add(desc.concat("(").concat(num.toString()).concat("次)"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Optional.of(stopFeeNum)
|
|
|
+ .map(MutableInt::getValue)
|
|
|
+ .filter(num -> num > 0)
|
|
|
+ .ifPresent(num -> labelDescs.add("有暂停扣费".concat("(").concat(num.toString()).concat("单)")));
|
|
|
+
|
|
|
+ Optional.of(refundFeeNum)
|
|
|
+ .map(MutableInt::getValue)
|
|
|
+ .filter(num -> num > 0)
|
|
|
+ .ifPresent(num -> labelDescs.add("有续期收费回退".concat("(").concat(num.toString()).concat("单)")));
|
|
|
+
|
|
|
+ if (failedContacted.isTrue()) {
|
|
|
+ labelDescs.add("多次联系不上");
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional.of(withinPayPeriodNum)
|
|
|
+ .map(MutableInt::getValue)
|
|
|
+ .filter(num -> num > 0)
|
|
|
+ .ifPresent(num -> labelDescs.add("多单交费".concat("(").concat(num.toString()).concat("单)")));
|
|
|
+
|
|
|
+ Optional.of(bqHangupNum)
|
|
|
+ .map(MutableInt::getValue)
|
|
|
+ .filter(num -> num > 0)
|
|
|
+ .ifPresent(num -> labelDescs.add("保全挂起中".concat("(").concat(num.toString()).concat("单)")));
|
|
|
+
|
|
|
+ Optional.of(lpHangupNum)
|
|
|
+ .map(MutableInt::getValue)
|
|
|
+ .filter(num -> num > 0)
|
|
|
+ .ifPresent(num -> labelDescs.add("理赔挂起中".concat("(").concat(num.toString()).concat("单)")));
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.保单信息 过滤只展示投保人数据
|
|
|
+ List<Object> policyInfos = (List<Object>) renewalNode.computeIfAbsent("policyInfos",
|
|
|
+ k -> Lists.newArrayListWithCapacity(insurancearrangement.size()));
|
|
|
+
|
|
|
+ ((List<Object>) insurancearrangement).stream()
|
|
|
+ .filter(o -> {
|
|
|
+ Map mp = (Map) o;
|
|
|
+ String applicantscustid = Optional.ofNullable(mp.get("applicantscustid"))
|
|
|
+ .map(Object::toString)
|
|
|
+ .orElse(null);
|
|
|
+ return StringUtils.equals(applicantscustid, scustid);
|
|
|
+ })
|
|
|
+ .forEach(policyInfos::add);
|
|
|
+
|
|
|
logger.info("出客户详情时间:"+DateUtils.getTime());
|
|
|
return AjaxResult.success(map);
|
|
|
} catch (Exception e) {
|