Browse Source

【证件类型】护照-导入完成修改

master
wangxianzhang 3 years ago
parent
commit
9242d2fef6
  1. 27
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/IdCardTypeEnum.java
  2. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiUserEntity.java
  3. 40
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

27
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/IdCardTypeEnum.java

@ -0,0 +1,27 @@
package com.epmet.commons.tools.enums;
/**
* 唯一整件类型
*/
public enum IdCardTypeEnum {
OTHERS("0", "其他"),
SFZH("1", "身份证号"),
PASSPORT("2", "护照");
private String type;
private String name;
IdCardTypeEnum(String type, String name) {
this.type = type;
this.name = name;
}
public String getType() {
return type;
}
public String getName() {
return name;
}
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiUserEntity.java

@ -96,10 +96,15 @@ public class IcResiUserEntity extends BaseEpmetEntity {
private String gender;
/**
* 身份证号
*
*/
private String idCard;
/**
* 证件类型1身份证号2护照
*/
private String idCardType;
/**
* 出生日期
*/

40
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

@ -18,6 +18,7 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
@ -98,6 +99,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
*/
private final Pattern PATTERN_18_ID = Pattern.compile("^\\d{6}(?<year>\\d{4})(?<month>0[1-9]|1[0-2])(?<day>[0-2][0-9]|3[0-1])\\d{2}(?<sex>\\d)[0-9a-xA-X]$");
/**
* 9位护照
*/
private final Pattern PATTERN_9_PASSPORT = Pattern.compile("^\\w{2}\\d{7}|\\w{1}\\d{8}$");
/**
* 日期解析不含时间
*/
@ -623,14 +629,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
if (StringUtils.isBlank(idCard)) {
log.debug("【居民信息导入】specifiedCheck身份证号为空的:{},{}", mobile, name);
String errorMsg = "身份证号不能为空";
String errorMsg = "证号不能为空";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
if (idCard.length() != 18 && idCard.length() != 15) {
errors.add("身份证号长度错误");
}
if (StringUtils.isNotBlank(mobile) && mobile.length() > 15) {
errors.add("手机号长度错误");
}
@ -642,12 +644,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
}
// ================== 数据补充 ===================
String year;
String month;
String day;
String sex;
String year = null, month = null, day = null, sex = null;
// 证件类型,默认是1身份证号
String idCardType = IdCardTypeEnum.SFZH.getType();
if (idCard.length() == 15) {
// 身份证
Matcher matcher = PATTERN_15_ID.matcher(idCard);
if (matcher.matches()) {
year = "19".concat(matcher.group("year"));
@ -655,10 +658,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
day = matcher.group("day");
sex = matcher.group("sex");
} else {
String s = "身份证号解析错误";
String s = "证号解析错误";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
} else if (idCard.length() == 18) {
// 身份证
Matcher matcher = PATTERN_18_ID.matcher(idCard);
if (matcher.matches()) {
year = matcher.group("year");
@ -666,14 +670,25 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
day = matcher.group("day");
sex = matcher.group("sex");
} else {
String s = "身份证号解析错误";
String s = "证号解析错误";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
} else if (idCard.length() == 9) {
// 护照
Matcher matcher = PATTERN_9_PASSPORT.matcher(idCard);
if (matcher.matches()) {
idCardType = IdCardTypeEnum.PASSPORT.getType();
}
} else {
String s = "身份证号位数错误";
String s = "证件号解析错误";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
// 存储证件类型
columnAndValues.put("ID_CARD_TYPE", idCardType);
if (idCardType.equals(IdCardTypeEnum.SFZH.getType())) {
//只有证件类型是身份证号才做相关解析
// 出生日期 & 年龄
LocalDate birthday = null;
try {
@ -689,6 +704,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
columnAndValues.put("GENDER", isMale ? "1" : "2");
columnAndValues.put("IS_OLD_PEOPLE", age >= 60 ? "1" : "0");
}
}
/**
* 持久化IC居民附加信息

Loading…
Cancel
Save