Browse Source

除了身份证,其他的证件类型不校验格式

lhqzyy
ccsens_zhengzhichuan 2 weeks ago
parent
commit
ccbf6caa25
  1. 2
      ruisi_java/ruisi-system/src/main/java/com/ccsens/system/domain/dto/PmsPatientDto.java
  2. 26
      ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/controller/PmsController.java

2
ruisi_java/ruisi-system/src/main/java/com/ccsens/system/domain/dto/PmsPatientDto.java

@ -211,6 +211,8 @@ public class PmsPatientDto {
// @NotNull(message="请填写身份证号")
@ApiModelProperty("病人身份证号")
private String idcard;
@ApiModelProperty("病人身份证号类型")
private Byte idCardType = 0;
@NotNull(message = "请选择性别")
@ApiModelProperty("性别(0:男 1:女)")
private Byte sex;

26
ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/controller/PmsController.java

@ -153,16 +153,19 @@ public class PmsController extends BaseController {
if (StrUtil.isEmpty(patientDto.getIdcard())) {
throw new BaseException(ErrorConstant.ID_CARD_NULL);
}
if (!IdcardUtil.isValidCard(patientDto.getIdcard())) {
if ("1".equals(patientDto.getIdCardType()) && !IdcardUtil.isValidCard(patientDto.getIdcard())) {
throw new BaseException(ErrorConstant.ID_CARD_ERROR);
}
//通过身份证获取出生年份
patientDto.setBirthYear(IdcardUtil.getYearByIdCard(patientDto.getIdcard()).intValue());
//计算年龄
patientDto.setAge(IdcardUtil.getAgeByIdCard(patientDto.getIdcard()));
if ("1".equals(patientDto.getIdCardType())) {
patientDto.setBirthYear(IdcardUtil.getYearByIdCard(patientDto.getIdcard()).intValue());
//计算年龄
patientDto.setAge(IdcardUtil.getAgeByIdCard(patientDto.getIdcard()));
}
//使用md5加密手机号
if (flag) {
if ("1".equals(patientDto.getIdCardType()) && flag) {
// patientDto.setMobile(Md5Utils.hash(patientDto.getMobile()));
//使用md5加密处理身份证
String hash = Md5Utils.hash(patientDto.getIdcard().substring(2, 14));
@ -181,7 +184,7 @@ public class PmsController extends BaseController {
}
}
//校验身份证格式
if (StrUtil.isNotEmpty(patientDto.getIdcard())) {
if (StrUtil.isNotEmpty(patientDto.getIdcard()) && "1".equals(patientDto.getIdCardType())) {
if (!IdcardUtil.isValidCard(patientDto.getIdcard())) {
throw new BaseException(ErrorConstant.ID_CARD_ERROR);
}
@ -237,14 +240,17 @@ public class PmsController extends BaseController {
if (StrUtil.isEmpty(patientDto.getIdcard())) {
throw new BaseException(ErrorConstant.ID_CARD_NULL);
}
if (!IdcardUtil.isValidCard(patientDto.getIdcard())) {
//只有身份证才校验格式
if (patientDto.getIdCardType() == 1 && !IdcardUtil.isValidCard(patientDto.getIdcard())) {
throw new BaseException(ErrorConstant.ID_CARD_ERROR);
}
//通过身份证获取出生年份
patientDto.setBirthYear(IdcardUtil.getYearByIdCard(patientDto.getIdcard()).intValue());
if (patientDto.getIdCardType() == 1) {
patientDto.setBirthYear(IdcardUtil.getYearByIdCard(patientDto.getIdcard()).intValue());
}
if (flag) {
if (flag && patientDto.getIdCardType() == 1) {
try {
//计算年龄
patientDto.setAge(IdcardUtil.getAgeByIdCard(patientDto.getIdcard()));
@ -270,7 +276,7 @@ public class PmsController extends BaseController {
}
}
//校验身份证格式
if (StrUtil.isNotEmpty(patientDto.getIdcard())) {
if (StrUtil.isNotEmpty(patientDto.getIdcard()) && patientDto.getIdCardType() == 1) {
if (!IdcardUtil.isValidCard(patientDto.getIdcard())) {
throw new BaseException(ErrorConstant.ID_CARD_ERROR);
}

Loading…
Cancel
Save