|
@ -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.CustomerStaffInfoCacheResult; |
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum; |
|
|
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.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
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]$"); |
|
|
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)) { |
|
|
if (StringUtils.isBlank(idCard)) { |
|
|
log.debug("【居民信息导入】specifiedCheck身份证号为空的:{},{}", mobile, name); |
|
|
log.debug("【居民信息导入】specifiedCheck身份证号为空的:{},{}", mobile, name); |
|
|
|
|
|
|
|
|
String errorMsg = "身份证号不能为空"; |
|
|
String errorMsg = "证件号不能为空"; |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, 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) { |
|
|
if (StringUtils.isNotBlank(mobile) && mobile.length() > 15) { |
|
|
errors.add("手机号长度错误"); |
|
|
errors.add("手机号长度错误"); |
|
|
} |
|
|
} |
|
@ -642,12 +644,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ================== 数据补充 ===================
|
|
|
// ================== 数据补充 ===================
|
|
|
String year; |
|
|
String year = null, month = null, day = null, sex = null; |
|
|
String month; |
|
|
|
|
|
String day; |
|
|
// 证件类型,默认是1身份证号
|
|
|
String sex; |
|
|
String idCardType = IdCardTypeEnum.SFZH.getType(); |
|
|
|
|
|
|
|
|
if (idCard.length() == 15) { |
|
|
if (idCard.length() == 15) { |
|
|
|
|
|
// 身份证
|
|
|
Matcher matcher = PATTERN_15_ID.matcher(idCard); |
|
|
Matcher matcher = PATTERN_15_ID.matcher(idCard); |
|
|
if (matcher.matches()) { |
|
|
if (matcher.matches()) { |
|
|
year = "19".concat(matcher.group("year")); |
|
|
year = "19".concat(matcher.group("year")); |
|
@ -655,10 +658,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
day = matcher.group("day"); |
|
|
day = matcher.group("day"); |
|
|
sex = matcher.group("sex"); |
|
|
sex = matcher.group("sex"); |
|
|
} else { |
|
|
} else { |
|
|
String s = "身份证号解析错误"; |
|
|
String s = "证件号解析错误"; |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s); |
|
|
} |
|
|
} |
|
|
} else if (idCard.length() == 18) { |
|
|
} else if (idCard.length() == 18) { |
|
|
|
|
|
// 身份证
|
|
|
Matcher matcher = PATTERN_18_ID.matcher(idCard); |
|
|
Matcher matcher = PATTERN_18_ID.matcher(idCard); |
|
|
if (matcher.matches()) { |
|
|
if (matcher.matches()) { |
|
|
year = matcher.group("year"); |
|
|
year = matcher.group("year"); |
|
@ -666,28 +670,40 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
day = matcher.group("day"); |
|
|
day = matcher.group("day"); |
|
|
sex = matcher.group("sex"); |
|
|
sex = matcher.group("sex"); |
|
|
} else { |
|
|
} else { |
|
|
String s = "身份证号解析错误"; |
|
|
String s = "证件号解析错误"; |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, 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 { |
|
|
} else { |
|
|
String s = "身份证号位数错误"; |
|
|
String s = "证件号解析错误"; |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 出生日期 & 年龄
|
|
|
// 存储证件类型
|
|
|
LocalDate birthday = null; |
|
|
columnAndValues.put("ID_CARD_TYPE", idCardType); |
|
|
try { |
|
|
|
|
|
birthday = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day)); |
|
|
|
|
|
} catch (DateTimeException e) { |
|
|
|
|
|
throw new EpmetException("身份证号中日期信息错误"); |
|
|
|
|
|
} |
|
|
|
|
|
int age = Period.between(birthday, LocalDate.now()).getYears(); |
|
|
|
|
|
|
|
|
|
|
|
// 性别 & 生日 & 老年人
|
|
|
if (idCardType.equals(IdCardTypeEnum.SFZH.getType())) { |
|
|
Boolean isMale = (Integer.parseInt(sex) % 2) == 1; |
|
|
//只有证件类型是身份证号才做相关解析
|
|
|
columnAndValues.put("BIRTHDAY", String.join("-", Arrays.asList(year, month,day))); |
|
|
// 出生日期 & 年龄
|
|
|
columnAndValues.put("GENDER", isMale ? "1" : "2"); |
|
|
LocalDate birthday = null; |
|
|
columnAndValues.put("IS_OLD_PEOPLE", age >= 60 ? "1" : "0"); |
|
|
try { |
|
|
|
|
|
birthday = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day)); |
|
|
|
|
|
} catch (DateTimeException e) { |
|
|
|
|
|
throw new EpmetException("身份证号中日期信息错误"); |
|
|
|
|
|
} |
|
|
|
|
|
int age = Period.between(birthday, LocalDate.now()).getYears(); |
|
|
|
|
|
|
|
|
|
|
|
// 性别 & 生日 & 老年人
|
|
|
|
|
|
Boolean isMale = (Integer.parseInt(sex) % 2) == 1; |
|
|
|
|
|
columnAndValues.put("BIRTHDAY", String.join("-", Arrays.asList(year, month, day))); |
|
|
|
|
|
columnAndValues.put("GENDER", isMale ? "1" : "2"); |
|
|
|
|
|
columnAndValues.put("IS_OLD_PEOPLE", age >= 60 ? "1" : "0"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|