Browse Source

党员自动认证规则修改

dev_shibei_match
zhaoqifeng 5 years ago
parent
commit
278fbb4f21
  1. 2
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java
  2. 136
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java

2
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);

136
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<PartymemberB
if (null != idCardList && idCardList.size() > 0) {
//优先判断身份证和手机号
Optional<PartymemberBaseInfoEntity> matchingResult =
idCardList.stream().filter(baseInfo -> baseInfo.getMobile().equals(partyMemberInfo.getMobile())).findFirst();
if (matchingResult.isPresent()) {
confirmAutoDTO = getResult(matchingResult.get(), partyMemberInfo, true);
return confirmAutoDTO;
List<PartymemberBaseInfoEntity> matchingList = idCardList.stream().filter(baseInfo ->
baseInfo.getMobile().equals(partyMemberInfo.getMobile())).collect(toList());
if (matchingList.size() > 0) {
//姓名匹配度是01(含)以上
List<PartymemberBaseInfoEntity> 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<PartymemberBaseInfoEntity> 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<PartymemberB
if (null != mobileList && mobileList.size() > 0) {
//判断手机号和姓名
Optional<PartymemberBaseInfoEntity> matchingResult =
mobileList.stream().filter(baseInfo -> baseInfo.getName().equals(name)).findFirst();
if (matchingResult.isPresent()) {
confirmAutoDTO = getResult(matchingResult.get(), partyMemberInfo, true);
List<PartymemberBaseInfoEntity> matchingList =
mobileList.stream().filter(baseInfo -> baseInfo.getName().equals(name)).collect(toList());
if (matchingList.size() > 0) {
//身份证匹配度是01(含)以上
List<PartymemberBaseInfoEntity> 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<PartymemberBaseInfoEntity> nameList = baseDao.selectBaseInfoByName(partyMemberInfo);
if (null != nameList && nameList.size() > 0) {
//有一项是11的情况下,另外两项需要是10(含)以上,可以认证通过;
List<PartymemberBaseInfoEntity> 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<PartymemberB
}
}
PartymemberBaseInfoEntity similar =
PartymemberBaseInfoEntity similar =
sortList.stream().sorted(Comparator.comparing((PartymemberBaseInfoEntity p) ->
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<PartymemberB
return result;
}
/**
* 相似度判断
*
* @return String
*/
private boolean getOneSimilarity(String base, String input, double rule) {
Levenshtein levenshtein = new Levenshtein();
double result = levenshtein.distance(base, input);
return result <= rule;
}
}
Loading…
Cancel
Save