From 278fbb4f21aa2df4fd1a83201e204448761f8653 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 21 Apr 2020 14:11:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E5=91=98=E8=87=AA=E5=8A=A8=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PartyMemberConfirmServiceImpl.java | 2 +- .../impl/PartymemberBaseInfoServiceImpl.java | 136 ++++++++++++++---- 2 files changed, 108 insertions(+), 30 deletions(-) diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java index 54e7dc19f4..28959478c1 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java @@ -153,7 +153,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService PartymemberInfoEntity partyMemberInfoEntity = ConvertUtils.sourceToTarget(partyMemberInfoDTO, PartymemberInfoEntity.class); - if (confirmAutoDTO == null || (confirmAutoDTO.getResult().compareTo(PartyMemberConstant.BENCHMARK) < 0 && !confirmAutoDTO.getComparisonResults())) { + if (confirmAutoDTO == null || !confirmAutoDTO.getComparisonResults()) { //将访问记录更新到热心居民申请行为记录表 saveOrUpdateVisit(partyMemberInfoDTO.getPartymemberVisitId(), null, PartyMemberConstant.OPERATE_AUTO_FAILED); diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java index 2f8e281b68..8d0381e8a3 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java @@ -40,6 +40,9 @@ import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; /** * 党员库基本信息表 @@ -125,25 +128,58 @@ public class PartymemberBaseInfoServiceImpl extends BaseServiceImpl 0) { //优先判断身份证和手机号 - Optional matchingResult = - idCardList.stream().filter(baseInfo -> baseInfo.getMobile().equals(partyMemberInfo.getMobile())).findFirst(); - - if (matchingResult.isPresent()) { - confirmAutoDTO = getResult(matchingResult.get(), partyMemberInfo, true); - return confirmAutoDTO; + List matchingList = idCardList.stream().filter(baseInfo -> + baseInfo.getMobile().equals(partyMemberInfo.getMobile())).collect(toList()); + + if (matchingList.size() > 0) { + //姓名匹配度是01(含)以上 + List nameMatchingList = idCardList.stream().filter(baseInfo -> + getOneSimilarity(baseInfo.getName(), name, + PartyMemberConstant.NAME_SMALL)).collect(toList()); + if (nameMatchingList.size() > 0) { + //获取匹配度最高的一条 + PartymemberBaseInfoEntity baseInfoEntity = + nameMatchingList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); + confirmAutoDTO = getResult(baseInfoEntity, partyMemberInfo, true); + return confirmAutoDTO; + } } //判断身份证和姓名 - matchingResult = idCardList.stream().filter(baseInfo -> baseInfo.getName().equals(name)).findFirst(); - - if (matchingResult.isPresent()) { - confirmAutoDTO = getResult(matchingResult.get(), partyMemberInfo, true); + matchingList = idCardList.stream().filter(baseInfo -> baseInfo.getName().equals(name)).collect(toList()); + + if (matchingList.size() > 0) { + //手机号匹配度是01(含)以上 + List mobileMatchingList = idCardList.stream().filter(baseInfo -> + getOneSimilarity(baseInfo.getMobile(), partyMemberInfo.getMobile(), + PartyMemberConstant.MOBILE_SMALL)).collect(toList()); + if (mobileMatchingList.size() > 0) { + //获取匹配度最高的一条 + PartymemberBaseInfoEntity baseInfoEntity = + mobileMatchingList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); + confirmAutoDTO = getResult(baseInfoEntity, partyMemberInfo, true); + return confirmAutoDTO; + } + } + //有一项是11的情况下,另外两项需要是10(含)以上,可以认证通过; + matchingList = idCardList.stream().filter(baseInfo -> + getOneSimilarity(baseInfo.getMobile(), partyMemberInfo.getMobile(), + PartyMemberConstant.MOBILE_MOST) && getOneSimilarity(baseInfo.getName(), + name, PartyMemberConstant.NAME_MOST)).collect(toList()); + + if (matchingList.size() > 0) { + //获取匹配度最高的一条 + PartymemberBaseInfoEntity baseInfoEntity = + matchingList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); + confirmAutoDTO = getResult(baseInfoEntity, partyMemberInfo, true); return confirmAutoDTO; } - //获取匹配度最高的数据 sortList.add(idCardList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> - getSimilarity(p, partyMemberInfo)).reversed()).collect(Collectors.toList()).get(0)); + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0)); } else { //根据手机号匹配数据 @@ -151,32 +187,63 @@ public class PartymemberBaseInfoServiceImpl extends BaseServiceImpl 0) { //判断手机号和姓名 - Optional matchingResult = - mobileList.stream().filter(baseInfo -> baseInfo.getName().equals(name)).findFirst(); - - if (matchingResult.isPresent()) { - confirmAutoDTO = getResult(matchingResult.get(), partyMemberInfo, true); + List matchingList = + mobileList.stream().filter(baseInfo -> baseInfo.getName().equals(name)).collect(toList()); + + if (matchingList.size() > 0) { + //身份证匹配度是01(含)以上 + List idCardMatchingList = mobileList.stream().filter(baseInfo -> + getOneSimilarity(baseInfo.getIdCard(), partyMemberInfo.getIdCard(), + PartyMemberConstant.ID_SMALL)).collect(toList()); + if (idCardMatchingList.size() > 0) { + //获取匹配度最高的一条 + PartymemberBaseInfoEntity baseInfoEntity = + idCardMatchingList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); + confirmAutoDTO = getResult(baseInfoEntity, partyMemberInfo, true); + return confirmAutoDTO; + } + } + //有一项是11的情况下,另外两项需要是10(含)以上,可以认证通过; + matchingList = mobileList.stream().filter(baseInfo -> + getOneSimilarity(baseInfo.getIdCard(), partyMemberInfo.getIdCard(), + PartyMemberConstant.ID_MOST) && getOneSimilarity(baseInfo.getName(), + name, PartyMemberConstant.NAME_MOST)).collect(toList()); + + if (matchingList.size() > 0) { + //获取匹配度最高的一条 + PartymemberBaseInfoEntity baseInfoEntity = + matchingList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); + confirmAutoDTO = getResult(baseInfoEntity, partyMemberInfo, true); return confirmAutoDTO; } - //获取匹配度最高的数据 sortList.add(mobileList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> - getSimilarity(p, partyMemberInfo)).reversed()).collect(Collectors.toList()).get(0)); + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0)); } else { //根据姓名匹配数据 List nameList = baseDao.selectBaseInfoByName(partyMemberInfo); if (null != nameList && nameList.size() > 0) { + //有一项是11的情况下,另外两项需要是10(含)以上,可以认证通过; + List matchingList = nameList.stream().filter(baseInfo -> + getOneSimilarity(baseInfo.getIdCard(), partyMemberInfo.getIdCard(), + PartyMemberConstant.ID_MOST) && getOneSimilarity(baseInfo.getMobile(), + partyMemberInfo.getMobile(), PartyMemberConstant.MOBILE_MOST)).collect(toList()); + + if (matchingList.size() > 0) { + //获取匹配度最高的一条 + PartymemberBaseInfoEntity baseInfoEntity = + matchingList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); + confirmAutoDTO = getResult(baseInfoEntity, partyMemberInfo, true); + return confirmAutoDTO; + } + //获取匹配度最高的数据 sortList.add(nameList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> - getSimilarity(p, partyMemberInfo)).reversed()).collect(Collectors.toList()).get(0)); - - PartymemberBaseInfoEntity similar = - nameList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) -> - getSimilarity(p, partyMemberInfo)).reversed()).collect(Collectors.toList()).get(0); - - confirmAutoDTO = getResult(similar, partyMemberInfo, false); - return confirmAutoDTO; + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0)); } else { return null; @@ -184,9 +251,9 @@ public class PartymemberBaseInfoServiceImpl extends BaseServiceImpl - getSimilarity(p, partyMemberInfo)).reversed()).collect(Collectors.toList()).get(0); + getSimilarity(p, partyMemberInfo)).reversed()).collect(toList()).get(0); return getResult(similar, partyMemberInfo, false); } @@ -274,4 +341,15 @@ public class PartymemberBaseInfoServiceImpl extends BaseServiceImpl